dishmint / Markdown2WL

Lex and Parse Markdown in Wolfram Language
MIT License
13 stars 2 forks source link

[Parsing] Using Fold and Character lists #40

Open dishmint opened 3 months ago

dishmint commented 3 months ago

I've read a few times that using RegEx for markdown parsing is not ideal, iirc, because the regex can't capture certain markdown scenarios.

A character reader could be implemented with Fold:


string = "_this_ is **markdown**";

Fold[ lex, "<start_markdown>", Characters@string ]

could add DataStructure into this


string = "_this_ is **markdown**";

ds = CreateDataStructure["Stack"];

Fold[ lex[ds], "<start_markdown>", Characters@string ]

Then the lex function would update the stack.