網站地圖 最近更新 News ElispArea 教导

MarkdownMode

markdown-mode is a major mode for GNU Emacs which provides syntax highlighting and supporting commands for editing Markdown files. It provides keybindings and commands for inserting Markdown elements and to assist in calling Markdown to parse the source code or preview the document in a browser. It also, optionally, provides syntax highlighting for wiki links and embedded itex mathematical expressions.

http://jblevins.org/projects/markdown-mode/

markdown-mode version 2.0 was released on March 24, 2013. Release notes can be found here:

http://jblevins.org/projects/markdown-mode/rev-2-0

Customization

It can be useful to enforce certain static constraints on Markdown files; for example, the heavy use of brackets and parentheses in link syntax mean it is easy to omit a closing parentheses, especially if one is linking something inside a natural language digression (where one will have 2 or more closing parentheses). Balance can be checked with 'check-parens', and it can be automatically invoked after file saves with the usual hooks, eg.

    (add-hook 'markdown-mode-hook
            (lambda ()
              (when buffer-file-name
                (add-hook 'after-save-hook
                          'check-parens
                          nil t))))

A similar logic applies to double-quotes, especially if one is frequently adding tooltips to links. ‘check-parens’ works off the buffer syntax table, and double-quotes are not special to markdown-mode, so one must do a more invasive hook:

    ; warning, may yield wrong results in edge-cases like single double-quotes in code block.
    ; Use only if your files usually are balanced w/r/t double-quotes
    ; <http://stackoverflow.com/questions/9527593/customizing-check-parens-to-check-double-quotes>
    (add-hook 'markdown-mode-hook (lambda () (modify-syntax-entry ?\" "\"" markdown-mode-syntax-table)))

Usage notes

Useful markdown-specific editing features:


MarkupModes