Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
497e0bdf29873 opened this issue Oct 24, 2022 · 4 comments
Closed

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

497e0bdf29873 opened this issue Oct 24, 2022 · 4 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@497e0bdf29873
Copy link

497e0bdf29873 commented Oct 24, 2022

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.

@ehuss
Copy link
Contributor

ehuss commented Oct 24, 2022

The markdown standard does not call for markdown to be disabled inside inline HTML tags. It is only disabled in very specific circumstances described in HTML Blocks. This can be seen on dingus or here on GitHub:

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

I don't have a particular suggestion other than escaping with backslashes.

@497e0bdf29873
Copy link
Author

497e0bdf29873 commented Oct 24, 2022

Neither backslash escapes work

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

becomes the same old

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

Edit: Oh, wait, you need like 10 million escapes there.

@aDotInTheVoid
Copy link
Member

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

becomes

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

Which I think is what you want

(At least in dingus)

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Oct 27, 2022
@GuillaumeGomez
Copy link
Member

Should we close it then?

@notriddle notriddle closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants