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

Incorrect <strong> tag and HTML formatting in mixed markdown #3621

Closed
MajaEffenberg opened this issue Feb 18, 2025 · 1 comment
Closed

Incorrect <strong> tag and HTML formatting in mixed markdown #3621

MajaEffenberg opened this issue Feb 18, 2025 · 1 comment

Comments

@MajaEffenberg
Copy link

Marked version:
15.0.7

Describe the bug
When parsing a markdown input containing a mix of bold, italic, links, and lists, the output HTML is incorrectly formatted. Specifically, the <strong> tag is not applied correctly across the entire range of content.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following code to parse the Markdown input:
const marked = require('marked');
const markdown = 'Title ****Text1**, _Text2_, [Link](https://test.ai/), list: 
- Element 1
- Element 2**.';
const html = marked.parse(markdown);
console.log(html);
  1. Actual output:
Title **<strong>Text1</strong>, <em>Text2</em>, <a href="https://test.ai/" target="_blank" title="Link">Link</a>, list: 
<ul>
<li>Element 1</li>
<li>Element 2**.</li>
</ul>
  1. Expected output:
Title <strong><strong>Text1</strong>, <em>Text2</em>, <a href="https://test.ai/" target="_blank" title="Link">Link</a>, list: 
<ul>
<li>Element 1</li>
<li>Element 2</li>
</ul>
</strong>.

Expected behavior
The expected output should ensure that the full content from Text1 through to the last list item Element 2. is correctly wrapped in a single <strong></strong> tag. This includes everything after the title, all the way down to the last list element, with appropriate HTML tags applied to the individual markdown elements.

Title <strong><strong>Text1</strong>, <em>Text2</em>, <a href="https://test.ai/" target="_blank" title="Link">Link</a>, list: 
<ul>
<li>Element 1</li>
<li>Element 2</li>
</ul>
</strong>.
@UziTech
Copy link
Member

UziTech commented Feb 18, 2025

We follow the CommonMark spec.

Plus in HTML a block tag (like ul) should not be inside an inline tag (like strong)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants