Wrap raw blocks in `<code>` tag additionally to `<pre>` tag (#6701)

This commit is contained in:
Laurenz 2025-08-04 15:21:27 +02:00 committed by GitHub
parent 2809dac6a7
commit 04b8b3195f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 2 deletions

View File

@ -415,9 +415,16 @@ const RAW_RULE: ShowFn<RawElem> = |elem, _, styles| {
seq.push(line.clone().pack()); 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))) .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<RawLine> = |elem, _, _| Ok(elem.body.clone()); const RAW_LINE_RULE: ShowFn<RawLine> = |elem, _, _| Ok(elem.body.clone());

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>#set text(blue)<br><strong>*</strong><strong>Hello</strong><strong>*</strong> <em>_</em><em>world</em><em>_</em>!</code></pre>
</body>
</html>

View File

@ -487,6 +487,13 @@ test
assert.eq(block, c.input.block, message: "in point " + c.name + ", expect " + repr(block) + ", got " + repr(c.input.block) + "") 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 --- --- raw-line ---
#set page(width: 200pt) #set page(width: 200pt)