Repository navigation
Fix dropped text in emphasis handling - #1696
Conversation
Due to the way Python Markdown processes content, we must safeguard against content placed into tails that we've already processed. 1. Built HTML elements we plan to replace ahead of time and place in the cache. They are built as the text is when they were processed. Each entry in the cache will contain the element, the region it replaces, and the anchor (position of next delimiter Python Markdown will before that that region so we can account for new index of the modified buffer). 2. While the cache is not empty, we will sometimes receive tail content, already processed tail content so we can identify and ignore them. 3. Now we just return the pre-built HTML elements until the cache is spent.
- We missed some rule of 3 logic when porting the solution over from BetterEm. - Add in placeholder protection logic that I thought wasn't needed here because we didn't use punctuation logic, but the same placeholder fix that is required in BetterEm is required here as well.
|
It seems in #1691, I had hand ported changes from BetterEm, which Python Markdown's solution is based on, over to Python Markdown. But I had missed that some of the tests used So, I:
I've run a comparison of BetterEm logic to the logic here to make sure we aren't missing anything. The same tests that pass there pass here. There should be no more dropped text. |
|
For reference, the "rule of 3" changes here were supposed to mirror the changes in: And these placeholder changes mirror BetterEm changes here: I have a couple extra things I have to handle in BetterEm due to some Pandoc style superscript and subscript, which is why I mistakenly didn't include some of the rule of 3 things here, and since some of the tests were silently not running here due to the test name mismatch, it got missed. Had the tests been running properly, I would have also caught that we needed the placeholder changes as well. Live and learn, I guess. |
|
Oh, and for completeness, the rest of the emphasis fixes here are based on the changes: If anything, the original changes were fully verified; it was just that when I ported them, I got burned by not properly updating the tests to the framework here and assumed all the tests were passing. To be sure, I have now also hand-verified the test results in this PR to make sure they are correct, and double-checked the results in the CommonMark dingus. I believe we have all the changes properly ported over. |
Description
Due to the way Python Markdown processes content, we must safeguard
against content placed into tails that we've already processed.
the cache. They are built as the text is when they were processed.
Each entry in the cache will contain the element, the region it
replaces, and the anchor (position of next delimiter Python Markdown
will before that that region so we can account for new index of the
modified buffer).
already processed tail content so we can identify and ignore them.
spent.
Fixes #1694
AI Assistance Disclosure
No AI tools were used in preparing this PR.
AI tools were used and I have disclosed which ones, and have fully reviewed and verified their output.
AI tools were use to assist with the following:
Checklist