Overhaul HTML Formatter Delegation#2286
Merged
Merged
Conversation
Member
Author
|
In particular, @mojavelinux, I think asciidoctor should be using a custom formatter. I am happy to contribute one. |
Member
Author
|
Actually it looks like asciidoctor is using custom formatters, which is nice to see. It does seem to be passing an ignored parameter |
UlyssesZh
reviewed
May 4, 2026
e94b375 to
5d9590f
Compare
added 11 commits
May 15, 2026 18:24
5d9590f to
6fb8078
Compare
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.
Fixes #2279.
Reverts #1156 and #1083, and adds warning comments to all the HTML* formatters that take delegators.
In the above patches, there was a strict assumption that all HTML formatters were capable of being wrapped, which they are not, which caused all manner of confusion, extra newlines, extra wrapping tags, etc. In general, it is only safe to call the
#span(tok, val)method of a delegator, which will yield precisely a span for that token. Calling#streamdirectly can be safe, but only for the non-nesting HTML formatters, which are HTML, HTMLInline, and HTMLDebug, which guarantee no newline-handling or wrapping of their input.I have also added a temporary polyfill for #1082, with a deprecation warning.
HTMLTable.new(...), when passed a Formatter other than one of the three non-nesting HTML formatters, will become anHTMLLegacyTableand warn. Those using that kind of nesting should maintain their own formatters for their application going into the future. Other unsupported combinations will raise. Users who have written their own formatters should not be affected by any of these changes.If there is a desire for a more packaged approach, then others are welcome to publish a plugin with fancier HTML formatters. As it is, this stack is far too complicated for Rouge core.
Request for comment from @UlyssesZh, @mojavelinux, and @ashmaroli.