GDQuest / product-packager

A collection of build tools to parse, preprocess, and output content for GDSchool, our LMS for gamedev education
MIT License
56 stars 8 forks source link

Markdown parser needs better error handling for malformed input #31

Closed razcore-rad closed 2 years ago

razcore-rad commented 2 years ago

For example the following Markdown input:

product-packager/tools on  course-builder-rewrite [?⇡] via 👑 v1.6.0 
❯ bat test.md                                                                                                                                                         15:59:23
         File: test.md
     1   ```
     2     # test
     3   Test
     4   
     5   Multi
     6   

Results in this malformed output because we lack the closing triple ` mark:

product-packager/tools on  course-builder-rewrite [?⇡] via 👑 v1.6.0 
❯ nim r --verbosity=0 format_tutorials.nim test.md                                                                                                                    15:59:25

Multi

This could lead to loss of data, especially for the --in-place flag.

razcore-rad commented 2 years ago

The solution I found is to use the tiny honeycomb module and construct a simple GDQuest-focused markdown parser using the parser-combinator methodology.

For reference see TMPA Effects vs Transformers In Parsing and its accompanying repo.