Repository navigation
fix: drop empty links and unwrap semantic-only tags in clean flavors - #442
Merged
Merged
Conversation
In flavors that do not keep raw HTML: - An <a> without href (a named target) keeps only its content instead of becoming [](). - A link with nothing visible inside is dropped, keeping its whitespace. This removes the [](href) left behind when a <div> inside a link closes the surrounding <p>. - time, data, bdi and bdo change nothing visible, so they keep only their text instead of passing through as unknown tags. CommonMark, GitHub and MultiMarkdown still keep all of these as raw HTML. Follow-up to #440
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #440 (fixed in #441), covering the two leftovers noted there.
Empty links
<p><a href="…"><div>One</div><div>Two</div></a> after</p>gives separate paragraphs because the HTML parser closes the<p>at the<div>and copies the link into each<div>, exactly as browsers do. That part is correct. The defect was the empty link the parser leaves in the closed<p>, written as[](href). Named anchors had the same problem:<a name="top"></a>and<a id="x"></a>became[]().In
AnchorReader, for flavors that do not keep raw HTML:<a>withouthrefkeeps only its content.<p><a href="x"><div>One</div><div>Two</div></a> after</p>[](x)+[One](x)+[Two](x)+after[One](x)+[Two](x)+after<p>x <a href="x"></a> y</p>x [](x) yx y<p>Top <a name="top"></a> here</p>Top []() hereTop hereSemantic-only tags
time,data,bdiandbdochange nothing visible, but in the Default flavor they fell through toTags.Unknown(PassThrough) and stayed as raw HTML, e.g. inside news-teaser links. In flavors that do not keep raw HTML they now keep only their text:<a href="n"><h3>Dimorphos</h3><time datetime="…">vor 22 Minuten</time><div>heise online</div></a>[Dimorphos <time datetime="…">vor 22 Minuten</time> heise online](n)[Dimorphos vor 22 Minuten heise online](n)Tags.PassThrough,Tags.Replacerand custom readers still take precedence. Tags with a visible effect (mark,u,small,kbd,q, …) are unchanged.docs/configuration.mdnotes the four tags underTags.Unknown.Unchanged
CommonMark, GitHub and MultiMarkdown still keep all of the above as raw HTML.
Behavior change
Both changes alter default output for HTML that relied on the old behavior, so they are worth a line in the release notes.
Tests
10 new cases in
Issue440Tests, including CommonMark raw passthrough and an explicitTags.PassThroughoverride. The full suite (535 tests) passes on net8.0, net9.0 and net10.0 with no existing expected output changed.