diff --git a/crates/typst-html/src/rules.rs b/crates/typst-html/src/rules.rs index c358a181..acf9046c 100644 --- a/crates/typst-html/src/rules.rs +++ b/crates/typst-html/src/rules.rs @@ -415,9 +415,16 @@ const RAW_RULE: ShowFn = |elem, _, styles| { seq.push(line.clone().pack()); } - Ok(HtmlElem::new(if elem.block.get(styles) { tag::pre } else { tag::code }) + let code = HtmlElem::new(tag::code) .with_body(Some(Content::sequence(seq))) - .pack()) + .pack() + .spanned(elem.span()); + + Ok(if elem.block.get(styles) { + HtmlElem::new(tag::pre).with_body(Some(code)).pack() + } else { + code + }) }; const RAW_LINE_RULE: ShowFn = |elem, _, _| Ok(elem.body.clone()); diff --git a/tests/ref/html/raw-html.html b/tests/ref/html/raw-html.html new file mode 100644 index 00000000..2df62ca8 --- /dev/null +++ b/tests/ref/html/raw-html.html @@ -0,0 +1,11 @@ + + + + + + + +

This is *inline*.

+
#set text(blue)
*Hello* _world_!
+ + diff --git a/tests/suite/text/raw.typ b/tests/suite/text/raw.typ index 97e77ada..79a1c000 100644 --- a/tests/suite/text/raw.typ +++ b/tests/suite/text/raw.typ @@ -487,6 +487,13 @@ test assert.eq(block, c.input.block, message: "in point " + c.name + ", expect " + repr(block) + ", got " + repr(c.input.block) + "") } +--- raw-html html --- +This is ```typ *inline*```. +```typ +#set text(blue) +*Hello* _world_! +``` + --- raw-line --- #set page(width: 200pt)