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

Cant escape characters #245

Open
Deijin27 opened this issue Aug 8, 2023 · 4 comments
Open

Cant escape characters #245

Deijin27 opened this issue Aug 8, 2023 · 4 comments

Comments

@Deijin27
Copy link

Deijin27 commented Aug 8, 2023

I was trying to type a less-than sign into a post, escaping it with a backslash, but it is not visible in the published page. It works when not followed by a letter immediately.

I tried this
\<th\>

Also tried this
&lt;th&gt;

Is it possible to support this?

@Deijin27
Copy link
Author

Deijin27 commented Aug 8, 2023

The commonmark spec does suggest that it should be possible in example 14

https://spec.commonmark.org/0.30/#backslash-escapes

I guess it's just a niche situation that the library you use doesnt account for.

@HermanMartinus
Copy link
Owner

I did a dig into it and it does seem to be a quirk of the Mistune markdown parser. There is an option to escape all (which would break a few too many things) but no specific break character.

One thing I've noticed is that if there is a space present then it renders fine (with the space though):
< th > and &lt; th &gt; both render as < th > < th >

This also only happens if there are opening and closing braces, so something like Less<More works fine. One reason I think this hasn't been pointed out before is that generally if you're trying to represent raw HTML as text you can just do it in a code block. This however doesn't solve for instances where Less<More>Less which would be interpreted as HTML-ish.

I'll give this some thought, but it seems like a minor issue in the grander scheme of things and easy to work around.

Thanks for pointing this out @Deijin27!

@Deijin27
Copy link
Author

I ran into the issue using an app called markdownr to convert html to markdown for offline viewing, and tried to create a page on bearblog to test more, and found bear had issues too but the opposite direction 😄

<> is often used when describing spelling reforms, to describe the letters that represent a sound. See this example

It would be easy enough to put them in inline code blocks, so it's very minor issue easy to workaround I agree.

@HermanMartinus
Copy link
Owner

😄 Yeah. Unfortunately we can't have one without the other. Either HTML is supported or not. The alternative being to include an explicit attribute of something like render_as: text/markdown/html which seems like overkill to me.

I appreciate having these cases pointed out, though.

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

No branches or pull requests

2 participants