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

Markdown escaping problem #2260

Open
1 task done
Tracked by #4
michaelkuhn opened this issue Aug 4, 2017 · 7 comments
Open
1 task done
Tracked by #4

Markdown escaping problem #2260

michaelkuhn opened this issue Aug 4, 2017 · 7 comments
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug

Comments

@michaelkuhn
Copy link
Contributor

Description

Escaping short links ([[link]]) does not work at the moment. Even if I type \[\[link\]\], Gitea still converts it into a link.

This is probably due to how Markdown is handled in markdown.go:

result := RenderRaw(rawBytes, urlPrefix, isWikiMarkdown)
result = PostProcess(result, urlPrefix, metas, isWikiMarkdown)

RenderRaw seems to remove the escaping backslashes, PostProcess then only sees a normal short link. Switching the order of the calls is also problematic because PostProcess converts links that it should not (for example, https://pthree.org/2012/04/17/install-zfs-on-debian-gnulinux/ is recognized as an issue link due to the numbers).

@lunny lunny added the type/bug label Aug 4, 2017
@lunny lunny added this to the 1.x.x milestone Aug 4, 2017
@jeromelebleu
Copy link

Is #2168 can be related to this bug in a way? Or could this issue help to resolve it - or at least opens the discussion of the way to go? In my opinion, we should not have to escape short links in a code block...

Thanks in advance!

@stale
Copy link

stale bot commented Feb 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Feb 13, 2019
@michaelkuhn
Copy link
Contributor Author

FYI: This still happens with Gitea 1.7.

@stale stale bot removed the issue/stale label Feb 18, 2019
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Feb 18, 2019
@schmittlauch
Copy link
Contributor

I just ran into this when trying to escape backticks inside a shell command, so they're getting displayed inside an inline code sample:

`foo=\`pwd\`/bin`

@lafriks
Copy link
Member

lafriks commented Oct 23, 2019

@schmittlauch that is different, to to use backtick in code you should use:

``foo=`pwd`/bin``

@lunny lunny removed this from the 1.x.x milestone Mar 20, 2023
@silkentrance
Copy link
Contributor

with 1.21.11 you can use

\[[[woo]]

which renders as

[[woo]]

if you'd used

\[[woo]]

then it would render as

[woo]]

so there is still some bug in there somewhere

@wxiaoguang
Copy link
Contributor

The problem is that the render parsers are wrong. At the moment, the markdown render works like this:

MarkdownText 
-> GoldmarkMarkdownRender(...EmphasisParser,List,etc...) 
-> IntermediateHTML 
-> PostProcess(...Linkify,etc...) 
-> FinalHTML

In the GoldmarkMarkdownRender step, it renders \[\[ to [[, then in PostProcess step, Linkify translates more Markdown syntaxes including [[.

The fix should be like this: move the Linkify from PostProcess to GoldmarkMarkdownRender step. And this fix will also fix "Markdown Formatting tokens in URLs should not be parsed #17958" if we could make the Linkify have a proper priority with EmphasisParser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Projects
None yet
Development

No branches or pull requests

7 participants