Skip to content

Markdown blockquote parsing issue with inline tags #2317

@MR-Addict

Description

@MR-Addict

Problem

When I upgrade to 0.4.37, some of my custom tags was broken, and I find that this was releated to mdbook blockqote parsing issue.

It will treat below right opening tag as blockquote while rending:

<button
  type="button"
  class="scroll-to-top"
  onclick="scrollToTop()"
>
  <i class="fas fa-arrow-up"></i>
</button>

And turn it into:

<p>&lt;button
type="button"
class="scroll-to-top"
onclick="scrollToTop()"</p>
<blockquote>
</blockquote>
<p><i class="fas fa-arrow-up"></i>
</button></p>

Steps

For example, I have below custom button element in my markdown:

<button
  type="button"
  class="scroll-to-top"
  onclick="scrollToTop()"
>
  <i class="fas fa-arrow-up"></i>
</button>

And turn it into:

<p>&lt;button
type="button"
class="scroll-to-top"
onclick="scrollToTop()"</p>
<blockquote>
</blockquote>
<p><i class="fas fa-arrow-up"></i>
</button></p>

Possible Solution(s)

However if I move button right opening tag > upper, it will render properly:

<button
  type="button"
  class="scroll-to-top"
  onclick="scrollToTop()" >
  <i class="fas fa-arrow-up"></i>
</button>

Notes

So I think mdbook treat button right opening tag as blockquote.

And I also find that, this issue only appers in button tag, it renders script, style, iframe, footer and div all properly, even these tags have some strange right opening tag positions.

This is okay, which > was separately put under a new line:

<script
>
  const scrollToTop = window.scroll({ top: 0, behavior: "smooth" });
</script>

And this is okay too, which > has a space with closing tag which is every similar to markdown blockquote syntax:

<iframe
  allowfullscreen
  loading="lazy"
  src="https://www.youtube.com/embed/DyTCOwB0DVw"
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
> </iframe>

So I think this is releated only to button and some other inline tags like span. It won't able to render below custom element properly too:

<span
> hello world</span>

Even with mdbook 0.4.36, it cannot pase it properly too.

Though above span example is strange and rarely there got any people would write raw html in markdown, but I think it's important to improve mdbook markdown parsing.

Version

0.4.37

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions