Skip to content

Render unknown Sink events as raw HTML in MarkdownSink - #1088

Merged
slachiewicz merged 1 commit into
masterfrom
markdown-sink-unknown-events
Sep 3, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
markdown-sink-unknown-events

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

MarkdownSink.unknown() logged a warning and silently dropped any Sink event it had no dedicated handling for, taking the content it carried with it (e.g. <object> embeds, image maps). It now delegates tag reconstruction to Xhtml5BaseSink.unknown() and emits the raw HTML tag instead, restoring that content in the converted output. <thead>/<tbody>/<tfoot> stay excluded, since they carry no content of their own and Doxia's table sink API already captures the structure they wrap.

Aligned with #1087 (xdoc-selfclosing-raw-html): a self-closing, non-void tag (e.g. <object/>) is never rendered self-closed, since HTML5 ignores the trailing slash on non-void elements and would otherwise swallow all following content as fallback children. It is written as an explicitly closed pair instead.

Root-cause fix for apache/maven-doxia-converter#159.

Verified: end-to-end conversion of the issue's xdoc fixture (<object type="image/svg+xml" data="x.svg"/>) through a locally built doxia-converter now yields <object type="image/svg+xml" data="x.svg"></object> in the Markdown output instead of silently vanishing.

This change was created with AI assistance.

MarkdownSink silently dropped any Sink event it had no dedicated
handling for (e.g. <object>, image maps), taking the content that
event carried with it. Emit them as raw HTML instead, mirroring
Xhtml5BaseSink, but never self-close a non-void tag: HTML5 ignores
a trailing slash on those, which would otherwise swallow all
following content (see xdoc-selfclosing-raw-html for the matching
parser-side fix).
@slachiewicz slachiewicz added the bug Something isn't working label Aug 24, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review August 24, 2026 11:29
@slachiewicz
slachiewicz requested review from kwin and michael-o and removed request for kwin August 24, 2026 11:33
@michael-o

Copy link
Copy Markdown
Member

Is the behavior of #unknown() defined in the API or left to the implementor, read undefined/impl specific?

@slachiewicz
slachiewicz marked this pull request as draft August 30, 2026 21:21
@slachiewicz
slachiewicz marked this pull request as ready for review September 3, 2026 12:07
@slachiewicz

Copy link
Copy Markdown
Member Author

Left to the implementor, explicitly. Sink#unknown says:

Adds an unknown event. This may be used by parsers to notify a general Sink about an event
that doesn't fit into any event defined by the Sink API. Depending on the parameters, a Sink
may decide whether or not to process the event, emit it as raw text, as a comment, log it, etc.

"emit it as raw text, as a comment, log it" is an explicit grant of latitude, and the existing
implementations already use all of it: SinkAdapter no-ops, AptSink logs and ignores,
Xhtml5BaseSink reconstructs the tag. So moving MarkdownSink from log-and-drop to emitting the
tag is a choice the contract allows rather than one it constrains.

MarkdownSink extends Xhtml5BaseSink, so this PR delegates to that implementation rather than
inventing its own interpretation, and only diverges where HTML5 forces it to (a self-closed
non-void tag).

This comment was created with AI assistance.

@slachiewicz
slachiewicz merged commit 571fab1 into master Sep 3, 2026
16 checks passed
@slachiewicz
slachiewicz deleted the markdown-sink-unknown-events branch September 3, 2026 16:13
@github-actions github-actions Bot added this to the 2.2.0 milestone Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants