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

Mermaid code blocks break rendering of footnotes #23

Open
CJKay opened this issue Aug 16, 2022 · 2 comments
Open

Mermaid code blocks break rendering of footnotes #23

CJKay opened this issue Aug 16, 2022 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@CJKay
Copy link
Contributor

CJKay commented Aug 16, 2022

Comment blocks that utilise Mermaid's code blocks break footnote rendering, e.g.:

#[cfg_attr(doc, aquamarine::aquamarine)]
/// This is a comment.
///
/// This is a diagram[^1]:
/// ```mermaid
/// flowchart LR
///     A --> B
/// ```
///
/// [^1]: This is a footnote.

Found:

Screenshot 2022-08-16 at 18 24 49

Expected (not including rendered diagram):

Screenshot 2022-08-16 at 18 26 08

@mersinvald mersinvald added bug Something isn't working help wanted Extra attention is needed labels Aug 17, 2022
@frehberg
Copy link
Collaborator

frehberg commented Mar 11, 2023

The implementation of aquamarine is using the macro quote!{ #[doc = ...} to embed into the rustdoc section the newly generated mermaid rendering script-hooks. This quote! macro is embedding as block-comment instead of using line-comments. The expanded result of Aquamarine will look similar to the following minimized example:

/// This is a comment.
///
/// This is a diagram[^1]:
/**
 <script> const x = 1;</script>
*/
/// [^1]: This is a footnote.
pub fn example_with_footnote() {}

It seem this block-comment is interrupting the line-comments and causing the footnote-feature to get out of sync.

If the html-code would be added using line-comments, the footnote feature would keep working as expected

/// This is a comment.
///
/// This is a diagram[^1]:
///
/// <script> const x = 1;</script>
/// 
/// [^1]: This is a footnote.
pub fn example_with_footnote() {}

image

Either the quote! macro needs to be modified to produce line-comments or the rustdoc footnote-feature needs to be improved to cope with the switch between different comment styles.

@frehberg
Copy link
Collaborator

frehberg commented Mar 27, 2023

It seems to be an issue with parsing of multi-line comments, so if the generated code would be a single line, the parser will be fine and footnotes rae respected

/// This is a comment.
///
/// This is a diagram[^1]:
/// <script src="https://unpkg.com/[email protected]/dist/mermaid.min.js"> </script> <div>dff</div> 
/// [^1]: This is a footnote.

But this does not go well with the mermaid markdown language, requiring multiline text within div-element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants