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

HTML table causes wrong sectioning (vfm 2.2.0) #183

Closed
MurakamiShinyu opened this issue Nov 3, 2023 · 0 comments · Fixed by #184
Closed

HTML table causes wrong sectioning (vfm 2.2.0) #183

MurakamiShinyu opened this issue Nov 3, 2023 · 0 comments · Fixed by #184
Assignees
Labels
bug Something isn't working

Comments

@MurakamiShinyu
Copy link
Member

Issue Details

問題が起きるMarkdownの例:

# A

## A-1

<table>
<tr>
<td>

P

</td>
</tr>
</table>

## A-2

VFMのsection化で、"A-2" のセクションは "A-1" のセクションと同じレベルのはずなのにひとつ下のレベルになってしまう不具合がある。

  • VFM version
    • 2.2.0

前のバージョン v2.1.0 ではこの問題ではこの不具合は起きない。v2.2.0 での修正の副作用のようである。

Expected Behavior

次のように "A-2" のセクションは "A-1" のセクションと同レベルになるべき(vfm 2.1.0 での出力):

<section class="level1" aria-labelledby="a">
  <h1 id="a">A</h1>
  <section class="level2" aria-labelledby="a-1">
    <h2 id="a-1">A-1</h2>
    <table>
      <tbody>
        <tr>
          <td>
            <p>P</p>
          </td>
        </tr>
      </tbody>
    </table>
  </section>
  <section class="level2" aria-labelledby="a-2">
    <h2 id="a-2">A-2</h2>
  </section>
</section>

Actual Behavior

次のように "A-2" のセクションは "A-1" のセクションの下のレベルになる(vfm 2.2.0 での出力):

<section class="level1" aria-labelledby="a">
  <h1 id="a">A</h1>
  <section class="level2" aria-labelledby="a-1">
    <h2 id="a-1">A-1</h2>
    <table>
      <tbody>
        <tr>
          <td>
            <p>P</p>
          </td>
        </tr>
      </tbody>
    </table>
    <section class="level2" aria-labelledby="a-2">
      <h2 id="a-2">A-2</h2>
    </section>
  </section>
</section>

Debug log (Any)

Run vfm with DEBUG=vfm to see detailed log.

DEBUG=vfm vfm TEST.md
  vfm 
  vfm ### mdast ### +0ms
  vfm root[3] (1:1-16:1, 0-64)
  vfm ├─0 section[2]
  vfm │   │ data: {"hName":"section","hProperties":{"class":["level1"],"aria-labelledby":"a"}}
  vfm │   │ depth: 1
  vfm │   ├─0 heading[1] (1:1-1:4, 0-3)
  vfm │   │   │ depth: 1
  vfm │   │   │ data: {"hProperties":{"id":"a"},"id":"a"}
  vfm │   │   └─0 text "A" (1:3-1:4, 2-3)
  vfm │   └─1 section[3]
  vfm │       │ data: {"hName":"section","hProperties":{"class":["level2"],"aria-labelledby":"a-1"}}
  vfm │       │ depth: 2
  vfm │       ├─0 heading[1] (3:1-3:7, 5-11)
  vfm │       │   │ depth: 2
  vfm │       │   │ data: {"hProperties":{"id":"a-1"},"id":"a-1"}
  vfm │       │   └─0 text "A-1" (3:4-3:7, 8-11)
  vfm │       ├─1 html "<table>\n<tr>\n<td>" (5:1-7:5, 13-30)
  vfm │       └─2 paragraph[1] (9:1-9:2, 32-33)
  vfm │           └─0 text "P" (9:1-9:2, 32-33)
  vfm ├─1 html "</td>\n</tr>\n</table>" (11:1-13:9, 35-55)
  vfm └─2 section[1]
  vfm     │ data: {"hName":"section","hProperties":{"class":["level2"],"aria-labelledby":"a-2"}}
  vfm     │ depth: 2
  vfm     └─0 heading[1] (15:1-15:7, 57-63)
  vfm         │ depth: 2
  vfm         │ data: {"hProperties":{"id":"a-2"},"id":"a-2"}
  vfm         └─0 text "A-2" (15:4-15:7, 60-63) +1ms
  vfm 
  vfm ### hast ### +6ms
  vfm root[1] (1:1-16:1, 0-64)
  vfm │ data: {"quirksMode":false}
  vfm └─0 element<section>[2] (13:1, 47)
  vfm     │ properties: {"className":["level1"],"ariaLabelledBy":["a"]}
  vfm     ├─0 element<h1>[1] (1:1-1:4, 0-3)
  vfm     │   │ properties: {"id":"a"}
  vfm     │   └─0 text "A" (1:3-1:4, 2-3)
  vfm     └─1 element<section>[4] (13:1, 47)
  vfm         │ properties: {"className":["level2"],"ariaLabelledBy":["a-1"]}
  vfm         ├─0 element<h2>[1] (3:1-3:7, 5-11)
  vfm         │   │ properties: {"id":"a-1"}
  vfm         │   └─0 text "A-1" (3:4-3:7, 8-11)
  vfm         ├─1 element<table>[2] (5:1-13:9, 13-55)
  vfm         │   │ properties: {}
  vfm         │   ├─0 text "\n" (5:8-6:1, 20-21)
  vfm         │   └─1 element<tbody>[2]
  vfm         │       │ properties: {}
  vfm         │       ├─0 element<tr>[3] (6:1-12:6, 21-46)
  vfm         │       │   │ properties: {}
  vfm         │       │   ├─0 text "\n" (6:5-7:1, 25-26)
  vfm         │       │   ├─1 element<td>[2] (7:1-11:6, 26-40)
  vfm         │       │   │   │ properties: {}
  vfm         │       │   │   ├─0 element<p>[1] (9:1-9:2, 32-33)
  vfm         │       │   │   │   │ properties: {}
  vfm         │       │   │   │   └─0 text "P" (9:1-9:2, 32-33)
  vfm         │       │   │   └─1 text "\n"
  vfm         │       │   └─2 text "\n" (11:6-12:1, 40-41)
  vfm         │       └─1 text "\n" (12:6-13:1, 46-47)
  vfm         ├─2 text "\n"
  vfm         └─3 element<section>[1]
  vfm             │ properties: {"className":["level2"],"ariaLabelledBy":["a-2"]}
  vfm             └─0 element<h2>[1] (15:1-15:7, 57-63)
  vfm                 │ properties: {"id":"a-2"}
  vfm                 └─0 text "A-2" (15:4-15:7, 60-63) +0ms
  vfm {} +6ms
@MurakamiShinyu MurakamiShinyu added the bug Something isn't working label Nov 3, 2023
@MurakamiShinyu MurakamiShinyu self-assigned this Nov 3, 2023
akabekobeko added a commit that referenced this issue Nov 5, 2023
* fix: HTML block causes wrong sectioning (vfm 2.2.0)

- fix #183

* Update src/plugins/section.ts

Co-authored-by: akabeko <akabekobeko@gmail.com>

* fix previous commit

---------

Co-authored-by: akabeko <akabekobeko@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant