Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/typst-html/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use typst_library::visualize::{Color, ImageElem};
use typst_macros::elem;
use typst_utils::singleton;

use crate::{FrameElem, HtmlAttrs, HtmlElem, HtmlTag, attr, css, tag};
use crate::{FrameElem, HtmlAttr, HtmlAttrs, HtmlElem, HtmlTag, attr, css, tag};

/// Registers show rules for the [HTML target](Target::Html).
pub fn register(rules: &mut NativeRuleMap) {
Expand Down Expand Up @@ -680,7 +680,9 @@ const RAW_RULE: ShowFn<RawElem> = |elem, _, styles| {
seq.push(line.clone().pack());
}

let lang = elem.lang.get_ref(styles);
let code = HtmlElem::new(tag::code)
.with_optional_attr(const { HtmlAttr::constant("data-lang") }, lang.clone())
.with_body(Some(Content::sequence(seq)))
.pack()
.spanned(elem.span());
Expand Down
4 changes: 2 additions & 2 deletions tests/ref/html/raw-html.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>This is <code><strong>*</strong><strong>inline</strong><strong>*</strong></code>.</p>
<pre><code>#[<br> <span style="color: #d73948">#</span><span style="color: #d73948">set</span> <span style="color: #4b69c6">text</span>(blue)<br> <strong>*</strong><strong>Hello</strong><strong>*</strong> <em>_</em><em>world</em><em>_</em>!<br>]</code></pre>
<p>This is <code data-lang="typ"><strong>*</strong><strong>inline</strong><strong>*</strong></code>.</p>
<pre><code data-lang="typ">#[<br> <span style="color: #d73948">#</span><span style="color: #d73948">set</span> <span style="color: #4b69c6">text</span>(blue)<br> <strong>*</strong><strong>Hello</strong><strong>*</strong> <em>_</em><em>world</em><em>_</em>!<br>]</code></pre>
</body>
</html>