1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-11-12 10:00:15 +01:00

Make code block in IF generate p container if no markdown code is generated

This commit is contained in:
Elisabeth Henry 2017-06-04 06:13:29 +02:00
parent 4de088fefb
commit 165a332959

@ -96,6 +96,11 @@ impl<'a> HtmlIfRenderer<'a> {
} }
} }
gen_code.push_str(&code[i..]); gen_code.push_str(&code[i..]);
let container = if i == 0 {
"p"
} else {
"div"
};
let id = html_if.n_fn; let id = html_if.n_fn;
html_if.fn_defs html_if.fn_defs
.push_str(&format!("function fn_{id}() {{ .push_str(&format!("function fn_{id}() {{
@ -106,11 +111,12 @@ impl<'a> HtmlIfRenderer<'a> {
html_if.curr_init html_if.curr_init
.push_str(&format!(" result = fn_{id}(); .push_str(&format!(" result = fn_{id}();
if (result != undefined) {{ if (result != undefined) {{
document.getElementById(\"result_{id}\").innerHTML = fn_{id}(); document.getElementById(\"result_{id}\").innerHTML = result;
}}\n", }}\n",
id = id)); id = id));
let content = format!("<div id = \"result_{}\"></div>\n", let content = format!("<{container} id = \"result_{id}\"></{container}>\n",
(html_if.n_fn)); id = (html_if.n_fn),
container = container);
html_if.n_fn += 1; html_if.n_fn += 1;
Ok(content) Ok(content)