textlint-plugin-latex2e
textlint-plugin-latex2e copied to clipboard
tabular environment is treated as a paragraph in the textlint AST
Problem
textlint-rule-ja-no-mixed-period points out "no period" errors in tabular environments.

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.
https://github.com/orangain/textlint-plugin-review/pull/6
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.
@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
OMG, should we send request to ast-node-types?
Thanks for writing the issue. I will wait answers and decide which node to use for tabluar environments.