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
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]
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 markdown-mode is also available in several package managers, including:
27 * Debian Linux: [emacs-goodies-el][]
28 * Ubuntu Linux: [emacs-goodies-el][emacs-goodies-el-ubuntu]
29 * RedHat and Fedora Linux: [emacs-goodies][]
30 * NetBSD: [textproc/markdown-mode][]
31 * Arch Linux (AUR): [emacs-markdown-mode-git][]
32 * MacPorts: [markdown-mode.el][macports-package] ([pending][macports-ticket])
33 * FreeBSD: [textproc/markdown-mode.el][freebsd-port]
35 [emacs-goodies-el]: http://packages.debian.org/emacs-goodies-el
36 [emacs-goodies-el-ubuntu]: http://packages.ubuntu.com/search?keywords=emacs-goodies-el
37 [emacs-goodies]: https://apps.fedoraproject.org/packages/emacs-goodies
38 [textproc/markdown-mode]: http://pkgsrc.se/textproc/markdown-mode
39 [emacs-markdown-mode-git]: https://aur.archlinux.org/packages/emacs-goodies-el/
40 [macports-package]: https://trac.macports.org/browser/trunk/dports/editors/markdown-mode.el/Portfile
41 [macports-ticket]: http://trac.macports.org/ticket/35716
42 [freebsd-port]: http://svnweb.freebsd.org/ports/head/textproc/markdown-mode.el
44 The latest development version can be downloaded directly
45 ([markdown-mode.el][devel.el]) or it can be obtained from the
46 (browsable and clonable) Git repository at
47 <http://jblevins.org/git/markdown-mode.git>. The entire repository,
48 including the full project history, can be cloned via the Git protocol
51 git clone git://jblevins.org/git/markdown-mode.git
53 [devel.el]: http://jblevins.org/git/markdown-mode.git/plain/markdown-mode.el
57 Make sure to place `markdown-mode.el` somewhere in the load-path and add
58 the following lines to your `.emacs` file to associate markdown-mode
59 with `.text`, `.markdown`, and `.md` files:
61 (autoload 'markdown-mode "markdown-mode"
62 "Major mode for editing Markdown files" t)
63 (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
64 (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
65 (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
67 There is no official Markdown file extension, nor is there even a
68 _de facto_ standard, so you can easily add, change, or remove any
69 of the file extensions above as needed.
73 Keybindings are grouped by prefixes based on their function. For
74 example, the commands for inserting links are grouped under `C-c
75 C-a`, where the <kbd>C-a</kbd> is a mnemonic for the HTML `<a>` tag. In
76 other cases, the connection to HTML is not direct. For example,
77 commands dealing with headings begin with <kbd>C-c C-t</kbd> (mnemonic:
78 titling). The primary commands in each group will are described
79 below. You can obtain a list of all keybindings by pressing `C-c
80 C-h`. Movement and shifting commands tend to be associated with
81 paired delimiters such as <kbd>M-{</kbd> and <kbd>M-}</kbd> or <kbd>C-c <</kbd> and <kbd>C-c ></kbd>.
82 Outline navigation keybindings the same as in `org-mode`. Finally,
83 commands for running Markdown or doing maintenance on an open file
84 are grouped under the <kbd>C-c C-c</kbd> prefix. The most commonly used
85 commands are described below. You can obtain a list of all
86 keybindings by pressing <kbd>C-c C-h</kbd>.
88 * Hyperlinks: <kbd>C-c C-a</kbd>
90 In this group, <kbd>C-c C-a l</kbd> inserts an inline link of the form
91 `[text](url)`. The link text is determined as follows. First,
92 if there is an active region (i.e., when transient mark mode is
93 on and the mark is active), use it as the link text. Second,
94 if the point is at a word, use that word as the link text. In
95 these two cases, the original text will be replaced with the
96 link and point will be left at the position for inserting a
97 URL. Otherwise, insert empty link markup and place the point
98 for inserting the link text.
100 <kbd>C-c C-a L</kbd> inserts a reference link of the form `[text][label]`
101 and, optionally, a corresponding reference label definition.
102 The link text is determined in the same way as with an inline
103 link (using the region, when active, or the word at the point),
104 but instead of inserting empty markup as a last resort, the
105 link text will be read from the minibuffer. The reference
106 label will be read from the minibuffer in both cases, with
107 completion from the set of currently defined references. To
108 create an implicit reference link, press <kbd>RET</kbd> to accept the
109 default, an empty label. If the entered referenced label is
110 not defined, additionally prompt for the URL and (optional)
111 title. If a URL is provided, a reference definition will be
112 inserted in accordance with `markdown-reference-location`.
113 If a title is given, it will be added to the end of the
114 reference definition and will be used to populate the title
115 attribute when converted to XHTML.
117 <kbd>C-c C-a u</kbd> inserts a bare url, delimited by angle brackets. When
118 there is an active region, the text in the region is used as the
119 URL. If the point is at a URL, that url is used. Otherwise,
120 insert angle brackets and position the point in between them
121 for inserting the URL.
123 <kbd>C-c C-a f</kbd> inserts a footnote marker at the point, inserts a
124 footnote definition below, and positions the point for
125 inserting the footnote text. Note that footnotes are an
126 extension to Markdown and are not supported by all processors.
128 <kbd>C-c C-a w</kbd> behaves much like the inline link insertion command
129 and inserts a wiki link of the form `[[WikiLink]]`. If there
130 is an active region, use the region as the link text. If the
131 point is at a word, use the word as the link text. If there is
132 no active region and the point is not at word, simply insert
133 link markup. Note that wiki links are an extension to Markdown
134 and are not supported by all processors.
136 * Images: <kbd>C-c C-i</kbd>
138 <kbd>C-c C-i i</kbd> inserts markup for an inline image, using the
139 active region or the word at point, if any, as the alt text.
140 <kbd>C-c C-i I</kbd> behaves similarly and inserts a reference-style
143 * Styles: <kbd>C-c C-s</kbd>
145 <kbd>C-c C-s e</kbd> inserts markup to make a region or word italic (<kbd>e</kbd>
146 for `<em>` or emphasis). If there is an active region, make
147 the region italic. If the point is at a non-italic word, make
148 the word italic. If the point is at an italic word or phrase,
149 remove the italic markup. Otherwise, simply insert italic
150 delimiters and place the cursor in between them. Similarly,
151 use <kbd>C-c C-s s</kbd> for bold (`<strong>`) and <kbd>C-c C-s c</kbd> for
152 inline code (`<code>`).
154 <kbd>C-c C-s b</kbd> inserts a blockquote using the active region, if any,
155 or starts a new blockquote. <kbd>C-c C-s C-b</kbd> is a variation which
156 always operates on the region, regardless of whether it is
157 active or not. The appropriate amount of indentation, if any,
158 is calculated automatically given the surrounding context, but
159 may be adjusted later using the region indentation commands.
161 <kbd>C-c C-s p</kbd> behaves similarly for inserting preformatted code
162 blocks, with <kbd>C-c C-s C-p</kbd> being the region-only counterpart.
164 * Headings: <kbd>C-c C-t</kbd>
166 All heading insertion commands use the text in the active
167 region, if any, as the heading text. Otherwise, if the current
168 line is not blank, they use the text on the current line.
169 Finally, the setext commands will prompt for heading text if
170 there is no active region and the current line is blank.
172 <kbd>C-c C-t h</kbd> inserts a heading with automatically chosen type and
173 level (both determined by the previous heading). <kbd>C-c C-t H</kbd>
174 behaves similarly, but uses setext (underlined) headings when
175 possible, still calculating the level automatically.
176 In cases where the automatically-determined level is not what
177 you intended, the level can be quickly promoted or demoted
178 (as described below). Alternatively, a <kbd>C-u</kbd> prefix can be
179 given to insert a heading promoted by one level or a <kbd>C-u C-u</kbd>
180 prefix can be given to insert a heading demoted by one level.
182 To insert a heading of a specific level and type, use <kbd>C-c C-t 1</kbd>
183 through <kbd>C-c C-t 6</kbd> for atx (hash mark) headings and <kbd>C-c C-t !</kbd> or
184 <kbd>C-c C-t @</kbd> for setext headings of level one or two, respectively.
185 Note that <kbd>!</kbd> is <kbd>S-1</kbd> and <kbd>@</kbd> is <kbd>S-2</kbd>.
187 If the point is at a heading, these commands will replace the
188 existing markup in order to update the level and/or type of the
189 heading. To remove the markup of the heading at the point,
190 press <kbd>C-c C-k</kbd> to kill the heading and press <kbd>C-y</kbd> to yank the
191 heading text back into the buffer.
193 * Horizontal Rules: <kbd>C-c -</kbd>
195 <kbd>C-c -</kbd> inserts a horizontal rule. By default, insert the
196 first string in the list `markdown-hr-strings` (the most
197 prominent rule). With a <kbd>C-u</kbd> prefix, insert the last string.
198 With a numeric prefix <kbd>N</kbd>, insert the string in position <kbd>N</kbd>
201 * Markdown and Maintenance Commands: <kbd>C-c C-c</kbd>
203 *Compile:* <kbd>C-c C-c m</kbd> will run Markdown on the current buffer
204 and show the output in another buffer. *Preview*: <kbd>C-c C-c p</kbd>
205 runs Markdown on the current buffer and previews, stores the
206 output in a temporary file, and displays the file in a browser.
207 *Export:* <kbd>C-c C-c e</kbd> will run Markdown on the current buffer
208 and save the result in the file `basename.html`, where
209 `basename` is the name of the Markdown file with the extension
210 removed. *Export and View:* press <kbd>C-c C-c v</kbd> to export the
211 file and view it in a browser. **For both export commands, the
212 output file will be overwritten without notice.**
213 *Open:* <kbd>C-c C-c o</kbd> will open the Markdown source file directly
214 using `markdown-open-command`.
218 - <kbd>C-c C-c m</kbd>: `markdown-command` > `*markdown-output*` buffer.
219 - <kbd>C-c C-c p</kbd>: `markdown-command` > temporary file > browser.
220 - <kbd>C-c C-c e</kbd>: `markdown-command` > `basename.html`.
221 - <kbd>C-c C-c v</kbd>: `markdown-command` > `basename.html` > browser.
222 - <kbd>C-c C-c w</kbd>: `markdown-command` > kill ring.
223 - <kbd>C-c C-c o</kbd>: `markdown-open-command`.
225 <kbd>C-c C-c c</kbd> will check for undefined references. If there are
226 any, a small buffer will open with a list of undefined
227 references and the line numbers on which they appear. In Emacs
228 22 and greater, selecting a reference from this list and
229 pressing <kbd>RET</kbd> will insert an empty reference definition at the
230 end of the buffer. Similarly, selecting the line number will
231 jump to the corresponding line.
233 <kbd>C-c C-c n</kbd> renumbers any ordered lists in the buffer that are
236 <kbd>C-c C-c ]</kbd> completes all headings and normalizes all horizontal
239 * Following Links: <kbd>C-c C-o</kbd>
241 Press <kbd>C-c C-o</kbd> when the point is on an inline or reference
242 link to open the URL in a browser. When the point is at a
243 wiki link, open it in another buffer (in the current window,
244 or in the other window with the <kbd>C-u</kbd> prefix). Use <kbd>M-p</kbd> and
245 <kbd>M-n</kbd> to quickly jump to the previous or next link of any type.
247 * Jumping: <kbd>C-c C-j</kbd>
249 Use <kbd>C-c C-j</kbd> to jump from the object at point to its counterpart
250 elsewhere in the text, when possible. Jumps between reference
251 links and definitions; between footnote markers and footnote
252 text. If more than one link uses the same reference name, a
253 new buffer will be created containing clickable buttons for jumping
254 to each link. You may press <kbd>TAB</kbd> or <kbd>S-TAB</kbd> to jump between
255 buttons in this window.
257 * Promotion and Demotion: <kbd>C-c C--</kbd> and <kbd>C-c C-=</kbd>
259 Headings, horizontal rules, and list items can be promoted and
260 demoted, as well as bold and italic text. For headings,
261 "promotion" means *decreasing* the level (i.e., moving from
262 `<h2>` to `<h1>`) while "demotion" means *increasing* the
263 level. For horizontal rules, promotion and demotion means
264 moving backward or forward through the list of rule strings in
265 `markdown-hr-strings`. For bold and italic text, promotion and
266 demotion means changing the markup from underscores to asterisks.
267 Press <kbd>C-c C--</kbd> or <kbd>M-LEFT</kbd> to promote the element at the point
270 To remember these commands, note that <kbd>-</kbd> is for decreasing the
271 level (promoting), and <kbd>=</kbd> (on the same key as <kbd>+</kbd>) is for
272 increasing the level (demoting). Similarly, the left and right
273 arrow keys indicate the direction that the atx heading markup
274 is moving in when promoting or demoting.
276 * Completion: <kbd>C-c C-]</kbd>
278 Complete markup is in normalized form, which means, for
279 example, that the underline portion of a setext header is the
280 same length as the heading text, or that the number of leading
281 and trailing hash marks of an atx header are equal and that
282 there is no extra whitespace in the header text. <kbd>C-c C-]</kbd>
283 completes the markup at the point, if it is determined to be
286 * Editing Lists: <kbd>M-RET</kbd>, <kbd>M-UP</kbd>, <kbd>M-DOWN</kbd>, <kbd>M-LEFT</kbd>, and <kbd>M-RIGHT</kbd>
288 New list items can be inserted with <kbd>M-RET</kbd>. This command
289 determines the appropriate marker (one of the possible
290 unordered list markers or the next number in sequence for an
291 ordered list) and indentation level by examining nearby list
292 items. If there is no list before or after the point, start a
293 new list. Prefix this command by <kbd>C-u</kbd> to decrease the
294 indentation by one level. Prefix this command by <kbd>C-u C-u</kbd> to
295 increase the indentation by one level.
297 Existing list items can be moved up or down with <kbd>M-UP</kbd> or
298 <kbd>M-DOWN</kbd> and indented or exdented with <kbd>M-RIGHT</kbd> or <kbd>M-LEFT</kbd>.
300 * Editing Subtrees: <kbd>M-S-UP</kbd>, <kbd>M-S-DOWN</kbd>, <kbd>M-S-LEFT</kbd>, and <kbd>M-S-RIGHT</kbd>
302 Entire subtrees of ATX headings can be promoted and demoted
303 with <kbd>M-S-LEFT</kbd> and <kbd>M-S-RIGHT</kbd>, which mirror the bindings
304 for promotion and demotion of list items. Similarly, subtrees
305 can be moved up and down with <kbd>M-S-UP</kbd> and <kbd>M-S-DOWN</kbd>.
307 Please note the following "boundary" behavior for promotion and
308 demotion. Any level-six headings will not be demoted further
309 (i.e., they remain at level six, since Markdown and HTML define
310 only six levels) and any level-one headings will promoted away
311 entirely (i.e., heading markup will be removed, since a
312 level-zero heading is not defined).
314 * Shifting the Region: <kbd>C-c <</kbd> and <kbd>C-c ></kbd>
316 Text in the region can be indented or exdented as a group using
317 <kbd>C-c ></kbd> to indent to the next indentation point (calculated in
318 the current context), and <kbd>C-c <</kbd> to exdent to the previous
319 indentation point. These keybindings are the same as those for
320 similar commands in `python-mode`.
322 * Killing Elements: <kbd>C-c C-k</kbd>
324 Press <kbd>C-c C-k</kbd> to kill the thing at point and add important
325 text, without markup, to the kill ring. Possible things to
326 kill include (roughly in order of precedece): inline code,
327 headings, horizonal rules, links (add link text to kill ring),
328 images (add alt text to kill ring), angle URIs, email
329 addresses, bold, italics, reference definitions (add URI to
330 kill ring), footnote markers and text (kill both marker and
331 text, add text to kill ring), and list items.
333 * 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>
335 Navigation between headings is possible using `outline-mode`.
336 Use <kbd>C-c C-n</kbd> and <kbd>C-c C-p</kbd> to move between the next and previous
337 visible headings. Similarly, <kbd>C-c C-f</kbd> and <kbd>C-c C-b</kbd> move to the
338 next and previous visible headings at the same level as the one
339 at the point. Finally, <kbd>C-c C-u</kbd> will move up to a lower-level
340 (higher precedence) visible heading.
342 * Movement by Paragraph or Block: <kbd>M-{</kbd> and <kbd>M-}</kbd>
344 The definition of a "paragraph" is slightly different in
345 markdown-mode than, say, text-mode, because markdown-mode
346 supports filling for list items and respects hard line breaks,
347 both of which break paragraphs. So, markdown-mode overrides
348 the usual paragraph navigation commands <kbd>M-{</kbd> and <kbd>M-}</kbd> so that
349 with a <kbd>C-u</kbd> prefix, these commands jump to the beginning or
350 end of an entire block of text, respectively, where "blocks"
351 are separated by one or more lines.
353 * Movement by Defun: <kbd>C-M-a</kbd>, <kbd>C-M-e</kbd>, and <kbd>C-M-h</kbd>
355 The usual Emacs commands can be used to move by defuns
356 (top-level major definitions). In markdown-mode, a defun is a
357 section. As usual, <kbd>C-M-a</kbd> will move the point to the
358 beginning of the current or preceding defun, <kbd>C-M-e</kbd> will move
359 to the end of the current or following defun, and <kbd>C-M-h</kbd> will
360 put the region around the entire defun.
362 As noted, many of the commands above behave differently depending
363 on whether Transient Mark mode is enabled or not. When it makes
364 sense, if Transient Mark mode is on and the region is active, the
365 command applies to the text in the region (e.g., <kbd>C-c C-s s</kbd> makes the
366 region bold). For users who prefer to work outside of Transient
367 Mark mode, since Emacs 22 it can be enabled temporarily by pressing
368 <kbd>C-SPC C-SPC</kbd>. When this is not the case, many commands then
369 proceed to look work with the word or line at the point.
371 When applicable, commands that specifically act on the region even
372 outside of Transient Mark mode have the same keybinding as their
373 standard counterpart, but the letter is uppercase. For example,
374 `markdown-insert-blockquote` is bound to <kbd>C-c C-s b</kbd> and only acts on
375 the region in Transient Mark mode while `markdown-blockquote-region`
376 is bound to <kbd>C-c C-s B</kbd> and always applies to the region (when nonempty).
378 Note that these region-specific functions are useful in many
379 cases where it may not be obvious. For example, yanking text from
380 the kill ring sets the mark at the beginning of the yanked text
381 and moves the point to the end. Therefore, the (inactive) region
382 contains the yanked text. So, <kbd>C-y</kbd> followed by <kbd>C-c C-s C-b</kbd> will
383 yank text and turn it into a blockquote.
385 markdown-mode attempts to be flexible in how it handles
386 indentation. When you press <kbd>TAB</kbd> repeatedly, the point will cycle
387 through several possible indentation levels corresponding to things
388 you might have in mind when you press <kbd>RET</kbd> at the end of a line or
389 <kbd>TAB</kbd>. For example, you may want to start a new list item,
390 continue a list item with hanging indentation, indent for a nested
391 pre block, and so on. Exdention is handled similarly when backspace
392 is pressed at the beginning of the non-whitespace portion of a line.
394 markdown-mode supports outline-minor-mode as well as org-mode-style
395 visibility cycling for atx- or hash-style headings. There are two
396 types of visibility cycling: Pressing <kbd>S-TAB</kbd> cycles globally between
397 the table of contents view (headings only), outline view (top-level
398 headings only), and the full document view. Pressing <kbd>TAB</kbd> while the
399 point is at a heading will cycle through levels of visibility for the
400 subtree: completely folded, visible children, and fully visible.
401 Note that mixing hash and underline style headings will give undesired
406 Although no configuration is *necessary* there are a few things
407 that can be customized. The <kbd>M-x customize-mode</kbd> command
408 provides an interface to all of the possible customizations:
410 * `markdown-command` - the command used to run Markdown (default:
411 `markdown`). This variable may be customized to pass
412 command-line options to your Markdown processor of choice.
414 * `markdown-command-needs-filename` - set to <kbd>t</kbd> if
415 `markdown-command` does not accept standard input (default:
416 `nil`). When `nil`, `markdown-mode` will pass the Markdown
417 content to `markdown-command` using standard input (`stdin`).
418 When set to <kbd>t</kbd>, `markdown-mode` will pass the name of the file
419 as the final command-line argument to `markdown-command`. Note
420 that in the latter case, you will only be able to run
421 `markdown-command` from buffers which are visiting a file.
423 * `markdown-open-command` - the command used for calling a standalone
424 Markdown previewer which is capable of opening Markdown source files
425 directly (default: `nil`). This command will be called
426 with a single argument, the filename of the current buffer.
427 A representative program is the Mac app [Marked 2][], a
428 live-updating Markdown previewer which can be [called from a
429 simple shell script](http://jblevins.org/log/marked-2-command).
431 * `markdown-hr-strings` - list of strings to use when inserting
432 horizontal rules. Different strings will not be distinguished
433 when converted to HTML--they will all be converted to
434 `<hr/>`--but they may add visual distinction and style to plain
435 text documents. To maintain some notion of promotion and
436 demotion, keep these sorted from largest to smallest.
438 * `markdown-bold-underscore` - set to a non-nil value to use two
439 underscores for bold instead of two asterisks (default: `nil`).
441 * `markdown-italic-underscore` - set to a non-nil value to use
442 underscores for italic instead of asterisks (default: `nil`).
444 * `markdown-asymmetric-header` - set to a non-nil value to use
445 asymmetric header styling, placing header characters only on
446 the left of headers (default: `nil`).
448 * `markdown-indent-function` - the function to use for automatic
449 indentation (default: `markdown-indent-line`).
451 * `markdown-indent-on-enter` - set to a non-nil value to
452 automatically indent new lines when the enter key is pressed
453 (default: <kbd>t</kbd>)
455 * `markdown-wiki-link-alias-first` - set to a non-nil value to
456 treat aliased wiki links like `[[link text|PageName]]`
457 (default: <kbd>t</kbd>). When set to nil, they will be treated as
458 `[[PageName|link text]]`.
460 * `markdown-uri-types` - a list of protocol schemes (e.g., "http")
461 for URIs that `markdown-mode` should highlight.
463 * `markdown-enable-math` - syntax highlighting for LaTeX
464 fragments (default: `nil`). Set this to <kbd>t</kbd> to turn on math
465 support by default. Math support can be toggled later using
466 the function `markdown-enable-math`."
468 * `markdown-css-paths` - CSS files to link to in XHTML output
471 * `markdown-content-type` - when set to a nonempty string, an
472 `http-equiv` attribute will be included in the XHTML `<head>`
473 block (default: `""`). If needed, the suggested values are
474 `application/xhtml+xml` or `text/html`. See also:
475 `markdown-coding-system`.
477 * `markdown-coding-system` - used for specifying the character
478 set identifier in the `http-equiv` attribute when included
479 (default: `nil`). See `markdown-content-type`, which must
480 be set before this variable has any effect. When set to `nil`,
481 `buffer-file-coding-system` will be used to automatically
482 determine the coding system string (falling back to
483 `iso-8859-1` when unavailable). Common settings are `utf-8`
486 * `markdown-xhtml-header-content` - additional content to include
487 in the XHTML `<head>` block (default: `""`).
489 * `markdown-xhtml-standalone-regexp` - a regular expression which
490 `markdown-mode` uses to determine whether the output of
491 `markdown-command` is a standalone XHTML document or an XHTML
492 fragment (default: `"^\\(<\\?xml\\|<!DOCTYPE\\|<html\\)"`). If
493 this regular expression not matched in the first five lines of
494 output, `markdown-mode` assumes the output is a fragment and
495 adds a header and footer.
497 * `markdown-link-space-sub-char` - a character to replace spaces
498 when mapping wiki links to filenames (default: `"_"`).
499 For example, use an underscore for compatibility with the
500 Python Markdown WikiLinks extension. In `gfm-mode`, this is
501 set to `"-"` to conform with GitHub wiki links.
503 * `markdown-reference-location` - where to insert reference
504 definitions (default: `header`). The possible locations are
505 the end of the document (`end`), after the current block
506 (`immediately`), before the next header (`header`).
508 * `markdown-footnote-location` - where to insert footnote text
509 (default: `end`). The set of location options is the same as
510 for `markdown-reference-location`.
512 * `markdown-font-lock-support-mode` - the variable
513 `font-lock-support-mode` is made buffer-local and set to
514 `markdown-font-lock-support-mode`, which is `jit-mode` by
515 default. This is currently the default support mode in Emacs as
516 well. However, if fontification of multi-line constructs such
517 as preformatted code blocks, nested lists, and so on is
518 inaccurate, setting this to `nil` will allow more aggressive
519 fontification at the expense of some performance.
521 * `comment-auto-fill-only-comments` - variable is made
522 buffer-local and set to `nil` by default. In programming
523 language modes, when this variable is non-nil, only comments
524 will be filled by auto-fill-mode. However, comments in
525 Markdown documents are rare and the most users probably intend
526 for the actual content of the document to be filled. Making
527 this variable buffer-local allows `markdown-mode` to override
528 the default behavior induced when the global variable is non-nil.
530 * `markdown-make-gfm-checkboxes-buttons` - Whether GitHub Flavored
531 Markdown style checkboxes should be turned into buttons that can
532 be toggled with mouse-1 or RET. If non-nil buttons are enabled, the
533 default is t. This works in `markdown-mode` as well as `gfm-mode`.
535 Additionally, the faces used for syntax highlighting can be modified to
536 your liking by issuing <kbd>M-x customize-group RET markdown-faces</kbd>
537 or by using the "Markdown Faces" link at the bottom of the mode
538 customization screen.
540 [Marked 2]: https://itunes.apple.com/us/app/marked-2/id890031187?mt=12&uo=4&at=11l5Vs&ct=mm
544 Besides supporting the basic Markdown syntax, markdown-mode also
545 includes syntax highlighting for `[[Wiki Links]]` by default. Wiki
546 links may be followed by pressing <kbd>C-c C-o</kbd> when the point
547 is at a wiki link. Use <kbd>M-p</kbd> and <kbd>M-n</kbd> to quickly jump to the
548 previous and next links (including links of other types).
549 Aliased or piped wiki links of the form `[[link text|PageName]]`
550 are also supported. Since some wikis reverse these components, set
551 `markdown-wiki-link-alias-first` to nil to treat them as
552 `[[PageName|link text]]`. By default, Markdown Mode only searches
553 for target files in the current directory. Sequential parent
554 directory search (as in [Ikiwiki][]) can be enabled by setting
555 `markdown-wiki-link-search-parent-directories` to a non-nil value.
557 [Ikiwiki]: https://ikiwiki.info
559 [SmartyPants][] support is possible by customizing `markdown-command`.
560 If you install `SmartyPants.pl` at, say, `/usr/local/bin/smartypants`,
561 then you can set `markdown-command` to `"markdown | smartypants"`.
562 You can do this either by using <kbd>M-x customize-group markdown</kbd>
563 or by placing the following in your `.emacs` file:
565 (defun markdown-custom ()
567 (setq markdown-command "markdown | smartypants"))
568 (add-hook 'markdown-mode-hook '(lambda() (markdown-custom)))
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
581 A [GitHub Flavored Markdown][GFM] (GFM) mode, `gfm-mode`, is also
582 available. The GitHub implementation of differs slightly from
583 standard Markdown. The most important differences are that
584 newlines are significant, triggering hard line breaks, and that
585 underscores inside of words (e.g., variable names) need not be
586 escaped. As such, `gfm-mode` turns off `auto-fill-mode` and turns
587 on `visual-line-mode` (or `longlines-mode` if `visual-line-mode` is
588 not available). Underscores inside of words (such as
589 test_variable) will not trigger emphasis.
591 Wiki links in this mode will be treated as on GitHub, with hyphens
592 replacing spaces in filenames and where the first letter of the
593 filename capitalized. For example, `[[wiki link]]` will map to a
594 file named `Wiki-link` with the same extension as the current file.
596 GFM code blocks, with optional programming language keywords, will
597 be highlighted. They can be inserted with <kbd>C-c C-s P</kbd>. If there
598 is an active region, the text in the region will be placed inside
599 the code block. You will be prompted for the name of the language,
600 but may press enter to continue without naming a language.
602 Similarly, strike through text is supoorted in GFM mode and can be
603 inserted (and toggled) using <kbd>C-c C-s d</kbd>. Following the mnemonics
604 for the other style keybindings, the letter <kbd>d</kbd> coincides with the
607 For GFM preview can be powered by setting `markdown-command` to
608 use [Docter][]. This may also be configured to work with [Marked 2][]
609 for `markdown-open-command`.
611 [GFM]: http://github.github.com/github-flavored-markdown/
612 [Docter]: https://github.com/alampros/Docter
616 markdown-mode has benefited greatly from the efforts of the
619 * Cyril Brulebois for Debian packaging.
620 * Conal Elliott for a font-lock regexp patch.
621 * Edward O'Connor for a font-lock regexp fix and
622 GitHub Flavored Markdown mode (`gfm-mode`).
623 * Greg Bognar for menus and running
624 `markdown` with an active region.
625 * Daniel Burrows for filing Debian bug #456592.
626 * Peter S. Galbraith for maintaining `emacs-goodies-el`.
627 * Dmitry Dzhus for undefined reference checking.
628 * Carsten Dominik for `org-mode`, from which the
629 visibility cycling functionality was derived, and for a bug fix
630 related to `orgtbl-mode`.
631 * Bryan Kyle for indentation code.
632 * Ben Voui for font-lock face customizations.
633 * Ankit Solanki for `longlines.el`
634 compatibility and custom CSS.
635 * Hilko Bengen for proper XHTML output.
636 * Jose A. Ortega Ruiz for Emacs 23 fixes.
637 * Nelson Minar for `html-helper-mode`, from which
638 comment matching functions were derived.
639 * Alec Resnick for bug reports.
640 * Joost Kremers for footnote-handling
641 functions, bug reports regarding indentation, and
642 fixes for byte-compilation warnings.
643 * Peter Williams for `fill-paragraph`
645 * George Ogata for fixing several
646 byte-compilation warnings.
647 * Eric Merritt for wiki link features.
648 * Philippe Ivaldi for XHTML preview
649 customizations and XHTML export.
650 * Jeremiah Dodds for supporting
651 Markdown processors which do not accept input from stdin.
652 * Werner Dittmann for bug reports
653 regarding the `cl` dependency and `auto-fill-mode` and indentation.
654 * Scott Pfister for generalizing the space
655 substitution character for mapping wiki links to filenames.
656 * Marcin Kasperski for a patch to
657 escape shell commands.
658 * Christopher J. Madsen for patches to fix a match
659 data bug and to prefer `visual-line-mode` in `gfm-mode`.
660 * Shigeru Fukaya for better adherence to
661 Emacs Lisp coding conventions.
662 * Donald Ephraim Curtis for fixing the `fill-paragraph`
663 regexp, refactoring the compilation and preview functions,
664 heading font-lock generalizations, list renumbering,
666 * Kevin Porter for wiki link handling in `gfm-mode`.
667 * Max Penet and Peter Eisentraut <peter_e@gmx.net>
668 for an autoload token for `gfm-mode`.
669 * Ian Yang for improving the reference definition regex.
670 * Akinori Musha for an imenu index function.
671 * Michael Sperber for XEmacs fixes.
672 * Francois Gannaz for suggesting charset
673 declaration in XHTML output.
674 * Zhenlei Jia for smart exdention function.
675 * Matus Goljer for improved wiki link following
676 and GFM code block insertion.
677 * Peter Jones for link following functions.
678 * Bryan Fink for a bug report regarding
679 externally modified files.
680 * Vegard Vesterheim for a bug fix
681 related to `orgtbl-mode`.
682 * Makoto Motohashi for before- and after-
683 export hooks, unit test improvements, and updates to support
685 * Michael Dwyer for `gfm-mode` underscore regexp.
686 * Chris Lott for suggesting reference label
688 * Gunnar Franke for a completion bug report.
689 * David Glasser for a `paragraph-separate` fix.
690 * Daniel Brotsky for better auto-fill defaults.
691 * Samuel Freilich for improved filling
692 behavior regarding list items, footnotes, and reference
693 definitions, improved killing of footnotes, and numerous other
695 * Antonis Kanouras for strike through support.
696 * Tim Visher for multiple CSS files and other
697 general improvements.
698 * Matt McClure for a patch to prevent
699 overwriting source files with .html extensions upon export.
700 * Roger Bolsius for ordered list improvements.
701 * Google's Open Source Programs Office for recognizing the project with
702 a monetary contribution in June 2015.
703 * Howard Melman for supporting GFM checkboxes
708 Although markdown-mode is developed and tested primarily using
709 GNU Emacs 24, compatibility with earlier Emacsen is also a
712 If you find any bugs in markdown-mode, please construct a test case
713 or a patch and open a ticket on the [GitHub issue tracker][issues].
715 [issues]: https://github.com/jrblevin/markdown-mode/issues
719 markdown-mode was written and is maintained by Jason Blevins. The
720 first version was released on May 24, 2007.
722 * 2007-05-24: Version 1.1
723 * 2007-05-25: Version 1.2
724 * 2007-06-05: [Version 1.3][]
725 * 2007-06-29: Version 1.4
726 * 2007-10-11: [Version 1.5][]
727 * 2008-06-04: [Version 1.6][]
728 * 2009-10-01: [Version 1.7][]
729 * 2011-08-12: [Version 1.8][]
730 * 2011-08-15: [Version 1.8.1][]
731 * 2013-01-25: [Version 1.9][]
732 * 2013-03-24: [Version 2.0][]
734 [Version 1.3]: http://jblevins.org/projects/markdown-mode/rev-1-3
735 [Version 1.5]: http://jblevins.org/projects/markdown-mode/rev-1-5
736 [Version 1.6]: http://jblevins.org/projects/markdown-mode/rev-1-6
737 [Version 1.7]: http://jblevins.org/projects/markdown-mode/rev-1-7
738 [Version 1.8]: http://jblevins.org/projects/markdown-mode/rev-1-8
739 [Version 1.8.1]: http://jblevins.org/projects/markdown-mode/rev-1-8-1
740 [Version 1.9]: http://jblevins.org/projects/markdown-mode/rev-1-9
741 [Version 2.0]: http://jblevins.org/projects/markdown-mode/rev-2-0