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

Unable to apply attributes to the last column of tables. #150

Closed
RedSparr0w opened this issue Jan 27, 2023 · 1 comment · Fixed by #155
Closed

Unable to apply attributes to the last column of tables. #150

RedSparr0w opened this issue Jan 27, 2023 · 1 comment · Fixed by #155

Comments

@RedSparr0w
Copy link

RedSparr0w commented Jan 27, 2023

Unable to apply attributes to the last column of tables, if there is an attribute in the last <td> it will apply it to the parent <tr>.

Markdown-it versions:

markdown-it@13.0.1
markdown-it-attrs@4.1.6

Example input:

| title | title |
| :----: | :----: |
| text | text {.text-primary} | 
| text {.text-primary} | text |

Current output:

<table>
  <thead>
    <tr>
      <th style="text-align:center">title</th>
      <th style="text-align:center">title</th>
    </tr>
  </thead>
  <tbody>
    <tr class="text-primary">
      <td style="text-align:center">text</td>
      <td style="text-align:center">text</td>
    </tr>
    <tr>
      <td style="text-align:center" class="text-primary">text</td>
      <td style="text-align:center">text</td>
    </tr>
  </tbody>
</table>

Expected output:

<table>
  <thead>
    <tr>
      <th style="text-align:center">title</th>
      <th style="text-align:center">title</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align:center">text</td>
      <td style="text-align:center" class="text-primary">text</td>
    </tr>
    <tr>
      <td style="text-align:center" class="text-primary">text</td>
      <td style="text-align:center">text</td>
    </tr>
  </tbody>
</table>

Diff:

<table>
  <thead>
    <tr>
      <th style="text-align:center">title</th>
      <th style="text-align:center">title</th>
    </tr>
  </thead>
  <tbody>
-    <tr class="text-primary">
+    <tr>
      <td style="text-align:center">text</td>
-      <td style="text-align:center">text</td>
+      <td style="text-align:center" class="text-primary">text</td>
    </tr>
    <tr>
      <td style="text-align:center" class="text-primary">text</td>
      <td style="text-align:center">text</td>
    </tr>
  </tbody>
</table>
@arve0
Copy link
Owner

arve0 commented Aug 11, 2024

Fixed in v4.2.0, thanks to @TheNorthMemory :octocat:

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

Successfully merging a pull request may close this issue.

2 participants