Skip to content

The serializer escapes a leading asterisk the strong run beside it already leaves literal #353

Description

@Azganoth

Summary

The serializer escapes a leading * that the strong run beside it already keeps literal. ***text** parses as a literal asterisk followed by strong emphasis, and saving it writes \***text**. The backslash changes nothing: the unescaped form reparses to the same document, measured below.

This is the class #252, #256, #257, #258, #271, #289, #292, and #293 removed, reaching a run the pairing leaves over. It is also the serializer disagreeing with itself: the same save drops an unnecessary escape from a link destination and from a text run, then adds one here.

Steps to reproduce

  1. Open a document containing ***text**.
  2. Save it without editing.
  3. Read the file.

Expected behavior

***text**. The three-asterisk run spells one literal asterisk and a two-asterisk opener, and the run itself is what keeps the leftover literal, so no backslash is needed to hold it.

Actual behavior

Measured against 83033d4b by driving the editor mount used by the plugin tests, on corpus/commonmark/emphasis.md line 59.

Document Saved
***asterisk combination missing one closer** \***asterisk combination missing one closer**

The escape is redundant, not merely cosmetic. Both spellings parse to the same document:

Source Document
\***asterisk combination missing one closer** literal * followed by strong asterisk combination missing one closer
***asterisk combination missing one closer** literal * followed by strong asterisk combination missing one closer

Closure and convergence both hold today, so neither the corpus round-trip guard nor the document-preservation guard can see this. What it costs is byte identity for corpus/commonmark/emphasis.md.

The same save normalizes in the opposite direction elsewhere in the corpus, which is what makes this a defect rather than a house style: [Escaped](garden\(section\).md) is written back as [Escaped](garden(section).md), and a run of escaped ASCII punctuation is written back with only the escapes that carry weight.

Related context

Done when

Notes, logs, screenshots

Out of scope

  • The underscore spelling, ___text__, which was not measured. Confirm whether it behaves the same before deciding whether the fix covers one delimiter or both.
  • Escapes dropped from a link destination and from a text run, which follow from an escape being derived rather than owned and are not defects.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions