Skip to content

Rustdoc does not correctly ignore input inside HTML tags. #103473

Closed as not planned
@497e0bdf29873

Description

@497e0bdf29873

I am trying to use the KaTeX html-in-header autorender workaround to include mathematics in documentation (see, for example, https://docs.rs/rustdoc-katex-demo/latest/rustdoc_katex_demo/). However, KaTeX auto-render postprocessing is severely incompatible with markdown due to markdown processing almost any underscores it encounters as italics.

For example, the documentation

/// For an operator $A$ this is an operator $A_*$ such that its adjoint $(A_*)^*=A$. 

gets converted into the HTML

For an operator $A$ this is an operator $A_<em>$ such that its adjoint $(A_</em>)^*=A$.

The standard workaround (unreadable-as-text, and will also stop README.md sharing with a modern markdown processor that directly supports KaTeX) would be to to write instead

/// For an operator $A$ this is an operator <span>$A_*$</span> such that its adjoint <span>$(A_*)^*=A$</span> 

because markdown should not process things between HTML tags. This does not work with rustdoc:

For an operator $A$ this is an operator <span>$A_<em>$</span> such that its adjoint <span>$(A_</em>)^*=A$</span>. 

So it seems rustdoc is incorrectly processing input between HTML tags, that standard markdown would ignore.

This is on nightly.

Issue related to : #17390, #16300, and several others begging some form of LaTeX math support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions