Skip to content

Lightpanda: the headless browser designed for AI and automation

Merge pull request #4120 from lightpanda-io/markdown-code-links

Adrià Arrufat55ba8fe41faa
diff --cc src/browser/markdown.zig
index e87a5ca90,fbb68d8e5..62427a408
--- a/src/browser/markdown.zig
+++ b/src/browser/markdown.zig
@@@ -781,18 -795,36 +809,46 @@@ test "browser.markdown: inline code"
\\`` a`b `` and ``` ``x`` ```
\\
);
+ try testMarkdownHTML(
+ \\<table><thead><tr><th>Type</th></tr></thead>
+ \\<tbody><tr><td><code>string | null</code></td></tr></tbody></table>
+ ,
+ \\
+ \\| Type |
+ \\|---|
+ \\| `string \| null` |
+ \\
+ );
}
+ test "browser.markdown: empty inline code" {
+ try testMarkdownHTML("<p>a<code></code>b<code> </code>c<code><img src=\"/x.png\"></code>d</p>",
+ \\
+ \\ab c![](http://localhost/x.png)d
+ \\
+ );
+ }
+
+ test "browser.markdown: links inside inline code" {
+ try testMarkdownHTML("<p>See <code><a href=\"/vec\">Vec</a></code> and <code><a href=\"/vec\">Vec</a>&lt;<a href=\"/t\">T</a>&gt;</code></p>",
+ \\
+ \\See [`Vec`](http://localhost/vec) and `Vec<T>`
+ \\
+ );
+ }
+
+ test "browser.markdown: inline markup inside code is literal" {
+ try testMarkdownHTML("<p><code><b>x</b> <i>y</i> <img src=\"/e.png\" alt=\"z\"></code> <code>a<img alt=\"``\"></code></p><pre><a href=\"/f\">f</a>(<em>a</em>)</pre>",
+ \\
+ \\`x y z` ``` a`` ```
+ \\
+ \\```
+ \\f(a)
+ \\```
+ \\
+ );
+ }
+
test "browser.markdown: code fence keeps the language" {
try testMarkdownHTML("<pre><code class=\"hljs language-zig\">const x = 1;</code></pre>",
\\