Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 4 tasks
chrda81 opened this issue Sep 14, 2023 · 20 comments
Open
1 of 4 tasks
Labels

Comments

@chrda81
Copy link

chrda81 commented Sep 14, 2023

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
@chrda81 chrda81 added the bug Something isn't working label Sep 14, 2023
@juliusknorr
Copy link
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?

@chrda81
Copy link
Author

chrda81 commented Sep 14, 2023

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 ;)

@juliusknorr
Copy link
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.

@juliusknorr
Copy link
Member

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

@max-nextcloud
Copy link
Collaborator

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.

@Mat-DB
Copy link

Mat-DB commented Oct 8, 2023

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!

@juliusknorr
Copy link
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.

@sn0n
Copy link

sn0n commented Feb 18, 2024

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?

@sn0n
Copy link

sn0n commented Feb 18, 2024

Maybe some xss filter trying to do its sanitation?

@KFreon
Copy link

KFreon commented Mar 27, 2024

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?

@janLo
Copy link

janLo commented Apr 29, 2024

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.

@KFreon
Copy link

KFreon commented May 6, 2024

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

@punkyard
Copy link

punkyard commented Jun 12, 2024

same for us with Logseq
it doesnt make it 'hard' to work with any other markdown editor - it simply makes it impossible

trilium, joplin, obsidian, logseq may work on the same documents - just not NC

it's a pity to think of a plugin for each editor (as mentioned above) to work this problem around - as it's once again the users - people's work in other words - that is at stake instead of a technical response to teams' needs

it seems to be a general state of things at this erea: i work in state schools in France, students and teachers are highly limited in their work because of IT services decisions and processes - it seems that 'work' and ´usage' come after the ´tool' and its conception - i think its a break down to our investment in working with computers ..

good luck to everyone to build a better future for the collaboration of our human organisations 🙏✌️

@juliusknorr
Copy link
Member

This originates from https://github.com/ProseMirror/prosemirror-markdown/blob/e59521463f62b296cc072962aa2d60b267ea4397/src/to_markdown.ts#L432-L443

I don't see a quick and easy way to adjust escaping directly

@janLo

This comment has been minimized.

@punkyard
Copy link

It would be great to have at least the option to just open and view the file

Well, can't you do this yet? by choosing the option of the action to perform when file is opened in Collectives: view or edit?

@janLo
Copy link

janLo commented Jun 21, 2024

It would be great to have at least the option to just open and view the file

Well, can't you do this yet? by choosing the option of the action to perform when file is opened in Collectives: view or edit?

As soon as I click on it it opens in the the editor and is broken 😕

@punkyard
Copy link

punkyard commented Jun 21, 2024

@janLo then you might have to think of a different way to publish your notes, and view them or edit them on line.

Have you had to disable wikilinks in Obsidian? aren't the wikilinks preserved by the NC editor?

@jannikgade
Copy link

No solution to this?

@punkyard
Copy link

punkyard commented Jul 1, 2024

No solution to this?

not on my side :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants