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

Docsify latex in different positions are invalid #12

Closed
Kwaiyu opened this issue Dec 2, 2020 · 9 comments
Closed

Docsify latex in different positions are invalid #12

Kwaiyu opened this issue Dec 2, 2020 · 9 comments
Assignees
Labels
bug Something isn't working upstream

Comments

@Kwaiyu
Copy link

Kwaiyu commented Dec 2, 2020

Describe the bug
Docsify latex in different positions of the same file are invalid

To Reproduce
Steps to reproduce the behavior:

  1. add code

    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css"/>
    <script src="//cdn.jsdelivr.net/gh/upupming/docsify-katex@latest/dist/docsify-katex.js"></script>
    
  2. white markdown article, use latex like this PythonTutorial.md

  3. add latex to beginning of article, add below latex to middle of the article.

    Latex as:

    $$x=\frac {-b±\sqrt{b^2-4ac}}{2a}$$
    

Expected behavior
Latex in all positions are valid

Screenshots
beginning of article latex normal analysis:

markdown file:
K%@$5M7M`FZ0O8G9DTS4P12

show:
U}8 `98Y8NHWYCGAV38 Z43

Latex doesn't seem to parse at the middle of the article:
markdown file:
A VK@Q9QC@3 JXUP(CPV5

show:
{)_KNNO$GS3YOG LNV2ZFG1

Desktop (please complete the following information):

  • Browser version:Chrome 87.0.4280.66(正式版本) (64 位)
  • docsify version :4.4.1
  • docsify-katex version:1.4.3

Additional context
I try latex below code, or latex above code both show nomal.
But also it’s not work in this position:
@ GYIAR5W0YMQ B(}20{@{3

Please help me check why it doesn't work.

@upupming
Copy link
Owner

upupming commented Dec 2, 2020

@Kwaiyu Thanks for the feedback, I will take a look soon.

@upupming
Copy link
Owner

upupming commented Dec 2, 2020

Hi @Kwaiyu, I have confirmed this bug which is caused by the design of docsify-katex is just a find-replace renderer for math equations, which may fail in a complex context. I will try to find another way to extend marked.js to know the context of the KaTeX, which may take some time~ Just a note, we should do something like this

@upupming upupming self-assigned this Dec 2, 2020
@upupming upupming added the bug Something isn't working label Dec 2, 2020
@upupming
Copy link
Owner

upupming commented Dec 3, 2020

Hi @Kwaiyu , I have inspected your markdown file, which contains ````` can not be recognized well by docsify-katex, you can delete that for a temp workaround:
image

A fix will come soon~

@Kwaiyu
Copy link
Author

Kwaiyu commented Dec 3, 2020

Hi @upupming,
Thank you very much for your help, "" means the code part in markdown, deleting "" will not be able to parse the code, how to make a decision? Hope docsify latex and markdown syntax are compatible.
Regards,
kwaiyu

@upupming
Copy link
Owner

upupming commented Dec 3, 2020

Hope docsify latex and markdown syntax are compatible.

@Kwaiyu I will fix this soon, AKA make docsify-katex behaves the same as Markdown All in One

@Kwaiyu
Copy link
Author

Kwaiyu commented Dec 3, 2020

@upupming ok, As you said, delete "" can solve the issue, I can still use "```" to mark the code. I will try to avoid using "". Thanks.

@upupming
Copy link
Owner

upupming commented Dec 5, 2020

@Kwaiyu I have reported an issue to the marked.js repo. It seems the only way to achieve this is to make a PR to mark.js repo and then write our own plugin for math tokenization & rendering.

It will take some time for this bug to be fixed, so please be patient.

@Kwaiyu
Copy link
Author

Kwaiyu commented Dec 7, 2020

@upupming Thanks for your help!

@Kwaiyu
Copy link
Author

Kwaiyu commented Feb 3, 2021

Closed

@Kwaiyu Kwaiyu closed this as completed Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants