MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.73k stars 38 forks source link

Pylatexenc support not working #32

Closed AlejandroGomezFrieiro closed 5 months ago

AlejandroGomezFrieiro commented 5 months ago

I installed pylatexenc using pipx such that it's available globally, but math mode rendering is not working.

I tested copying the markdown file kn the demo folder, and everything looks the same except for the math mode.

Other tests I did to no avail:

MeanderingProgrammer commented 5 months ago

What OS are you running? I haven't done any testing with windows, so just checking that first.

pylatexenc should come with an executable called latex2text which is what this plugin uses to do the translation. Does running latex2text on the command line work for you?

AlejandroGomezFrieiro commented 5 months ago

Using Ubuntu, lates2text worked as expected on both CLI and as a command within nvim (:!latex2text)

MeanderingProgrammer commented 5 months ago

Hmm, could be a few things.

I've added some debug statements to the plugin to help figure out whats going on.

Can you update the plugin so that you have this recent commit: https://github.com/MeanderingProgrammer/markdown.nvim/commit/7aedbde39ab236d27096a8f8846235af050dbd7f

Set the log_level of this plugin to debug:

require('render-markdown').setup({
    log_level = 'debug',
})

Then create a markdown file with the following contents:

# Inline Formula

$\sqrt{3x-1}+(1+x)^2$

# Block Formula

$$
f(x,y) = x + \sqrt{y}
f(x,y) = \sqrt{y} + \frac{x^2}{4y}
$$

Open it such that this plugin renders the contents, the headings should at least work.

Then copy & paste the contents of the log file here. The log file should be located at: ~/.local/state/nvim/render-markdown.log.

bickman commented 5 months ago

I have the same problem, I test it on both archlinux and windows 11, just latex not render, everything else work alright. I have installed Pylatexenc, and latex2text can work in cmd and nvim cmd :!latex2text -c ..., here is the screenshot: 屏幕截图 2024-06-05 051004 and here is the log: 屏幕截图 2024-06-05 052110

MeanderingProgrammer commented 5 months ago

Based on the logs above it appears you do not have the latex tree sitter parser installed. Please TSInstall it and let me know if it works.

bickman commented 5 months ago

Based on the logs above it appears you do not have the latex tree sitter parser installed. Please TSInstall it and let me know if it works.

♥️ It works! I thought about this reason, then I thought markdown parser should support latex, so I didn't try it, maybe you could add this in readme.

AlejandroGomezFrieiro commented 5 months ago

Same, I had the texlab LSP installed so I though it would be sufficient

After running :TSInstallFromGrammar latex to set it up, it runs as expected. I recommend adding instructions for this to the README

MeanderingProgrammer commented 5 months ago

Ah, that makes sense, should have been more clear of the requirements.

I've updated the README as well as the health check to make debugging this easier in the future: https://github.com/MeanderingProgrammer/markdown.nvim/commit/a2788a8c711539d9425a96e413a26b67eba60131.

Thanks for the feedback!