mongodb-university / Bluehawk

A markup language and tool for extracting code examples, checkpointing tutorials, and dynamically transforming text
https://mongodb-university.github.io/Bluehawk/
Other
29 stars 17 forks source link

Fix C++ syntax collision #150

Closed dacharyc closed 6 months ago

dacharyc commented 6 months ago

Closes #145

This adds regex to avoid matching Bluehawk tags surrounded by :: - it should only match tags with a single : surrounding them. This resolves C++ syntax issues, as C++ uses :: to reference class members.

Added a test - with the old patterns, it fails as expected, but with the new patterns, the integration test runs.

This also coincidentally fixes 1 of the failing tests reported in #149.

Upon initially adding the new regex, I got a few warnings from Chevrotain which Bluehawk reported as Errors. First was Unable to identify line terminator usage in pattern, detailed in the Chevrotain docs here: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR

Adding line_breaks: false, resolved this warning/error.

Then I got Failed parsing < /.../ > Using the regexp-to-ast library, detailed in the Chevrotain docs here: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING

Per the docs recommendation, I added the start_chars_hint property to resolve these errors.

With these changes, the only failing tests are now tests that were failing before this PR.