PDConSec / vsc-print

Completely local print support for VS Code with syntax-colouring and line numbering
Other
69 stars 28 forks source link

Markdown Math is printed twice #266

Closed maxZangl closed 11 months ago

maxZangl commented 1 year ago

When printing math expressions, the extension adds the expression twice,
once translated to math and once without translation to math

e.g.

the single line:

$S_0 * M_n = 7^2$

will look like this in the pdf:

image

PeterWone commented 1 year ago

See https://github.com/PDConSec/vsc-print/discussions/258. Let us know whether your problem is the same, either with more details or by closing the issue.

PeterWone commented 11 months ago

@maxZangl Was your issue the same problem as #258?

If not please share any additional information. Otherwise I'll have to treat this as a duplicate and close it.

PeterWone commented 11 months ago

I'm going to close this. If you object because adding a stylesheet didn't resolve it for you then add details and I'll re-open it.

maxZangl commented 11 months ago

Hi,

so adding the same stylesheet as in #258 is giving me the following result: image

This does solve the problem of duplicate math, however it is not usable. I tried other stylesheets, like this https://github.com/sindresorhus/github-markdown-css/blob/main/github-markdown.css With the following result: image
The markdown in VS Code itself is changed though, by using this second stylesheet:
image

Also no matter what i do, the color scheme settings are not doing anything. I selected a few.

I do not know if the bug above is therefore fixed or not.

But i could not get the extension to print a single line of readable math yet unfortunately. I would like to though.

PeterWone commented 11 months ago

Max, what's rendering the LaTeX for you? Dump your installed extensions like so

code --list-extensions

and share the result. You can shorten the list if you want to edit out extensions you know are irrelevant to Markdown. For example, my system has 30 or so but only the following are relevant.

bierner.markdown-checkbox
bierner.markdown-mermaid
DavidAnson.vscode-markdownlint
fcrespo82.markdown-table-formatter
goessner.mdmath
mathpix.vscode-mathpix-markdown
pdconsec.vscode-print
tomoyukim.vscode-mermaid-editor

I should warn you that recently the person who maintains the built-in Markdown rendering pipeline used by the in-built preview has started to add in Markdown enhancements. He never considers anyone's needs but his own frequently introduces breaking changes - there is no published API for using the built-in rendering pipeline, I had to reverse engineer it and use an exploit.

If you didn't install a separate markdown extension like

this may be the source of your problems. Try installing one of these. The goessner one is faster and widely used. The mathpix one is slower but less dependent on stylesheets and also handles SMILES notation (chemistry). #258 refers to a problem with very similar symptoms that occurs with the goessner implementation.

maxZangl commented 11 months ago

This is mycode --list-extensions output:

bierner.markdown-image-size
GitHub.codespaces
goessner.mdmath
koehlma.markdown-math
mathpix.vscode-mathpix-markdown
mlxprs.mlxprs
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.remote-explorer
mushan.vscode-paste-image
pdconsec.vscode-print
yzane.markdown-pdf
yzane.markdown-pdf`

Also i tested with disabling all extensions but:

goessner.mdmath
pdconsec.vscode-print

And also tried only:

mathpix.vscode-mathpix-markdown
pdconsec.vscode-print

And also tried all but:

pdconsec.vscode-print

In all three cases the math expression is printed twice.. I checked all settings related to markdowns but did not find anything i should change.

thank you for the warning and your help.

Also i am on windows and have MiKTeX and Texmaker installed, but these probably do not interfere here id assume.

PeterWone commented 11 months ago

Something broke between 0.10.16 (which doesn't have the problem) and 0.10.18 (current release). Since there aren't many changes I should be able to track this down soon. The stylesheet link isn't being added to the HTML.

PeterWone commented 11 months ago

False alarm, I forgot that changing settings in my dev copy of vscode affect a running extension debug host.

Using the goessner extension, having no extra stylesheets like this

image

produces this

image

Adding this

image

produces this

image


In settings turn off Print and close and then print to render the broken formula in your browser. Then right-click and Inspect the page. Up the top in the header have a look at what stylesheets are linked. Mine looks like this.

image

When I hack the page to add a stylesheet

  1. Right click on the existing stylesheet link
  2. Choose Duplicate Element from the context menu
  3. Edit the URL to read https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css

then the page immediately renders correctly.

image

maxZangl commented 11 months ago

yeah i just tested it again with the same stylesheet and it works fine now.. That is great thank you!

however i tested the same stylesheet earlier and it messed up the math expressions.... I just found the culprit, using this extension: https://marketplace.visualstudio.com/items?itemName=koehlma.markdown-math is messing up the math, as in my second comment. That is good to know.

but anyway i am happy Thanks for your help :D nice extension! I will use it frequently now

PeterWone commented 11 months ago

Max - historically I have tried to use VS Code's Markdown rendering pipeline in order to keep Print in sync with the Markdown preview pane. But Microsoft decisions are making this problematic, and I will probably instead support my own pipeline. Once you can serve the rendered page and its resource to a browser there is fundamentally no need for a built it preview. Having it in a browser also lets you put the preview on a second monitor, something VS Code cannot support directly.

When I do that, I'll probably take a bunch of the most useful markdown extensions, bake them into Print and resolve the resource and compatibility issues. To that end I need to know what people are using. I could rip a list of markdown extensions out of people's installations and send it to my server but some people would get bent out of shape over privacy (I don't care who has what, just what and how many).

So I'm interested in how people are using it. Tell me what you do with it, if you want to influence these decisions.

maxZangl commented 11 months ago

Hi Peter,

i am using markdowns as my preferred format to document anything, but mostly:

So i always need to be able to paste images very easily, where currently i use a combination of the tool greenshot and this extension: https://marketplace.visualstudio.com/items?itemName=mushan.vscode-paste-image to paste the results.

Why do i need the print function from your extension? To convert these markdowns into pdfs which i can easily read on my phone or share, since there is no good app to display markdowns in the same way as i have them in VS Code.

So basically i use markdowns as offline single confluence pages with decent math expressions support. And as long as the images are in the output and the math expressions are still readable i am a happy person.

Here is an example from my lecture notes, where i pasted some screenshot fom wikipedia and added my personal notes below, which use some math notation:

image image