Skip to content

[DOXIA-762] Clarify code highlighting for verbatim text in Markdown and APT #876

Closed

Description

@jira-importer

Konrad Windszus opened DOXIA-762 and commented

Currently it is undocumented how to emit Sink.verbatim(SinkEventAttributes) blocks with/without the SinkEventAttributeSet.SOURCE argument.


Issue Links:

  • DOXIA-685 Replace SinkEventAttributes#BOXED with #SOURCE to clearly separate between regular verbatim and verbatim source (code)

  • DOXIA-763 MarkdownSink: Distinguish between verbatim with source attribute and without

Activity

  1. self-assigned this
    on Feb 10, 2026
  2. kwin commented on Feb 26, 2026

    @kwin
    Member

    The situation right now differs a lot between the different markup parsers:

    1. AptParser
    • +--: Sink.verbatim(SinkEventAttributeSet(DECORATION, "source"))
    • ---: Sink.verbatim(null)
    1. MarkdownParser:
    • ```: <pre><code class="nohighlight nocode"> -> Sink.verbatim(); Sink.inline(new SinkEventAttributeSet("semantics", "code", "class", "nohighlight nocode"))
    • ```java: <pre><code class="language-java"> -> Sink.verbatim(); Sink.inline(new SinkEventAttributeSet("semantics", "code", "class", "language-java"))
    1. XDocParser:
    • <source>: Sink.verbatim(new SinkEventAttributeSet(DECORATION, "source"))
    1. XHTML5Parser
    • <pre>: Sink.verbatim(null)
    • <pre><code>: Sink.verbatim(null); Sink.inline(SinkEventAttributeSet.Semantics.CODE)

    Particularly the class nohighlight seems to be very specific to https://highlightjs.readthedocs.io/en/latest/readme.html?highlight=nohighlight#ignoring-a-code-block while nocode is specific to https://github.com/googlearchive/code-prettify?tab=readme-ov-file#how-do-i-prevent-a-portion-of-markup-from-being-marked-as-code

  3. slachiewicz commented on Aug 8, 2026

    @slachiewicz
    Member

    Picked this up. Two PRs cover the documentation the issue asks for; the behavioural question underneath it I have left alone deliberately.

    Current state, verified against master

    Confirming @kwin's table, which still holds, with the sink output added:

    Source verbatim event nested inline event rendered
    APT +-- source decoration — <pre><code>
    APT --- no attributes — <pre>
    XDoc <source> source decoration — <pre><code>
    XHTML5 <pre> tag attributes only — <pre>
    XHTML5 <pre><code> tag attributes only Semantics.CODE <pre><code>
    Markdown ```java no attributes semantics=code, class=language-java <pre><code class="language-java">
    Markdown ``` no attributes semantics=code, class=nohighlight nocode <pre><code class="nohighlight nocode">
    Markdown indented no attributes semantics=code, class=nohighlight nocode <pre><code class="nohighlight nocode">

    Xhtml5BaseSink.verbatim(SinkEventAttributes) opens the CODE element only when the decoration is source, so both representations land on <pre><code> in XHTML5 output; they differ in what a Sink other than XHTML5 sees.

    One thing worth flagging, found while writing this up: the MarkdownHtmlParser javadoc claims PRE elements are marked as source so the sink wraps them in <div class="source"> for the skins. Neither half of that is true any more — there is no div wrapper in Xhtml5BaseSink and Markdown sets no decoration. That is fixed in #1076.

    What the docs cannot settle

    There are two representations of "this is code" in the Sink API, source on the verbatim event and Semantics.CODE on a nested inline event, and which one you get depends on the input format rather than on anything meaningful. A Sink that is not the XHTML5 one has to handle both to treat code blocks consistently, and a Sink implementor has nothing telling them that.

    Documenting it, as these PRs do, is worth doing either way. But if the intent is that the two should converge, the docs will need rewriting when they do, so it may be worth deciding that first. Happy to open a separate issue for the convergence question if that is useful.

  4. slachiewicz commented on Nov 4, 2026

    @slachiewicz
    Member

    The documentation this issue asks for is in place: #1076 covers Markdown code blocks, and the APT reference now explains +-- versus --- (https://maven.apache.org/doxia/references/apt-format.html). The remaining design question, the two Sink representations of code, moved to #1121. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions