Skip to content

"markdown-it-attrs limitation: New line attributes not correctly assigned to list items" #2313

@SPWwj

Description

@SPWwj

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

#2272

Tell us about your environment

Window 10

MarkBind version

v4.1.0

Describe the bug and the steps to reproduce it

Consider the following code:

* item 1
* item 2 
  * item 2.1
  * item 2.2
  
  {icons="light-bulb"}
* item 3

{icons="thumbs-up"}

Here is the rendered output:

248452486-8deb39ba-782b-42a4-9b6b-9eec5a4d441b

Observe that despite both the nested list and the outer list being declared identically, they render differently in HTML.

Innermost list items are output as standalone <li> elements, whereas the outer list items are wrapped within <li><p>{item}</p></li>. This inconsistency suggests a potential bug in our current processing pipeline, meriting further investigation and potentially the filing of a new issue.

However, all parameters are preserved, enabling DOM manipulation to achieve the desired output. Consequently, we should refine our processing pipeline to standardize and bring consistency to the output, thereby enhancing the predictability and reliability of our rendering process.

Expected behavior

Both outer layer and inter layer should be render the same way:
Code:

* item 1 Without P Fix this
  * item 1.1 With P

  * item 1.2 With P
* item 2 Without P Fix this
  * item 2.1 With P
    * item 2.1 Without P
    * item 2.2 Without P

  * item 2.2 With P
* item 3 Without P Fix this
  * item 3.1 Without P Fix this
    * item 3.1.1 Without P
    * item 3.1.2 Without P
  * item 3.2 Without P Fix this

  {icons="light-3"}
* item 4 Without P Fix this
  * item 4.1 With P 
    * item 4.1.1 Without P
    * item 4.1.2 Without P
    
  * item 4.2 With P 

  {icons="light-4"}

{icons="thumbs-up"}

Output:
image

Anything else?

Please refer to the official markdown-it-attrs documentation on GitHub for an explanation of ambiguous syntax: markdown-it-attrs Ambiguity Syntax.

The recommended way of declaring block variables is not consistent and intuitive. Therefore, a standardization and improvement is required. It might look something like this:

* item 1 With P Fix this
  * item 1.1 With P

  * item 1.2 With P
* item 2 With P Fix this
  * item 2.1 With P
    * item 2.1 Without P
    * item 2.2 Without P

  * item 2.2 With P
  
  {icons="light-2"}
* item 3 With P Fix this
  * item 3.1 Without P Fix this
    * item 3.1.1 Without P
    * item 3.1.2 Without P
  * item 3.2 Without P Fix this

  {icons="light-3"}
* item 4 With P Fix this
  * item 4.1 With P Fix this
    * item 4.1.1 Without P
    * item 4.1.2 Without P
    
  * item 4.2 With P Fix this

  {icons="light-4"}

{icons="thumbs-up"}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions