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

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

Open
kn1cht opened this issue Jan 31, 2021 · 4 comments
Open

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

kn1cht opened this issue Jan 31, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@kn1cht
Copy link
Member

kn1cht commented Jan 31, 2021

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

@kn1cht kn1cht added the bug Something isn't working label Jan 31, 2021
@kn1cht kn1cht self-assigned this Jan 31, 2021
@tani
Copy link
Member

tani commented Jan 31, 2021

Textlint AST provides Table node. Why not use it instead of ListItem?
I note you that the third party parser latex-utensils has no node for table unfortunately.

@kn1cht
Copy link
Member Author

kn1cht commented Jan 31, 2021

@tani
Table nodes surely exists in markdown-to-ast but not in @textlint/ast-node-types.
Thus I couldn't use node types like `ASTnodetypes.Table'.

https://github.com/textlint/textlint/blob/master/docs/txtnode.md#type

@tani
Copy link
Member

tani commented Jan 31, 2021

OMG, should we send request to ast-node-types?

@kn1cht
Copy link
Member Author

kn1cht commented Jan 31, 2021

Thanks for writing the issue.
I will wait answers and decide which node to use for tabluar environments.

@pddg pddg mentioned this issue Feb 11, 2024
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

No branches or pull requests

2 participants