streamline adding new languages to buffer's list
[markdown-mode.git] / README.md
blob7b2ba341d0d1a0522e755d1ef81b6515470e578c
1 # Emacs Markdown Mode
3 <!-- This file is autogenerated by webpage.sh from the comments at the top of
4      markdown-mode.el. Make edits there, not here. -->
6 markdown-mode is a major mode for editing [Markdown][]-formatted
7 text files in GNU Emacs.  markdown-mode is free software, licensed
8 under the GNU GPL.
10  [Markdown]: http://daringfireball.net/projects/markdown/
12 The latest stable version is markdown-mode 2.0, released on March 24, 2013:
14    * [markdown-mode.el][]
15    * [Screenshot][][^theme]
16    * [Release notes][]
18  [markdown-mode.el]: http://jblevins.org/projects/markdown-mode/markdown-mode.el
19  [Screenshot]: http://jblevins.org/projects/markdown-mode/screenshots/20130131-002.png
20  [Release notes]: http://jblevins.org/projects/markdown-mode/rev-2-0
22 [^theme]: The theme used in the screenshot is
23     [color-theme-twilight](https://github.com/crafterm/twilight-emacs).
25 The latest development version can be obtained from the Git
26 repository at <http://jblevins.org/git/markdown-mode.git> or from
27 [GitHub][]:
29     git clone git://jblevins.org/git/markdown-mode.git
30     git clone https://github.com/jrblevin/markdown-mode.git
32 [![Build Status][status]][travis]
34  [devel.el]: http://jblevins.org/git/markdown-mode.git/plain/markdown-mode.el
35  [GitHub]: https://github.com/jrblevin/markdown-mode/
36  [travis]: https://travis-ci.org/jrblevin/markdown-mode
37  [status]: https://travis-ci.org/jrblevin/markdown-mode.svg?branch=master
39 markdown-mode is also available in several package managers, including:
41    * Debian Linux: [emacs-goodies-el][]
42    * Ubuntu Linux: [emacs-goodies-el][emacs-goodies-el-ubuntu]
43    * RedHat and Fedora Linux: [emacs-goodies][]
44    * NetBSD: [textproc/markdown-mode][]
45    * Arch Linux (AUR): [emacs-markdown-mode-git][]
46    * MacPorts: [markdown-mode.el][macports-package] ([pending][macports-ticket])
47    * FreeBSD: [textproc/markdown-mode.el][freebsd-port]
49  [emacs-goodies-el]: http://packages.debian.org/emacs-goodies-el
50  [emacs-goodies-el-ubuntu]: http://packages.ubuntu.com/search?keywords=emacs-goodies-el
51  [emacs-goodies]: https://apps.fedoraproject.org/packages/emacs-goodies
52  [textproc/markdown-mode]: http://pkgsrc.se/textproc/markdown-mode
53  [emacs-markdown-mode-git]: https://aur.archlinux.org/packages/emacs-goodies-el/
54  [macports-package]: https://trac.macports.org/browser/trunk/dports/editors/markdown-mode.el/Portfile
55  [macports-ticket]: http://trac.macports.org/ticket/35716
56  [freebsd-port]: http://svnweb.freebsd.org/ports/head/textproc/markdown-mode.el
58 ## Installation
60 Make sure to place `markdown-mode.el` somewhere in the load-path and add
61 the following lines to your `.emacs` file to associate markdown-mode
62 with `.text`, `.markdown`, and `.md` files:
64     (autoload 'markdown-mode "markdown-mode"
65        "Major mode for editing Markdown files" t)
66     (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
67     (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
68     (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
70 There is no official Markdown file extension, nor is there even a
71 _de facto_ standard, so you can easily add, change, or remove any
72 of the file extensions above as needed.
74 ## Usage
76 Keybindings are grouped by prefixes based on their function.  For
77 example, the commands for inserting links are grouped under `C-c
78 C-a`, where the <kbd>C-a</kbd> is a mnemonic for the HTML `<a>` tag.  In
79 other cases, the connection to HTML is not direct.  For example,
80 commands dealing with headings begin with <kbd>C-c C-t</kbd> (mnemonic:
81 titling).  The primary commands in each group will are described
82 below.  You can obtain a list of all keybindings by pressing `C-c
83 C-h`.  Movement and shifting commands tend to be associated with
84 paired delimiters such as <kbd>M-{</kbd> and <kbd>M-}</kbd> or <kbd>C-c <</kbd> and <kbd>C-c ></kbd>.
85 Outline navigation keybindings the same as in `org-mode`.  Finally,
86 commands for running Markdown or doing maintenance on an open file
87 are grouped under the <kbd>C-c C-c</kbd> prefix.  The most commonly used
88 commands are described below.  You can obtain a list of all
89 keybindings by pressing <kbd>C-c C-h</kbd>.
91   * Hyperlinks: <kbd>C-c C-a</kbd>
93     In this group, <kbd>C-c C-a l</kbd> inserts an inline link of the form
94     `[text](url)`.  The link text is determined as follows.  First,
95     if there is an active region (i.e., when transient mark mode is
96     on and the mark is active), use it as the link text.  Second,
97     if the point is at a word, use that word as the link text.  In
98     these two cases, the original text will be replaced with the
99     link and point will be left at the position for inserting a
100     URL.  Otherwise, insert empty link markup and place the point
101     for inserting the link text.
103     <kbd>C-c C-a L</kbd> inserts a reference link of the form `[text][label]`
104     and, optionally, a corresponding reference label definition.
105     The link text is determined in the same way as with an inline
106     link (using the region, when active, or the word at the point),
107     but instead of inserting empty markup as a last resort, the
108     link text will be read from the minibuffer.  The reference
109     label will be read from the minibuffer in both cases, with
110     completion from the set of currently defined references.  To
111     create an implicit reference link, press <kbd>RET</kbd> to accept the
112     default, an empty label.  If the entered referenced label is
113     not defined, additionally prompt for the URL and (optional)
114     title.  If a URL is provided, a reference definition will be
115     inserted in accordance with `markdown-reference-location`.
116     If a title is given, it will be added to the end of the
117     reference definition and will be used to populate the title
118     attribute when converted to XHTML.
120     <kbd>C-c C-a u</kbd> inserts a bare url, delimited by angle brackets.  When
121     there is an active region, the text in the region is used as the
122     URL.  If the point is at a URL, that url is used.  Otherwise,
123     insert angle brackets and position the point in between them
124     for inserting the URL.
126     <kbd>C-c C-a f</kbd> inserts a footnote marker at the point, inserts a
127     footnote definition below, and positions the point for
128     inserting the footnote text.  Note that footnotes are an
129     extension to Markdown and are not supported by all processors.
131     <kbd>C-c C-a w</kbd> behaves much like the inline link insertion command
132     and inserts a wiki link of the form `[[WikiLink]]`.  If there
133     is an active region, use the region as the link text.  If the
134     point is at a word, use the word as the link text.  If there is
135     no active region and the point is not at word, simply insert
136     link markup.  Note that wiki links are an extension to Markdown
137     and are not supported by all processors.
139   * Images: <kbd>C-c C-i</kbd>
141     <kbd>C-c C-i i</kbd> inserts markup for an inline image, using the
142     active region or the word at point, if any, as the alt text.
143     <kbd>C-c C-i I</kbd> behaves similarly and inserts a reference-style
144     image.
146   * Styles: <kbd>C-c C-s</kbd>
148     <kbd>C-c C-s e</kbd> inserts markup to make a region or word italic (<kbd>e</kbd>
149     for `<em>` or emphasis).  If there is an active region, make
150     the region italic.  If the point is at a non-italic word, make
151     the word italic.  If the point is at an italic word or phrase,
152     remove the italic markup.  Otherwise, simply insert italic
153     delimiters and place the cursor in between them.  Similarly,
154     use <kbd>C-c C-s s</kbd> for bold (`<strong>`) and <kbd>C-c C-s c</kbd> for
155     inline code (`<code>`).
157     <kbd>C-c C-s b</kbd> inserts a blockquote using the active region, if any,
158     or starts a new blockquote.  <kbd>C-c C-s C-b</kbd> is a variation which
159     always operates on the region, regardless of whether it is
160     active or not.  The appropriate amount of indentation, if any,
161     is calculated automatically given the surrounding context, but
162     may be adjusted later using the region indentation commands.
164     <kbd>C-c C-s p</kbd> behaves similarly for inserting preformatted code
165     blocks, with <kbd>C-c C-s C-p</kbd> being the region-only counterpart.
167   * Headings: <kbd>C-c C-t</kbd>
169     All heading insertion commands use the text in the active
170     region, if any, as the heading text.  Otherwise, if the current
171     line is not blank, they use the text on the current line.
172     Finally, the setext commands will prompt for heading text if
173     there is no active region and the current line is blank.
175     <kbd>C-c C-t h</kbd> inserts a heading with automatically chosen type and
176     level (both determined by the previous heading).  <kbd>C-c C-t H</kbd>
177     behaves similarly, but uses setext (underlined) headings when
178     possible, still calculating the level automatically.
179     In cases where the automatically-determined level is not what
180     you intended, the level can be quickly promoted or demoted
181     (as described below).  Alternatively, a <kbd>C-u</kbd> prefix can be
182     given to insert a heading promoted by one level or a <kbd>C-u C-u</kbd>
183     prefix can be given to insert a heading demoted by one level.
185     To insert a heading of a specific level and type, use <kbd>C-c C-t 1</kbd>
186     through <kbd>C-c C-t 6</kbd> for atx (hash mark) headings and <kbd>C-c C-t !</kbd> or
187     <kbd>C-c C-t @</kbd> for setext headings of level one or two, respectively.
188     Note that <kbd>!</kbd> is <kbd>S-1</kbd> and <kbd>@</kbd> is <kbd>S-2</kbd>.
190     If the point is at a heading, these commands will replace the
191     existing markup in order to update the level and/or type of the
192     heading.  To remove the markup of the heading at the point,
193     press <kbd>C-c C-k</kbd> to kill the heading and press <kbd>C-y</kbd> to yank the
194     heading text back into the buffer.
196   * Horizontal Rules: <kbd>C-c -</kbd>
198     <kbd>C-c -</kbd> inserts a horizontal rule.  By default, insert the
199     first string in the list `markdown-hr-strings` (the most
200     prominent rule).  With a <kbd>C-u</kbd> prefix, insert the last string.
201     With a numeric prefix <kbd>N</kbd>, insert the string in position <kbd>N</kbd>
202     (counting from 1).
204   * Markdown and Maintenance Commands: <kbd>C-c C-c</kbd>
206     *Compile:* <kbd>C-c C-c m</kbd> will run Markdown on the current buffer
207     and show the output in another buffer.  *Preview*: <kbd>C-c C-c p</kbd>
208     runs Markdown on the current buffer and previews, stores the
209     output in a temporary file, and displays the file in a browser.
210     *Export:* <kbd>C-c C-c e</kbd> will run Markdown on the current buffer
211     and save the result in the file `basename.html`, where
212     `basename` is the name of the Markdown file with the extension
213     removed.  *Export and View:* press <kbd>C-c C-c v</kbd> to export the
214     file and view it in a browser.  *Open:* <kbd>C-c C-c o</kbd> will open
215     the Markdown source file directly using `markdown-open-command`.
216     *Live Export*: Press <kbd>C-c C-c l</kbd> to turn on
217     `markdown-live-preview-mode` to view the exported output
218     side-by-side with the source Markdown. **For all export commands,
219     the output file will be overwritten without notice.**
220     `markdown-live-preview-window-function` can be customized to open
221     in a browser other than `eww`.
223     To summarize:
225       - <kbd>C-c C-c m</kbd>: `markdown-command` > `*markdown-output*` buffer.
226       - <kbd>C-c C-c p</kbd>: `markdown-command` > temporary file > browser.
227       - <kbd>C-c C-c e</kbd>: `markdown-command` > `basename.html`.
228       - <kbd>C-c C-c v</kbd>: `markdown-command` > `basename.html` > browser.
229       - <kbd>C-c C-c w</kbd>: `markdown-command` > kill ring.
230       - <kbd>C-c C-c o</kbd>: `markdown-open-command`.
231       - <kbd>C-c C-c l</kbd>: `markdown-live-preview-mode` > `*eww*` buffer.
233     <kbd>C-c C-c c</kbd> will check for undefined references.  If there are
234     any, a small buffer will open with a list of undefined
235     references and the line numbers on which they appear.  In Emacs
236     22 and greater, selecting a reference from this list and
237     pressing <kbd>RET</kbd> will insert an empty reference definition at the
238     end of the buffer.  Similarly, selecting the line number will
239     jump to the corresponding line.
241     <kbd>C-c C-c n</kbd> renumbers any ordered lists in the buffer that are
242     out of sequence.
244     <kbd>C-c C-c ]</kbd> completes all headings and normalizes all horizontal
245     rules in the buffer.
247   * Following Links: <kbd>C-c C-o</kbd>
249     Press <kbd>C-c C-o</kbd> when the point is on an inline or reference
250     link to open the URL in a browser.  When the point is at a
251     wiki link, open it in another buffer (in the current window,
252     or in the other window with the <kbd>C-u</kbd> prefix).  Use <kbd>M-p</kbd> and
253     <kbd>M-n</kbd> to quickly jump to the previous or next link of any type.
255   * Jumping: <kbd>C-c C-j</kbd>
257     Use <kbd>C-c C-j</kbd> to jump from the object at point to its counterpart
258     elsewhere in the text, when possible.  Jumps between reference
259     links and definitions; between footnote markers and footnote
260     text.  If more than one link uses the same reference name, a
261     new buffer will be created containing clickable buttons for jumping
262     to each link.  You may press <kbd>TAB</kbd> or <kbd>S-TAB</kbd> to jump between
263     buttons in this window.
265   * Promotion and Demotion: <kbd>C-c C--</kbd> and <kbd>C-c C-=</kbd>
267     Headings, horizontal rules, and list items can be promoted and
268     demoted, as well as bold and italic text.  For headings,
269     "promotion" means *decreasing* the level (i.e., moving from
270     `<h2>` to `<h1>`) while "demotion" means *increasing* the
271     level.  For horizontal rules, promotion and demotion means
272     moving backward or forward through the list of rule strings in
273     `markdown-hr-strings`.  For bold and italic text, promotion and
274     demotion means changing the markup from underscores to asterisks.
275     Press <kbd>C-c C--</kbd> or <kbd>M-LEFT</kbd> to promote the element at the point
276     if possible.
278     To remember these commands, note that <kbd>-</kbd> is for decreasing the
279     level (promoting), and <kbd>=</kbd> (on the same key as <kbd>+</kbd>) is for
280     increasing the level (demoting).  Similarly, the left and right
281     arrow keys indicate the direction that the atx heading markup
282     is moving in when promoting or demoting.
284   * Completion: <kbd>C-c C-]</kbd>
286     Complete markup is in normalized form, which means, for
287     example, that the underline portion of a setext header is the
288     same length as the heading text, or that the number of leading
289     and trailing hash marks of an atx header are equal and that
290     there is no extra whitespace in the header text.  <kbd>C-c C-]</kbd>
291     completes the markup at the point, if it is determined to be
292     incomplete.
294   * Editing Lists: <kbd>M-RET</kbd>, <kbd>M-UP</kbd>, <kbd>M-DOWN</kbd>, <kbd>M-LEFT</kbd>, and <kbd>M-RIGHT</kbd>
296     New list items can be inserted with <kbd>M-RET</kbd>.  This command
297     determines the appropriate marker (one of the possible
298     unordered list markers or the next number in sequence for an
299     ordered list) and indentation level by examining nearby list
300     items.  If there is no list before or after the point, start a
301     new list.  Prefix this command by <kbd>C-u</kbd> to decrease the
302     indentation by one level.  Prefix this command by <kbd>C-u C-u</kbd> to
303     increase the indentation by one level.
305     Existing list items can be moved up or down with <kbd>M-UP</kbd> or
306     <kbd>M-DOWN</kbd> and indented or exdented with <kbd>M-RIGHT</kbd> or <kbd>M-LEFT</kbd>.
308   * Editing Subtrees: <kbd>M-S-UP</kbd>, <kbd>M-S-DOWN</kbd>, <kbd>M-S-LEFT</kbd>, and <kbd>M-S-RIGHT</kbd>
310     Entire subtrees of ATX headings can be promoted and demoted
311     with <kbd>M-S-LEFT</kbd> and <kbd>M-S-RIGHT</kbd>, which mirror the bindings
312     for promotion and demotion of list items. Similarly, subtrees
313     can be moved up and down with <kbd>M-S-UP</kbd> and <kbd>M-S-DOWN</kbd>.
315     Please note the following "boundary" behavior for promotion and
316     demotion.  Any level-six headings will not be demoted further
317     (i.e., they remain at level six, since Markdown and HTML define
318     only six levels) and any level-one headings will promoted away
319     entirely (i.e., heading markup will be removed, since a
320     level-zero heading is not defined).
322   * Shifting the Region: <kbd>C-c <</kbd> and <kbd>C-c ></kbd>
324     Text in the region can be indented or exdented as a group using
325     <kbd>C-c ></kbd> to indent to the next indentation point (calculated in
326     the current context), and <kbd>C-c <</kbd> to exdent to the previous
327     indentation point.  These keybindings are the same as those for
328     similar commands in `python-mode`.
330   * Killing Elements: <kbd>C-c C-k</kbd>
332     Press <kbd>C-c C-k</kbd> to kill the thing at point and add important
333     text, without markup, to the kill ring.  Possible things to
334     kill include (roughly in order of precedece): inline code,
335     headings, horizonal rules, links (add link text to kill ring),
336     images (add alt text to kill ring), angle URIs, email
337     addresses, bold, italics, reference definitions (add URI to
338     kill ring), footnote markers and text (kill both marker and
339     text, add text to kill ring), and list items.
341   * Outline Navigation: <kbd>C-c C-n</kbd>, <kbd>C-c C-p</kbd>, <kbd>C-c C-f</kbd>, <kbd>C-c C-b</kbd>, and <kbd>C-c C-u</kbd>
343     Navigation between headings is possible using `outline-mode`.
344     Use <kbd>C-c C-n</kbd> and <kbd>C-c C-p</kbd> to move between the next and previous
345     visible headings.  Similarly, <kbd>C-c C-f</kbd> and <kbd>C-c C-b</kbd> move to the
346     next and previous visible headings at the same level as the one
347     at the point.  Finally, <kbd>C-c C-u</kbd> will move up to a lower-level
348     (higher precedence) visible heading.
350   * Movement by Paragraph or Block: <kbd>M-{</kbd> and <kbd>M-}</kbd>
352     The definition of a "paragraph" is slightly different in
353     markdown-mode than, say, text-mode, because markdown-mode
354     supports filling for list items and respects hard line breaks,
355     both of which break paragraphs.  So, markdown-mode overrides
356     the usual paragraph navigation commands <kbd>M-{</kbd> and <kbd>M-}</kbd> so that
357     with a <kbd>C-u</kbd> prefix, these commands jump to the beginning or
358     end of an entire block of text, respectively, where "blocks"
359     are separated by one or more lines.
361   * Movement by Defun: <kbd>C-M-a</kbd>, <kbd>C-M-e</kbd>, and <kbd>C-M-h</kbd>
363     The usual Emacs commands can be used to move by defuns
364     (top-level major definitions).  In markdown-mode, a defun is a
365     section.  As usual, <kbd>C-M-a</kbd> will move the point to the
366     beginning of the current or preceding defun, <kbd>C-M-e</kbd> will move
367     to the end of the current or following defun, and <kbd>C-M-h</kbd> will
368     put the region around the entire defun.
370 As noted, many of the commands above behave differently depending
371 on whether Transient Mark mode is enabled or not.  When it makes
372 sense, if Transient Mark mode is on and the region is active, the
373 command applies to the text in the region (e.g., <kbd>C-c C-s s</kbd> makes the
374 region bold).  For users who prefer to work outside of Transient
375 Mark mode, since Emacs 22 it can be enabled temporarily by pressing
376 <kbd>C-SPC C-SPC</kbd>.  When this is not the case, many commands then
377 proceed to look work with the word or line at the point.
379 When applicable, commands that specifically act on the region even
380 outside of Transient Mark mode have the same keybinding as their
381 standard counterpart, but the letter is uppercase.  For example,
382 `markdown-insert-blockquote` is bound to <kbd>C-c C-s b</kbd> and only acts on
383 the region in Transient Mark mode while `markdown-blockquote-region`
384 is bound to <kbd>C-c C-s B</kbd> and always applies to the region (when nonempty).
386 Note that these region-specific functions are useful in many
387 cases where it may not be obvious.  For example, yanking text from
388 the kill ring sets the mark at the beginning of the yanked text
389 and moves the point to the end.  Therefore, the (inactive) region
390 contains the yanked text.  So, <kbd>C-y</kbd> followed by <kbd>C-c C-s C-b</kbd> will
391 yank text and turn it into a blockquote.
393 markdown-mode attempts to be flexible in how it handles
394 indentation.  When you press <kbd>TAB</kbd> repeatedly, the point will cycle
395 through several possible indentation levels corresponding to things
396 you might have in mind when you press <kbd>RET</kbd> at the end of a line or
397 <kbd>TAB</kbd>.  For example, you may want to start a new list item,
398 continue a list item with hanging indentation, indent for a nested
399 pre block, and so on.  Exdention is handled similarly when backspace
400 is pressed at the beginning of the non-whitespace portion of a line.
402 markdown-mode supports outline-minor-mode as well as org-mode-style
403 visibility cycling for atx- or hash-style headings.  There are two
404 types of visibility cycling: Pressing <kbd>S-TAB</kbd> cycles globally between
405 the table of contents view (headings only), outline view (top-level
406 headings only), and the full document view.  Pressing <kbd>TAB</kbd> while the
407 point is at a heading will cycle through levels of visibility for the
408 subtree: completely folded, visible children, and fully visible.
409 Note that mixing hash and underline style headings will give undesired
410 results.
412 ## Customization
414 Although no configuration is *necessary* there are a few things
415 that can be customized.  The <kbd>M-x customize-mode</kbd> command
416 provides an interface to all of the possible customizations:
418   * `markdown-command` - the command used to run Markdown (default:
419     `markdown`).  This variable may be customized to pass
420     command-line options to your Markdown processor of choice.
422   * `markdown-command-needs-filename` - set to <kbd>t</kbd> if
423     `markdown-command` does not accept standard input (default:
424     `nil`).  When `nil`, `markdown-mode` will pass the Markdown
425     content to `markdown-command` using standard input (`stdin`).
426     When set to <kbd>t</kbd>, `markdown-mode` will pass the name of the file
427     as the final command-line argument to `markdown-command`.  Note
428     that in the latter case, you will only be able to run
429     `markdown-command` from buffers which are visiting a file.
431   * `markdown-open-command` - the command used for calling a standalone
432     Markdown previewer which is capable of opening Markdown source files
433     directly (default: `nil`).  This command will be called
434     with a single argument, the filename of the current buffer.
435     A representative program is the Mac app [Marked 2][], a
436     live-updating Markdown previewer which can be [called from a
437     simple shell script](http://jblevins.org/log/marked-2-command).
439   * `markdown-hr-strings` - list of strings to use when inserting
440     horizontal rules.  Different strings will not be distinguished
441     when converted to HTML--they will all be converted to
442     `<hr/>`--but they may add visual distinction and style to plain
443     text documents.  To maintain some notion of promotion and
444     demotion, keep these sorted from largest to smallest.
446   * `markdown-bold-underscore` - set to a non-nil value to use two
447     underscores for bold instead of two asterisks (default: `nil`).
449   * `markdown-italic-underscore` - set to a non-nil value to use
450     underscores for italic instead of asterisks (default: `nil`).
452   * `markdown-asymmetric-header` - set to a non-nil value to use
453     asymmetric header styling, placing header characters only on
454     the left of headers (default: `nil`).
456   * `markdown-list-indent-width` - depth of indentation for lists
457     when inserting, promoting, and demoting list items (default: 4).
459   * `markdown-indent-function` - the function to use for automatic
460     indentation (default: `markdown-indent-line`).
462   * `markdown-indent-on-enter` - set to a non-nil value to
463     automatically indent new lines when the enter key is pressed
464     (default: <kbd>t</kbd>)
466   * `markdown-wiki-link-alias-first` - set to a non-nil value to
467     treat aliased wiki links like `[[link text|PageName]]`
468     (default: <kbd>t</kbd>).  When set to nil, they will be treated as
469     `[[PageName|link text]]`.
471   * `markdown-uri-types` - a list of protocol schemes (e.g., "http")
472     for URIs that `markdown-mode` should highlight.
474   * `markdown-enable-math` - syntax highlighting for LaTeX
475     fragments (default: `nil`).  Set this to <kbd>t</kbd> to turn on math
476     support by default.  Math support can be toggled later using
477     the function `markdown-enable-math`."
479   * `markdown-css-paths` - CSS files to link to in XHTML output
480     (default: `nil`).
482   * `markdown-content-type` - when set to a nonempty string, an
483     `http-equiv` attribute will be included in the XHTML `<head>`
484     block (default: `""`).  If needed, the suggested values are
485     `application/xhtml+xml` or `text/html`.  See also:
486     `markdown-coding-system`.
488   * `markdown-coding-system` - used for specifying the character
489     set identifier in the `http-equiv` attribute when included
490     (default: `nil`).  See `markdown-content-type`, which must
491     be set before this variable has any effect.  When set to `nil`,
492     `buffer-file-coding-system` will be used to automatically
493     determine the coding system string (falling back to
494     `iso-8859-1` when unavailable).  Common settings are `utf-8`
495     and `iso-latin-1`.
497   * `markdown-xhtml-header-content` - additional content to include
498     in the XHTML `<head>` block (default: `""`).
500   * `markdown-xhtml-standalone-regexp` - a regular expression which
501     `markdown-mode` uses to determine whether the output of
502     `markdown-command` is a standalone XHTML document or an XHTML
503     fragment (default: `"^\\(<\\?xml\\|<!DOCTYPE\\|<html\\)"`).  If
504     this regular expression not matched in the first five lines of
505     output, `markdown-mode` assumes the output is a fragment and
506     adds a header and footer.
508   * `markdown-link-space-sub-char` - a character to replace spaces
509     when mapping wiki links to filenames (default: `"_"`).
510     For example, use an underscore for compatibility with the
511     Python Markdown WikiLinks extension.  In `gfm-mode`, this is
512     set to `"-"` to conform with GitHub wiki links.
514   * `markdown-reference-location` - where to insert reference
515     definitions (default: `header`).  The possible locations are
516     the end of the document (`end`), after the current block
517     (`immediately`), before the next header (`header`).
519   * `markdown-footnote-location` - where to insert footnote text
520     (default: `end`).  The set of location options is the same as
521     for `markdown-reference-location`.
523   * `comment-auto-fill-only-comments` - variable is made
524     buffer-local and set to `nil` by default.  In programming
525     language modes, when this variable is non-nil, only comments
526     will be filled by auto-fill-mode.  However, comments in
527     Markdown documents are rare and the most users probably intend
528     for the actual content of the document to be filled.  Making
529     this variable buffer-local allows `markdown-mode` to override
530     the default behavior induced when the global variable is non-nil.
532   * `markdown-make-gfm-checkboxes-buttons` - Whether GitHub
533     Flavored Markdown style task lists (checkboxes) should be
534     turned into buttons that can be toggled with mouse-1 or RET. If
535     non-nil (default), then buttons are enabled.  This works in
536     `markdown-mode` as well as `gfm-mode`.
538 Additionally, the faces used for syntax highlighting can be modified to
539 your liking by issuing <kbd>M-x customize-group RET markdown-faces</kbd>
540 or by using the "Markdown Faces" link at the bottom of the mode
541 customization screen.
543 [Marked 2]: https://itunes.apple.com/us/app/marked-2/id890031187?mt=12&uo=4&at=11l5Vs&ct=mm
545 ## Extensions
547 Besides supporting the basic Markdown syntax, markdown-mode also
548 includes syntax highlighting for `[[Wiki Links]]` by default.  Wiki
549 links may be followed by pressing <kbd>C-c C-o</kbd> when the point
550 is at a wiki link.  Use <kbd>M-p</kbd> and <kbd>M-n</kbd> to quickly jump to the
551 previous and next links (including links of other types).
552 Aliased or piped wiki links of the form `[[link text|PageName]]`
553 are also supported.  Since some wikis reverse these components, set
554 `markdown-wiki-link-alias-first` to nil to treat them as
555 `[[PageName|link text]]`.  By default, Markdown Mode only searches
556 for target files in the current directory.  Sequential parent
557 directory search (as in [Ikiwiki][]) can be enabled by setting
558 `markdown-wiki-link-search-parent-directories` to a non-nil value.
560 [Ikiwiki]: https://ikiwiki.info
562 [SmartyPants][] support is possible by customizing `markdown-command`.
563 If you install `SmartyPants.pl` at, say, `/usr/local/bin/smartypants`,
564 then you can set `markdown-command` to `"markdown | smartypants"`.
565 You can do this either by using <kbd>M-x customize-group markdown</kbd>
566 or by placing the following in your `.emacs` file:
568     (setq markdown-command "markdown | smartypants")
570 [SmartyPants]: http://daringfireball.net/projects/smartypants/
572 Syntax highlighting for mathematical expressions written
573 in LaTeX (only expressions denoted by `$..$`, `$$..$$`, or `\[..\]`)
574 can be enabled by setting `markdown-enable-math` to a non-nil value,
575 either via customize or by placing `(setq markdown-enable-math t)`
576 in `.emacs`, and then restarting Emacs or calling
577 `markdown-reload-extensions`.
579 ## GitHub Flavored Markdown (GFM)
581 A [GitHub Flavored Markdown][GFM] mode, `gfm-mode`, is also
582 available.  The GitHub implementation differs slightly from
583 standard Markdown in that it supports things like different
584 behavior for underscores inside of words, automatic linking of
585 URLs, strikethrough text, and fenced code blocks with an optional
586 language keyword.
588 The GFM-specific features above apply to `README.md` files, wiki
589 pages, and other Markdown-formatted files in repositories on
590 GitHub.  GitHub also enables [additional features][GFM comments] for
591 writing on the site (for issues, pull requests, messages, etc.)
592 that are further extensions of GFM.  These features include task
593 lists (checkboxes), newlines corresponding to hard line breaks,
594 auto-linked references to issues and commits, wiki links, and so
595 on.  To make matters more confusing, although task lists are not
596 part of [GFM proper][GFM], [since 2014][] they are rendered (in a
597 read-only fashion) in all Markdown documents in repositories on the
598 site.  These additional extensions are supported to varying degrees
599 by `markdown-mode` and `gfm-mode` as described below.
601 * **URL autolinking:** Both `markdown-mode` and `gfm-mode` support
602   highlighting of URLs without angle brackets.
604 * **Multiple underscores in words:** You must enable `gfm-mode` to
605   toggle support for underscores inside of words. In this mode
606   variable names such as `a_test_variable` will not trigger
607   emphasis (italics).
609 * **Fenced code blocks:** Code blocks quoted with backticks, with
610   optional programming language keywords, are highlighted in
611   both `markdown-mode` and `gfm-mode`.  They can be inserted with
612   <kbd>C-c C-s P</kbd>.  If there is an active region, the text in the
613   region will be placed inside the code block.  You will be
614   prompted for the name of the language, but may press enter to
615   continue without naming a language.
617 * **Strikethrough:** Strikethrough text is only supported in
618   `gfm-mode` and can be inserted (and toggled) using <kbd>C-c C-s d</kbd>.
619   Following the mnemonics for the other style keybindings, the
620   letter <kbd>d</kbd> coincides with the HTML tag `<del>`.
622 * **Task lists:** GFM task lists will be rendered as checkboxes
623   (Emacs buttons) in both `markdown-mode` and `gfm-mode` when
624   `markdown-make-gfm-checkboxes-buttons` is set to a non-nil value
625   (and it is set to t by default).  These checkboxes can be
626   toggled by clicking `mouse-1` or pressing <kbd>RET</kbd> over the button.
628 * **Wiki links:** Generic wiki links are supported in
629   `markdown-mode`, but in `gfm-mode` specifically they will be
630   treated as they are on GitHub: spaces will be replaced by hyphens
631   in filenames and the first letter of the filename will be
632   capitalized.  For example, `[[wiki link]]` will map to a file
633   named `Wiki-link` with the same extension as the current file.
635 * **Newlines:** Neither `markdown-mode` nor `gfm-mode` do anything
636   specifically with respect to newline behavior.  If you use
637   `gfm-mode` mostly to write text for comments or issues on the
638   GitHub site--where newlines are significant and correspond to
639   hard line breaks--then you may want to enable `visual-line-mode`
640   for line wrapping in buffers.  You can do this with a
641   `gfm-mode-hook` as follows:
643         ;; Use visual-line-mode in gfm-mode
644         (defun my-gfm-mode-hook ()
645           (visual-line-mode 1))
646         (add-hook 'gfm-mode-hook 'my-gfm-mode-hook)
648 * **Preview:** GFM-specific preview can be powered by setting
649   `markdown-command` to use [Docter][].  This may also be
650   configured to work with [Marked 2][] for `markdown-open-command`.
652 [GFM]: http://github.github.com/github-flavored-markdown/
653 [GFM comments]: https://help.github.com/articles/writing-on-github/
654 [since 2014]: https://github.com/blog/1825-task-lists-in-all-markdown-documents
655 [Docter]: https://github.com/alampros/Docter
657 ## Acknowledgments
659 markdown-mode has benefited greatly from the efforts of the
660 following people:
662   * Cyril Brulebois for Debian packaging.
663   * Conal Elliott for a font-lock regexp patch.
664   * Edward O'Connor for a font-lock regexp fix and
665     GitHub Flavored Markdown mode (`gfm-mode`).
666   * Greg Bognar for menus and running
667     `markdown` with an active region.
668   * Daniel Burrows for filing Debian bug #456592.
669   * Peter S. Galbraith for maintaining `emacs-goodies-el`.
670   * Dmitry Dzhus for undefined reference checking.
671   * Carsten Dominik for `org-mode`, from which the
672     visibility cycling functionality was derived, and for a bug fix
673     related to `orgtbl-mode`.
674   * Bryan Kyle for indentation code.
675   * Ben Voui for font-lock face customizations.
676   * Ankit Solanki for `longlines.el`
677     compatibility and custom CSS.
678   * Hilko Bengen for proper XHTML output.
679   * Jose A. Ortega Ruiz for Emacs 23 fixes.
680   * Nelson Minar for `html-helper-mode`, from which
681     comment matching functions were derived.
682   * Alec Resnick for bug reports.
683   * Joost Kremers for footnote-handling
684     functions, bug reports regarding indentation, and
685     fixes for byte-compilation warnings.
686   * Peter Williams for `fill-paragraph`
687     enhancements.
688   * George Ogata for fixing several
689     byte-compilation warnings.
690   * Eric Merritt for wiki link features.
691   * Philippe Ivaldi for XHTML preview
692     customizations and XHTML export.
693   * Jeremiah Dodds for supporting
694     Markdown processors which do not accept input from stdin.
695   * Werner Dittmann for bug reports
696     regarding the `cl` dependency and `auto-fill-mode` and indentation.
697   * Scott Pfister for generalizing the space
698     substitution character for mapping wiki links to filenames.
699   * Marcin Kasperski for a patch to
700     escape shell commands.
701   * Christopher J. Madsen for patches to fix a match
702     data bug and to prefer `visual-line-mode` in `gfm-mode`.
703   * Shigeru Fukaya for better adherence to
704     Emacs Lisp coding conventions.
705   * Donald Ephraim Curtis for fixing the `fill-paragraph`
706     regexp, refactoring the compilation and preview functions,
707     heading font-lock generalizations, list renumbering,
708     and kill ring save.
709   * Kevin Porter for wiki link handling in `gfm-mode`.
710   * Max Penet and Peter Eisentraut <peter_e@gmx.net>
711     for an autoload token for `gfm-mode`.
712   * Ian Yang for improving the reference definition regex.
713   * Akinori Musha for an imenu index function.
714   * Michael Sperber for XEmacs fixes.
715   * Francois Gannaz for suggesting charset
716     declaration in XHTML output.
717   * Zhenlei Jia for smart exdention function.
718   * Matus Goljer for improved wiki link following
719     and GFM code block insertion.
720   * Peter Jones for link following functions.
721   * Bryan Fink for a bug report regarding
722     externally modified files.
723   * Vegard Vesterheim for a bug fix
724     related to `orgtbl-mode`.
725   * Makoto Motohashi for before- and after-
726     export hooks, unit test improvements, and updates to support
727     wide characters.
728   * Michael Dwyer for `gfm-mode` underscore regexp.
729   * Chris Lott for suggesting reference label
730     completion.
731   * Gunnar Franke for a completion bug report.
732   * David Glasser for a `paragraph-separate` fix.
733   * Daniel Brotsky for better auto-fill defaults.
734   * Samuel Freilich for improved filling
735     behavior regarding list items, footnotes, and reference
736     definitions, improved killing of footnotes, and numerous other
737     tests and bug fixes.
738   * Antonis Kanouras for strikethrough support.
739   * Tim Visher for multiple CSS files and other
740     general improvements.
741   * Matt McClure for a patch to prevent
742     overwriting source files with .html extensions upon export.
743   * Roger Bolsius for ordered list improvements.
744   * Google's Open Source Programs Office for recognizing the project with
745     a monetary contribution in June 2015.
746   * Howard Melman for supporting GFM checkboxes
747     as buttons.
748   * Danny McClanahan for live preview mode.
749   * Syohei Yoshida for better heading detection
750     and movement functions.
752 ## Bugs
754 Although markdown-mode is developed and tested primarily using
755 GNU Emacs 24, compatibility with earlier Emacsen is also a
756 priority.
758 If you find any bugs in markdown-mode, please construct a test case
759 or a patch and open a ticket on the [GitHub issue tracker][issues].
761  [issues]: https://github.com/jrblevin/markdown-mode/issues
763 ## History
765 markdown-mode was written and is maintained by Jason Blevins.  The
766 first version was released on May 24, 2007.
768   * 2007-05-24: Version 1.1
769   * 2007-05-25: Version 1.2
770   * 2007-06-05: [Version 1.3][]
771   * 2007-06-29: Version 1.4
772   * 2007-10-11: [Version 1.5][]
773   * 2008-06-04: [Version 1.6][]
774   * 2009-10-01: [Version 1.7][]
775   * 2011-08-12: [Version 1.8][]
776   * 2011-08-15: [Version 1.8.1][]
777   * 2013-01-25: [Version 1.9][]
778   * 2013-03-24: [Version 2.0][]
780 [Version 1.3]: http://jblevins.org/projects/markdown-mode/rev-1-3
781 [Version 1.5]: http://jblevins.org/projects/markdown-mode/rev-1-5
782 [Version 1.6]: http://jblevins.org/projects/markdown-mode/rev-1-6
783 [Version 1.7]: http://jblevins.org/projects/markdown-mode/rev-1-7
784 [Version 1.8]: http://jblevins.org/projects/markdown-mode/rev-1-8
785 [Version 1.8.1]: http://jblevins.org/projects/markdown-mode/rev-1-8-1
786 [Version 1.9]: http://jblevins.org/projects/markdown-mode/rev-1-9
787 [Version 2.0]: http://jblevins.org/projects/markdown-mode/rev-2-0