Skip to content

div開始タグ直後のテキストが二重に出力される #170

Description

@MurakamiShinyu

不具合が起きるMDの例:

TEST.md

# TEST

<div>
Text

</div>

VFMでのHTMLへの変換結果:

    <section class="level1" aria-labelledby="test">
      <h1 id="test">TEST</h1>
      <div>TextText</div>
    </section>

div要素内のテキストが "Text" のはずなのが "TextText" と二重に出力されている。

この不具合が起きる条件は以下:

  • 見出しが前にある
  • divなどブロック要素の開始タグ直後に(空行なしで)テキストがある
  • テキストのあとに空行があり、そのあとにHTMLタグ(この例のdiv終了タグ以外でも)がある

Debug log

Run vfm with DEBUG=vfm to see detailed log.

DEBUG=vfm vfm TEST.md
  vfm 
  vfm ### mdast ### +0ms
  vfm root[1]
  vfm └─0 section[3]
  vfm     │ data: {"hName":"section","hProperties":{"class":["level1"],"aria-labelledby":"test"}}
  vfm     │ depth: 1
  vfm     ├─0 heading[1]
  vfm     │   │ depth: 1
  vfm     │   │ data: {"hProperties":{"id":"test"},"id":"test"}
  vfm     │   └─0 text "TEST"
  vfm     ├─1 html "<div>\nText"
  vfm     └─2 html "</div>" +0ms
  vfm 
  vfm ### hast ### +3ms
  vfm root[1] (1:1-7:1, 0-27)
  vfm │ data: {"quirksMode":false}
  vfm └─0 element<section>[2]
  vfm     │ properties: {"className":["level1"],"ariaLabelledBy":["test"]}
  vfm     ├─0 element<h1>[1]
  vfm     │   │ properties: {"id":"test"}
  vfm     │   └─0 text "TEST"
  vfm     └─1 element<div>[1] (1:1-1:7, 0-6)
  vfm         │ properties: {}
  vfm         └─0 text "\nTextText" (1:6-1:1, 5-0) +1ms
  vfm {} +2ms
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>TEST</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <section class="level1" aria-labelledby="test">
      <h1 id="test">TEST</h1>
      <div>TextText</div>
    </section>
  </body>
</html>

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions