Repository navigation
Conversation
markdown-it's default preset enables strikethrough, but the CommonMark model has no node for it, so fromMarkdown threw "Unknown inline type s_open" on any ~~...~~ span, in CommonMark and CiceroMark alike. Disable the rule on the CommonMark, CiceroMark and TemplateMark parsers so ~~ stays literal text, as in CommonMark 0.31.2. toMarkdown wrote | unescaped inside table cells, so a cell containing an escaped pipe split into two on the next parse and a header row lost its table. The Text and Code rules now escape | as \| inside TableCell and HeaderCell, which also covers text inside emphasis, links and other inline nodes. Text outside a table is unchanged. Closes accordproject#692 Signed-off-by: rue19 <shrinjalik@gmail.com>
This branch has not been deployed
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.
Closes #692
fromMarkdownno longer throws on~~...~~, andtoMarkdownescapes|inside table cells, so tables containing a pipe round-trip intact.On
main(15a54f7) and on this branch:mainPrice is ~~$100~~ $80.(CommonMark and CiceroMarkfromMarkdown)Unknown inline type s_openTextnode,~~kept, round-trips unchangeda | btoMarkdownwrites| a | b | ok |, reparsed as['a', 'b']a \| b, reparsed as['a | b', 'ok']a | b`a | b`or*a | b*in a cella | boutside a tableChanges
CommonMarkTransformer.toTokens,CiceroMarkTransformer.toTokens,templateToTokens:.disable('strikethrough'). The CommonMark model has no strikethrough node, so~~is kept as literal text, as in CommonMark 0.31.2.CommonMarkUtils: addsinTableCell(parameters), which checks the block stack forTableCell/HeaderCell, andescapeTableCell().fromcommonmarkrules.ts: theTextandCoderules escape|as\|only inside a cell. Emphasis, links and other inline nodes are covered because their text is rendered byText. CiceroMark'stoMarkdownCicerouses the same rules, so it's fixed too.Flags
~~vs a strikethrough node: this keeps~~as text and doesn't change the model. Modelling strikethrough would mean a new node in the hosted CommonMark model plus rules in every transformer, which seemed better as its own discussion. Happy to change direction if you'd prefer that.fromMarkdownthrew on~~, so no existing document could depend on strikethrough. No snapshots changed.Testing
CommonMarkTransformer.test.ts: literal~~with an exact DOM and round trip; body cell, header cell, inline code and emphasis cases, each asserting the reparsed DOM equals the original; the escaped output; and|outside a table left alone.CiceroMarkTransformer.test.ts:~~throughfromMarkdownCicero/toMarkdownCicero, and a table round trip.TemplateMarkTransformer.test.ts: nos_opentoken, and~~kept as text next to a{{variable}}.mainand pass here. The tenth (|outside a table) passes on both, as intended.npm test(all packages, licence check): passes, no snapshot changes. Lint is clean in all 8 packages. The Playwright e2e suite passes (10/10).Author Checklist
--signoffoption of git commit.mainfromfork:branchnameAI Assistance
AI assistance was used in preparing, reviewing, and testing this change.