yzhang-gh / vscode-markdown

Markdown All in One
https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
MIT License
2.91k stars 322 forks source link

katex macros not correctly rendered when printing to pdf #1274

Open yd278 opened 1 year ago

yd278 commented 1 year ago

What's the problem

I set costumed katex macros and it works perfectly fine when I preview it in vscode. However when I print that to html it says

 ParseError: KaTeX parse error: Undefined control sequence

What's the expected result

The html file should be rendered as the same as the preview in vsc

How to reproduce

  1. set some macros
  2. use that in a markdown file
  3. print it into html

Other information

I encountered this issue on both mac and pc

plugin version : v3.5.1 vscode version: 1.78.1 (user setup)

yzhang-gh commented 1 year ago

Thanks for the feedback. Could you provide a minimal reproduction example?

yd278 commented 1 year ago

example.zip Hi, just realized I accidentally typed "printing to pdf" in the title as I meant to say "printing to html", hope that doesn't cause any misunderstanding.

As for the example, the ".vscode" folder contains my macro configuration, problems concurred on line 114 (and below) as it described previously.

Thank you for your reply

yzhang-gh commented 1 year ago

Thanks. Will try to have a look this weekend.

yzhang-gh commented 1 year ago

Which VS Code and extension versions are you using? The exported HTML looks alright on my machine.

image

yd278 commented 1 year ago

Hi. the extension version is v3.5.1 and vscode version is 1.78.1

Since I had this issue on both my pc and mac, could that be a KaTeX issue as you may set some extra configurations so it works well on your machine?

yzhang-gh commented 1 year ago

I probably know the reason. Can you open https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css in your browser? Some network resources may not be correctly loaded.

May be related: #1127

yd278 commented 1 year ago

Hi, Yes I can open it.

May I know is there a debug mode so I can print out logs on my machine? That may help.

yzhang-gh commented 1 year ago

You can press F12 to open the console of the browser, and see whether there is any error.

image

yd278 commented 1 year ago

Hi, The browser console doesn't give any error. I directly open the html file in a text editor and see the ParseError hence I believe that should be static.

Is there any way I can check the log of the plugin? Especially when generating the html file.

yzhang-gh commented 1 year ago

It is menubar > help > toggle developer tools

kulisak12 commented 1 year ago

Since the original author stopped commenting, I will take it from here.

I made the following tiny example: macros.zip

When I use the command directly, it works. When I use it via a macro, it errors out. That would suggest it can't be a CDN fault. The error is already present in the generated HTML.

Environment

yzhang-gh commented 1 year ago

image

still works well on my machine.

I checked my settings and guess that might be because you have the VS Code's built-in math support enabled.

image

yd278 commented 1 year ago

That works. Thank you for your time!

@.***

From: Yu Zhang Date: 2023-07-02 07:23 To: yzhang-gh/vscode-markdown CC: Y. Ding; Comment Subject: Re: [yzhang-gh/vscode-markdown] katex macros not correctly rendered when printing to pdf (Issue #1274) still works well on my machine. I checked my settings and guess that might be because you have the VS Code's built-in math support enabled. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

kulisak12 commented 1 year ago

I checked my settings and guess that might be because you have the VS Code's built-in math support enabled.

Yes, this was the cause. It works now, thanks!

kapple19 commented 1 year ago

Hi all. If I've understood correctly, a fix has been found?

I've tried disabling markdown.math.enabled and markdown.extension.math.enabled, but my HTML outputs still don't render some symbols properly.

F12 in the browser provides the following information.

image

The math symbols render properly in the VSCode previewer, as per other people's experiences.

kulisak12 commented 1 year ago

I've tried disabling markdown.math.enabled and markdown.extension.math.enabled, but my HTML outputs still don't render some symbols properly.

Only set markdown.math.enabled to false. Leave markdown.extension.math.enabled set to true (the default).

kapple19 commented 1 year ago

I've made a mistake, I've been confusing Markdown+Math rendering with this extension, and have been previewing my KaTeX renders in VSCode without issues, but have been using this extension's HTML exporting, expecting the KaTeX renders.

Markdown+Math provides the option of setting KateX macros in a .json file, which suits my use case, and I just realised they have a HTML exporting option as well, I'll use theirs.

Thanks for getting back to me.