arve0 / markdown-it-attrs

Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes
MIT License
300 stars 58 forks source link

Last column attribute setting results unexpectedly #142

Open hasanozgilik opened 2 years ago

hasanozgilik commented 2 years ago

Hi team I am trying to solve sonar security issue , https://rules.sonarsource.com/html/RSPEC-1102. Following sample shows that , only last column attribute settings is sending compiled attribute to "thead" instead of "th". And it does not solve the sonar issue. Is there a way to fix it.

Markdown-it versions:

"markdown-it": "^13.0.1",
"markdown-it-attrs": "^4.1.4",

Example input:

| Value {scope=col}   | Description {scope=col}                    | Is Final Status {scope=col}  |
|:-------|:------------------------------|:----------------:|
| -1     | MESSAGE NOT FOUND             |       YES        |
| 0      | NEW MESSAGE                   |        NO        |

Current output:

<thead scope="col">
<tr>
  <th style="text-align:left;" scope="col">Value</th>
  <th style="text-align:left;" scope="col">Description</th>
  <th style="text-align:center;">Is Final Status</th>
</tr>
</thead>

Expected output:

<thead >
<tr>
  <th style="text-align:left;" scope="col">Value</th>
  <th style="text-align:left;" scope="col">Description</th>
  <th style="text-align:center;" scope="col">Is Final Status</th>
</tr>
</thead>
TheNorthMemory commented 3 months ago

It was resolved by #155 and released on v4.2.0. See the test case:

https://github.com/arve0/markdown-it-attrs/blob/80a8e5278fb336725bcdde14b7c93ec8fbaafc04/test.js#L304-L307