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

Attribute behavior for list elements differs from expectations #158

Closed
sahksas opened this issue Oct 8, 2024 · 2 comments
Closed

Attribute behavior for list elements differs from expectations #158

sahksas opened this issue Oct 8, 2024 · 2 comments

Comments

@sahksas
Copy link

sahksas commented Oct 8, 2024

I appreciate the hard work on this plugin! However, I encountered an issue that behaves differently than I expected when applying attributes to list elements in Markdown.

Markdown-it versions:

# run this command and copy the output
# npm ls | grep markdown-it
$ bun pm ls | grep markdown-it
├── @types/markdown-it@14.1.2
├── @types/markdown-it-attrs@4.1.3
├── markdown-it@14.1.0
├── markdown-it-attrs@4.2.0

Example input:

- item
  - child
- item
{.item}

Current output:

<ul>
  <li>item
    <ul class="item">
      <li>child</li>
    </ul>
  </li>
  <li>item</li>
</ul>

Expected output:

<ul class="item">
  <li>item
    <ul>
      <li>child</li>
    </ul>
  </li>
  <li>item</li>
</ul>

I was expecting the .item class to be applied to the outer ul element, but instead, it was applied to the inner one.

Could this behavior be part of the intended functionality of the plugin? Or might I be misunderstanding how to correctly apply attributes in this case? I would greatly appreciate any guidance on this matter.

Thank you very much for your time and for maintaining this fantastic plugin!

@sahksas
Copy link
Author

sahksas commented Oct 8, 2024

Apologies for the confusion. After reading this section and issue #32, it seems that the behavior I encountered is indeed expected according to the specification.

In fact, when I rewrote the Markdown as shown below, the result changed as expected:

- item
  - child
- item

{.item}
<ul class="item">
  <li>item
    <ul>
      <li>child</li>
    </ul>
  </li>
  <li>item</li>
</ul>

For now, I will close this issue, but I would still appreciate any comments or further insights you might have!

@sahksas sahksas closed this as completed Oct 8, 2024
@arve0
Copy link
Owner

arve0 commented Oct 9, 2024

Hi! It’s a lot of work reimplementing as a parser plugin, so this’ll be the behavior. Though I agree that it’s unexpected.

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

No branches or pull requests

2 participants