Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pylatexenc support not working #32

Closed
AlejandroGomezFrieiro opened this issue Jun 1, 2024 · 8 comments
Closed

Pylatexenc support not working #32

AlejandroGomezFrieiro opened this issue Jun 1, 2024 · 8 comments

Comments

@AlejandroGomezFrieiro
Copy link

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:

  • Running pylatexenc through terminal inside and outside neovim and both return the expected unicode.
  • Using a local python venv with pylatexenc.
  • Removing other markdown plugins that might be interfering
@MeanderingProgrammer
Copy link
Owner

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
Copy link
Author

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

@MeanderingProgrammer
Copy link
Owner

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: 7aedbde

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
Copy link

bickman commented Jun 4, 2024

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
Copy link
Owner

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
Copy link

bickman commented Jun 4, 2024

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
Copy link
Author

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 added a commit that referenced this issue Jun 5, 2024
## Details

The requirements to get latex support working for this plugin are
not clear as shown by: #32.

Update the README to add the missing need for the latex parser.

More importantly the current health check logic only checked for
the minimum needs of this plugin as there was no way to indicate
whether the user wanted latex support or not.

Add a `latex_enabled` flag which defaults to true. Functionally it
does allow enabling / disabling the latex handler but it is mainly
used in the updated health check logic to check for the additional
requirements needed for latex, i.e. the parser and the latex2text
executable. Setting the flag to false allows users to remove these
warnings if they do not want latex support by this plugin.
@MeanderingProgrammer
Copy link
Owner

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: a2788a8.

Thanks for the feedback!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants