Difference between revisions of "Markdown"

From WikEmacs
Jump to navigation Jump to search
(md wikipedia link)
(7 intermediate revisions by 2 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.  
  
= See also =
+
== 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.
 +
 
  
 
== Live preview as you type ==
 
== Live preview as you type ==
  
 
There are a few possibilities.
 
There are a few possibilities.
 +
 +
=== flymd ===
 +
 +
That may be the easiest one. Install [https://github.com/mola-T/flymd flymd] (in [[melpa]]), go to your markdown buffer and call '''M-x flymd-flyit'''. It opens a browser window with your markdown being updated live.
 +
 +
It also nows Github Flavoured Markdown.
 +
 +
If you have a problem with scrolling the page, just click on "Auto scroll" in the browser (the red link on the right).
 +
 +
Or look at impatient-mode below, which also works for html.
  
 
=== Impatient-mode ===
 
=== Impatient-mode ===
Line 20: Line 35:
 
See [https://github.com/skeeto/impatient-mode impatient-mode] (in MELPA). It only depends on emacs packages. This package is designed for html though, but it is possible to make it render markdown. Evaluate this somewhere so you have the function:
 
See [https://github.com/skeeto/impatient-mode impatient-mode] (in MELPA). It only depends on emacs packages. This package is designed for html though, but it is possible to make it render markdown. Evaluate this somewhere so you have the function:
  
   defun markdown-html (buffer)
+
   (defun markdown-html (buffer)
 
   (princ (with-current-buffer buffer
 
   (princ (with-current-buffer buffer
 
           (format "<!DOCTYPE html><html><title>Impatient Markdown</title><xmp theme=\"united\" style=\"display:none;\"> %s  </xmp><script src=\"http://strapdownjs.com/v/0.2/strapdown.js\"></script></html>" (buffer-substring-no-properties (point-min) (point-max))))
 
           (format "<!DOCTYPE html><html><title>Impatient Markdown</title><xmp theme=\"united\" style=\"display:none;\"> %s  </xmp><script src=\"http://strapdownjs.com/v/0.2/strapdown.js\"></script></html>" (buffer-substring-no-properties (point-min) (point-max))))
Line 26: Line 41:
  
 
Then '''M-x imp-set-user-filter''' in your markdown buffer, and supply markdown-html when it asks for the function. Live updating markdown!
 
Then '''M-x imp-set-user-filter''' in your markdown buffer, and supply markdown-html when it asks for the function. Live updating markdown!
 +
 +
Another filter which cooperates 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-mode ===
Line 34: Line 60:
  
 
[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.
 
[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 =
Line 39: Line 71:
 
* [http://jblevins.org/projects/markdown-mode/ Markdown Mode Project]
 
* [http://jblevins.org/projects/markdown-mode/ Markdown Mode Project]
 
* [http://jblevins.org/git/markdown-mode.git Source (git)]
 
* [http://jblevins.org/git/markdown-mode.git Source (git)]
* [http://melpa.milkbox.net/#/markdown-toc Markdown-toc (Melpa)], a simple TOC generator for a markdown file
 
  
 
[[Category:Markup languages]][[Category:Document authoring]]
 
[[Category:Markup languages]][[Category:Document authoring]]

Revision as of 13:33, 8 July 2016

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.


Live preview as you type

There are a few possibilities.

flymd

That may be the easiest one. Install flymd (in melpa), go to your markdown buffer and call M-x flymd-flyit. It opens a browser window with your markdown being updated live.

It also nows Github Flavoured Markdown.

If you have a problem with scrolling the page, just click on "Auto scroll" in the browser (the red link on the right).

Or look at impatient-mode below, which also works for html.

Impatient-mode

See impatient-mode (in MELPA). It only depends on emacs packages. This package is designed for html though, but it is possible to make it render markdown. Evaluate this somewhere so you have the function:

  (defun markdown-html (buffer)
  (princ (with-current-buffer buffer
          (format "<!DOCTYPE html><html><title>Impatient Markdown</title><xmp theme=\"united\" style=\"display:none;\"> %s  </xmp><script src=\"http://strapdownjs.com/v/0.2/strapdown.js\"></script></html>" (buffer-substring-no-properties (point-min) (point-max))))
        (current-buffer)))

Then M-x imp-set-user-filter in your markdown buffer, and supply markdown-html when it asks for the function. Live updating markdown!

Another filter which cooperates 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