` per run of code paragraphs whose attributes match: they share the
// ``'s shading, so a different background starts a new block.
- let attrs = para_attrs(p);
+ let attrs = para_attrs(p, false);
out.push_str(&format!(""));
let mut first = true;
while let Some(FBlock::Para(q)) = blocks.get(i) {
- if q.kind != Kind::Code || q.list.is_some() || para_attrs(q) != attrs {
+ if q.kind != Kind::Code || q.list.is_some() || para_attrs(q, false) != attrs {
break;
}
if !first {
@@ -390,14 +423,14 @@ fn blocks_html(blocks: &[FBlock], out: &mut String, depth: usize) {
if q.kind != Kind::Quote || q.list.is_some() {
break;
}
- out.push_str(¶_html(&Para { kind: Kind::Normal, ..q.clone() }));
+ out.push_str(¶_html(&Para { kind: Kind::Normal, ..q.clone() }, false));
out.push('\n');
i += 1;
}
out.push_str("\n");
}
FBlock::Para(p) => {
- out.push_str(¶_html(p));
+ out.push_str(¶_html(p, spaced));
out.push('\n');
i += 1;
}
@@ -421,11 +454,12 @@ pub fn export(doc: &Document) -> String {
}
/// `doc`'s content as an HTML fragment (no head or style sheet): what a copy puts on the system
-/// clipboard beside its text, equations as MathML (#816).
+/// clipboard beside its text, equations as MathML (#816). With no style sheet to give them, its
+/// plain paragraphs and headings carry their own spacing and indents.
pub fn export_fragment(doc: &Document) -> String {
let flow = model::from_doc_with(doc, model::FlowOpts { paras: true, ..Default::default() });
let mut out = String::from("");
- blocks_html(&flow.blocks, &mut out, 0);
+ blocks_html(&flow.blocks, &mut out, 0, true);
out
}
@@ -446,7 +480,7 @@ pub fn export_flow(flow: &Flow, lang: &str) -> String {
table{border-collapse:collapse;margin:0.5em 0}\nblockquote{margin:0.5em 2em;font-style:italic;color:#404040}\n\
pre{background:#f5f5f5;padding:0.5em;font-family:'Courier New',monospace;font-size:10pt}\n\n\n\n",
);
- blocks_html(&flow.blocks, &mut out, 0);
+ blocks_html(&flow.blocks, &mut out, 0, false);
out.push_str("\n