Skip to content

[BUG] Doxygen Markdown parser leaks internal commands into generated HTML for malformed code fences #3222

Description

@ayandevofficial

Description

When Doxygen processes a Markdown file with a poorly formed fenced code block, it does not handle the Markdown elements properly.

Instead of treating the surrounding Markdown as regular content, Doxygen adds internal commands like @icode, @endicode, @subsection, and @subsubsection directly into the output HTML.

This can lead to broken or misformatted documentation.

The issue was reproduced with Doxygen 1.15.0 using a simple Markdown test case. It was also seen while processing the repository's CONTRIBUTING.md.


Expected behavior

Doxygen should manage poorly formed or inconsistent Markdown code fences without issues.

At a minimum, it should not expose internal commands like @icode, @endicode, @subsection, and @subsubsection as plain text in the output HTML.

The generated documentation should either:

  • render the Markdown according to Doxygen's supported Markdown syntax, or
  • show a clear parsing warning or error without revealing internal commands in the documentation.

Actual behavior

Doxygen generates HTML that includes raw internal commands such as:

@icode{cpp}
@endicode
@subsection
@subsubsection

These commands show up as plain text in the produced HTML instead of being processed as internal Doxygen markup.

For example, the output HTML can include entries like:

@subsection autotoc_md5 Making Changes
@subsubsection autotoc_md6 Code
@icode{cpp}
@endicode

Steps to reproduce

  1. Install Doxygen 1.15.0.

  2. Create a simple Doxygen project with a Doxyfile set up to process a Markdown file.

  3. Use a Markdown file that includes headings and a poorly formed fenced code block, for example:

    Test Page

    Making Changes

    Some text.

    Code Example

    ``cpp
    #include

    int main() {
    return 0;
    }
    ``

  4. Configure the Doxyfile:

    INPUT = malformed.md

  5. Generate the documentation:

    rm -rf build
    doxygen Doxyfile

  6. Search the generated HTML for Doxygen's internal commands:

    grep -R -n -E '@icode|@endicode|@subsection|@subsubsection' build/html

  7. Notice that these internal commands are present in the generated HTML.


Context

Doxygen version: 1.15.0

Environment:

  • Ubuntu Linux
  • Markdown input
  • HTML output

The issue was first noticed while inspecting the documentation generated from TheAlgorithms/C-Plus-Plus CONTRIBUTING.md.

The Doxygen debug output also shows that Markdown sections and fenced code blocks are being turned into commands like @subsection, @subsubsection, @icode, and @endicode before appearing unprocessed in the final HTML.

Additional information

The problem seems to relate to Doxygen's handling of poorly formed or inconsistent Markdown fenced code blocks.

In contrast, correctly formed Markdown fenced code blocks with matching triple-backtick delimiters do not have the same issue.

The problem can be reproduced with a simple Markdown test case, indicating that it does not rely solely on the size or complexity of CONTRIBUTING.md.

Generated HTML and Doxygen debug output can be shared as further evidence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions