Skip to content

HTML プラグインと併用すると検出されない場合がある #4

@hankei6km

Description

@hankei6km

再現手順

設定(textlintrc)

{
  "plugins": [
    "html"
  ],
  "rules": {
     "@textlint-ja/no-synonyms": true
  }
}

試した文章(test.html)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <p>サーバとサーバーの表記揺れがある。</p>
    <p>この雇入と雇入れの違いを見つける。</p>
  </body>
</html>

実行結果。

$ npx textlint --c textlintrc test.html

<< 結果の出力無し >>

期待する結果

  • 「サーバ」と「サーバー」、「雇入」と「雇入れ」それぞれが同義語として検出される。

実際の結果

  • どちらも検出されない。

ワークアラウンド

body 内のみの記述にすると検出されます。

試した文章(test-body.html)

<p>サーバとサーバーの表記揺れがある。</p>
<p>この雇入と雇入れの違いを見つける。</p>

実行結果。

$ npx textlint --c textlintrc test-body.html

/sandbox/reproduce/no-synonym-html/test-body.html
  1:8  error  同義語である「サーバ」と「サーバー」が利用されています  @textlint-ja/no-synonyms
  2:9  error  同義語である「雇入」と「雇入れ」が利用されています      @textlint-ja/no-synonyms

✖ 2 problems (2 errors, 0 warnings)

ワークアラウンドの HTML から作成される AST は Document の直下に Paragraph が作成されます。
一方で、<html><body></body></html> で囲まれていると AST は Document/Html/Html となります。
そのため、以下の設定により除外されていると予想しています。

ignoreNodeTypes: [Syntax.BlockQuote, Syntax.CodeBlock, Syntax.Code, Syntax.Html, Syntax.Link, Syntax.Image, Syntax.Comment]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions