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

[bug] Content containing math formulas cannot be rendered #62

Open
jaywhj opened this issue Dec 9, 2024 · 11 comments · May be fixed by #63
Open

[bug] Content containing math formulas cannot be rendered #62

jaywhj opened this issue Dec 9, 2024 · 11 comments · May be fixed by #63
Assignees
Labels
bug Something isn't working

Comments

@jaywhj
Copy link

jaywhj commented Dec 9, 2024

@neatc0der Hi, This found a bug.

When I use markmap in a code block, it can't render content containing math formulas, it doesn't parse out. for example:
- Katex: $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$

If the markdown text contains similar mathematical formulas, it will cause the entire document to fail to render and load.

iShot_2024-12-06_17 38 40

I'm using the latest version of the plugin :

iShot_2024-12-06_17 14 00


Here is the source file, you can try it.
markmap-plugin-test.md

Just remove the line - Katex: $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$ above and it parses fine, but the table block below parses a bit imperfectly, being partially blocked.

Originally posted by @jaywhj in #61 (comment)

@jaywhj
Copy link
Author

jaywhj commented Dec 9, 2024

At first, I thought it was caused by no update, but it turned out that it wasn't, and it should be that there were some problems with the plugin. Using markmap-cli alone doesn't have any problems, it parses correctly.

@jaywhj
Copy link
Author

jaywhj commented Dec 16, 2024

@gera2ld Can you help me take a look?

@gera2ld
Copy link
Member

gera2ld commented Dec 18, 2024

@jaywhj It works as expected. Can you provide a minimal reproduction (a complete project or docker image)?
image

@jaywhj
Copy link
Author

jaywhj commented Dec 18, 2024

@gera2ld I found out why, it's the use of KaTex.

Since Material for MkDocs also used KaTex to render math before this, using markmap again has the potential to cause conflicts.

In addition, even without this conflict, using it via file inclusion, there are cases where parts of the content are rendered incorrectly, cf. the rendering of the test.md file.

iShot_2024-12-19_01 06 28

this is a minimal reproduction:
test-proj.zip

@gera2ld gera2ld added the bug Something isn't working label Dec 19, 2024
@gera2ld gera2ld self-assigned this Dec 19, 2024
@jaywhj
Copy link
Author

jaywhj commented Dec 19, 2024

@gera2ld

Add a detailed description of the parsing rendering issues:

Issue-1: Rendering by file inclusion has the following problems:

  • There is a small problem with code block parsing, it renders, but the style is not right, it seems to be only half parsed and there are missing.
  • Tables don't render.
  • Image or icons don't render either.

Issue-2: Rendering directly within the document using code block wrapping has the following problems:

  • Table rendering styles that don't display properly and are partially blocked, everything else works fine.

Issue-3: Through the CLI alone or VS Code plugin rendering (not MkDocs plugin form), the image is not rendered, I do not know if it is a normal phenomenon, test cases see above test-proj.zip in the markmap.mm.md file, the bottom image in the document is not rendered.


iShot_2024-12-19_11 55 14

@gera2ld
Copy link
Member

gera2ld commented Dec 19, 2024

There are several issues here:

  • Parse error - fixed in the related PR
  • Conflicts with KaTeX - fixed in the related PR
  • Incorrect sizes of code blocks and tables - fixed in markmap 0.18
  • Images don't render when included from an external file - expected because img is not included in htmlParser.selector

@gera2ld
Copy link
Member

gera2ld commented Dec 19, 2024

@jaywhj You may verify the fix by:

pip install mkdocs-markmap@git+https://github.com/gera2ld/mkdocs-markmap@699e391
extra_javascript:
  - https://unpkg.com/[email protected]/dist/d3.min.js
  - https://unpkg.com/[email protected]/dist/browser/index.iife.js
  - https://unpkg.com/[email protected]/dist/browser/index.js

@jaywhj
Copy link
Author

jaywhj commented Dec 19, 2024

@gera2ld
Received it, thank you very much. That's a speedy fix, fantastic 👍, I'll try it out later, thanks a lot.
Images don't render was that I wasn't paying attention and forgot to add the img tag, no problem now!

@jaywhj
Copy link
Author

jaywhj commented Dec 19, 2024

@gera2ld
I just tested it and the problem is almost solved 👍, but there are 2 more doubts:

  1. The way the file is included, the rendering of the code block is missing;
  2. Rendering of code blocks, missing syntax highlighting, which was available in previous versions.
iShot_2024-12-19_18 40 36

@gera2ld
Copy link
Member

gera2ld commented Dec 19, 2024

Fixed in:

pip install mkdocs-markmap@git+https://github.com/gera2ld/mkdocs-markmap@50a559b

@jaywhj
Copy link
Author

jaywhj commented Dec 19, 2024

@gera2ld

Done, problem all fixed, thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants