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

markdown-it as markdown-command not found, despite being visible in shell #784

Open
Kabouik opened this issue Aug 3, 2023 · 7 comments
Open

Comments

@Kabouik
Copy link

Kabouik commented Aug 3, 2023

I am trying to use markdown-it as my markdown-command but markdown-mode returns "Markdown command markdown-it is not found". Yet, it is well available and working when I run it from my shell in a terminal.

Expected Behavior

Markdown export to html should work. markdown-it works from the shell:

$ echo "# toto" > toto.md
$ markdown-it toto.md
<h1>toto</h1>

Actual Behavior

I get the above error.

Steps to Reproduce

Evaluate the following and try a Markdown export in a Markdown buffer:

(use-package markdown-mode
  :ensure t
  :mode ("README\\.md\\'" . gfm-mode)
  :init (setq markdown-command "markdown-it"))

Software Versions

  • Markdown Mode: version 2.6-alpha (Guix package)
  • Emacs: GNU Emacs 30.0.50
  • OS: Linux, Guix system
@Kabouik
Copy link
Author

Kabouik commented Aug 3, 2023

The error vanishes if I hardcode the absolute path of the markdown-it executable:

(use-package markdown-mode
  :ensure t
  :mode ("README\\.md\\'" . gfm-mode)
  :init (setq markdown-command "/home/mat/.local/bin/markdown-it"))

But this is weird because $HOME/.local/bin is in my $PATH, so there is still something off.

Also, the export didn't actually work, but my CPU use got quite high. I don't know if this is a markdown-it issue or because markdown-mode was missing some arguments after the command.

@syohex
Copy link
Collaborator

syohex commented Aug 3, 2023

Please check PATH environment variable and exec-path value on Emacs(M-: exec-path, M-: (getenv "PATH") etc).

If you don't launch Emacs from shell, Emacs doesn't inherit PATH value and you have to set PATH configurations in your init.el.

There are some tools to set PATH configuration from your shell configuration files like .bashrc, .zshrc

@Kabouik
Copy link
Author

Kabouik commented Aug 3, 2023

Thanks, you're right, that was my issue because I launch emacs-daemon from my sway configuration, so it doesn't inherit my shell $PATH.

I'm still experiencing the second issue though: using markdown-it as my markdown-command makes the export use a lot of CPU (and never end unless interrupted) like it is stalling, while running markdown-it somefile.md in shell works immediately. Can markdown-mode work with markdown-it or does it expect a different command line syntax than COMMAND FILE.md?

@syohex
Copy link
Collaborator

syohex commented Aug 4, 2023

I cannot reproduce your high CPU usage issue by converting markdown file to HTML with markdown-it and M-x markdown . When does your issue happen ? Could you tell us how to reproduce your issue ?

@Kabouik
Copy link
Author

Kabouik commented Aug 4, 2023

Alright, good to know it does not happen on your end. The steps to reproduce are exactly what you did:

  1. Open a markdown buffer
  2. M-x markdown or M-x markdown-export

So somehow it's on my end, but what I don't get is why markdown-it outside of emacs and markdown-mode works fine. My emacs configuration related to markdown-mode is just the 4 lines of elisp written in the first post.

@syohex
Copy link
Collaborator

syohex commented Aug 7, 2023

FYI markdown-mode evaluates (shell-command-on-region (point-min) (point-max) "markdown-it" (get-buffer-create "*markdown-output*")) to convert markdown file into a HTML file.

@snan
Copy link

snan commented Nov 10, 2023

@Kabouik try setting markdown-command-needs-filename to t

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

No branches or pull requests

3 participants