45

I am using emacs 24 on fedora 17. I installed markdown-mode, but whenever I try to export a file by typing C-c C-c m or C-c C-c p in emacs, I got this error:

/bin/bash: markdown: command not found

Screenshot of emacs' markdown error message

I read that this is probably an issue with the path variable, so I compared the env variable by typing $ env at the command line and Esc-! env RET in emacs. I found the path variable description is the same in both cases.

What is this error? How can I fix it and execute markdown previews from within emacs?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Txe Llenne
  • 606
  • 1
  • 5
  • 6
  • 1
    What is your path for the markdown.pl script? What happens when you call the markdown script from bash? – atlpeg Jan 09 '13 at 21:24
  • Thank you for your reply & excuse me, I'm still newbie rummaging in the guts of software. That script you ask about has .pl (Perl isn't) file extension. I just followed instructions included in the package itself and saw no other requirement than place the .el file in the emacs load-path and let my emacs init file know about autoloading. Then, I tried the automatic way by typing at emacs `M-x package-install markdown mode` just if it were a dependencies problem. How might I check for the markdown.pl script? Scripts installed by the latter way said don't include any .pl file. – Txe Llenne Jan 10 '13 at 10:43
  • 1
    OK, I think, I'm following you now. For further references I recommend this [reading](http://www.cyberciti.biz/faq/linux-unix-command-not-found-error-and-how-to-get-rid-of-it/). So, by typing at cli `$ which markdown` or `$ which markdown-mode` I got: `no markdown-mode in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/txe/.local/bin:/home/txe/bin)`. but, I'm still at the same point, so any clue is welcomed. – Txe Llenne Jan 12 '13 at 18:57
  • 1
    Ok, I got it. I think. As reference for others looking for this same. I should also install, in my case, the proper package `$ sudo yum install python-markdown2`or $ sudo yum install [pandoc](http://johnmacfarlane.net/pandoc/) which offers to be like a swiss army knife when is about converting files from a markup format into another. Thanks anyway to everyone. This log post will be probably useful to anyone in the same point. – Txe Llenne Jan 13 '13 at 23:55
  • 1
    Ok after lot of testing, markdown is the best for me `$ yum install python-markdown2` then `$ ln -s /usr/bin/markdown2 /usr/local/bin/markdown` (thanks again, RupertPupkin ✪ fedora-forums) – Txe Llenne Feb 08 '13 at 16:51
  • For Ubuntu users, this would be `sudo apt-get install markdown`. – untill May 26 '14 at 09:38

6 Answers6

53

Install any markdown generating tool as you like, for example pandoc.

Then add the following line to your .emacs file:

(custom-set-variables
 '(markdown-command "/usr/local/bin/pandoc"))
Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
Kai Zhang
  • 1,028
  • 8
  • 9
  • 3
    Just a reminder: In my case, after installing the `pandoc` using `apt-get install` , command for markdown is just ` " pandoc"` – Tony Jan 26 '15 at 03:21
  • This worked for me, after I installed markdown with "brew install markdown". I think this can be marked as the answer. – Jake May 17 '16 at 16:16
  • `brew install pandoc` on OS X – Nic Nilov Mar 01 '17 at 12:45
  • Can confirm this works on Windows too. Got pandoc windows release from github, extracted it, and set the path in emacs. Thanks! – Baggers Oct 27 '21 at 07:50
19

This error occurs when you do not have a markdown parser installed. Installing one is simple with brew. From the command line:

brew install markdown

This should result in something like:

==> Downloading http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
######################################################################## 100.0%
  /usr/local/Cellar/markdown/1.0.1: 2 files, 40K, built in 2 seconds

Before running that command, I had the same error you did. After running that command, which installs a markdown parser on your system, the emacs commands C-c C-c m and C-c C-c p worked as expected by opening an HTML version of my markdown file in either another buffer or the browser, respectively.

Dave Liepmann
  • 1,555
  • 1
  • 18
  • 22
  • 1
    This is a nice easy way to get a copy of `markdown`, but the commands you referenced didn't work for me until I mapped the `markdown` parser to the `markdown-command` in my `~/.emacs` like so: `(custom-set-variables '(markdown-command "/usr/local/bin/markdown"))` – Technetium May 18 '16 at 22:56
8

You just need to pick and install a markdown parser:

  • rdiscount (gem install rdiscount).
  • python2-markdown (yum install python-markdown2)
  • or some other.

Then, in emacs:

M-x customize-mode RET markdown-mode

Set 'Markdown Command' to the name of the executable you installed -- for example, rdiscount or /usr/bin/markdown2.

John Ledbetter
  • 13,557
  • 1
  • 61
  • 80
3
  • Add emacs package repository to init.el:
(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)
  • Refresh packages:

M-x package-refresh-contents

  • Install emacs major mode markdown-mode by evaluating:

M-x package-install RET markdown-mode RET

  • Install markdown processor for your operating system:
brew install pandoc
#OR
sudo apt-get install pandoc
  • Verify pandoc installation:
which pandoc
# returns /usr/local/bin/pandoc
  • Map the markdown parser in init.el:
(custom-set-variables
  '(markdown-command "/usr/local/bin/pandoc"))
Saurabh
  • 5,176
  • 4
  • 32
  • 46
1

You need to setting up the markdown-command, there is a thread about displaying it in github way, through pandoc.

Xiaoqin Zhu
  • 101
  • 2
  • 4
0

I migrated to a new machine recently and it looks like in macOS Monterey (maybe before) it looks like brew changed where it is installed. I changed my markdown-command to "/opt/homebrew/bin/pandoc" based on Saurabh's answer

Jav Solo
  • 576
  • 1
  • 6
  • 15