Skip to content

HTML following between two comments don't get recognized as HTML #1032

Closed

Description

@qzhou1607-zz
<!-- This is a comment -->
<details>
<summary>
    This is the summary.
</summary>
Hello!

hello!

hello!
</details>
<!-- This is a comment -->

Expectation

<!-- This is a comment -->
<details>
<summary>
    This is the summary.
</summary>
Hello!

hello!

hello!
</details>
<!-- This is a comment -->

Result

<!-- This is a comment -->
<p><details></p>
<p><summary>
    This is the summary.
</summary>
Hello!</p>
<p>hello!</p>
<p>hello!
</details>
<!-- This is a comment --></p>

What was attempted

As shown above, HTML code between two comments are identified as paragraphs instead of html. Inserting blank lines between the comments and the HTML code in markdown temporarily solved the rendering issue. But the html regex in marked.js needs to be modified to recognize HTML both before and after a comment.

Alternatively, it could just mention in the documentation that blank lines are required between the comments and the HTML code.

https://github.com/chjj/marked/blob/84c330b62beee7dab83764f373eaf80414b2516e/lib/marked.js#L23

Activity

  1. Feder1co5oave commented on Jan 23, 2018

    @Feder1co5oave
    Contributor

    There sure are a lot of \n inside the html regex...
    Commonmark.js parses this as expected.
    I'g flag this for 0.4 and categorize under html (/mixed content ?)

    Thanks for reporting this @qzhou1607 !

  2. joshbruce commented on Jan 24, 2018

    @joshbruce
    Member

    Sounds fair. I don't know the specs well enough to understand their stance on comments. Logically it's just part of HTML - but I'm weird when it comes to my Markdown (avoid putting HTML in there like the plague). :)

  3. added this to the milestone on Jan 24, 2018
  4. added
    L2 - annoying
    and removed on Jan 24, 2018
  5. joshbruce commented on Jan 24, 2018

    @joshbruce
    Member
  6. removed this from the milestone on Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L2 - annoyingcategory: mixed content

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions