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

HTML inside markdown will cause it fail to parse. #2018

Closed
Nness opened this issue Apr 20, 2021 · 10 comments · Fixed by #2052
Closed

HTML inside markdown will cause it fail to parse. #2018

Nness opened this issue Apr 20, 2021 · 10 comments · Fixed by #2052
Labels
category: html blocks L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue released

Comments

@Nness
Copy link

Nness commented Apr 20, 2021

Marked version:: Since 1.2.2, latest I have test is 2.0.2.

Describe the bug
In version 1.2.2 to 2.0.2, all those version have issue where if there is HTML inside markdown, it will cause anything after HTML to not be parsed.

To Reproduce
Steps to reproduce the behavior:

 ### Title

<h3>Header 3</h3>

<p style="font-size:14px;">First HTML sentence</p>

<p style="font-size:14px;">Second HTML sentence</p>

<p style="font-size:14px;">Third HTML sentence</p>  

  

### Full Name

Test name

  
### ABC title with space at end of line  
Another line

marked options

    const options: MarkedOptions = {
      smartypants: true,
      gfm: true,
      breaks: true,
      silent: true
    };

Expected behavior
Markdown after HTML should be parsed. This was fine on version 1.1.1.

@UziTech
Copy link
Member

UziTech commented Apr 20, 2021

It looks like it is working fine in this demo. Even if you change the version to 2.0.2.

Could you explain more about where this is happening and your exact code? Some screenshots would be helpful as well.

@Nness
Copy link
Author

Nness commented Apr 20, 2021

@UziTech I have tried to reproduce on online editor such as codepen, but fail to do so. I have now successfully created an demo with Angular 2 repository. Which you can access at here.

Once cloned, execute npm install, then npm start. You should be able to see a section of parsed markdown at http://localhost:4200/.

The marked version I have used is 2.0.3. I do use custom renderer, but even without the custom renderer, the problem still persist I believe.

@UziTech
Copy link
Member

UziTech commented Apr 20, 2021

I see the issue. Your markdown is indented (demo).

The html elements are ended at the first blank line but you don't have any actual blank lines after the html elements because they all have space characters in them.

Marked should be fixed to see lines with only spaces as an end to html elements but you can also fix it by removing the spaces from blank lines.

@UziTech UziTech added category: html blocks L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue and removed need more info labels Apr 20, 2021
@Nness
Copy link
Author

Nness commented Apr 21, 2021

Looks like that is cause, we will use older version until its fixed. Thanks

@UziTech
Copy link
Member

UziTech commented Apr 21, 2021

If you want to create a PR it could be fixed faster 😁👍

@krassowski
Copy link
Contributor

krassowski commented May 14, 2021

After checking different versions with the interactive demo tool I believe that it was introduced in 1.2.8, so this might have been related to this PR: #1889

@krassowski
Copy link
Contributor

krassowski commented May 14, 2021

Should the following render markdown as well (no new lines) too?

<details>
   <summary>Dropdown title</summary>
   ## Hidden text.
</details>

Currently it doesn't. This works (empty line, no indent):

<details>
   <summary>Dropdown title</summary>

   ## Hidden text.
</details>

But this doesn't (line with whitespaces):

<details>
   <summary>Dropdown title</summary>
   
   ## Hidden text.
</details>

@UziTech
Copy link
Member

UziTech commented May 15, 2021

@krassowski no according to the spec

@krassowski
Copy link
Contributor

Indeed. It might not be a great UX but I guess this how the spec was defined, so no discussion here. Does it mean that my #2052 PR does solve this issue properly?

@github-actions
Copy link

🎉 This issue has been resolved in version 2.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: html blocks L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants