Skip to content

Link text escaping of backslash is removed #2703

@susnux

Description

@susnux

Describe the bug

If a link text contains a backslash the escaping of it is removed after the serialization, this leads to invalid markdown after the file is opened the next time.

To Reproduce

Consider this markdown file (from example 549 of the commonmark specs):

[bar\\]: /uri

[bar\\]

Open is using the text app, save it and have a look at the content using a plain text editor.

Expected behavior
Best case would be no modification, but at least the link should stay the same, so following output is expected:

[bar\\](/uri)

But instead this is generated by the text app:

[bar\](/uri)

Which is not a link as now the backslash escapes the ].

Details

This was introduced as a fix for #325 with 3c350b2.
There is this testcase for it, which I am not sure why it is there as this is not valid markdown:

expect(markdownThroughEditor('- [ [asd](sdf)')).toBe('* [ [asd](sdf)')

- [ [asd](sdf)

The specification forbids (github) forbids more than one character inside task items and CommonMark forbids unescaped brackets within link texts, so this should be interpreted as this instead:

- \[ [asd](sdf)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions