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 < and > has weird behavior #3563

Closed
nicfv opened this issue Feb 1, 2024 · 2 comments
Closed

Escaping < and > has weird behavior #3563

nicfv opened this issue Feb 1, 2024 · 2 comments

Comments

@nicfv
Copy link

nicfv commented Feb 1, 2024

Problem

Escaping angled brackets sometimes shows \

Description

Hi, what is the official way to escape angled brackets? To me, it seems like <tag\> works the best with mkdocs but escaping all the brackets like \<tag\> makes the most sense. Check out my example code below with associated screenshot, and the markdown contents pasted directly into this post. Here is a brief summary of my findings.

ID Option Works in VS Code? GitHub? Mkdocs?
1 <tag> No No No
2 \<tag> Yes Yes No (renders \)
3 <tag\> Yes Yes Yes
4 \<tag\> Yes Yes Sort of (renders \<tag>)

Proposed Solution

I have 2 ideas here.

  1. Simply check if any < or > character is preceded by a \ and make sure it is properly escaped.
  2. Add a config option that when turned on, converts all instances of \< and \> to the HTML entities, &gt; and &lt;

References

Raw Markdown:

# 1 <tag> 1
# 2 \<tag> 2
# 3 <tag\> 3
# 4 \<tag\> 4

```
1 <tag> 1
2 \<tag> 2
3 <tag\> 3
4 \<tag\> 4
```

- 1 <tag> 1
- 2 \<tag> 2
- 3 <tag\> 3
- 4 \<tag\> 4\

Mkdocs Markdown:

image

VS Code Markdown:

image

GitHub Markdown:

1 1

2 <tag> 2

3 <tag> 3

4 <tag> 4

1 <tag> 1
2 \<tag> 2
3 <tag\> 3
4 \<tag\> 4
  • 1 1
  • 2 <tag> 2
  • 3 <tag> 3
  • 4 <tag> 4
@nicfv
Copy link
Author

nicfv commented Feb 1, 2024

I discovered this because of my workflow using typedoc2md/typedoc-plugin-markdown#564 and realized that the behavior of mkdocs doesn't match that of standard markdown editors.

@oprypin
Copy link
Contributor

oprypin commented Apr 9, 2024

This behavior is entirely up to MkDocs' dependency https://github.com/Python-Markdown/markdown, so nothing that can be done here.

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