nextcloud / text

📑 Collaborative document editing using Markdown
GNU Affero General Public License v3.0
550 stars 87 forks source link

Lines that start with a colon are escaped upon save #969

Closed ainola closed 1 year ago

ainola commented 4 years ago

Describe the bug Related to #325 in that escapes are wrongly saved into the file under specific circumstances. In this case, it appears to happen only when the line begins with a colon (I use markdown with vimwiki and tags start with a colon)

To Reproduce Steps to reproduce the behavior:

  1. Create new .md file from the web interface
  2. Input the following text:
    test:
    :test:
    :test:test:
    :test:
  3. Close the document
  4. Download the document and open in a text edit
  5. Observe that lines 2 and 3 now begin with a slash:
    test:
    \:test:
    \:test:test:
    :test:

Expected behavior Preserved documents

Client details:

Server details **Text app version:** 3.0.1 **Operating system:** Debian 10 **Web server:** Nginx **Database:** PostgreSQL 11 **PHP version:** 7.3 **Nextcloud version:** 19.0.1
ainola commented 4 years ago

I just noticed that it appears to occur with any special character: My lists are all mangled whether they're asterisks or hyphens.

susnux commented 2 years ago

This is an upstream issue: https://github.com/ProseMirror/prosemirror-markdown/issues/76

susnux commented 2 years ago

Fixed upstream, will be fixed with next prosemirror-markdown release (>= 1.9.4)

ainola commented 2 years ago

Thanks for this, @susnux!

Looking at the fix, it seems it would only solve colons whereas asterisks (possibly even more) are currently experiencing the same issue.

susnux commented 2 years ago
  1. A single * should be interpreted as an empty list element if the line, above it is empty, as of commonmark specs. e.g.:
    
    text

*


should be interpreted as an empty list, this works as expected.

2. An asterisk on a new line following a line with text is not defined within common mark, so it has no meaning but could either be the start of formatting or simply one typed an asterisks, for prosemirror this is hard to distinguish so it is interpreted as a normal character and therefor escaped.

Of cause this could be interpreted the other way, but I doubt upstream will change the behavior :/
mejo- commented 1 year ago

Given that this was fixed in prosemirror-markdown 1.9.4 and we already use 1.10.0, I'll close this ticket. Feel free to reopen if it's still an issue.