Difference between revisions of "Markdown"

From WikEmacs
Jump to navigation Jump to search
m (added major-mode infobox)
(rm flymd, update doc for impatient-mode and remove html snippet causing new problem with mediawiki security)
 
(31 intermediate revisions by 11 users not shown)
Line 6: Line 6:
 
}}
 
}}
  
[http://jblevins.org/projects/markdown-mode/ Markdown Mode] provides a major mode for editing Markdown-formatted text files.  
+
[http://jblevins.org/projects/markdown-mode/ Markdown Mode] provides a major mode for editing [https://en.wikipedia.org/wiki/Markdown Markdown]-formatted text files.  
  
 
This package is not currently part of the Emacs distribution.  
 
This package is not currently part of the Emacs distribution.  
 +
 +
== Generate a table of content ==
 +
 +
Super easy with [https://github.com/ardumont/markdown-toc markdown-toc], in [[MELPA]].
 +
 +
You can re-generate the toc, put it wherever you want and customize it.
 +
 +
=== Table of content sidebar ===
 +
 +
See [https://github.com/abingham/outline-toc.el outline-toc.el] (in development and not in MELPA yet). It displays a TOC on the sidebar, highlighting the one that you're editing in the master document. Also works for org-mode (and other outline-mode compatible files).
 +
 +
== Live preview as you type ==
 +
 +
There are a few possibilities.
 +
 +
=== Impatient-mode ===
 +
 +
See [https://github.com/skeeto/impatient-mode impatient-mode] (in MELPA). It only depends on emacs packages. This package is designed for html, but it is possible to make it render markdown, with two possibilities.
 +
 +
The first one is to use the snippet we can find here: https://stackoverflow.com/questions/36183071/how-can-i-preview-markdown-in-emacs-in-real-time/36189456?noredirect=1#comment104784050_36189456
 +
 +
Evaluate the snippet somewhere, then run '''M-x imp-set-user-filter''' in your markdown buffer and supply the newly-created markdown-html symbol when it asks for the function.
 +
 +
Go to localhost:8080/imp, choose the file to watch, and enjoy live updating markdown!
 +
 +
The second possible snippet cooperates with markdown-mode:
 +
 +
    (defun markdown-filter (buffer)
 +
      (princ
 +
        (with-temp-buffer
 +
          (let ((tmpname (buffer-name)))
 +
            (set-buffer buffer)
 +
            (set-buffer (markdown tmpname)) ; the function markdown is in `markdown-mode.el'
 +
            (buffer-string)))
 +
        (current-buffer)))
 +
 +
=== Livedown-mode ===
 +
 +
[https://github.com/shime/emacs-livedown livedown] is specific to markdown but it requires nodejs packages (to be easily installed with npm).
 +
 +
=== Realtime-preview ===
 +
 +
[https://github.com/niku/realtime-preview.el realtime-preview.el] requires a ruby package (''redcarpet''). Then it does the rendering in [[EWW]], which is embedded in Emacs24.4.
 +
 +
= See also =
 +
 +
== Pandoc-mode ==
 +
 +
[http://pandoc.org/ Pandoc] is a swiss-army knife to convert a mark-up format into another (markdown to rst, org, etc) and [https://github.com/joostkremers/pandoc-mode pandoc-mode] (in melpa) is an emacs interface to it.
  
 
= External Links =
 
= External Links =

Latest revision as of 12:00, 24 February 2020

Markdown
Library markdown-mode
Command markdown-mode
Builtin no


Markdown Mode provides a major mode for editing Markdown-formatted text files.

This package is not currently part of the Emacs distribution.

Generate a table of content

Super easy with markdown-toc, in MELPA.

You can re-generate the toc, put it wherever you want and customize it.

Table of content sidebar

See outline-toc.el (in development and not in MELPA yet). It displays a TOC on the sidebar, highlighting the one that you're editing in the master document. Also works for org-mode (and other outline-mode compatible files).

Live preview as you type

There are a few possibilities.

Impatient-mode

See impatient-mode (in MELPA). It only depends on emacs packages. This package is designed for html, but it is possible to make it render markdown, with two possibilities.

The first one is to use the snippet we can find here: https://stackoverflow.com/questions/36183071/how-can-i-preview-markdown-in-emacs-in-real-time/36189456?noredirect=1#comment104784050_36189456

Evaluate the snippet somewhere, then run M-x imp-set-user-filter in your markdown buffer and supply the newly-created markdown-html symbol when it asks for the function.

Go to localhost:8080/imp, choose the file to watch, and enjoy live updating markdown!

The second possible snippet cooperates with markdown-mode:

   (defun markdown-filter (buffer)
     (princ
       (with-temp-buffer
         (let ((tmpname (buffer-name)))
           (set-buffer buffer)
           (set-buffer (markdown tmpname)) ; the function markdown is in `markdown-mode.el'
           (buffer-string)))
       (current-buffer)))

Livedown-mode

livedown is specific to markdown but it requires nodejs packages (to be easily installed with npm).

Realtime-preview

realtime-preview.el requires a ruby package (redcarpet). Then it does the rendering in EWW, which is embedded in Emacs24.4.

See also

Pandoc-mode

Pandoc is a swiss-army knife to convert a mark-up format into another (markdown to rst, org, etc) and pandoc-mode (in melpa) is an emacs interface to it.

External Links