slachiewicz opened a new issue, #1086:
URL: https://github.com/apache/maven-doxia/issues/1086

   A self-closing HTML tag for a non-void element (e.g. `<object .../>`, 
hand-embedded in a Markdown source or produced by tooling) is rendered by 
`doxia-module-markdown` as an unclosed tag, and everything that follows in the 
same block gets nested inside it instead of being a sibling.
   
   This is what broke https://maven.apache.org/scm.html: apache/maven-site#1645 
(fixed there by hboutemy's apache/maven-site#1652, closing the `<object>` 
explicitly by hand).
   
   ### Reproduction
   
   Markdown input:
   
   ```markdown
   Heading
   =======
   
   <p><object type="image/svg+xml" data="x.svg"/></p>
   
   Text after the object.
   ```
   
   Converting markdown → xhtml with `doxia-converter` (2.1.0):
   
   ```
   $ java -jar doxia-converter-shaded.jar -in fixture.md -from markdown -out 
fixture.xhtml -to xhtml
   ```
   
   Output:
   
   ```html
   <body><section>
   <h1>Heading</h1>
   
   <p><object type="image/svg+xml" data="x.svg">
   <p></p>
   
   <p>Text after the object.</p></object></section></body></html>
   ```
   
   The `<object>` is never closed. "Text after the object." ends up nested 
inside it, along with the empty `<p></p>` from the source paragraph break; the 
real `</object>` close only appears right before `</section>`. In a browser, an 
`<object>` element's content is only shown as fallback when the object itself 
fails to load, so everything after the tag silently disappears whenever the 
referenced resource loads successfully — exactly the symptom on scm.html.
   
   ### Root cause
   
   `MarkdownParser.toXhtml()` re-serializes flexmark's raw-HTML passthrough by 
parsing it with Jsoup and calling 
`outputSettings().syntax(Document.OutputSettings.Syntax.xml)`. Jsoup follows 
the HTML5 spec correctly here: a trailing `/` on a non-void element's start tag 
is a no-op, not a self-close. `<br/>`, `<img/>`, `<hr/>` etc. are fine because 
those *are* void elements, but `<object/>`, `<div/>`, `<span/>`, `<a/>`, ... 
are not, so the parser is left with a genuinely unclosed tag and nests all 
following sibling content as its children until the end of the containing 
block, where Jsoup then emits the missing close tag.
   
   Verified with jsoup's own `Tag.valueOf(name).isSelfClosing()`: true for 
`img`/`br`/`hr`/`input`/`param`, false for 
`object`/`div`/`p`/`span`/`a`/`script`/`svg`.
   
   Note: this is distinct from `doxia-converter`'s xdoc→markdown conversion, 
which doesn't reproduce this particular symptom — it drops a raw `<object>` 
from xdoc entirely (`Unknown Sink event 'object', ignoring!`), the same way it 
already drops `<map>`/`<area>` image maps. The unclosed-tag defect is purely in 
how `doxia-module-markdown` parses Markdown that already contains such a 
self-closing tag, however it got there.
   
   *This issue was created with AI assistance.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to