;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*- ;; Copyright (C) 2007-2017 Jason R. Blevins and markdown-mode ;; contributors (see the commit log for details). ;; Author: Jason R. Blevins ;; Maintainer: Jason R. Blevins ;; Created: May 24, 2007 ;; Version: 2.3 ;; Package-Version: 2.3 ;; Package-Requires: ((emacs "24") (cl-lib "0.5")) ;; Keywords: Markdown, GitHub Flavored Markdown, itex ;; URL: https://jblevins.org/projects/markdown-mode/ ;; This file is not part of GNU Emacs. ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; markdown-mode is a major mode for editing [Markdown][]-formatted ;; text. The latest stable version is markdown-mode 2.3, released on ;; August 31, 2017. See the [release notes][] for details. ;; markdown-mode is free software, licensed under the GNU GPL, ;; version 3 or later. ;; ![Markdown Mode Screenshot](https://jblevins.org/projects/markdown-mode/screenshots/20170818-001.png) ;; [Markdown]: http://daringfireball.net/projects/markdown/ ;; [release notes]: https://jblevins.org/projects/markdown-mode/rev-2-3 ;;; Documentation: ;; ;; ;; ;; The primary documentation for Markdown Mode is available below, and ;; is generated from comments in the source code. For a more in-depth ;; treatment, the [_Guide to Markdown Mode for Emacs_][guide] covers ;; Markdown syntax, advanced movement and editing in Emacs, ;; extensions, configuration examples, tips and tricks, and a survey ;; of other packages that work with Markdown Mode. Finally, Emacs is ;; also a self-documenting editor. This means that the source code ;; itself contains additional documentation: each function has its own ;; docstring available via `C-h f` (`describe-function'), individual ;; keybindings can be investigated with `C-h k` (`describe-key'), and ;; a complete list of keybindings is available using `C-h m` ;; (`describe-mode'). ;; [guide]: https://leanpub.com/markdown-mode ;;; Installation: ;; _Note:_ To use all of the features of `markdown-mode', you'll need ;; to install the Emacs package itself and also have a local Markdown ;; processor installed (e.g., Markdown.pl, MultiMarkdown, or Pandoc). ;; The external processor is not required for editing, but will be ;; used for rendering HTML for preview and export. After installing ;; the Emacs package, be sure to configure `markdown-command' to point ;; to the preferred Markdown executable on your system. See the ;; Customization section below for more details. ;; The recommended way to install `markdown-mode' is to install the package ;; from [MELPA Stable](https://stable.melpa.org/#/markdown-mode) ;; using `package.el'. First, configure `package.el' and the MELPA Stable ;; repository by adding the following to your `.emacs', `init.el', ;; or equivalent startup file: ;; ``` Lisp ;; (require 'package) ;; (add-to-list 'package-archives ;; '("melpa-stable" . "https://stable.melpa.org/packages/")) ;; (package-initialize) ;; ``` ;; Then, after restarting Emacs or evaluating the above statements, issue ;; the following command: `M-x package-install RET markdown-mode RET`. ;; When installed this way, the major modes `markdown-mode' and `gfm-mode' ;; will be autoloaded and `markdown-mode' will be used for file names ;; ending in either `.md` or `.markdown`. ;; ;; Alternatively, if you manage loading packages with [use-package][] ;; then you can automatically install and configure `markdown-mode' by ;; adding a declaration such as this one to your init file (as an ;; example; adjust settings as desired): ;; ;; ``` Lisp ;; (use-package markdown-mode ;; :ensure t ;; :commands (markdown-mode gfm-mode) ;; :mode (("README\\.md\\'" . gfm-mode) ;; ("\\.md\\'" . markdown-mode) ;; ("\\.markdown\\'" . markdown-mode)) ;; :init (setq markdown-command "multimarkdown")) ;; ``` ;; [MELPA Stable]: http://stable.melpa.org/ ;; [use-package]: https://github.com/jwiegley/use-package ;; **Direct Download** ;; Alternatively you can manually download and install markdown-mode. ;; First, download the [latest stable version][markdown-mode.el] and ;; save the file where Emacs can find it (i.e., a directory in your ;; `load-path'). You can then configure `markdown-mode' and `gfm-mode' ;; to load automatically by adding the following to your init file: ;; ``` Lisp ;; (autoload 'markdown-mode "markdown-mode" ;; "Major mode for editing Markdown files" t) ;; (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode)) ;; (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) ;; ;; (autoload 'gfm-mode "markdown-mode" ;; "Major mode for editing GitHub Flavored Markdown files" t) ;; (add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) ;; ``` ;; [markdown-mode.el]: https://jblevins.org/projects/markdown-mode/markdown-mode.el ;; **Development Version** ;; To follow or contribute to markdown-mode development, you can ;; browse or clone the Git repository ;; [on GitHub](https://github.com/jrblevin/markdown-mode): ;; ``` ;; git clone https://github.com/jrblevin/markdown-mode.git ;; ``` ;; If you prefer to install and use the development version, which may ;; become unstable at some times, you can either clone the Git ;; repository as above or install markdown-mode from ;; [MELPA](https://melpa.org/#/markdown-mode). ;; ;; If you clone the repository directly, then make sure that Emacs can ;; find it by adding the following line to your startup file: ;; ;; ``` Lisp ;; (add-to-list 'load-path "/path/to/markdown-mode/repository") ;; ``` ;; **Packaged Installation** ;; markdown-mode is also available in several package managers. You ;; may want to confirm that the package you install contains the ;; latest stable version first (and please notify the package ;; maintainer if not). ;; ;; * Debian Linux: [elpa-markdown-mode][] and [emacs-goodies-el][] ;; * Ubuntu Linux: [elpa-markdown-mode][elpa-ubuntu] and [emacs-goodies-el][emacs-goodies-el-ubuntu] ;; * RedHat and Fedora Linux: [emacs-goodies][] ;; * NetBSD: [textproc/markdown-mode][] ;; * MacPorts: [markdown-mode.el][macports-package] ([pending][macports-ticket]) ;; * FreeBSD: [textproc/markdown-mode.el][freebsd-port] ;; ;; [elpa-markdown-mode]: https://packages.debian.org/sid/lisp/elpa-markdown-mode ;; [elpa-ubuntu]: http://packages.ubuntu.com/search?keywords=elpa-markdown-mode ;; [emacs-goodies-el]: http://packages.debian.org/emacs-goodies-el ;; [emacs-goodies-el-ubuntu]: http://packages.ubuntu.com/search?keywords=emacs-goodies-el ;; [emacs-goodies]: https://apps.fedoraproject.org/packages/emacs-goodies ;; [textproc/markdown-mode]: http://pkgsrc.se/textproc/markdown-mode ;; [macports-package]: https://trac.macports.org/browser/trunk/dports/editors/markdown-mode.el/Portfile ;; [macports-ticket]: http://trac.macports.org/ticket/35716 ;; [freebsd-port]: http://svnweb.freebsd.org/ports/head/textproc/markdown-mode.el ;; **Dependencies** ;; To enable editing of code blocks in indirect buffers using `C-c '`, ;; you will need to install the [`edit-indirect'][ei] package. ;; [ei]: https://github.com/Fanael/edit-indirect/ ;;; Usage: ;; Keybindings are grouped by prefixes based on their function. For ;; example, the commands for styling text are grouped under `C-c C-s` ;; and toggle commands begin with `C-c C-x`. The primary commands in ;; each group will are described below. You can obtain a list of all ;; keybindings by pressing `C-c C-h`. Movement and shifting commands ;; tend to be associated with paired delimiters such as `M-{` and ;; `M-}` or `C-c <` and `C-c >`. Outline navigation keybindings the ;; same as in `org-mode'. Finally, commands for running Markdown or ;; doing maintenance on an open file are grouped under the `C-c C-c` ;; prefix. The most commonly used commands are described below. You ;; can obtain a list of all keybindings by pressing `C-c C-h`. ;; ;; * Links and Images: `C-c C-l` and `C-c C-i` ;; ;; `C-c C-l` (`markdown-insert-link`) is a general command for ;; inserting new link markup or editing existing link markup. This ;; is especially useful when markup or URL hiding is enabled, so ;; that URLs can't easily be edited directly. This command can be ;; used to insert links of any form: either inline links, ;; reference links, or plain URLs in angle brackets. The URL or ;; `[reference]` label, link text, and optional title are entered ;; through a series of interactive prompts. The type of link is ;; determined by which values are provided: ;; ;; * If both a URL and link text are given, insert an inline link: ;; `[text](url)`. ;; * If both a `[reference]` label and link text are given, insert ;; a reference link: `[text][reference]`. ;; * If only link text is given, insert an implicit reference link: ;; `[text][]`. ;; * If only a URL is given, insert a plain URL link: ;; ``. ;; ;; Similarly, `C-c C-i` (`markdown-insert-image`) is a general ;; command for inserting or editing image markup. As with the link ;; insertion command, through a series interactive prompts you can ;; insert either an inline or reference image: ;; ;; * If both a URL and alt text are given, insert an inline ;; image: `![alt text](url)`. ;; * If both a `[reference]` label and alt text are given, ;; insert a reference link: `![alt text][reference]`. ;; ;; If there is an existing link or image at the point, these ;; command will edit the existing markup rather than inserting new ;; markup. Otherwise, if there is an active region, these commands ;; use the region as either the default URL (if it seems to be a ;; URL) or link text value otherwise. In that case, the region ;; will be deleted and replaced by the link. ;; ;; Note that these functions can be used to convert links and ;; images from one type to another (inline, reference, or plain ;; URL) by selectively adding or removing properties via the ;; interactive prompts. ;; ;; If a reference label is given that is not yet defined, you ;; will be prompted for the URL and optional title and the ;; reference will be inserted according to the value of ;; `markdown-reference-location'. If a title is given, it will be ;; added to the end of the reference definition and will be used ;; to populate the title attribute when converted to HTML. ;; ;; Local images associated with image links may be displayed ;; inline in the buffer by pressing `C-c C-x C-i` ;; (`markdown-toggle-inline-images'). This is a toggle command, so ;; pressing this once again will remove inline images. ;; ;; * Text Styles: `C-c C-s` ;; ;; `C-c C-s i` inserts markup to make a region or word italic. If ;; there is an active region, make the region italic. If the point ;; is at a non-italic word, make the word italic. If the point is ;; at an italic word or phrase, remove the italic markup. ;; Otherwise, simply insert italic delimiters and place the cursor ;; in between them. Similarly, use `C-c C-s b` for bold, `C-c C-s c` ;; for inline code, and `C-c C-s k` for inserting `` tags. ;; ;; `C-c C-s q` inserts a blockquote using the active region, if ;; any, or starts a new blockquote. `C-c C-s Q` is a variation ;; which always operates on the region, regardless of whether it ;; is active or not (i.e., when `transient-mark-mode` is off but ;; the mark is set). The appropriate amount of indentation, if ;; any, is calculated automatically given the surrounding context, ;; but may be adjusted later using the region indentation ;; commands. ;; ;; `C-c C-s p` behaves similarly for inserting preformatted code ;; blocks (with `C-c C-s P` being the region-only counterpart) ;; and `C-c C-s C` inserts a GFM style backquote fenced code block. ;; ;; * Headings: `C-c C-s` ;; ;; To insert or replace headings, there are two options. You can ;; insert a specific level heading directly or you can have ;; `markdown-mode' determine the level for you based on the previous ;; heading. As with the other markup commands, the heading ;; insertion commands use the text in the active region, if any, ;; as the heading text. Otherwise, if the current line is not ;; blank, they use the text on the current line. Finally, the ;; setext commands will prompt for heading text if there is no ;; active region and the current line is blank. ;; ;; `C-c C-s h` inserts a heading with automatically chosen type and ;; level (both determined by the previous heading). `C-c C-s H` ;; behaves similarly, but uses setext (underlined) headings when ;; possible, still calculating the level automatically. ;; In cases where the automatically-determined level is not what ;; you intended, the level can be quickly promoted or demoted ;; (as described below). Alternatively, a `C-u` prefix can be ;; given to insert a heading _promoted_ (lower number) by one ;; level or a `C-u C-u` prefix can be given to insert a heading ;; demoted (higher number) by one level. ;; ;; To insert a heading of a specific level and type, use `C-c C-s 1` ;; through `C-c C-s 6` for atx (hash mark) headings and `C-c C-s !` or ;; `C-c C-s @` for setext headings of level one or two, respectively. ;; Note that `!` is `S-1` and `@` is `S-2`. ;; ;; If the point is at a heading, these commands will replace the ;; existing markup in order to update the level and/or type of the ;; heading. To remove the markup of the heading at the point, ;; press `C-c C-k` to kill the heading and press `C-y` to yank the ;; heading text back into the buffer. ;; ;; * Horizontal Rules: `C-c C-s -` ;; ;; `C-c C-s -` inserts a horizontal rule. By default, insert the ;; first string in the list `markdown-hr-strings' (the most ;; prominent rule). With a `C-u` prefix, insert the last string. ;; With a numeric prefix `N`, insert the string in position `N` ;; (counting from 1). ;; ;; * Footnotes: `C-c C-s f` ;; ;; `C-c C-s f` inserts a footnote marker at the point, inserts a ;; footnote definition below, and positions the point for ;; inserting the footnote text. Note that footnotes are an ;; extension to Markdown and are not supported by all processors. ;; ;; * Wiki Links: `C-c C-s w` ;; ;; `C-c C-s w` inserts a wiki link of the form `[[WikiLink]]`. If ;; there is an active region, use the region as the link text. If the ;; point is at a word, use the word as the link text. If there is ;; no active region and the point is not at word, simply insert ;; link markup. Note that wiki links are an extension to Markdown ;; and are not supported by all processors. ;; ;; * Markdown and Maintenance Commands: `C-c C-c` ;; ;; *Compile:* `C-c C-c m` will run Markdown on the current buffer ;; and show the output in another buffer. *Preview*: `C-c C-c p` ;; runs Markdown on the current buffer and previews, stores the ;; output in a temporary file, and displays the file in a browser. ;; *Export:* `C-c C-c e` will run Markdown on the current buffer ;; and save the result in the file `basename.html`, where ;; `basename` is the name of the Markdown file with the extension ;; removed. *Export and View:* press `C-c C-c v` to export the ;; file and view it in a browser. *Open:* `C-c C-c o` will open ;; the Markdown source file directly using `markdown-open-command'. ;; *Live Export*: Press `C-c C-c l` to turn on ;; `markdown-live-preview-mode' to view the exported output ;; side-by-side with the source Markdown. **For all export commands, ;; the output file will be overwritten without notice.** ;; `markdown-live-preview-window-function' can be customized to open ;; in a browser other than `eww'. If you want to force the ;; preview window to appear at the bottom or right, you can ;; customize `markdown-split-window-direction'. ;; ;; To summarize: ;; ;; - `C-c C-c m`: `markdown-command' > `*markdown-output*` buffer. ;; - `C-c C-c p`: `markdown-command' > temporary file > browser. ;; - `C-c C-c e`: `markdown-command' > `basename.html`. ;; - `C-c C-c v`: `markdown-command' > `basename.html` > browser. ;; - `C-c C-c w`: `markdown-command' > kill ring. ;; - `C-c C-c o`: `markdown-open-command'. ;; - `C-c C-c l`: `markdown-live-preview-mode' > `*eww*` buffer. ;; ;; `C-c C-c c` will check for undefined references. If there are ;; any, a small buffer will open with a list of undefined ;; references and the line numbers on which they appear. In Emacs ;; 22 and greater, selecting a reference from this list and ;; pressing `RET` will insert an empty reference definition at the ;; end of the buffer. Similarly, selecting the line number will ;; jump to the corresponding line. ;; ;; `C-c C-c n` renumbers any ordered lists in the buffer that are ;; out of sequence. ;; ;; `C-c C-c ]` completes all headings and normalizes all horizontal ;; rules in the buffer. ;; ;; * Following Links: `C-c C-o` ;; ;; Press `C-c C-o` when the point is on an inline or reference ;; link to open the URL in a browser. When the point is at a ;; wiki link, open it in another buffer (in the current window, ;; or in the other window with the `C-u` prefix). Use `M-p` and ;; `M-n` to quickly jump to the previous or next link of any type. ;; ;; * Doing Things: `C-c C-d` ;; ;; Use `C-c C-d` to do something sensible with the object at the point: ;; ;; - Jumps between reference links and reference definitions. ;; If more than one link uses the same reference label, a ;; window will be shown containing clickable buttons for ;; jumping to each link. Pressing `TAB` or `S-TAB` cycles ;; between buttons in this window. ;; - Jumps between footnote markers and footnote text. ;; - Toggles the completion status of GFM task list items ;; (checkboxes). ;; ;; * Promotion and Demotion: `C-c C--` and `C-c C-=` ;; ;; Headings, horizontal rules, and list items can be promoted and ;; demoted, as well as bold and italic text. For headings, ;; "promotion" means *decreasing* the level (i.e., moving from ;; `

` to `

`) while "demotion" means *increasing* the ;; level. For horizontal rules, promotion and demotion means ;; moving backward or forward through the list of rule strings in ;; `markdown-hr-strings'. For bold and italic text, promotion and ;; demotion means changing the markup from underscores to asterisks. ;; Press `C-c C--` or `C-c LEFT` to promote the element at the point ;; if possible. ;; ;; To remember these commands, note that `-` is for decreasing the ;; level (promoting), and `=` (on the same key as `+`) is for ;; increasing the level (demoting). Similarly, the left and right ;; arrow keys indicate the direction that the atx heading markup ;; is moving in when promoting or demoting. ;; ;; * Completion: `C-c C-]` ;; ;; Complete markup is in normalized form, which means, for ;; example, that the underline portion of a setext header is the ;; same length as the heading text, or that the number of leading ;; and trailing hash marks of an atx header are equal and that ;; there is no extra whitespace in the header text. `C-c C-]` ;; completes the markup at the point, if it is determined to be ;; incomplete. ;; ;; * Editing Lists: `M-RET`, `C-c UP`, `C-c DOWN`, `C-c LEFT`, and `C-c RIGHT` ;; ;; New list items can be inserted with `M-RET` or `C-c C-j`. This ;; command determines the appropriate marker (one of the possible ;; unordered list markers or the next number in sequence for an ;; ordered list) and indentation level by examining nearby list ;; items. If there is no list before or after the point, start a ;; new list. As with heading insertion, you may prefix this ;; command by `C-u` to decrease the indentation by one level. ;; Prefix this command by `C-u C-u` to increase the indentation by ;; one level. ;; ;; Existing list items (and their nested sub-items) can be moved ;; up or down with `C-c UP` or `C-c DOWN` and indented or ;; outdented with `C-c RIGHT` or `C-c LEFT`. ;; ;; * Editing Subtrees: `C-c UP`, `C-c DOWN`, `C-c LEFT`, and `C-c RIGHT` ;; ;; Entire subtrees of ATX headings can be promoted and demoted ;; with `C-c LEFT` and `C-c RIGHT`, which are the same keybindings ;; used for promotion and demotion of list items. If the point is in ;; a list item, the operate on the list item. Otherwise, they operate ;; on the current heading subtree. Similarly, subtrees can be ;; moved up and down with `C-c UP` and `C-c DOWN`. ;; ;; These commands currently do not work properly if there are ;; Setext headings in the affected region. ;; ;; Please note the following "boundary" behavior for promotion and ;; demotion. Any level-six headings will not be demoted further ;; (i.e., they remain at level six, since Markdown and HTML define ;; only six levels) and any level-one headings will promoted away ;; entirely (i.e., heading markup will be removed, since a ;; level-zero heading is not defined). ;; ;; * Shifting the Region: `C-c <` and `C-c >` ;; ;; Text in the region can be indented or outdented as a group using ;; `C-c >` to indent to the next indentation point (calculated in ;; the current context), and `C-c <` to outdent to the previous ;; indentation point. These keybindings are the same as those for ;; similar commands in `python-mode'. ;; ;; * Killing Elements: `C-c C-k` ;; ;; Press `C-c C-k` to kill the thing at point and add important ;; text, without markup, to the kill ring. Possible things to ;; kill include (roughly in order of precedece): inline code, ;; headings, horizonal rules, links (add link text to kill ring), ;; images (add alt text to kill ring), angle URIs, email ;; addresses, bold, italics, reference definitions (add URI to ;; kill ring), footnote markers and text (kill both marker and ;; text, add text to kill ring), and list items. ;; ;; * Outline Navigation: `C-c C-n`, `C-c C-p`, `C-c C-f`, `C-c C-b`, and `C-c C-u` ;; ;; These keys are used for hierarchical navigation in lists and ;; headings. When the point is in a list, they move between list ;; items. Otherwise, they move between headings. Use `C-c C-n` and ;; `C-c C-p` to move between the next and previous visible ;; headings or list items of any level. Similarly, `C-c C-f` and ;; `C-c C-b` move to the next and previous visible headings or ;; list items at the same level as the one at the point. Finally, ;; `C-c C-u` will move up to the parent heading or list item. ;; ;; * Movement by Markdown paragraph: `M-{`, `M-}`, and `M-h` ;; ;; Paragraphs in `markdown-mode' are regular paragraphs, ;; paragraphs inside blockquotes, individual list items, headings, ;; etc. These keys are usually bound to `forward-paragraph' and ;; `backward-paragraph', but the built-in Emacs functions are ;; based on simple regular expressions that fail in Markdown ;; files. Instead, they are bound to `markdown-forward-paragraph' ;; and `markdown-backward-paragraph'. To mark a paragraph, ;; you can use `M-h` (`markdown-mark-paragraph'). ;; ;; * Movement by Markdown block: `C-M-{`, `C-M-}`, and `C-c M-h` ;; ;; Markdown blocks are regular paragraphs in many cases, but ;; contain many paragraphs in other cases: blocks are considered ;; to be entire lists, entire code blocks, and entire blockquotes. ;; To move backward one block use `C-M-{` ;; (`markdown-beginning-block`) and to move forward use `C-M-}` ;; (`markdown-end-of-block`). To mark a block, use `C-c M-h` ;; (`markdown-mark-block`). ;; ;; * Movement by Defuns: `C-M-a`, `C-M-e`, and `C-M-h` ;; ;; The usual Emacs commands can be used to move by defuns ;; (top-level major definitions). In markdown-mode, a defun is a ;; section. As usual, `C-M-a` will move the point to the ;; beginning of the current or preceding defun, `C-M-e` will move ;; to the end of the current or following defun, and `C-M-h` will ;; put the region around the entire defun. ;; ;; * Miscellaneous Commands: ;; ;; When the [`edit-indirect'][ei] package is installed, `C-c '` ;; (`markdown-edit-code-block`) can be used to edit a code block ;; in an indirect buffer in the native major mode. Press `C-c C-c` ;; to commit changes and return or `C-c C-k` to cancel. ;; ;; As noted, many of the commands above behave differently depending ;; on whether Transient Mark mode is enabled or not. When it makes ;; sense, if Transient Mark mode is on and the region is active, the ;; command applies to the text in the region (e.g., `C-c C-s b` makes the ;; region bold). For users who prefer to work outside of Transient ;; Mark mode, since Emacs 22 it can be enabled temporarily by pressing ;; `C-SPC C-SPC`. When this is not the case, many commands then ;; proceed to look work with the word or line at the point. ;; ;; When applicable, commands that specifically act on the region even ;; outside of Transient Mark mode have the same keybinding as their ;; standard counterpart, but the letter is uppercase. For example, ;; `markdown-insert-blockquote' is bound to `C-c C-s q` and only acts on ;; the region in Transient Mark mode while `markdown-blockquote-region' ;; is bound to `C-c C-s Q` and always applies to the region (when nonempty). ;; ;; Note that these region-specific functions are useful in many ;; cases where it may not be obvious. For example, yanking text from ;; the kill ring sets the mark at the beginning of the yanked text ;; and moves the point to the end. Therefore, the (inactive) region ;; contains the yanked text. So, `C-y` followed by `C-c C-s Q` will ;; yank text and turn it into a blockquote. ;; ;; markdown-mode attempts to be flexible in how it handles ;; indentation. When you press `TAB` repeatedly, the point will cycle ;; through several possible indentation levels corresponding to things ;; you might have in mind when you press `RET` at the end of a line or ;; `TAB`. For example, you may want to start a new list item, ;; continue a list item with hanging indentation, indent for a nested ;; pre block, and so on. Outdenting is handled similarly when backspace ;; is pressed at the beginning of the non-whitespace portion of a line. ;; ;; markdown-mode supports outline-minor-mode as well as org-mode-style ;; visibility cycling for atx- or hash-style headings. There are two ;; types of visibility cycling: Pressing `S-TAB` cycles globally between ;; the table of contents view (headings only), outline view (top-level ;; headings only), and the full document view. Pressing `TAB` while the ;; point is at a heading will cycle through levels of visibility for the ;; subtree: completely folded, visible children, and fully visible. ;; Note that mixing hash and underline style headings will give undesired ;; results. ;;; Customization: ;; Although no configuration is *necessary* there are a few things ;; that can be customized. The `M-x customize-mode` command ;; provides an interface to all of the possible customizations: ;; ;; * `markdown-command' - the command used to run Markdown (default: ;; `markdown`). This variable may be customized to pass ;; command-line options to your Markdown processor of choice. ;; ;; * `markdown-command-needs-filename' - set to `t' if ;; `markdown-command' does not accept standard input (default: ;; `nil'). When `nil', `markdown-mode' will pass the Markdown ;; content to `markdown-command' using standard input (`stdin`). ;; When set to `t', `markdown-mode' will pass the name of the file ;; as the final command-line argument to `markdown-command'. Note ;; that in the latter case, you will only be able to run ;; `markdown-command' from buffers which are visiting a file. ;; ;; * `markdown-open-command' - the command used for calling a standalone ;; Markdown previewer which is capable of opening Markdown source files ;; directly (default: `nil'). This command will be called ;; with a single argument, the filename of the current buffer. ;; A representative program is the Mac app [Marked 2][], a ;; live-updating Markdown previewer which can be [called from a ;; simple shell script](https://jblevins.org/log/marked-2-command). ;; ;; * `markdown-hr-strings' - list of strings to use when inserting ;; horizontal rules. Different strings will not be distinguished ;; when converted to HTML--they will all be converted to ;; `
`--but they may add visual distinction and style to plain ;; text documents. To maintain some notion of promotion and ;; demotion, keep these sorted from largest to smallest. ;; ;; * `markdown-bold-underscore' - set to a non-nil value to use two ;; underscores when inserting bold text instead of two asterisks ;; (default: `nil'). ;; ;; * `markdown-italic-underscore' - set to a non-nil value to use ;; underscores when inserting italic text instead of asterisks ;; (default: `nil'). ;; ;; * `markdown-asymmetric-header' - set to a non-nil value to use ;; asymmetric header styling, placing header characters only on ;; the left of headers (default: `nil'). ;; ;; * `markdown-header-scaling' - set to a non-nil value to use ;; a variable-pitch font for headings where the size corresponds ;; to the level of the heading (default: `nil'). ;; ;; * `markdown-header-scaling-values' - list of scaling values, ;; relative to baseline, for headers of levels one through six, ;; used when `markdown-header-scaling' is non-nil ;; (default: `(2.0 1.7 1.4 1.1 1.0 1.0)`). ;; ;; * `markdown-list-indent-width' - depth of indentation for lists ;; when inserting, promoting, and demoting list items (default: 4). ;; ;; * `markdown-indent-function' - the function to use for automatic ;; indentation (default: `markdown-indent-line'). ;; ;; * `markdown-indent-on-enter' - Set to a non-nil value to ;; automatically indent new lines when `RET' is pressed. ;; Set to `indent-and-new-item' to additionally continue lists ;; when `RET' is pressed (default: `t'). ;; ;; * `markdown-enable-wiki-links' - syntax highlighting for wiki ;; links (default: `nil'). Set this to a non-nil value to turn on ;; wiki link support by default. Wiki link support can be toggled ;; later using the function `markdown-toggle-wiki-links'." ;; ;; * `markdown-wiki-link-alias-first' - set to a non-nil value to ;; treat aliased wiki links like `[[link text|PageName]]` ;; (default: `t'). When set to nil, they will be treated as ;; `[[PageName|link text]]'. ;; ;; * `markdown-uri-types' - a list of protocol schemes (e.g., "http") ;; for URIs that `markdown-mode' should highlight. ;; ;; * `markdown-enable-math' - font lock for inline and display LaTeX ;; math expressions (default: `nil'). Set this to `t' to turn on ;; math support by default. Math support can be toggled ;; interactively later using `C-c C-x C-e` ;; (`markdown-toggle-math'). ;; ;; * `markdown-css-paths' - CSS files to link to in XHTML output ;; (default: `nil`). ;; ;; * `markdown-content-type' - when set to a nonempty string, an ;; `http-equiv` attribute will be included in the XHTML `` ;; block (default: `""`). If needed, the suggested values are ;; `application/xhtml+xml` or `text/html`. See also: ;; `markdown-coding-system'. ;; ;; * `markdown-coding-system' - used for specifying the character ;; set identifier in the `http-equiv` attribute when included ;; (default: `nil'). See `markdown-content-type', which must ;; be set before this variable has any effect. When set to `nil', ;; `buffer-file-coding-system' will be used to automatically ;; determine the coding system string (falling back to ;; `iso-8859-1' when unavailable). Common settings are `utf-8' ;; and `iso-latin-1'. ;; ;; * `markdown-xhtml-header-content' - additional content to include ;; in the XHTML `` block (default: `""`). ;; ;; * `markdown-xhtml-standalone-regexp' - a regular expression which ;; `markdown-mode' uses to determine whether the output of ;; `markdown-command' is a standalone XHTML document or an XHTML ;; fragment (default: `"^\\(<\\?xml\\|")) "Character for hiding blockquote markup." :type 'string :safe 'stringp :package-version '(markdown-mode . "2.3")) (defcustom markdown-hr-display-char (cond ((char-displayable-p ?─) ?─) ((char-displayable-p ?━) ?━) (t ?-)) "Character for hiding horizontal rule markup." :type 'character :safe 'characterp :package-version '(markdown-mode . "2.3")) (defcustom markdown-definition-display-char (cond ((char-displayable-p ?⁘) ?⁘) ((char-displayable-p ?⁙) ?⁙) ((char-displayable-p ?≡) ?≡) ((char-displayable-p ?⌑) ?⌑) ((char-displayable-p ?◊) ?◊) (t nil)) "Character for replacing definition list markup." :type 'character :safe 'characterp :package-version '(markdown-mode . "2.3")) (defcustom markdown-enable-math nil "Syntax highlighting for inline LaTeX and itex expressions. Set this to a non-nil value to turn on math support by default. Math support can be enabled, disabled, or toggled later using `markdown-toggle-math' or \\[markdown-toggle-math]." :group 'markdown :type 'boolean :safe 'booleanp) (make-variable-buffer-local 'markdown-enable-math) (defcustom markdown-css-paths nil "URL of CSS file to link to in the output XHTML." :group 'markdown :type 'list) (defcustom markdown-content-type "" "Content type string for the http-equiv header in XHTML output. When set to a non-empty string, insert the http-equiv attribute. Otherwise, this attribute is omitted." :group 'markdown :type 'string) (defcustom markdown-coding-system nil "Character set string for the http-equiv header in XHTML output. Defaults to `buffer-file-coding-system' (and falling back to `iso-8859-1' when not available). Common settings are `utf-8' and `iso-latin-1'. Use `list-coding-systems' for more choices." :group 'markdown :type 'coding-system) (defcustom markdown-xhtml-header-content "" "Additional content to include in the XHTML block." :group 'markdown :type 'string) (defcustom markdown-xhtml-standalone-regexp "^\\(<\\?xml\\| Links & Images menu." :group 'markdown :type 'boolean :safe 'booleanp :package-version '(markdown-mode . "2.3")) (make-variable-buffer-local 'markdown-hide-urls) ;;; Regular Expressions ======================================================= (defconst markdown-regex-comment-start "") (setq-local comment-start-skip "