Skip to content

tabular environment is treated as a paragraph in the textlint AST #69

@kn1cht

Description

@kn1cht

Problem

textlint-rule-ja-no-mixed-period points out "no period" errors in tabular environments.

image

Cause

\begin{table}[]
  \begin{tabular}{cc}
    This is & a table
  \end{tabular}
\end{table}

This LaTeX code is converted to an AST like below.
Since textlint-rule-ja-no-mixed-period treats the last Str node of a Paragraph node as the end of a sentence, converting a tabular environment to these nodes causes an unexpected error.

{
  "type": "Document",
  "raw": "...",
  "range": [],
  "loc": {},
  "children": [
    {
      "loc": {},
      "range": [],
      "raw": "cc}\n        This is & a table",
      "type": "Paragraph",
      "children": [
        {
          "loc": {},
          "range": [],
          "raw": "cc",
          "type": "Str",
          "value": "cc"
        },
        {
          "loc": {},
          "range": [],
          "raw": "}\n        ",
          "type": "Html",
          "value": "}\n        "
        },
        {
          "loc": {},
          "range": [],
          "raw": "This",
          "type": "Str",
          "value": "This"
        },
        // ...
      ]
    }
  ]
}

Solution

textlint-plugin-review seems to treat each item in a table as a ListItem node.
We can also wrap Str nodes into ListItem nodes.

orangain/textlint-plugin-review#6

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions