Skip to content

Escaping of square brackets breaks links of embedded attachments for external Markdown Editor #4795

Closed

Description

@chrda81

Short summary of the issue

I'm using an external Markdown Editor (Obsidian) and sync the files via the NextCloud Desktop Client to the server. When saving a markdown file with the NextCloud text editor in the web interface, the links for embedded attachements are broken, because the square brackets are escaped with a backslash. Can this escaping for square brackets (or other chars) manually turned off?

  • Markdown syntax is not properly rendered in text
  • Markdown syntax is removed after closing text
  • Markdown syntax is changed after closing text
  • Something else: Please describe more in detail

Example markdown content

![[Pasted image 20230908203759.png]]

Resulting markdown content after saving

!\[\[Pasted image 20230908203759.png\]\]

Screenshot of the rendering in text

image

Details

  • Nextcloud version: Nextcloud AIO v7.1.1

Activity

  1. juliusknorr commented on Sep 14, 2023

    @juliusknorr
    Member

    Thanks for the report. Can you tell how Obsidian renders this? Is it just a regular image element with a relative path to the image?

  2. chrda81 commented on Sep 14, 2023

    @chrda81
    Author

    Yes, this embedded attachment is put as separate file besides the markdown file and is rendered as image element. Of course, it would be brilliant if the NextCloud text editor could also render these ;)

  3. juliusknorr commented on Sep 14, 2023

    @juliusknorr
    Member

    Kind of related to #1065 but while i commented back then I feel less hesitant to add those if we just cover them to preserve syntax for now.

    This would need a few steps though:

    • Figure out a way to extend markdown-it to properly handle wikilink style links and images
    • Make sure that the used syntax is persistent during editing in the tiptap nodes
    • Properly write back markdown depending on the current syntax

    Most relevant spec for Obsidian is this one https://help.obsidian.md/Linking+notes+and+files/Embedding+files

    As a side note: I kind of like this syntax for "embedding files or links". This could also be interesting to separate a bit more between link previews and parts where people actually want to embed the file content (like a pdf that is rendered inline) - though that is probably something for a different discussion.

  4. juliusknorr commented on Sep 14, 2023

    @juliusknorr
    Member

    @max-nextcloud @mejo- Any thoughts or objections on adding support for that syntax?

  5. max-nextcloud commented on Sep 15, 2023

    @max-nextcloud
    Contributor

    No objections at all. I actually like the syntax and the distinction between embedded content and links.
    First of all I think we should make sure not to mess with the syntax.

  6. Mat-DB commented on Oct 8, 2023

    @Mat-DB

    I noticed the same issue but for a different reason.
    I wanted to add a link to a website but with the link embedded in text.
    The markdown standard supports this in the following way: [Link](http://a.com) markdown website
    But as the issue says the "[" and "]" are escaped with a backslash in the nextcloud text editor and it does not work.

    Is it possible to disable the escaping of this character?
    Or have an option in the menu to do this or using the smart picker, just some ideas.

    Thanks!

  7. juliusknorr commented on Oct 12, 2023

    @juliusknorr
    Member

    I noticed the same issue but for a different reason. I wanted to add a link to a website but with the link embedded in text. The markdown standard supports this in the following way: [Link](http://a.com) markdown website But as the issue says the "[" and "]" are escaped with a backslash in the nextcloud text editor and it does not work.

    Is it possible to disable the escaping of this character? Or have an option in the menu to do this or using the smart picker, just some ideas.

    Thanks!

    This is likely a different topic. We already support []() links in the markdown source, just not during typing. Maybe you can open a separate issue for that.

    You can already create such links through the menu when marking existing text.

  8. sn0n commented on Feb 18, 2024

    @sn0n

    I think there is something else goin on here.... What would be the explanation for this? y\~

    My original text was y~ along with some other password like characters.... Not a ( [ ] or ) in sight.... Or { } either for that matter... Unless starting a line with & is illegal?

  9. sn0n commented on Feb 18, 2024

    @sn0n

    Maybe some xss filter trying to do its sanitation?

  10. KFreon commented on Mar 27, 2024

    @KFreon

    Is there any workaround anyone has found?
    I'm using Obsidian too and it makes switching between editing in nextcloud and obsidian painful due to breaking all the links.

    Is there a way to get raw editing or hook into file save to run my own cleanup script or something?

  11. janLo commented on Apr 29, 2024

    @janLo

    Is there any workaround anyone has found? I'm using Obsidian too and it makes switching between editing in nextcloud and obsidian painful due to breaking all the links.

    Is there a way to get raw editing or hook into file save to run my own cleanup script or something?

    I used to use https://apps.nextcloud.com/apps/files_markdown. But it's a pita that NC decided to not allow to change the default away from texts.

    I've also got this issue if I just want to share a note for viewing. It gets open in the text app and is broken.

    Even if there is no support or exception for unsupported syntax, the app should not change the content if no input was made.

  12. KFreon commented on May 6, 2024

    @KFreon

    I've ended up writing an Obsidian plugin to fix them.
    Looking to get it published to the Obsidian list for use.

  13. 13 remaining items

  14. MrToph commented on Feb 1, 2026

    @MrToph

    same issue for me, nextcloud web shouldn't alter text files upon viewing, this leads to pure synchronization chaos

  15. LuvForAirplanes commented on Feb 2, 2026

    @LuvForAirplanes

    I would be happy to contribute if pointed in the right direction.

  16. Arjenlodder commented on Feb 13, 2026

    @Arjenlodder

    Same issue here! Tried putting the Markdown editor in read-only mode, but even then it edits the files! This should absolutely not happen when something is in read-only mode.

  17. EdoardoCostantini commented on Mar 30, 2026

    @EdoardoCostantini

    Same issue here. Saving a markdown file with wikilinks results in the addition of a backslash (\) before the opened and closed squared bracket of the internal reference.

    Example markdown content

    [[FIle Name]]
    

    Resulting markdown content after saving

    \[\[FIle Name\]\]
    
  18. NEET-FEET commented on Apr 14, 2026

    @NEET-FEET

    Bumping this because it seems like a lossy round-trip serialization bug, not just a rendering issue.

    "![[...]]" is Obsidian wikilink/embed syntax, not plain text. Right now, opening and saving a file appears to flatten that existing source syntax into text and then escape "[" / "]", which rewrites:
    ![[Pasted image 20230908203759.png]]
    to
    !\[\[Pasted image 20230908203759.png\]\]

    That means the editor is not preserving existing Markdown source faithfully. Even if full Obsidian syntax support is out of scope, opening and saving a file without editing that construct should not rewrite it.

    Escaping still makes sense for newly entered literal text. The problem is applying that escaping to already-authored source syntax during round-trip.

    A safer fix would be to either preserve unknown constructs verbatim, or ensure wikilink/embed syntax does not go through the generic text escaping path.

  19. LuvForAirplanes commented on Apr 15, 2026

    @LuvForAirplanes

    If you all can put steam behind this one, it fixes the issue: #8420

  20. self-assigned this
    on May 10, 2026
  21. added 3 commits that reference this issue on May 10, 2026
    9fd2637
    6856eb0
    4cd5699
  22. reopened this on May 10, 2026
  23. added a commit that references this issue on May 10, 2026
    5711ca8
  24. added a commit that references this issue on May 13, 2026
    7101149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions