Fix nested comment parsing in literate scripts and add AddHtmlPrinter tests#1138
Merged
Fix nested comment parsing in literate scripts and add AddHtmlPrinter tests#1138
Conversation
… tests
- Fix ParseScript.fs: the comment block parser used LastIndexOf("*)")
to detect comment endings, which incorrectly matched nested
(*** command ***) markers inside markdown text (e.g. backtick-quoted
examples of include-it or include-it-raw). This caused content after
such references to be silently dropped from HTML output. Replaced
with a nesting-aware scanner (findOuterCommentEnd) that properly
tracks (* ... *) depth.
- Add integration tests for:
- Comment blocks containing nested (*** ***) markers
- AddHtmlPrinter with include-it-raw
- AddHtmlPrinter with CSS/JS resources
- AddHtmlPrinter with base64 image pattern (as documented)
- AddPrintTransformer chained with AddHtmlPrinter and include-it-raw
- Fix missing [<Test>] attribute on Can include-output-and-it test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The literate script comment parser in
ParseScript.fsusedLastIndexOf("*)")to detect where(**comment blocks end. This incorrectly matched*)inside nested(*** command ***)markers that appeared in markdown text — for example, backtick-quoted references like `(*** include-it ***)` or `(*** include-it-raw ***)`.This caused a rendering bug in
docs/evaluation.fsx: the section starting with "A common use-case is embedding chart or plot images..." was silently dropped from the generated HTML because the*)inside `(*** include-it-raw ***)` prematurely closed the surrounding(**block.Fix
Replaced the naive
LastIndexOf("*)")with a nesting-aware scanner (findOuterCommentEnd) that properly tracks(* ... *)depth, only matching*)at depth 0.Tests added
(*** ***)markers are not truncatedAddHtmlPrinterwithinclude-it-rawAddHtmlPrinterwith CSS/JS resourcesAddHtmlPrinterwith base64 image pattern (as documented in evaluation.fsx)AddPrintTransformerchained withAddHtmlPrinterandinclude-it-rawOther fixes
[<Test>]attribute onCan include-output-and-ittest (was never executed by the test runner)