You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In pdfTeX, long documents with many short markdown fragments present a speed challenge, since every fragment loads the whole Markdown package with its requirements and PEG parsers. The cache implemented by the option eagerCache improves the situation by preventing the repeated parsing of the same fragments on subsequent runs. However, the package is still loaded.
We should separate the file markdown.lua into a new file markdown-parser.lua, which would contain most of the current implementation, and a smaller file markdown.lua, which would only contain a skeleton method M.new(). This method would lazily load the Markdown package only when there is a conversion attempt that cannot be satisfied by the cache.
Adding an extra file would make the manual installation somewhat more error-prone and would slightly increase the chance of version mismatch between files. However, it would provide us with some extra breathing room when it comes to speed.
The text was updated successfully, but these errors were encountered:
Witiko
added
lua
Related to the Lua interface and implementation
speed
Related to speed improvements
labels
Aug 22, 2024
Interestingly, this change would also allow us to use other parsers instead of markdown-parser.lua. I don't have any clear use cases but using a Gruber-style parser from Markdown 2 instead of the CommonMark parser from Markdown 3 or a parser for different flavor of markdown altogether, using a simpler and faster parser for simple documents with no syntax extensions, or having a separate PEG parser for YAML documents instead of tinyyaml, which is regex-based, kinda slow, and only supports a subset of YAML, all seem feasible and potentially useful.
More generally, this change could be a stepping stone towards a more general architecture that might subsume the Markdown package and support different types of lightweight markup languages with separate parsers.
In pdfTeX, long documents with many short markdown fragments present a speed challenge, since every fragment loads the whole Markdown package with its requirements and PEG parsers. The cache implemented by the option
eagerCache
improves the situation by preventing the repeated parsing of the same fragments on subsequent runs. However, the package is still loaded.We should separate the file
markdown.lua
into a new filemarkdown-parser.lua
, which would contain most of the current implementation, and a smaller filemarkdown.lua
, which would only contain a skeleton methodM.new()
. This method would lazily load the Markdown package only when there is a conversion attempt that cannot be satisfied by the cache.Adding an extra file would make the manual installation somewhat more error-prone and would slightly increase the chance of version mismatch between files. However, it would provide us with some extra breathing room when it comes to speed.
The text was updated successfully, but these errors were encountered: