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

Improve parsing \item in itemize, enumerate environment #84

Open
pddg opened this issue Feb 20, 2021 · 0 comments
Open

Improve parsing \item in itemize, enumerate environment #84

pddg opened this issue Feb 20, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@pddg
Copy link
Member

pddg commented Feb 20, 2021

Abstract

ListItem represents an item in the List environment. However, itemize and enumerate environments are parsed as ListItem nodes in Paragraph, now.

Sample source

Sample of itemize environment: itemize.tex

\begin{itemize}
  \item item1
  \item item2
\end{itemize}

Sample of enumerate environment: enumerate.tex

\begin{enumerate}
  \item item1
  \item item2
\end{enumerate}

Current behavior

npx tex2tast -r itemize.tex
{
  "type": "Document",
  "raw": "\\begin{itemize}\n    \\item item1\n    \\item item2\n\\end{itemize}",
  "children": [
    {
      "raw": "item1\n    \\item item2",
      "type": "Paragraph",
      "children": [
        {
          "raw": "item1",
          "type": "ListItem",
          "children": [
            {
              "raw": "item1",
              "type": "Str",
              "value": "item1"
            }
          ]
        },
        {
          "raw": "\n    \\item ",
          "type": "Html",
          "value": "\n    \\item "
        },
        {
          "raw": "item2",
          "type": "ListItem",
          "children": [
            {
              "raw": "item2",
              "type": "Str",
              "value": "item2"
            }
          ]
        }
      ]
    }
  ]
}
npx tex2tast -r enumerate.tex
{
  "type": "Document",
  "raw": "\\begin{enumerate}\n    \\item item1\n    \\item item2\n\\end{enumerate}",
  "children": [
    {
      "raw": "item1\n    \\item item2",
      "type": "Paragraph",
      "children": [
        {
          "raw": "item1",
          "type": "ListItem",
          "children": [
            {
              "raw": "item1",
              "type": "Str",
              "value": "item1"
            }
          ]
        },
        {
          "raw": "\n    \\item ",
          "type": "Html",
          "value": "\n    \\item "
        },
        {
          "raw": "item2",
          "type": "ListItem",
          "children": [
            {
              "raw": "item2",
              "type": "Str",
              "value": "item2"
            }
          ]
        }
      ]
    }
  ]
}

Expected behavior

  • ListItem must be in List.
  • \item is a part of LIstItem.
  • ListItem's children must be parsed normally.
{
  "type": "Document",
  "raw": "\\begin{itemize}\n    \\item item1\n    \\item item2\n\\end{itemize}",
  "children": [
    {
      "raw": "\\begin{itemize}\n    \\item item1\n    \\item item2\n\\end{itemize}",
      "type": "List",
      "children": [
        {
          "raw": "\n    ",
          "type": "Html",
          "value": "\n    "
        },
        {
          "raw": "\\item item1",
          "type": "ListItem",
          "children": [
            {
              "raw": "item1",
              "type": "Paragraph",
              "children": [
                {
                  "raw": "item1",
                  "type": "Str",
                  "value": "item1"
                }
              ]
            }
          ]
        },
        {
          "raw": "\n    ",
          "type": "Html",
          "value": "\n    "
        },
        {
          "raw": "\\item item2",
          "type": "ListItem",
          "children": [
            {
              "raw": "item2",
              "type": "Paragraph",
              "children": [
                {
                  "raw": "item2",
                  "type": "Str",
                  "value": "item2"
                }
              ]
            }
          ]
        },
        {
          "raw": "\n",
          "type": "Html",
          "value": "\n"
        },
      ]
    }
  ]
}
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

1 participant