Summary
A link title is rewritten to the double-quoted form on save, whichever of CommonMark's three forms the author used. The title text is preserved, so this is an authored-form rewrite rather than a loss, and it is one of the differences keeping corpus/commonmark/links-and-images.md from byte identity.
Steps to reproduce
- Open a document containing
[Single quote](garden.md 'Garden').
- Save it.
- Read the file.
Expected behavior
[Single quote](garden.md 'Garden'). CommonMark accepts a title in double quotes, single quotes, or parentheses, and the corpus covers all three.
Actual behavior
Measured against 9626471d by driving the editor mount used by the plugin tests. Stable across a second save:
| Document |
Saved |
[Single quote](garden.md 'Garden') |
[Single quote](garden.md "Garden") |
[Parentheses](garden.md (Garden)) |
[Parentheses](garden.md "Garden") |
[Double quote](garden.md "Garden") is unchanged.
Related context
Done when
Notes, logs, screenshots
Diagnosis
mdast records only the title's text, not its delimiters, and mdast-util-to-markdown writes it with the single quote option, which is one setting for the whole document. Nothing in the pipeline carries the authored form as far as the serializer.
Implementation direction
#243 solved the same shape of problem for a bare URL by recovering the authored form from the source rather than by adding document state, and #245 concluded against storing an authored form where it can be derived. Neither applies cleanly here: a title's delimiters are not recoverable from the title text, so this one probably does need the authored delimiter carried on the node, which makes it a smaller version of the decision #245 answered for escapes. Worth confirming the direction in this issue before implementation.
The quote option is per document, so a per-node choice needs a link, image, and definition handler override in createMilkdownEditor.ts, alongside the text one #252 added.
Out of scope
- The destination, which is a separate normalization filed on its own.
- Reference definitions disappearing on save, filed on its own.
Summary
A link title is rewritten to the double-quoted form on save, whichever of CommonMark's three forms the author used. The title text is preserved, so this is an authored-form rewrite rather than a loss, and it is one of the differences keeping
corpus/commonmark/links-and-images.mdfrom byte identity.Steps to reproduce
[Single quote](garden.md 'Garden').Expected behavior
[Single quote](garden.md 'Garden'). CommonMark accepts a title in double quotes, single quotes, or parentheses, and the corpus covers all three.Actual behavior
Measured against
9626471dby driving the editor mount used by the plugin tests. Stable across a second save:[Single quote](garden.md 'Garden')[Single quote](garden.md "Garden")[Parentheses](garden.md (Garden))[Parentheses](garden.md "Garden")[Double quote](garden.md "Garden")is unchanged.Related context
corpus/commonmark/links-and-images.mdunderQuoted and parenthesized link titles.Done when
Notes, logs, screenshots
Diagnosis
mdastrecords only the title's text, not its delimiters, andmdast-util-to-markdownwrites it with the singlequoteoption, which is one setting for the whole document. Nothing in the pipeline carries the authored form as far as the serializer.Implementation direction
#243 solved the same shape of problem for a bare URL by recovering the authored form from the source rather than by adding document state, and #245 concluded against storing an authored form where it can be derived. Neither applies cleanly here: a title's delimiters are not recoverable from the title text, so this one probably does need the authored delimiter carried on the node, which makes it a smaller version of the decision #245 answered for escapes. Worth confirming the direction in this issue before implementation.
The
quoteoption is per document, so a per-node choice needs alink,image, anddefinitionhandler override increateMilkdownEditor.ts, alongside thetextone #252 added.Out of scope