README.md (54992B)
1 # Emacs Markdown Mode 2 [![NonGNU ELPA badge][nongnu-elpa-badge]][nongnu-elpa-link] [![MELPA badge][melpa-badge]][melpa-link] [![MELPA stable badge][melpa-stable-badge]][melpa-stable-link] [![Github Actions Status][github-actions-badge]][github-actions-link] [![Guide to Markdown Mode for Emacs][leanpub-badge]][leanpub-link] 3 4 [nongnu-elpa-link]: https://elpa.nongnu.org/nongnu/markdown-mode.html 5 [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/markdown-mode.svg 6 [melpa-link]: https://melpa.org/#/markdown-mode 7 [melpa-stable-link]: https://stable.melpa.org/#/markdown-mode 8 [melpa-badge]: https://melpa.org/packages/markdown-mode-badge.svg 9 [melpa-stable-badge]: https://stable.melpa.org/packages/markdown-mode-badge.svg 10 [github-actions-link]: https://github.com/jrblevin/markdown-mode/actions 11 [github-actions-badge]: https://github.com/jrblevin/markdown-mode/workflows/CI/badge.svg 12 [leanpub-link]: https://leanpub.com/markdown-mode 13 [leanpub-badge]: https://img.shields.io/badge/leanpub-guide-orange.svg 14 15 markdown-mode is a major mode for editing [Markdown][]-formatted 16 text. The latest stable version is markdown-mode 2.5, released on 17 Feb 12, 2022. See the [release notes][] for details. 18 markdown-mode is free software, licensed under the GNU GPL, 19 version 3 or later. 20 21  22 23 [Markdown]: http://daringfireball.net/projects/markdown/ 24 [release notes]: https://github.com/jrblevin/markdown-mode/releases/tag/v2.5 25 26 ## Documentation 27 28 <a href="https://leanpub.com/markdown-mode"> 29 <img src="https://jblevins.org/projects/markdown-mode/guide-v2.3.png" align="right" height="350" width="231"> 30 </a> 31 32 The primary documentation for Markdown Mode is available below, and 33 is generated from comments in the source code. For a more in-depth 34 treatment, the [_Guide to Markdown Mode for Emacs_][guide] covers 35 Markdown syntax, advanced movement and editing in Emacs, 36 extensions, configuration examples, tips and tricks, and a survey 37 of other packages that work with Markdown Mode. Finally, Emacs is 38 also a self-documenting editor. This means that the source code 39 itself contains additional documentation: each function has its own 40 docstring available via <kbd>C-h f</kbd> (`describe-function`), individual 41 keybindings can be investigated with <kbd>C-h k</kbd> (`describe-key`), and 42 a complete list of keybindings is available using <kbd>C-h m</kbd> 43 (`describe-mode`). 44 45 [guide]: https://leanpub.com/markdown-mode 46 47 ## Installation 48 49 _Note:_ To use all of the features of `markdown-mode`, you'll need 50 to install the Emacs package itself and also have a local Markdown 51 processor installed (e.g., Markdown.pl, MultiMarkdown, or Pandoc). 52 The external processor is not required for editing, but will be 53 used for rendering HTML for preview and export. After installing 54 the Emacs package, be sure to configure `markdown-command` to point 55 to the preferred Markdown executable on your system. See the 56 Customization section below for more details. 57 58 The recommended way to install `markdown-mode` is to install the package 59 from [MELPA Stable](https://stable.melpa.org/#/markdown-mode) 60 using `package.el`. First, configure `package.el` and the MELPA Stable 61 repository by adding the following to your `.emacs`, `init.el`, 62 or equivalent startup file: 63 64 ```lisp 65 (require 'package) 66 (add-to-list 'package-archives 67 '("melpa-stable" . "https://stable.melpa.org/packages/")) 68 (package-initialize) 69 ``` 70 71 Then, after restarting Emacs or evaluating the above statements, issue 72 the following command: <kbd>M-x package-install RET markdown-mode RET</kbd>. 73 When installed this way, the major modes `markdown-mode` and `gfm-mode` 74 will be autoloaded and `markdown-mode` will be used for file names 75 ending in `.md`, `.markdown`, `.mkd`, `.mdown`, `.mkdn`, `.mdwn`. 76 77 Alternatively, if you manage loading packages with [use-package][] 78 then you can automatically install and configure `markdown-mode` by 79 adding a declaration such as this one to your init file (as an 80 example; adjust settings as desired): 81 82 ```lisp 83 (use-package markdown-mode 84 :ensure t 85 :mode ("README\\.md\\'" . gfm-mode) 86 :init (setq markdown-command "multimarkdown")) 87 ``` 88 89 [MELPA Stable]: http://stable.melpa.org/ 90 [use-package]: https://github.com/jwiegley/use-package 91 92 **Direct Download** 93 94 Alternatively you can manually download and install markdown-mode. 95 First, download the [latest stable version][markdown-mode.el] and 96 save the file where Emacs can find it (i.e., a directory in your 97 `load-path`). You can then configure `markdown-mode` and `gfm-mode` 98 to load automatically by adding the following to your init file: 99 100 ```lisp 101 (autoload 'markdown-mode "markdown-mode" 102 "Major mode for editing Markdown files" t) 103 (add-to-list 'auto-mode-alist 104 '("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode)) 105 106 (autoload 'gfm-mode "markdown-mode" 107 "Major mode for editing GitHub Flavored Markdown files" t) 108 (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) 109 ``` 110 111 [markdown-mode.el]: https://raw.githubusercontent.com/jrblevin/markdown-mode/v2.5/markdown-mode.el 112 113 **Development Version** 114 115 To follow or contribute to markdown-mode development, you can 116 browse or clone the Git repository 117 [on GitHub](https://github.com/jrblevin/markdown-mode): 118 119 ``` 120 git clone https://github.com/jrblevin/markdown-mode.git 121 ``` 122 123 If you prefer to install and use the development version, which may 124 become unstable at some times, you can either clone the Git 125 repository as above or install markdown-mode from 126 [MELPA](https://melpa.org/#/markdown-mode). 127 128 If you clone the repository directly, then make sure that Emacs can 129 find it by adding the following line to your startup file: 130 131 ```lisp 132 (add-to-list 'load-path "/path/to/markdown-mode/repository") 133 ``` 134 135 **Packaged Installation** 136 137 markdown-mode is also available in several package managers. You 138 may want to confirm that the package you install contains the 139 latest stable version first (and please notify the package 140 maintainer if not). 141 142 * Debian Linux: [elpa-markdown-mode][] and [emacs-goodies-el][] 143 * Ubuntu Linux: [elpa-markdown-mode][elpa-ubuntu] and [emacs-goodies-el][emacs-goodies-el-ubuntu] 144 * RedHat and Fedora Linux: [emacs-goodies][] 145 * NetBSD: [textproc/markdown-mode][] 146 * MacPorts: [markdown-mode.el][macports-package] ([pending][macports-ticket]) 147 * FreeBSD: [textproc/markdown-mode.el][freebsd-port] 148 149 [elpa-markdown-mode]: https://packages.debian.org/sid/lisp/elpa-markdown-mode 150 [elpa-ubuntu]: http://packages.ubuntu.com/search?keywords=elpa-markdown-mode 151 [emacs-goodies-el]: http://packages.debian.org/emacs-goodies-el 152 [emacs-goodies-el-ubuntu]: http://packages.ubuntu.com/search?keywords=emacs-goodies-el 153 [emacs-goodies]: https://apps.fedoraproject.org/packages/emacs-goodies 154 [textproc/markdown-mode]: http://pkgsrc.se/textproc/markdown-mode 155 [macports-package]: https://trac.macports.org/browser/trunk/dports/editors/markdown-mode.el/Portfile 156 [macports-ticket]: http://trac.macports.org/ticket/35716 157 [freebsd-port]: http://svnweb.freebsd.org/ports/head/textproc/markdown-mode.el 158 159 **Dependencies** 160 161 To enable editing of code blocks in indirect buffers using <kbd>C-c '</kbd>, 162 you will need to install the [`edit-indirect`][ei] package. 163 164 [ei]: https://github.com/Fanael/edit-indirect/ 165 166 ## Usage 167 168 Keybindings are grouped by prefixes based on their function. For 169 example, the commands for styling text are grouped under <kbd>C-c C-s</kbd> 170 and toggle commands begin with <kbd>C-c C-x</kbd>. The primary commands in 171 each group will are described below. You can obtain a list of all 172 keybindings by pressing <kbd>C-c C-h</kbd>. Movement and shifting commands 173 tend to be associated with paired delimiters such as <kbd>M-{</kbd> and 174 <kbd>M-}</kbd> or <kbd>C-c <</kbd> and <kbd>C-c ></kbd>. Outline navigation keybindings the 175 same as in `org-mode`. Finally, commands for running Markdown or 176 doing maintenance on an open file are grouped under the <kbd>C-c C-c</kbd> 177 prefix. The most commonly used commands are described below. You 178 can obtain a list of all keybindings by pressing <kbd>C-c C-h</kbd>. 179 180 * Links and Images: <kbd>C-c C-l</kbd> and <kbd>C-c C-i</kbd> 181 182 <kbd>C-c C-l</kbd> (`markdown-insert-link`) is a general command for 183 inserting new link markup or editing existing link markup. This 184 is especially useful when markup or URL hiding is enabled, so 185 that URLs can't easily be edited directly. This command can be 186 used to insert links of any form: either inline links, 187 reference links, or plain URLs in angle brackets. The URL or 188 `[reference]` label, link text, and optional title are entered 189 through a series of interactive prompts. The type of link is 190 determined by which values are provided: 191 192 * If both a URL and link text are given, insert an inline link: 193 `[text](url)`. 194 * If both a `[reference]` label and link text are given, insert 195 a reference link: `[text][reference]`. 196 * If only link text is given, insert an implicit reference link: 197 `[text][]`. 198 * If only a URL is given, insert a plain URL link: 199 `<url>`. 200 201 Similarly, <kbd>C-c C-i</kbd> (`markdown-insert-image`) is a general 202 command for inserting or editing image markup. As with the link 203 insertion command, through a series interactive prompts you can 204 insert either an inline or reference image: 205 206 * If both a URL and alt text are given, insert an inline 207 image: ``. 208 * If both a `[reference]` label and alt text are given, 209 insert a reference link: `![alt text][reference]`. 210 211 If there is an existing link or image at the point, these 212 command will edit the existing markup rather than inserting new 213 markup. Otherwise, if there is an active region, these commands 214 use the region as either the default URL (if it seems to be a 215 URL) or link text value otherwise. In that case, the region 216 will be deleted and replaced by the link. 217 218 Note that these functions can be used to convert links and 219 images from one type to another (inline, reference, or plain 220 URL) by selectively adding or removing properties via the 221 interactive prompts. 222 223 If a reference label is given that is not yet defined, you 224 will be prompted for the URL and optional title and the 225 reference will be inserted according to the value of 226 `markdown-reference-location`. If a title is given, it will be 227 added to the end of the reference definition and will be used 228 to populate the title attribute when converted to HTML. In addition, it is 229 possible to have the `markdown-link-make-text-function` function, if 230 non-nil, define the default link text before prompting the user for it. 231 232 If `markdown-disable-tooltip-prompt` is non-nil, the user will not be 233 prompted to add or modify a tooltip text. 234 235 Images associated with image links may be displayed 236 inline in the buffer by pressing <kbd>C-c C-x C-i</kbd> 237 (`markdown-toggle-inline-images`). This is a toggle command, so 238 pressing this once again will remove inline images. 239 By default, only local images are displayed. However, remote 240 images will also be downloaded and displayed if 241 `markdown-display-remote-images` is non-nil. 242 243 Large images may be scaled down to fit in the buffer using 244 `markdown-max-image-size`, a cons cell of the form `(max-width 245 . max-height)`. Resizing requires Emacs to be built with 246 ImageMagick support. 247 248 * Text Styles: <kbd>C-c C-s</kbd> 249 250 <kbd>C-c C-s i</kbd> inserts markup to make a region or word italic. If 251 there is an active region, make the region italic. If the point 252 is at a non-italic word, make the word italic. If the point is 253 at an italic word or phrase, remove the italic markup. 254 Otherwise, simply insert italic delimiters and place the point 255 in between them. Similarly, use <kbd>C-c C-s b</kbd> for bold, <kbd>C-c C-s c</kbd> 256 for inline code, and <kbd>C-c C-s k</kbd> for inserting `<kbd>` tags. 257 258 <kbd>C-c C-s q</kbd> inserts a blockquote using the active region, if 259 any, or starts a new blockquote. <kbd>C-c C-s Q</kbd> is a variation 260 which always operates on the region, regardless of whether it 261 is active or not (i.e., when `transient-mark-mode` is off but 262 the mark is set). The appropriate amount of indentation, if 263 any, is calculated automatically given the surrounding context, 264 but may be adjusted later using the region indentation 265 commands. 266 267 <kbd>C-c C-s p</kbd> behaves similarly for inserting preformatted code 268 blocks (with <kbd>C-c C-s P</kbd> being the region-only counterpart) 269 and <kbd>C-c C-s C</kbd> inserts a GFM style backquote fenced code block. 270 271 * Headings: <kbd>C-c C-s</kbd> 272 273 To insert or replace headings, there are two options. You can 274 insert a specific level heading directly or you can have 275 `markdown-mode` determine the level for you based on the previous 276 heading. As with the other markup commands, the heading 277 insertion commands use the text in the active region, if any, 278 as the heading text. Otherwise, if the current line is not 279 blank, they use the text on the current line. Finally, the 280 setext commands will prompt for heading text if there is no 281 active region and the current line is blank. 282 283 <kbd>C-c C-s h</kbd> inserts a heading with automatically chosen type and 284 level (both determined by the previous heading). <kbd>C-c C-s H</kbd> 285 behaves similarly, but uses setext (underlined) headings when 286 possible, still calculating the level automatically. 287 In cases where the automatically-determined level is not what 288 you intended, the level can be quickly promoted or demoted 289 (as described below). Alternatively, a <kbd>C-u</kbd> prefix can be 290 given to insert a heading _promoted_ (lower number) by one 291 level or a <kbd>C-u C-u</kbd> prefix can be given to insert a heading 292 demoted (higher number) by one level. 293 294 To insert a heading of a specific level and type, use <kbd>C-c C-s 1</kbd> 295 through <kbd>C-c C-s 6</kbd> for atx (hash mark) headings and <kbd>C-c C-s !</kbd> or 296 <kbd>C-c C-s @</kbd> for setext headings of level one or two, respectively. 297 Note that <kbd>!</kbd> is <kbd>S-1</kbd> and <kbd>@</kbd> is <kbd>S-2</kbd>. 298 299 If the point is at a heading, these commands will replace the 300 existing markup in order to update the level and/or type of the 301 heading. To remove the markup of the heading at the point, 302 press <kbd>C-c C-k</kbd> to kill the heading and press <kbd>C-y</kbd> to yank the 303 heading text back into the buffer. 304 305 * Horizontal Rules: <kbd>C-c C-s -</kbd> 306 307 <kbd>C-c C-s -</kbd> inserts a horizontal rule. By default, insert the 308 first string in the list `markdown-hr-strings` (the most 309 prominent rule). With a <kbd>C-u</kbd> prefix, insert the last string. 310 With a numeric prefix <kbd>N</kbd>, insert the string in position <kbd>N</kbd> 311 (counting from 1). 312 313 * Footnotes: <kbd>C-c C-s f</kbd> 314 315 <kbd>C-c C-s f</kbd> inserts a footnote marker at the point, inserts a 316 footnote definition below, and positions the point for 317 inserting the footnote text. Note that footnotes are an 318 extension to Markdown and are not supported by all processors. 319 320 * Wiki Links: <kbd>C-c C-s w</kbd> 321 322 <kbd>C-c C-s w</kbd> inserts a wiki link of the form `[[WikiLink]]`. If 323 there is an active region, use the region as the link text. If the 324 point is at a word, use the word as the link text. If there is 325 no active region and the point is not at word, simply insert 326 link markup. Note that wiki links are an extension to Markdown 327 and are not supported by all processors. 328 329 * Markdown and Maintenance Commands: <kbd>C-c C-c</kbd> 330 331 *Compile:* <kbd>C-c C-c m</kbd> will run Markdown on the current buffer 332 and show the output in another buffer. *Preview*: <kbd>C-c C-c p</kbd> 333 runs Markdown on the current buffer and previews, stores the 334 output in a temporary file, and displays the file in a browser. 335 *Export:* <kbd>C-c C-c e</kbd> will run Markdown on the current buffer 336 and save the result in the file `basename.html`, where 337 `basename` is the name of the Markdown file with the extension 338 removed. *Export and View:* press <kbd>C-c C-c v</kbd> to export the 339 file and view it in a browser. *Open:* <kbd>C-c C-c o</kbd> will open 340 the Markdown source file directly using `markdown-open-command`. 341 *Live Export*: Press <kbd>C-c C-c l</kbd> to turn on 342 `markdown-live-preview-mode` to view the exported output 343 side-by-side with the source Markdown. **For all export commands, 344 the output file will be overwritten without notice.** 345 `markdown-live-preview-window-function` can be customized to open 346 in a browser other than `eww`. If you want to force the 347 preview window to appear at the bottom or right, you can 348 customize `markdown-split-window-direction`. 349 350 To summarize: 351 352 - <kbd>C-c C-c m</kbd>: `markdown-command` > `*markdown-output*` buffer. 353 - <kbd>C-c C-c p</kbd>: `markdown-command` > temporary file > browser. 354 - <kbd>C-c C-c e</kbd>: `markdown-command` > `basename.html`. 355 - <kbd>C-c C-c v</kbd>: `markdown-command` > `basename.html` > browser. 356 - <kbd>C-c C-c w</kbd>: `markdown-command` > kill ring. 357 - <kbd>C-c C-c o</kbd>: `markdown-open-command`. 358 - <kbd>C-c C-c l</kbd>: `markdown-live-preview-mode` > `*eww*` buffer. 359 360 <kbd>C-c C-c c</kbd> will check for undefined references. If there are 361 any, a small buffer will open with a list of undefined 362 references and the line numbers on which they appear. In Emacs 363 22 and greater, selecting a reference from this list and 364 pressing <kbd>RET</kbd> will insert an empty reference definition at the 365 end of the buffer. Similarly, selecting the line number will 366 jump to the corresponding line. 367 368 <kbd>C-c C-c u</kbd> will check for unused references. This will 369 also open a small buffer if any are found, similar to undefined 370 reference checking. The buffer for unused references will contain 371 `X` buttons that remove unused references when selected. 372 373 <kbd>C-c C-c n</kbd> renumbers any ordered lists in the buffer that are 374 out of sequence. 375 376 <kbd>C-c C-c ]</kbd> completes all headings and normalizes all horizontal 377 rules in the buffer. 378 379 * Following Links: <kbd>C-c C-o</kbd> 380 381 Press <kbd>C-c C-o</kbd> when the point is on an inline or reference 382 link to open the URL in a browser. When the point is at a 383 wiki link, open it in another buffer (in the current window, 384 or in the other window with the <kbd>C-u</kbd> prefix). Use <kbd>M-p</kbd> and 385 <kbd>M-n</kbd> to quickly jump to the previous or next link of any type. 386 387 * Doing Things: <kbd>C-c C-d</kbd> 388 389 Use <kbd>C-c C-d</kbd> to do something sensible with the object at the point: 390 391 - Jumps between reference links and reference definitions. 392 If more than one link uses the same reference label, a 393 window will be shown containing clickable buttons for 394 jumping to each link. Pressing <kbd>TAB</kbd> or <kbd>S-TAB</kbd> cycles 395 between buttons in this window. 396 - Jumps between footnote markers and footnote text. 397 - Toggles the completion status of GFM task list items 398 (checkboxes). 399 - Re-aligns table columns. 400 401 * Promotion and Demotion: <kbd>C-c C--</kbd> and <kbd>C-c C-=</kbd> 402 403 Headings, horizontal rules, and list items can be promoted and 404 demoted, as well as bold and italic text. For headings, 405 "promotion" means *decreasing* the level (i.e., moving from 406 `<h2>` to `<h1>`) while "demotion" means *increasing* the 407 level. For horizontal rules, promotion and demotion means 408 moving backward or forward through the list of rule strings in 409 `markdown-hr-strings`. For bold and italic text, promotion and 410 demotion means changing the markup from underscores to asterisks. 411 Press <kbd>C-c C--</kbd> or <kbd>C-c LEFT</kbd> to promote the element at the point 412 if possible. 413 414 To remember these commands, note that <kbd>-</kbd> is for decreasing the 415 level (promoting), and <kbd>=</kbd> (on the same key as <kbd>+</kbd>) is for 416 increasing the level (demoting). Similarly, the left and right 417 arrow keys indicate the direction that the atx heading markup 418 is moving in when promoting or demoting. 419 420 * Completion: <kbd>C-c C-]</kbd> 421 422 Complete markup is in normalized form, which means, for 423 example, that the underline portion of a setext header is the 424 same length as the heading text, or that the number of leading 425 and trailing hash marks of an atx header are equal and that 426 there is no extra whitespace in the header text. <kbd>C-c C-]</kbd> 427 completes the markup at the point, if it is determined to be 428 incomplete. 429 430 * Editing Lists: <kbd>M-RET</kbd>, <kbd>C-c UP</kbd>, <kbd>C-c DOWN</kbd>, <kbd>C-c LEFT</kbd>, and <kbd>C-c RIGHT</kbd> 431 432 New list items can be inserted with <kbd>M-RET</kbd> or <kbd>C-c C-j</kbd>. This 433 command determines the appropriate marker (one of the possible 434 unordered list markers or the next number in sequence for an 435 ordered list) and indentation level by examining nearby list 436 items. If there is no list before or after the point, start a 437 new list. As with heading insertion, you may prefix this 438 command by <kbd>C-u</kbd> to decrease the indentation by one level. 439 Prefix this command by <kbd>C-u C-u</kbd> to increase the indentation by 440 one level. 441 442 Existing list items (and their nested sub-items) can be moved 443 up or down with <kbd>C-c UP</kbd> or <kbd>C-c DOWN</kbd> and indented or 444 outdented with <kbd>C-c RIGHT</kbd> or <kbd>C-c LEFT</kbd>. 445 446 * Editing Subtrees: <kbd>C-c UP</kbd>, <kbd>C-c DOWN</kbd>, <kbd>C-c LEFT</kbd>, and <kbd>C-c RIGHT</kbd> 447 448 Entire subtrees of ATX headings can be promoted and demoted 449 with <kbd>C-c LEFT</kbd> and <kbd>C-c RIGHT</kbd>, which are the same keybindings 450 used for promotion and demotion of list items. If the point is in 451 a list item, the operate on the list item. Otherwise, they operate 452 on the current heading subtree. Similarly, subtrees can be 453 moved up and down with <kbd>C-c UP</kbd> and <kbd>C-c DOWN</kbd>. 454 455 These commands currently do not work properly if there are 456 Setext headings in the affected region. 457 458 Please note the following "boundary" behavior for promotion and 459 demotion. Any level-six headings will not be demoted further 460 (i.e., they remain at level six, since Markdown and HTML define 461 only six levels) and any level-one headings will promoted away 462 entirely (i.e., heading markup will be removed, since a 463 level-zero heading is not defined). 464 465 * Shifting the Region: <kbd>C-c <</kbd> and <kbd>C-c ></kbd> 466 467 Text in the region can be indented or outdented as a group using 468 <kbd>C-c ></kbd> to indent to the next indentation point (calculated in 469 the current context), and <kbd>C-c <</kbd> to outdent to the previous 470 indentation point. These keybindings are the same as those for 471 similar commands in `python-mode`. 472 473 * Killing Elements: <kbd>C-c C-k</kbd> 474 475 Press <kbd>C-c C-k</kbd> to kill the thing at point and add important 476 text, without markup, to the kill ring. Possible things to 477 kill include (roughly in order of precedece): inline code, 478 headings, horizontal rules, links (add link text to kill ring), 479 images (add alt text to kill ring), angle URIs, email 480 addresses, bold, italics, reference definitions (add URI to 481 kill ring), footnote markers and text (kill both marker and 482 text, add text to kill ring), and list items. 483 484 * 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> 485 486 These keys are used for hierarchical navigation in lists and 487 headings. When the point is in a list, they move between list 488 items. Otherwise, they move between headings. Use <kbd>C-c C-n</kbd> and 489 <kbd>C-c C-p</kbd> to move between the next and previous visible 490 headings or list items of any level. Similarly, <kbd>C-c C-f</kbd> and 491 <kbd>C-c C-b</kbd> move to the next and previous visible headings or 492 list items at the same level as the one at the point. Finally, 493 <kbd>C-c C-u</kbd> will move up to the parent heading or list item. 494 495 * Movement by Markdown paragraph: <kbd>M-{</kbd>, <kbd>M-}</kbd>, and <kbd>M-h</kbd> 496 497 Paragraphs in `markdown-mode` are regular paragraphs, 498 paragraphs inside blockquotes, individual list items, headings, 499 etc. These keys are usually bound to `forward-paragraph` and 500 `backward-paragraph`, but the built-in Emacs functions are 501 based on simple regular expressions that fail in Markdown 502 files. Instead, they are bound to `markdown-forward-paragraph` 503 and `markdown-backward-paragraph`. To mark a paragraph, 504 you can use <kbd>M-h</kbd> (`markdown-mark-paragraph`). 505 506 * Movement by Markdown block: <kbd>C-M-{</kbd>, <kbd>C-M-}</kbd>, and <kbd>C-c M-h</kbd> 507 508 Markdown blocks are regular paragraphs in many cases, but 509 contain many paragraphs in other cases: blocks are considered 510 to be entire lists, entire code blocks, and entire blockquotes. 511 To move backward one block use <kbd>C-M-{</kbd> 512 (`markdown-beginning-block`) and to move forward use <kbd>C-M-}</kbd> 513 (`markdown-end-of-block`). To mark a block, use <kbd>C-c M-h</kbd> 514 (`markdown-mark-block`). 515 516 * Movement by Defuns: <kbd>C-M-a</kbd>, <kbd>C-M-e</kbd>, and <kbd>C-M-h</kbd> 517 518 The usual Emacs commands can be used to move by defuns 519 (top-level major definitions). In markdown-mode, a defun is a 520 section. As usual, <kbd>C-M-a</kbd> will move the point to the 521 beginning of the current or preceding defun, <kbd>C-M-e</kbd> will move 522 to the end of the current or following defun, and <kbd>C-M-h</kbd> will 523 put the region around the entire defun. 524 525 * Table Editing: 526 527 Markdown Mode includes support for editing tables, which 528 have the following basic format: 529 530 | Right | Left | Center | Default | 531 |------:|:-----|:------:|---------| 532 | 12 | 12 | 12 | 12 | 533 | 123 | 123 | 123 | 123 | 534 | 1 | 1 | 1 | 1 | 535 536 The first line contains column headers. The second line 537 contains a separator line between the headers and the content. 538 Each following line is a row in the table. Columns are always 539 separated by the pipe character. The colons indicate column 540 alignment. 541 542 A table is re-aligned automatically each time you press <kbd>TAB</kbd> 543 or <kbd>RET</kbd> inside the table. <kbd>TAB</kbd> also moves to the next 544 field (<kbd>RET</kbd> to the next row) and creates new table rows at 545 the end of the table or before horizontal separator lines. The 546 indentation of the table is set by the first line. Column 547 centering inside Emacs is not supported. 548 549 Beginning pipe characters are required for proper detection of 550 table borders inside Emacs. Any line starting with `|-` or `|:` 551 is considered as a horizontal separator line and will be 552 expanded on the next re-align to span the whole table width. No 553 padding is allowed between the beginning pipe character and 554 header separator symbol. So, to create the above table, you 555 would only type 556 557 |Right|Left|Center|Default| 558 |- 559 560 and then press <kbd>TAB</kbd> to align the table and start filling in 561 cells. 562 563 Then you can jump with <kbd>TAB</kbd> from one cell to the next or with 564 <kbd>S-TAB</kbd> to the previous one. <kbd>RET</kbd> will jump to the to the 565 next cell in the same column, and create a new row if there is 566 no such cell or if the next row is beyond a separator line. 567 568 You can also convert selected region to a table. Basic editing 569 capabilities include inserting, deleting, and moving of columns 570 and rows, and table re-alignment, sorting, transposition: 571 572 - <kbd>C-c UP</kbd> or <kbd>C-c DOWN</kbd> - Move the current row up or down. 573 - <kbd>C-c LEFT</kbd> or <kbd>C-c RIGHT</kbd> - Move the current column left or right. 574 - <kbd>C-c S-UP</kbd> - Kill the current row. 575 - <kbd>C-c S-DOWN</kbd> - Insert a row above the current row. With a 576 prefix argument, row line is created below the current one. 577 - <kbd>C-c S-LEFT</kbd> - Kill the current column. 578 - <kbd>C-c S-RIGHT</kbd> - Insert a new column to the left of the current one. 579 - <kbd>C-c C-d</kbd> - Re-align the current table (`markdown-do`). 580 - <kbd>C-c C-c ^</kbd> - Sort the rows of a table by a specified column. 581 This command prompts you for the column number and a sort 582 method (alphabetical or numerical, optionally in reverse). 583 - <kbd>C-c C-c |</kbd> - Convert the region to a table. This function 584 attempts to recognize comma, tab, and space separated data 585 and then splits the data into cells accordingly. 586 - <kbd>C-c C-c t</kbd> - Transpose table at point. 587 588 The table editing functions try to handle markup hiding 589 correctly when calculating column widths, however, columns 590 containing hidden markup may not always be aligned properly. 591 592 <kbd>C-c C-s t</kbd> (`markdown-insert-table`) is a general command for inserting new table. 593 The command prompts for table size and column alignment and inserts an empty pipe table at point. 594 595 * Viewing Modes: 596 597 Read-only viewing modes, `markdown-view-mode` and `gfm-view-mode` 598 are provided for viewing Markdown content. These modes provide 599 simplified keybindings for navigating the buffer. Many of these 600 are like `help-mode` and `view-mode`, such as <kbd>SPC</kbd>, 601 <kbd>DEL</kbd>, <kbd><</kbd>, and <kbd>></kbd> for scrolling, 602 <kbd>q</kbd> for quitting, and <kbd>?</kbd> or <kbd>h</kbd> for 603 help. Other keys are provided that mirror the outline navigation 604 commands when editing: <kbd>n</kbd>, <kbd>p</kbd>, <kbd>f</kbd>, 605 <kbd>b</kbd>, and <kbd>u</kbd>. Both of these modes enable markup 606 hiding by default, but this can be customized by setting 607 `markdown-hide-markup-in-view-modes`. 608 609 * Miscellaneous Commands: 610 611 When the [`edit-indirect`][ei] package is installed, <kbd>C-c '</kbd> 612 (`markdown-edit-code-block`) can be used to edit a code block 613 in an indirect buffer in the native major mode. Press <kbd>C-c C-c</kbd> 614 to commit changes and return or <kbd>C-c C-k</kbd> to cancel. You can 615 also give a prefix argument to the insertion command, as in 616 <kbd>C-u C-c C-s C</kbd>, to edit the code block in an indirect buffer 617 upon insertion. 618 619 As noted, many of the commands above behave differently depending 620 on whether Transient Mark mode is enabled or not. When it makes 621 sense, if Transient Mark mode is on and the region is active, the 622 command applies to the text in the region (e.g., <kbd>C-c C-s b</kbd> makes the 623 region bold). For users who prefer to work outside of Transient 624 Mark mode, since Emacs 22 it can be enabled temporarily by pressing 625 <kbd>C-SPC C-SPC</kbd>. When this is not the case, many commands then 626 proceed to look work with the word or line at the point. 627 628 When applicable, commands that specifically act on the region even 629 outside of Transient Mark mode have the same keybinding as their 630 standard counterpart, but the letter is uppercase. For example, 631 `markdown-insert-blockquote` is bound to <kbd>C-c C-s q</kbd> and only acts on 632 the region in Transient Mark mode while `markdown-blockquote-region` 633 is bound to <kbd>C-c C-s Q</kbd> and always applies to the region (when nonempty). 634 635 Note that these region-specific functions are useful in many 636 cases where it may not be obvious. For example, yanking text from 637 the kill ring sets the mark at the beginning of the yanked text 638 and moves the point to the end. Therefore, the (inactive) region 639 contains the yanked text. So, <kbd>C-y</kbd> followed by <kbd>C-c C-s Q</kbd> will 640 yank text and turn it into a blockquote. 641 642 markdown-mode attempts to be flexible in how it handles 643 indentation. When you press <kbd>TAB</kbd> repeatedly, the point will cycle 644 through several possible indentation levels corresponding to things 645 you might have in mind when you press <kbd>RET</kbd> at the end of a line or 646 <kbd>TAB</kbd>. For example, you may want to start a new list item, 647 continue a list item with hanging indentation, indent for a nested 648 pre block, and so on. Outdenting is handled similarly when backspace 649 is pressed at the beginning of the non-whitespace portion of a line. 650 651 markdown-mode supports outline-minor-mode as well as org-mode-style 652 visibility cycling for atx- or hash-style headings. There are two 653 types of visibility cycling: Pressing <kbd>S-TAB</kbd> cycles globally between 654 the table of contents view (headings only), outline view (top-level 655 headings only), and the full document view. Pressing <kbd>TAB</kbd> while the 656 point is at a heading will cycle through levels of visibility for the 657 subtree: completely folded, visible children, and fully visible. 658 Note that mixing hash and underline style headings will give undesired 659 results. 660 661 ## Customization 662 663 Although no configuration is *necessary* there are a few things 664 that can be customized. The <kbd>M-x customize-mode</kbd> command 665 provides an interface to all of the possible customizations: 666 667 * `markdown-command` - the command used to run Markdown (default: 668 `markdown`). This variable may be customized to pass 669 command-line options to your Markdown processor of choice. We recommend 670 you to use list of strings if you want to set command line options like. 671 `'("pandoc" "--from=markdown" "--to=html5")`. It can also be a 672 function; in this case `markdown` will call it with three 673 arguments: the beginning and end of the region to process, and 674 a buffer to write the output to. 675 676 * `markdown-command-needs-filename` - set to `t` if 677 `markdown-command` does not accept standard input (default: 678 `nil`). When `nil`, `markdown-mode` will pass the Markdown 679 content to `markdown-command` using standard input (`stdin`). 680 When set to `t`, `markdown-mode` will pass the name of the file 681 as the final command-line argument to `markdown-command`. Note 682 that in the latter case, you will only be able to run 683 `markdown-command` from buffers which are visiting a file. If 684 `markdown-command` is a function, `markdown-command-needs-filename` 685 is ignored. 686 687 * `markdown-open-command` - the command used for calling a standalone 688 Markdown previewer which is capable of opening Markdown source files 689 directly (default: `nil`). This command will be called 690 with a single argument, the filename of the current buffer. 691 A representative program is the Mac app [Marked 2][], a 692 live-updating Markdown previewer which can be [called from a 693 simple shell script](https://jblevins.org/log/marked-2-command). 694 This variable can also be a function; in this case `markdown-open` 695 will call it without arguments to preview the current buffer. 696 697 * `markdown-open-image-command` - the command used for opening image 698 link (default: `nil`) via `markdown-follow-*` commands. This variable 699 can also be a function, in this case it is called with a single argument, 700 image-link. If this value is `nil`, `markdown-mode` opens image links 701 by `find-file`. 702 703 * `markdown-hr-strings` - list of strings to use when inserting 704 horizontal rules. Different strings will not be distinguished 705 when converted to HTML--they will all be converted to 706 `<hr/>`--but they may add visual distinction and style to plain 707 text documents. To maintain some notion of promotion and 708 demotion, keep these sorted from largest to smallest. 709 710 * `markdown-bold-underscore` - set to a non-nil value to use two 711 underscores when inserting bold text instead of two asterisks 712 (default: `nil`). 713 714 * `markdown-italic-underscore` - set to a non-nil value to use 715 underscores when inserting italic text instead of asterisks 716 (default: `nil`). 717 718 * `markdown-asymmetric-header` - set to a non-nil value to use 719 asymmetric header styling, placing header characters only on 720 the left of headers (default: `nil`). 721 722 * `markdown-header-scaling` - set to a non-nil value to use 723 a variable-pitch font for headings where the size corresponds 724 to the level of the heading (default: `nil`). 725 726 * `markdown-header-scaling-values` - list of scaling values, 727 relative to baseline, for headers of levels one through six, 728 used when `markdown-header-scaling` is non-nil 729 (default: `(2.0 1.7 1.4 1.1 1.0 1.0)`). 730 731 * `markdown-marginalize-headers` - put opening atx header markup 732 in the left margin when non-nil (default: `nil`). 733 734 * `markdown-marginalize-headers-margin-width` - width of margin 735 used for marginalized headers (default: 6). 736 737 * `markdown-list-indent-width` - depth of indentation for lists 738 when inserting, promoting, and demoting list items (default: 4). 739 740 * `markdown-indent-function` - the function to use for automatic 741 indentation (default: `markdown-indent-line`). 742 743 * `markdown-indent-on-enter` - Set to a non-nil value to 744 automatically indent new lines when <kbd>RET</kbd> is pressed. 745 Set to `indent-and-new-item` to additionally continue lists 746 when <kbd>RET</kbd> is pressed (default: `t`). 747 748 * `markdown-enable-wiki-links` - syntax highlighting for wiki 749 links (default: `nil`). Set this to a non-nil value to turn on 750 wiki link support by default. Wiki link support can be toggled 751 later using the function `markdown-toggle-wiki-links`." 752 753 * `markdown-wiki-link-alias-first` - set to a non-nil value to 754 treat aliased wiki links like `[[link text|PageName]]` 755 (default: `t`). When set to nil, they will be treated as 756 `[[PageName|link text]]`. 757 758 * `markdown-uri-types` - a list of protocol schemes (e.g., "http") 759 for URIs that `markdown-mode` should highlight. 760 761 * `markdown-enable-math` - font lock for inline and display LaTeX 762 math expressions (default: `nil`). Set this to `t` to turn on 763 math support by default. Math support can be toggled 764 interactively later using <kbd>C-c C-x C-e</kbd> 765 (`markdown-toggle-math`). 766 767 * `markdown-enable-html` - font lock for HTML tags and attributes 768 (default: `t`). 769 770 * `markdown-css-paths` - CSS files to link to in XHTML output 771 (default: `nil`). These can be either local files (relative or 772 absolute) or URLs. 773 774 * `markdown-content-type` - used to set to the `http-equiv` 775 attribute to be included in the XHTML `<head>` block (default: 776 `"text/html"`). Set to an alternate value `application/xhtml+xml` 777 if needed, or set to an empty string to remove the attribute. See 778 also: `markdown-coding-system`. 779 780 * `markdown-coding-system` - used for specifying the character 781 set identifier in the `http-equiv` attribute when included 782 (default: `nil`). See `markdown-content-type`, which must 783 be set for this variable to have any effect. When set to `nil`, 784 `buffer-file-coding-system` will be used to automatically 785 determine the coding system string (falling back to 786 `utf-8` when unavailable). Common settings are `iso-8859-1` 787 and `iso-latin-1`. 788 789 * `markdown-xhtml-header-content` - additional content to include 790 in the XHTML `<head>` block (default: `""`). 791 792 * `markdown-xhtml-body-preamble` - additional content to include in 793 the XHTML <body> block, before the output (default: `""`). This 794 is useful for enclosing additional elements around the Markdown 795 output. 796 797 * `markdown-xhtml-body-epilogue` - additional content to include in 798 the XHTML <body> block, after the output (default: `""`). This is 799 useful for enclosing additional elements around the Markdown 800 output. 801 802 * `markdown-xhtml-standalone-regexp` - a regular expression which 803 `markdown-mode` uses to determine whether the output of 804 `markdown-command` is a standalone XHTML document or an XHTML 805 fragment (default: `"^\\(<\\?xml\\|<!DOCTYPE\\|<html\\)"`). If 806 this regular expression not matched in the first five lines of 807 output, `markdown-mode` assumes the output is a fragment and 808 adds a header and footer. 809 810 * `markdown-link-space-sub-char` - a character to replace spaces 811 when mapping wiki links to filenames (default: `"_"`). 812 For example, use an underscore for compatibility with the 813 Python Markdown WikiLinks extension. In `gfm-mode`, this is 814 set to `"-"` to conform with GitHub wiki links. 815 816 * `markdown-reference-location` - where to insert reference 817 definitions (default: `header`). The possible locations are 818 the end of the document (`end`), after the current block 819 (`immediately`), the end of the current subtree (`subtree`), 820 or before the next header (`header`). 821 822 * `markdown-footnote-location` - where to insert footnote text 823 (default: `end`). The set of location options is the same as 824 for `markdown-reference-location`. 825 826 * `markdown-nested-imenu-heading-index` - Use nested imenu 827 heading instead of a flat index (default: `t`). A nested 828 index may provide more natural browsing from the menu, but a 829 flat list may allow for faster keyboard navigation via tab 830 completion. 831 832 * `markdown-add-footnotes-to-imenu` - Add footnote definitions to 833 the end of the imenu index (default: `t`). 834 835 * `comment-auto-fill-only-comments` - variable is made 836 buffer-local and set to `nil` by default. In programming 837 language modes, when this variable is non-nil, only comments 838 will be filled by auto-fill-mode. However, comments in 839 Markdown documents are rare and the most users probably intend 840 for the actual content of the document to be filled. Making 841 this variable buffer-local allows `markdown-mode` to override 842 the default behavior induced when the global variable is non-nil. 843 844 * `markdown-gfm-additional-languages`, - additional languages to 845 make available, aside from those predefined in 846 `markdown-gfm-recognized-languages`, when inserting GFM code 847 blocks (default: `nil`). Language strings must have be trimmed 848 of whitespace and not contain any curly braces. They may be of 849 arbitrary capitalization, though. 850 851 * `markdown-gfm-use-electric-backquote` - use 852 `markdown-electric-backquote` for interactive insertion of GFM 853 code blocks when backquote is pressed three times (default: `t`). 854 855 * `markdown-make-gfm-checkboxes-buttons` - Whether GitHub 856 Flavored Markdown style task lists (checkboxes) should be 857 turned into buttons that can be toggled with mouse-1 or RET. If 858 non-nil (default), then buttons are enabled. This works in 859 `markdown-mode` as well as `gfm-mode`. 860 861 * `markdown-hide-urls` - Determines whether URL and reference 862 labels are hidden for inline and reference links (default: `nil`). 863 When non-nil, inline links will appear in the buffer as 864 `[link](∞)` instead of 865 `[link](http://perhaps.a/very/long/url/)`. To change the 866 placeholder (composition) character used, set the variable 867 `markdown-url-compose-char`. URL hiding can be toggled 868 interactively using <kbd>C-c C-x C-l</kbd> (`markdown-toggle-url-hiding`) 869 or from the Markdown | Links & Images menu. 870 871 * `markdown-hide-markup` - Determines whether all possible markup 872 is hidden or otherwise beautified (default: `nil`). The actual 873 buffer text remains unchanged, but the display will be altered. 874 Brackets and URLs for links will be hidden, asterisks and 875 underscores for italic and bold text will be hidden, text 876 bullets for unordered lists will be replaced by Unicode 877 bullets, and so on. Since this includes URLs and reference 878 labels, when non-nil this setting supersedes `markdown-hide-urls`. 879 Markup hiding can be toggled using <kbd>C-c C-x C-m</kbd> 880 (`markdown-toggle-markup-hiding`) or from the Markdown | Show & 881 Hide menu. 882 883 Unicode bullets are used to replace ASCII list item markers. 884 The list of characters used, in order of list level, can be 885 specified by setting the variable `markdown-list-item-bullets`. 886 The placeholder characters used to replace other markup can 887 be changed by customizing the corresponding variables: 888 `markdown-blockquote-display-char`, 889 `markdown-hr-display-char`, and 890 `markdown-definition-display-char`. 891 892 * `markdown-fontify-code-blocks-natively` - Whether to fontify 893 code in code blocks using the native major mode. This only 894 works for fenced code blocks where the language is specified 895 where we can automatically determine the appropriate mode to 896 use. The language to mode mapping may be customized by setting 897 the variable `markdown-code-lang-modes`. This can be toggled 898 interactively by pressing <kbd>C-c C-x C-f</kbd> 899 (`markdown-toggle-fontify-code-blocks-natively`). 900 901 * `markdown-gfm-uppercase-checkbox` - When non-nil, complete GFM 902 task list items with `[X]` instead of `[x]` (default: `nil`). 903 This is useful for compatibility with `org-mode`, which doesn't 904 recognize the lowercase variant. 905 906 * `markdown-translate-filename-function` - A function to be used to 907 translate filenames in links. 908 909 * `markdown-unordered-list-item-prefix` - When non-nil, 910 `markdown-insert-list-item` inserts enumerated numbers for 911 ordered list marker. While nil, it always inserts `1.`. 912 913 * `markdown-enable-highlighting-syntax` - font lock for highlighting 914 syntax like Obsidian, Quilt(default: `nil`). 915 916 Additionally, the faces used for syntax highlighting can be modified to 917 your liking by issuing <kbd>M-x customize-group RET markdown-faces</kbd> 918 or by using the "Markdown Faces" link at the bottom of the mode 919 customization screen. 920 921 [Marked 2]: https://itunes.apple.com/us/app/marked-2/id890031187?mt=12&uo=4&at=11l5Vs&ct=mm 922 923 ## Extensions 924 925 Besides supporting the basic Markdown syntax, Markdown Mode also 926 includes syntax highlighting for `[[Wiki Links]]`. This can be 927 enabled by setting `markdown-enable-wiki-links` to a non-nil value. 928 Wiki links may be followed by pressing <kbd>C-c C-o</kbd> when the point 929 is at a wiki link. Use <kbd>M-p</kbd> and <kbd>M-n</kbd> to quickly jump to the 930 previous and next links (including links of other types). 931 Aliased or piped wiki links of the form `[[link text|PageName]]` 932 are also supported. Since some wikis reverse these components, set 933 `markdown-wiki-link-alias-first` to nil to treat them as 934 `[[PageName|link text]]`. If `markdown-wiki-link-fontify-missing` 935 is also non-nil, Markdown Mode will highlight wiki links with 936 missing target file in a different color. By default, Markdown 937 Mode only searches for target files in the current directory. 938 You can control search type by setting `markdown-wiki-link-search-type`. 939 This value type is a symbol list. Possible values are 940 941 - `sub-directories` : search in sub directories 942 - `parent-directories` : search in parent directories 943 - `project` : search under project root 944 945 [SmartyPants][] support is possible by customizing `markdown-command`. 946 If you install `SmartyPants.pl` at, say, `/usr/local/bin/smartypants`, 947 then you can set `markdown-command` to `"markdown | smartypants"`. 948 You can do this either by using <kbd>M-x customize-group markdown</kbd> 949 or by placing the following in your `.emacs` file: 950 951 ```lisp 952 (setq markdown-command "markdown | smartypants") 953 ``` 954 955 [SmartyPants]: http://daringfireball.net/projects/smartypants/ 956 957 Syntax highlighting for mathematical expressions written 958 in LaTeX (only expressions denoted by `$..$`, `$$..$$`, or `\[..\]`) 959 can be enabled by setting `markdown-enable-math` to a non-nil value, 960 either via customize or by placing `(setq markdown-enable-math t)` 961 in `.emacs`, and then restarting Emacs or calling 962 `markdown-reload-extensions`. 963 964 ## GitHub Flavored Markdown (GFM) 965 966 A [GitHub Flavored Markdown][GFM] mode, `gfm-mode`, is also 967 available. The GitHub implementation differs slightly from 968 standard Markdown in that it supports things like different 969 behavior for underscores inside of words, automatic linking of 970 URLs, strikethrough text, and fenced code blocks with an optional 971 language keyword. 972 973 The GFM-specific features above apply to `README.md` files, wiki 974 pages, and other Markdown-formatted files in repositories on 975 GitHub. GitHub also enables [additional features][GFM comments] for 976 writing on the site (for issues, pull requests, messages, etc.) 977 that are further extensions of GFM. These features include task 978 lists (checkboxes), newlines corresponding to hard line breaks, 979 auto-linked references to issues and commits, wiki links, and so 980 on. To make matters more confusing, although task lists are not 981 part of [GFM proper][GFM], [since 2014][] they are rendered (in a 982 read-only fashion) in all Markdown documents in repositories on the 983 site. These additional extensions are supported to varying degrees 984 by `markdown-mode` and `gfm-mode` as described below. 985 986 * **URL autolinking:** Both `markdown-mode` and `gfm-mode` support 987 highlighting of URLs without angle brackets. 988 989 * **Multiple underscores in words:** You must enable `gfm-mode` to 990 toggle support for underscores inside of words. In this mode 991 variable names such as `a_test_variable` will not trigger 992 emphasis (italics). 993 994 * **Fenced code blocks:** Code blocks quoted with backquotes, with 995 optional programming language keywords, are highlighted in 996 both `markdown-mode` and `gfm-mode`. They can be inserted with 997 <kbd>C-c C-s C</kbd>. If there is an active region, the text in the 998 region will be placed inside the code block. You will be 999 prompted for the name of the language, but may press enter to 1000 continue without naming a language. 1001 1002 In addition, in `gfm-mode`, GFM code blocks can be inserted via the 1003 option `markdown-gfm-use-electric-backquote`. If the option 1004 `markdown-code-block-braces` is set to `t`, code blocks inserted with 1005 <kbd>C-c C-s C</kbd> or electric backquotes will include braces ("{}") 1006 around the language attributes. 1007 1008 * **Strikethrough:** Strikethrough text is supported in both 1009 `markdown-mode` and `gfm-mode`. It can be inserted (and toggled) 1010 using <kbd>C-c C-s s</kbd>. 1011 1012 * **Task lists:** GFM task lists will be rendered as checkboxes 1013 (Emacs buttons) in both `markdown-mode` and `gfm-mode` when 1014 `markdown-make-gfm-checkboxes-buttons` is set to a non-nil value 1015 (and it is set to t by default). These checkboxes can be 1016 toggled by clicking `mouse-1`, pressing <kbd>RET</kbd> over the button, 1017 or by pressing <kbd>C-c C-d</kbd> (`markdown-do`) with the point anywhere 1018 in the task list item. A normal list item can be turned to a 1019 check list item by the same command, or more specifically 1020 <kbd>C-c C-s [</kbd> (`markdown-insert-gfm-checkbox`). 1021 1022 * **Wiki links:** Generic wiki links are supported in 1023 `markdown-mode`, but in `gfm-mode` specifically they will be 1024 treated as they are on GitHub: spaces will be replaced by hyphens 1025 in filenames and the first letter of the filename will be 1026 capitalized. For example, `[[wiki link]]` will map to a file 1027 named `Wiki-link` with the same extension as the current file. 1028 If a file with this name does not exist in the current directory, 1029 the first match in a subdirectory, if any, will be used instead. 1030 1031 * **Newlines:** Neither `markdown-mode` nor `gfm-mode` do anything 1032 specifically with respect to newline behavior. If you use 1033 `gfm-mode` mostly to write text for comments or issues on the 1034 GitHub site--where newlines are significant and correspond to 1035 hard line breaks--then you may want to enable `visual-line-mode` 1036 for line wrapping in buffers. You can do this with a 1037 `gfm-mode-hook` as follows: 1038 1039 ```lisp 1040 ;; Use visual-line-mode in gfm-mode 1041 (defun my-gfm-mode-hook () 1042 (visual-line-mode 1)) 1043 (add-hook 'gfm-mode-hook 'my-gfm-mode-hook) 1044 ``` 1045 1046 * **Preview:** GFM-specific preview can be powered by setting 1047 `markdown-command` to use [Docter][]. This may also be 1048 configured to work with [Marked 2][] for `markdown-open-command`. 1049 1050 [GFM]: http://github.github.com/github-flavored-markdown/ 1051 [GFM comments]: https://help.github.com/articles/writing-on-github/ 1052 [since 2014]: https://github.com/blog/1825-task-lists-in-all-markdown-documents 1053 [Docter]: https://github.com/alampros/Docter 1054 1055 ## Acknowledgments 1056 1057 markdown-mode has benefited greatly from the efforts of the many 1058 volunteers who have sent patches, test cases, bug reports, 1059 suggestions, helped with packaging, etc. Thank you for your 1060 contributions! See the [contributors graph][contrib] for details. 1061 1062 [contrib]: https://github.com/jrblevin/markdown-mode/graphs/contributors 1063 1064 ## Bugs 1065 1066 markdown-mode is developed and tested primarily for compatibility 1067 with GNU Emacs 25.1 and later. If you find any bugs in 1068 markdown-mode, please construct a test case or a patch and open a 1069 ticket on the [GitHub issue tracker][issues]. See the 1070 contributing guidelines in `CONTRIBUTING.md` for details on 1071 creating pull requests. 1072 1073 [issues]: https://github.com/jrblevin/markdown-mode/issues 1074 1075 ## History 1076 1077 markdown-mode was written and is maintained by Jason Blevins. The 1078 first version was released on May 24, 2007. 1079 1080 * 2007-05-24: [Version 1.1][] 1081 * 2007-05-25: [Version 1.2][] 1082 * 2007-06-05: [Version 1.3][] 1083 * 2007-06-29: [Version 1.4][] 1084 * 2007-10-11: [Version 1.5][] 1085 * 2008-06-04: [Version 1.6][] 1086 * 2009-10-01: [Version 1.7][] 1087 * 2011-08-12: [Version 1.8][] 1088 * 2011-08-15: [Version 1.8.1][] 1089 * 2013-01-25: [Version 1.9][] 1090 * 2013-03-24: [Version 2.0][] 1091 * 2016-01-09: [Version 2.1][] 1092 * 2017-05-26: [Version 2.2][] 1093 * 2017-08-31: [Version 2.3][] 1094 * 2020-05-30: [Version 2.4][] 1095 * 2022-02-12: [Version 2.5][] 1096 1097 [Version 1.1]: https://jblevins.org/projects/markdown-mode/rev-1-1 1098 [Version 1.2]: https://jblevins.org/projects/markdown-mode/rev-1-2 1099 [Version 1.3]: https://jblevins.org/projects/markdown-mode/rev-1-3 1100 [Version 1.4]: https://jblevins.org/projects/markdown-mode/rev-1-4 1101 [Version 1.5]: https://jblevins.org/projects/markdown-mode/rev-1-5 1102 [Version 1.6]: https://jblevins.org/projects/markdown-mode/rev-1-6 1103 [Version 1.7]: https://jblevins.org/projects/markdown-mode/rev-1-7 1104 [Version 1.8]: https://jblevins.org/projects/markdown-mode/rev-1-8 1105 [Version 1.8.1]: https://jblevins.org/projects/markdown-mode/rev-1-8-1 1106 [Version 1.9]: https://jblevins.org/projects/markdown-mode/rev-1-9 1107 [Version 2.0]: https://jblevins.org/projects/markdown-mode/rev-2-0 1108 [Version 2.1]: https://jblevins.org/projects/markdown-mode/rev-2-1 1109 [Version 2.2]: https://jblevins.org/projects/markdown-mode/rev-2-2 1110 [Version 2.3]: https://jblevins.org/projects/markdown-mode/rev-2-3 1111 [Version 2.4]: https://github.com/jrblevin/markdown-mode/releases/tag/v2.4 1112 [Version 2.5]: https://github.com/jrblevin/markdown-mode/releases/tag/v2.5