Skip to content

Working on v2 #463

@pddg

Description

@pddg

I have made some modifications since I became one of the maintainers, but I have not been able to actively participate in the development over the past few years.
I had discovered some problems but had put them off due to the complexity of the current code base.

Several major events have occurred during this time.

This project is a viable solution for using textlint in LaTeX, even in the year 2024, with no alternative.
I began to think that it might be appropriate to rebuild the entire project once in order to maintain it on an ongoing basis.
This means building v2 from scratch.

Which parser library is better for us?

For v2 I re-evaluated several LaTeX parsers written in TypeScript or JavaScript.
Sample TeX source is as follows:

% This is the beginning of the document
\documentclass{article}  % This is a comment

\begin{document}

This is a paragraph that contains inline math: $E=mc^2$.
This is a second line.

% This is the beginning of the nested document
\begin{itemize}
    \item First item
    \item Second item
    \item Third item
\end{itemize}

\begin{tabular}{|c|c|c|}
    \hline
    Column 1 & Column 2 & Column 3 \\
    \hline
    Row 1 & Row 1 & Row 1 \\
    \hline
    Row 2 & Row 2 & Row 2 \\
    \hline
\end{tabular}

\end{document}

latex-utensils v6.2.0

Generated AST of sample tex source is here.

  • Pros
    • We already know this parser
    • Fast
    • Less dependencies
  • Cons
    • space, linebreak, softbreak do not have location information.
    • Comments can be parsed, but it is not in AST. We should calculate the position of them in AST.
      • completeComment func is implemented for this.

unified-latex v1.6.0

Generated AST of sample tex source is here.

completeBlank and completeComment is hard to maintain. I think it might be worth the transition.

LaTeX.js v0.12.6

(As far as I could tell) this could not be used as a mere parser.
It may be possible to define a Generator that generates textlint ASTs from LaTeX ASTs.
However, I do not know how to create a Generator. Document says TODO, now.
https://latex.js.org/api.html#class-generator

Create original one

Another option would be to make your own, but the reason other parsers produce such output in the first place is because that is the way TeX syntax is written.
Therefore, it is difficult to imagine that a home-built parser would be significantly easier for us to use.

Goal of v2

Non Goal

  • Keep AST compatible with v1
  • Enhance unit tests currently implemented

How do we do

As maintainers, we should work on one of the following

  • Work on v2
  • Continue to improve on v1
  • Declare Deprecated and archive repository

Which one do you think is better? @tani @kn1cht

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions