phfaist / pylatexenc

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion
https://pylatexenc.readthedocs.io
MIT License
301 stars 37 forks source link

suggestion for simpler/more correct MacroArgs #80

Open nschloe opened 2 years ago

nschloe commented 2 years ago

Right now, macro args are represented as

ParsedMacroArgs(
    argspec="{",
    argnlist=[...],
)

where len(argspec) == len(argnlist). My suggestion would be to slightly alter this structure to

[
    MacroArg(
        argspec="[",
        arg=#...
    ),
    MacroArg(
        argspec="{",
        arg=#...
    ),
]

This has the advantage that illegal state are irrepresentable (len(argspec) == len(argnlist) is implicit).