Skip to content

markdown: don't nest a link inside a link - #1689

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
Lstarsky0:fix/markdown-nested-links
Aug 19, 2026
Merged

markdown: don't nest a link inside a link#1689
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
Lstarsky0:fix/markdown-nested-links

Conversation

@Lstarsky0

Copy link
Copy Markdown
Contributor

print_ty writes a named type as a markdown link, and then the html pass in
finish wraps every code span matching a known anchor in another link. For a type
reference that's the same span twice, so the html comes out as

<li><a id="g.a"></a><code>a</code>: <a href="#r"><a href="#r"><code>r</code></a></a></li>

which is what #1516 reported. Markdown links can't nest, so a bool tracking whether
we're inside one is enough to skip the second wrap. The .md output is unchanged;
only the html differs.

The regression test goes in crates/markdown/tests/codegen.rs, which turned out not
to run anywhere — test_unit names crates individually and
--workspace --exclude 'wit-bindgen*' filters this one out, so the test added in
#1673 hasn't been running either. Added one line to test_unit for it.

Closes #1516

`print_ty` already writes a named type as a markdown link, and then the
html pass in `finish` wrapped that same code span in a second link, so a
type reference came out as
`<a href="#r"><a href="#r"><code>r</code></a></a>`. Markdown links can't
nest, so track whether we're inside one and leave the code span alone.

The regression test goes in this crate's `tests/codegen.rs`, which wasn't
being run: `test_unit` names crates individually and
`--workspace --exclude 'wit-bindgen*'` filters this one out. Add it to
that list.
@alexcrichton
alexcrichton enabled auto-merge August 19, 2026 19:07
@alexcrichton
alexcrichton added this pull request to the merge queue Aug 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 19, 2026
@alexcrichton
alexcrichton added this pull request to the merge queue Aug 19, 2026
Merged via the queue into bytecodealliance:main with commit bd5e46c Aug 19, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown bindgen generates invalid HTML

2 participants