Repository navigation
Conversation
…reamed prefix The first one or two backticks or tildes of a fence opener, the start of an open fence's closing fence, and a lone $ before $$ showed as text or as a line of code and then vanished once the delimiter completed. The streaming filter now withholds them until the next character decides, so the result is the one the stream had before they arrived. Fixes software-mansion#1130.
|
Hello @Mohith26! Thanks for your effort in developing the library! I reviewed the code and it looks solid but I think it doesn't cover all cases. Could you checkout and possibly add unit tests for those examples: 1. A fence that starts a list item or quote still collapses The new hold keeps the
The same happens with Suggestion: while the opener waits, cut at the fence marker rather than at the line start, so 2. Closing fences in lists and quotes still add a line and then remove it The backticks are withheld, but the line's prefix is kept, and md4c reads that prefix as a blank code line. The new
A list closer does the same through its indent, for example Suggestion: inside an open fence, drop a last line that holds only whitespace or container markers. |
… in open fences While a fence waits for its opening line to end (or stays hidden), cut it at its marker instead of at the line start, so a list item or quote that starts with a fence keeps its bullet or quote bar (a streamed "- ```" now gives "- "). Inside an open fence, withhold a last line that holds only whitespace or container markers. md4c read it as a blank line of code that then disappeared when the closing fence arrived in a list item or quote. Adds unit tests for list, ordered, quoted, quoted-list and nested items, the closing-fence cases in quotes and lists, and a fuzz check that no streamed code block shows more lines than the finished one.
38726d8 to
84ad877
Compare
|
Thanks @jnowakow, both were real. Fixed in 84ad877 with tests for each case. 1. Fence at the start of a list item or quote. While the opener waits, the filter now cuts at the fence marker instead of the line start, so 2. Closing fences in lists and quotes. Inside an open fence, a last line that holds only whitespace or container markers (up to the fence's quote depth) is now withheld from its start. Your examples now give code contents I also added a list-item fence to the fuzz corpus and a second md4c check there: no streamed prefix may show a code block with more lines than the finished block has. On the previous commit it fails on the corpus; now it passes.
|

What/Why?
Fixes #1130. While a fence is streaming in, its first one or two backticks (or tildes) showed as prose and then vanished when the third arrived, which adds and removes a line in the native renderers. The same thing happens at the other end: inside an open fence, the first characters of the closing fence showed as a line of code until the fence closed. A lone
$before$$had the same flash.scanBlocksnow notes when the unterminated last line is only the start of one of these delimiters:$, read the same waycutPendingMathreads$$lines.In that case the filter returns the result for the text before those characters, so nothing changes on screen until the next character decides. Anything else (
`code`,~~strike~~,$5, four-space indents, mixed fence characters, an ended line) is released as before, and once the third character arrives the existing waiting-opener rule takes over. Quote markers and list bullets on the same line stay visible, so a list item that starts with inline code does not lose its bullet for a tick.Testing
scripts/test-core-parser.shpasses (filter unit tests, fuzz, cost-per-tick bench, golden AST, coexistence check).filter(head + partial) == filter(head)for each partial marker after nine different heads in both modes, plus explicit cases for the hand-off at three characters, releases, closing fences in quotes/lists, longer fences, tilde fences and math.$that the finished document does not contain. I added a tilde fence and a$$block to its corpus. Before this change that check fails on 42 prefix/mode combinations across the corpus and fixtures; after it, 0.I could not run the iOS/Android example apps or Maestro here, so the native checkboxes are unticked; the change is confined to the shared C++ filter.
PR Checklist