pax_global_header 0000666 0000000 0000000 00000000064 13217531627 0014521 g ustar 00root root 0000000 0000000 52 comment=2c58792b079a6a28d9660b8d3b684c7cba1091a9
markdown-mode-2.3+154/ 0000775 0000000 0000000 00000000000 13217531627 0014436 5 ustar 00root root 0000000 0000000 markdown-mode-2.3+154/.dir-locals.el 0000664 0000000 0000000 00000001055 13217531627 0017070 0 ustar 00root root 0000000 0000000 ;;; Directory Local Variables
;;; See Info node `(emacs) Directory Variables' for more information.
((nil
(require-final-newline . t)
;; not tabs in code
(indent-tabs-mode)
;; checkdoc, don't botch English grammar
(checkdoc-arguments-in-order-flag . nil)
;; checkdoc, we don't want docs for internal vars
(checkdoc-force-docstrings-flag . nil))
(emacs-lisp-mode
;; checkdoc, one space is enough
(sentence-end-double-space . nil)
;; remove trailing whitespace
(eval . (add-hook 'before-save-hook 'delete-trailing-whitespace nil t))))
markdown-mode-2.3+154/.github/ 0000775 0000000 0000000 00000000000 13217531627 0015776 5 ustar 00root root 0000000 0000000 markdown-mode-2.3+154/.github/ISSUE_TEMPLATE.md 0000664 0000000 0000000 00000002257 13217531627 0020511 0 ustar 00root root 0000000 0000000
## Expected Behavior
## Actual Behavior
## Steps to Reproduce
1. Step A
2. Step B
3. Step C
## Backtrace
## Software Versions
- Markdown Mode:
- Emacs:
- OS:
markdown-mode-2.3+154/.github/PULL_REQUEST_TEMPLATE.md 0000664 0000000 0000000 00000002231 13217531627 0021575 0 ustar 00root root 0000000 0000000
## Description
## Related Issue
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Improvement (non-breaking change which improves an existing feature)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist
- [ ] I have read the **CONTRIBUTING.md** document.
- [ ] I have updated the documentation in the **README.md** file if necessary.
- [ ] I have added an entry to **CHANGES.md**.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed (using `make test`).
markdown-mode-2.3+154/.gitignore 0000664 0000000 0000000 00000000021 13217531627 0016417 0 ustar 00root root 0000000 0000000 *.elc
index.text
markdown-mode-2.3+154/.travis.yml 0000664 0000000 0000000 00000000637 13217531627 0016555 0 ustar 00root root 0000000 0000000 language: generic
sudo: false
before_install:
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- evm install $EVM_EMACS --use --skip
env:
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-25.1-travis
- EVM_EMACS=emacs-25.2-travis
- EVM_EMACS=emacs-25.3-travis
script:
- emacs --version
- cd tests && make clean && make test
markdown-mode-2.3+154/CHANGES.md 0000664 0000000 0000000 00000216727 13217531627 0016047 0 ustar 00root root 0000000 0000000 # Markdown Mode 2.4
*Under development*
* **Breaking changes:**
- GNU Emacs 24.4 or later is required. Support for Emacs 24.3
has been dropped.
- Face variables, such as `markdown-italic-face` are now
obsolete. Use face names directly in code and customizations.
The face names themselves are unaffected, so this shouldn't
affect most users.
- Internal variables `markdown-font-lock-keywords-basic` and
`gfm-font-lock-keywords` are now obsolete.
`markdown-font-lock-keywords` is now used instead, but users
should use `font-lock-add-keywords` instead of modifying this
variable.
* New features:
- GFM task list item (checkbox) insertion with `C-c C-s [`, or
as a final fallback for `markdown-do` (`C-c C-d`). Thanks to
Akinori Musha for a patch. ([GH-229][])
- Optionally move leading atx heading markup to the left margin
when `markdown-marginalize-headers` is non-`nil`. Thanks to
Alexis Gallagher for a patch. ([GH-272][], [GH-274][])
- Added pipe table editing features. Thanks to Dmitry Safronov
for a patch. ([GH-171][], [GH-266][])
- Font lock for HTML tags and attributes, with new faces
`markdown-html-tag-name-face`,
`markdown-html-tag-delimiter-face`,
`markdown-html-attr-name-face`, and
`markdown-html-attr-value-face`. ([GH-249][])
- Font lock for HTML entities, with a new face
`markdown-html-entity-face`.
- Scale down large inline images using `markdown-max-image-size`,
a cons cell of the form `(max-width . max-height)`.
- Added read-only viewing modes `markdown-view-mode` and
`gfm-view-mode` with keymaps similar to `view-mode` and
`help-mode`. ([GH-296][])
- Optionally add footnote definitions to the end of the imenu
index using `markdown-add-footnotes-to-imenu`. ([GH-235][])
* Improvements:
- Insert references before local variables. Thanks to Philipp
Stephani for a patch. ([GH-216][], [GH-262][])
- Allow `markdown-command` and `markdown-open-command` to be
functions. ([GH-255][], [GH-263][])
- Save the buffer before running `markdown-open-command` and run
`markdown-open-command` asynchronously. Thanks to Dmitry
Safronov for a patch. ([GH-248][])
- New user option `markdown-translate-filename-function` to translate
filenames when following file links. ([GH-268][], [GH-277][])
- Support double-backslash math delimiters. ([GH-270][])
- New user option `markdown-export-kill-buffer` to kill or preserve
HTML export output buffer. ([GH-224][])
- Add `markdown-edit-code-block-default-mode` to specify default
mode for indirect editing of code blocks. ([GH-251][])
- Insert-and-indirect-edit GFM code blocks simultaneously by
giving a prefix argument to `C-c C-s C`. ([GH-251][])
- Improve package load time by deferring calls to
`char-displayable-p`. ([GH-264][])
- Only raise footnotes when markup hiding is on.
Footnote display properties may now be customized via
`markdown-footnote-display`. ([GH-247][])
- Customizable subscript and superscript display properties
via `markdown-sub-superscript-display`.
- Several font-lock performance improvements.
- Support horizontal rules consisting of underscores.
* Bug fixes:
- Remove GFM checkbox overlays when switching major modes.
([GH-238][], [GH-257][])
- Don't test the value of the `composition` property to avoid
failing tests. ([GH-246][], [GH-258][])
- Fix types for `markdown-open-command`, `markdown-uri-types`,
and `markdown-hr-strings` defcustoms. ([GH-254][], [GH-259][])
- Don't insert trailing whitespace when inserting a blockquote.
([GH-227][], [GH-260][])
- Make wiki link test work even when `/tmp` contains an
inaccessible subdirectory. ([GH-261][])
- Fix `markdown-inline-code-face`'s `:inherit` attribute.
([GH-252][])
- Fix type of customizable `markdown-css-paths` variable.
([GH-276][])
- Don't set `markdown-code-face` background color at package
load time. ([GH-273][])
- Don't clobber user specified font-lock keywords when toggling
features. ([GH-222][])
- Fix font-lock for inline code inside italics and bold.
([GH-275][])
- Make code block language detection handle unspecified
or unknown code block languages. ([GH-284][])
- Fix precedence of inline code over inline links.
[gh-171]: https://github.com/jrblevin/markdown-mode/issues/171
[gh-216]: https://github.com/jrblevin/markdown-mode/issues/216
[gh-222]: https://github.com/jrblevin/markdown-mode/issues/222
[gh-224]: https://github.com/jrblevin/markdown-mode/issues/224
[gh-227]: https://github.com/jrblevin/markdown-mode/issues/227
[gh-229]: https://github.com/jrblevin/markdown-mode/pull/229
[gh-235]: https://github.com/jrblevin/markdown-mode/issues/235
[gh-238]: https://github.com/jrblevin/markdown-mode/issues/238
[gh-246]: https://github.com/jrblevin/markdown-mode/issues/246
[gh-247]: https://github.com/jrblevin/markdown-mode/issues/247
[gh-248]: https://github.com/jrblevin/markdown-mode/issues/248
[gh-249]: https://github.com/jrblevin/markdown-mode/issues/249
[gh-251]: https://github.com/jrblevin/markdown-mode/issues/251
[gh-252]: https://github.com/jrblevin/markdown-mode/pull/252
[gh-254]: https://github.com/jrblevin/markdown-mode/issues/254
[gh-255]: https://github.com/jrblevin/markdown-mode/issues/255
[gh-257]: https://github.com/jrblevin/markdown-mode/pull/257
[gh-258]: https://github.com/jrblevin/markdown-mode/pull/258
[gh-259]: https://github.com/jrblevin/markdown-mode/pull/259
[gh-260]: https://github.com/jrblevin/markdown-mode/pull/260
[gh-261]: https://github.com/jrblevin/markdown-mode/pull/261
[gh-262]: https://github.com/jrblevin/markdown-mode/pull/262
[gh-263]: https://github.com/jrblevin/markdown-mode/pull/263
[gh-264]: https://github.com/jrblevin/markdown-mode/pull/264
[gh-266]: https://github.com/jrblevin/markdown-mode/issues/266
[gh-268]: https://github.com/jrblevin/markdown-mode/issues/268
[gh-270]: https://github.com/jrblevin/markdown-mode/issues/270
[gh-272]: https://github.com/jrblevin/markdown-mode/issues/272
[gh-273]: https://github.com/jrblevin/markdown-mode/issues/273
[gh-274]: https://github.com/jrblevin/markdown-mode/pull/274
[gh-275]: https://github.com/jrblevin/markdown-mode/issues/275
[gh-276]: https://github.com/jrblevin/markdown-mode/issues/276
[gh-277]: https://github.com/jrblevin/markdown-mode/pull/277
[gh-284]: https://github.com/jrblevin/markdown-mode/issues/284
[gh-296]: https://github.com/jrblevin/markdown-mode/issues/296
# Markdown Mode 2.3
*August 31, 2017*
* **Breaking changes:**
- `markdown-mode` now requires Emacs 24.3 or later.
- Markup insertion and replacement keybindings under C-c
C-s (_s_ for style) have been revised to make them
easier to remember. Now, when the prefix C-c C-s
is pressed, a short minibuffer help prompt is presented as a
reminder of a few of the most frequently used keys. The major
changes are that bold is now inserted with b
(previously s) and italic is now i
(previously e). As a result, blockquote is now
q (previously b) and strikethrough
markup is inserted with s (previously
d). Press C-c C-s C-h for a complete
list of markup insertion keybindings. Heading insertion
commands are also now under C-c C-s.
- Link insertion and editing has been consolidated into one
command, `markdown-insert-link`, bound to C-c C-l.
As such, the previous separate link insertion keybindings have
been removed: C-c C-a l, C-c C-a L,
C-c C-a r, and C-c C-a u.
- Image insertion and editing has been consolidated into one
command, `markdown-insert-image`, bound to C-c C-i.
As such, the previous separate image insertion keybindings have
been removed: C-c C-i i and C-c C-i I.
- Footnote and wiki link insertion have been moved to the
markup insertion prefix, as C-c C-s f and
C-c C-s w.
- The list and outline editing commands have been removed from
the top-level positions (previously M-LEFT,
M-RIGHT, M-UP, M-DOWN)
and moved to major mode keybindings under C-c to
C-c LEFT, C-c RIGHT,
C-c UP, and C-c DOWN, respectively.
([GH-164][])
- The list and outline editing commands have also been unified
so that they all operate on entire subtrees of list items and
subtrees of atx headings, symmetrically. Previously there were
separate commands for editing heading subtrees, but promoting
a single section is easy enough by directly inserting or
removing a hash mark or using the markup replacement commands.
- Jumping between references and reference definitions via
`markdown-jump`, previously bound to C-c C-l, has
been moved to C-c C-d and rebranded as
`markdown-do`, which attempts to do something sensible with
the object at the point.
- Rename internal `markdown-link-link` to `markdown-link-url`
for clarity.
- The old inline image toggling command C-c C-i C-t
has been removed and replaced C-c C-x C-i in order
to allow for the new interactive image insertion command at
C-c C-i. Toggling keybindings are currently being
grouped under C-c C-x.
- `markdown-blockquote-face` is now applied to the entire
blockquote, including the leading `>`, so it can be used to
apply a background if desired.
- In `markdown-regex-header`, groups 4 and 6 now include
whitespace surrounding hash marks in atx headings.
- Font lock for `~~strikethrough~~` is now supported in
`markdown-mode` in addition to `gfm-mode`.
- Introduced a new face for horizontal rules: `markdown-hr-face`.
Previously, `markdown-header-delimiter-face` was used.
- Markdown Mode is now distributed under the GNU GPL version 3
or later.
- Rename `markdown-fill-forward-paragraph-function` to
`markdown-fill-forward-paragraph`.
- Rename `markdown-footnote-face` to `markdown-footnote-marker-face`.
- Functions `markdown-insert-inline-link-dwim` and
`markdown-insert-reference-link-dwim` have been combined and
replaced with `markdown-insert-link`.
- Functions `markdown-exdent-region` and `markdown-exdent-or-delete`
are now named `markdown-outdent-region` and
`markdown-outdent-or-delete`, respectively.
- The non-interactive image insertion commands have been
refactored to mirror the corresponding link insertion
commands. `markdown-insert-image` (for inline images) has
been renamed `markdown-insert-inline-image` and it now takes
three arguments (previously one optional argument).
`markdown-insert-reference-image` now takes four arguments
(previously none).
* New features:
- Markup hiding: Add a custom variable `markdown-hide-markup`,
which determines whether to hide or otherwise beautify
Markdown markup. For example, for inline links the brackets,
URL, and title will be hidden and only the (clickable) link
text will remain. The URL can be seen by hovering with the
mouse pointer and edited by deleting one of the invisible
brackets or parentheses. This can be toggled interactively
using C-c C-x C-m (`markdown-toggle-markup-hiding`).
This setting supersedes URL hiding (below). ([GH-130][])
- Unicode bullets are used to replace ASCII list item markers
for unordered lists when markup hiding is enabled. The list
of characters used, in order of list level, can be specified
by setting the variable `markdown-list-item-bullets`.
([GH-130][])
- When markup hiding is enabled, the characters used for
replacing certain markup can be changed by customizing the
corresponding variables:
`markdown-blockquote-display-char`,
`markdown-hr-display-char`, and
`markdown-definition-display-char`.
- URL and reference label hiding: URLs for inline links and
labels for reference links can now be hidden if desired. This is
configurable via `markdown-hide-urls`. URLs will appear as
`[link](∞)` instead of
`[link](http://perhaps.a/very/long/url/)`. To change the
placeholder character used, set `markdown-url-compose-char`.
This feature can be toggled using C-c C-x C-l
(`markdown-toggle-url-hiding`). If full markup hiding (above)
is enabled, then URL hiding has no additional effect.
- Native code block font-lock: Add a custom variable
`markdown-fontify-code-blocks-natively`, which determines
whether to fontify code in code blocks using the native major
mode. This only works for fenced code blocks where the
language is specified where we can automatically determine the
appropriate mode to use. The language to mode mapping may be
customized by setting the variable `markdown-code-lang-modes`.
([GH-123][], [GH-185][])
- When the [`edit-indirect`](https://github.com/Fanael/edit-indirect/)
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.
- Add command C-c C-x C-f for toggling native font lock
for code blocks (`markdown-toggle-fontify-code-blocks-natively`).
- Add "page" movement, marking, and narrowing commands, where a
"page" in Markdown is defined to be a top-level subtree:
`markdown-forward-page` (C-x ]),
`markdown-backward-page` (C-x [),
`markdown-mark-page` (C-x C-p), and
`markdown-narrow-to-page` (C-x n p). ([GH-191][])
- Add subtree marking and narrowing functions:
`markdown-mark-subtree` (C-c C-M-h) and
`markdown-narrow-to-subtree` (C-x n s).
([GH-191][])
- Add syntax-aware Markdown paragraph movement commands:
M-{ (`markdown-backward-paragraph`) and
M-} (`markdown-forward-paragraph`). To mark a
paragraph, use M-h (`markdown-mark-paragraph`).
These move at a more granular level than the block movement
commands. ([GH-191][])
- The previous block movement and marking commands are now at
C-M-{, C-M-}, and C-c M-h.
In terms of lists, paragraph movement commands now stop at
each list item while block commands move over entire lists.
([GH-191][])
- Add `subtree` as a possible value for
`markdown-reference-location` and
`markdown-footnote-location`.
- Ask flyspell to ignore words in URLs, code fragments,
comments, and reference labels.
- Make inline links, reference links, angle bracket URLs, and
plain URLs clickable.
- Add an additional keybinding for toggling inline image
display, C-c C-x C-i.
- Add a keybinding for toggling LaTeX math (_e_quation) support:
C-c C-x C-e.
- Support Leanpub blocks (asides, info blocks, warnings, etc.).
These are simple extensions of the usual blockquote syntax.
- Font lock, with markup hiding, for subscripts (e.g., `H~2~0`)
and superscripts (e.g., `334^10^`). Thanks to Syohei Yoshida
for a patch on which this is based. ([GH-134][])
- Add basic font-lock support for inline attribute lists or
inline identifiers used by Pandoc, Python Markdown, PHP
Markdown Extra, Leanpub, etc.
- Add basic font-lock support for Leanpub section identifiers and
page breaks.
- Add basic font-lock support for common file inclusion syntax:
`<<(file)`, `<<[title](file)`, `<<[file]`, and `<<{file}`.
- Add font lock support for Pandoc inline footnotes. ([GH-81][])
- Raise footnote markers and inline footnote text, and
optionally hide markup.
- Filling with now respects Pandoc line blocks. ([GH-144][])
- Add interactive link editing and insertion command
`markdown-insert-link`. ([GH-199][])
- Added C-c C-d, `markdown-do`, which is a
replacement for C-c C-l, `markdown-jump`. In
addition to jumping between reference/footnote labels and
definitions, it also toggles GFM checkboxes.
- Outline movement keys C-c C-p, C-c C-n,
C-c C-f, C-c C-b, and C-c C-u
now move between list items, when the point is in a list,
and move between headings otherwise.
- New customization option `markdown-spaces-after-code-fence` to
control the number of spaces inserted after a code fence (` ``` `).
Thanks to Philipp Stephani for a patch. ([GH-232][])
- New customization option `markdown-gfm-uppercase-checkbox` which,
when non-nil, uses `[X]` to complete task list items instead of
`[x]`. Thanks to Paul Rankin for a patch. ([GH-236][])
- Add prefix-specific prompts for styles (`C-c C-s`) and toggles
(`C-c C-x`). These may be disabled if desired by setting
`markdown-enable-prefix-prompts` to `nil`.
* Improvements:
- Document customizable variables added in version 2.2 with
`:package-version` tags.
- Better consistency of function names: predicate functions
ending in `-p` shouldn't modify match data.
- Generalize rebinding of paragraph movement commands in case users
have customized `{forward,backward,mark}-paragraph` bindings.
- Adjust point so that it is left at beginning of setext
headings in heading navigation commands.
- Prevent inline link matching in code blocks.
- When inserting a new reference definition, don't add blank
line after existing reference definitions.
- `markdown-toggle-inline-images` now displays the status in the
minibuffer.
- Increased default heading scaling range slightly, to make
level differences more pronounced when markup is hidden.
- Reuse existing windows, when possible, rather than splitting
again in preferred direction. ([GH-129][])
- Update known languages in `markdown-gfm-recognized-languages`.
- Filling with `fill-region` now leaves code blocks unmodified.
([GH-192][])
- Avoid error when live-previewing a buffer that's not visiting
a file. Thanks to Tianxiang Xiong for a patch.
([GH-200][], [GH-201][])
- Adaptive filling for Leanpub blocks.
- Set variable `comment-use-syntax`. ([GH-213][])
- Support `electric-quote-inhibit-functions` for inhibiting
electric quoting in code spans and blocks. Thanks to Philipp
Stephani for patches to both Emacs and Markdown Mode.
([GH-220][])
- Stop inhibiting line breaks inside links when filling.
([GH-173][])
* Bug fixes:
- Fix spurious bold/italic faces in inline code. ([GH-172][])
- Fix defun movement at end of buffer. ([GH-197][])
- Fix bug with adjacent bold font-locking in a list
item. ([GH-176][])
- Prevent matching italics, bold, and inline code in comments.
- Prevent matching italics and bold in URLs.
- Prevent matching links in inline code or comment spans.
- Avoid infinite loop when promoting or demoting last section in
a buffer.
- Fix font lock for subsequent inline links after a malformed
inline link. ([GH-209][])
- Prevent clobbering match data in
`markdown-font-lock-extend-region-function`. Thanks to
Philipp Stephani for a patch. ([GH-221][])
- Fix incorrect indentation of inserted GFM code blocks in lists.
Thanks to Philipp Stephani for a patch. ([GH-215][])
- Fix an issue with font lock for headings with code blocks immediately
afterwards, without whitespace. ([GH-234][])
[gh-81]: https://github.com/jrblevin/markdown-mode/issues/81
[gh-123]: https://github.com/jrblevin/markdown-mode/issues/123
[gh-130]: https://github.com/jrblevin/markdown-mode/issues/130
[gh-134]: https://github.com/jrblevin/markdown-mode/issues/134
[gh-144]: https://github.com/jrblevin/markdown-mode/issues/144
[gh-164]: https://github.com/jrblevin/markdown-mode/issues/164
[gh-172]: https://github.com/jrblevin/markdown-mode/issues/172
[gh-173]: https://github.com/jrblevin/markdown-mode/issues/173
[gh-176]: https://github.com/jrblevin/markdown-mode/issues/176
[gh-185]: https://github.com/jrblevin/markdown-mode/issues/185
[gh-191]: https://github.com/jrblevin/markdown-mode/issues/191
[gh-192]: https://github.com/jrblevin/markdown-mode/issues/192
[gh-197]: https://github.com/jrblevin/markdown-mode/issues/197
[gh-199]: https://github.com/jrblevin/markdown-mode/issues/199
[gh-200]: https://github.com/jrblevin/markdown-mode/issues/200
[gh-201]: https://github.com/jrblevin/markdown-mode/issues/201
[gh-209]: https://github.com/jrblevin/markdown-mode/issues/209
[gh-213]: https://github.com/jrblevin/markdown-mode/issues/213
[gh-215]: https://github.com/jrblevin/markdown-mode/issues/215
[gh-220]: https://github.com/jrblevin/markdown-mode/pull/220
[gh-221]: https://github.com/jrblevin/markdown-mode/pull/221
[gh-232]: https://github.com/jrblevin/markdown-mode/pull/232
[gh-234]: https://github.com/jrblevin/markdown-mode/issues/234
[gh-236]: https://github.com/jrblevin/markdown-mode/pull/236
# Markdown Mode 2.2
*May 26, 2017*
Version 2.2 is a major new stable release and all users are encouraged
to upgrade. Thanks to everyone who submitted bug reports, feature
suggestions, and especially patches.
* **Breaking changes:**
- Now use C-c C-j for inserting list items, like
AUCTeX and similar to other programming modes. Since C-c
C-j was used for `markdown-jump` (for moving between
reference link/footnote markers and their definitions), it has
been changed to C-c C-l (think "leap" or "loop"
instead of jump). It's also close to C-c C-o (used
for opening links). ([GH-26][])
- Insertion of `kbd` tags with C-c C-s k or
`markdown-insert-kbd`.
- Add YAML metadata parsing. Also allow multiple Pandoc
metadata, with tests. Thanks to Danny McClanahan and Syohei
Yoshida. ([GH-66][], [GH-91][], [GH-155][], [GH-156][],
[GH-157][])
- Change the behavior of C-c C-o
(`markdown-follow-link-at-point`) so that if a link is a
complete URL, it will open in a browser. Otherwise, open it
with `find-file` after stripping anchors and/or query strings.
([GH-132][])
- Make font lock for missing wiki links optional and disabled by
default. Add new custom variable
`markdown-wiki-link-fontify-missing` to control this behavior.
- The _function_ `markdown-enable-math` has been made obsolete
and renamed to `markdown-toggle-math`. When called without an
argument, the result is to toggle this extension rather than
enable it.
* New features:
- Filling for definition list items. ([GH-13][])
- Added option `markdown-gfm-downcase-languages` to use
lowercase language name in GFM code blocks.
([GH-71][], [GH-73][])
- Customizable live preview window split direction via
`markdown-split-window-direction`. ([GH-129][], [GH-188][])
- Variable-height headings via
`markdown-header-scaling`. ([GH-121][])
- Implement inline image previews via
`markdown-toggle-inline-images` and C-c C-i C-t.
Thanks to Syohei Yoshida. ([GH-122][], [GH-128][])
- Added `markdown-wiki-link-search-subdirectories` to enable
searching for wiki link files in subdirectories. ([GH-174][])
- Added option to automatically continue lists when `RET` is
pressed. `markdown-indent-on-enter` now has three settings.
([GH-179][])
- Match fenced code blocks with language and info strings.
([GH-184][])
- Add smart Markdown block navigation commands M-{
and M-}. These replace the
regular-expression-based "paragraph" movement commands
provided by Emacs, which do not recognize Markdown syntax
(e.g., headings inside of code blocks). Also use
M-h for marking a block and C-x n b to
narrow to a block.
- Add `markdown-nested-imenu-heading-index` as a customizable
option. It may be disabled to instead generate a flat imenu
index.
- Basic font lock and filling for definition lists. As a side
effect, list item navigation and movement should also work.
- Add command for toggling GFM task list items via
C-c C-c C-x (`markdown-toggle-gfm-checkbox`).
- Ability to toggle wiki link support via a new custom variable
`markdown-enable-wiki-links`. This may be set in a file local
variable. Also added function `markdown-toggle-wiki-links`
and a menu item.
* Improvements:
- Menubar reorganization. Grouped related actions together,
added missing commands, and added several toggle options to
the menu. ([GH-147][])
- Use `toggle` menu style for macOS compatibility.
- Remove autoload for `.text` files. Thanks to Steve Purcell.
([GH-118][])
- Set own `adaptive-fill-regexp` so that `fill-paragraph` works
for list items. Thanks to Syohei Yoshida for the patch.
([GH-79][], [GH-80][])
- Suppress minibuffer output when generated HTML is small.
Thanks to Syohei Yoshida. ([GH-83][], [GH-86][])
- Use GitHub fetcher for `markdown-mode` on MELPA. ([GH-84][])
- Improve fenced code block parsing. Thanks to Danny McClanahan.
([GH-85][], [GH-95][])
- Markdown Mode is now automatically tested against Emacs
24.1-24.5 and 25.1-25.2. ([GH-99][])
- Make live-preview mode follow min or max point. Thanks to
Danny McClanahan. ([GH-102][])
- Improved font-lock performance. ([GH-119][])
- Maintain cursor position when indenting instead of moving to
the beginning of the line. Thanks to Isaac Hodes.
([GH-125][])
- Add used language names to front of list of known languages.
([GH-135][])
- Support basic TOML metadata. Thanks to Jorge Israel Peña.
([GH-137][])
- Prohibit setext heading text from starting with hyphens,
spaces or tabs, so that there is no ambiguity between setext
headings and in-progress lists. ([GH-139][], [GH-143][])
- Ignore heading lines in `fill-paragraph`. Thanks to Syohei
Yoshida. ([GH-159][], [GH-162][])
- Improve matching of multiple math blocks with non-math text in
between. Thanks to Dave Kleinschmidt for a patch.
([GH-168][])
- Prevent `fill-paragraph` from filling lines in code blocks.
([GH-169][])
- Fix font lock for links with URLs containing parentheses.
([GH-170][])
- `fill-paragraph` now respects paragraph boundaries within
blockquotes. ([GH-186][])
- Set mark when calling `markdown-up-heading`.
- Improved font locking after empty GFM code block insertion.
- Fix spurious italics from underscores in URLs.
- Respect `font-lock-mode` being nil. Only call
`font-lock-refresh-defaults` if `font-lock-mode` is non-nil to
prevent it from being turned on when disabled by user. Thanks
to Tom May for the patch.
- Fix list item insertion on ordered lists with hash marks
(Pandoc "fancy lists").
- Treat polymode blocks as code blocks when parsing the buffer.
- Require whitespace atx heading hashmarks, as required by the
original atx specification (but not enforced by Markdown.pl).
The benefit is that it prevents false positives for #hashtags
and things like "Engine #1" when lines wrap.
- Complete heading markup when point is on an setext heading and
`markdown-insert-header-dwim` is invoked
(C-c C-t h).
- Better point position after inserting asymmetric atx headings.
* Bug fixes:
- Fix `scripts/get-recognized-gfm-languages.el`, which skipped
languages with spaces. ([GH-72][], [GH-82][])
- `README.md` specified Arch (AUR) package (`emacs-goodies-el`),
which did not exist. ([GH-74][])
- Don't accidentally override user entries in `auto-mode-alist`.
([GH-127][])
- Fix `markdown-cycle` issue with heading-like strings in code
blocks. Thanks to Syohei Yoshida. ([GH-75][], [GH-76][])
- Fix moving same level heading over code block issue. Thanks
to Syohei Yoshida. ([GH-77][], [GH-78][])
- Don't insert empty title strings for links. Thanks to
Sebastian Wiesner for the patch. ([GH-89][])
- Fix possible infinite loop in `markdown-cleanup-list-numbers`.
Thanks to Danny McClanahan. ([GH-98][], [GH-100][])
- Fix an args-out-of-range error due to the syntax-propertize
function returning point which is larger than `point-max`.
Thanks to Syohei Yoshida. ([GH-142][])
- Respect narrowed region in `markdown-find-previous-prop`.
Thanks to Vitalie Spinu. ([GH-109][])
- Move point at least 1 char in
`markdown-match-propertized-text` to avoid possible infinite
loop in font-lock. Thanks to Vitalie Spinu. ([GH-110][])
- Fix issues where buffers could be marked as modified when no
modifications were made. ([GH-115][], [GH-116][], [GH-146][])
- Fix an issue where comments of the form ``
were not correctly identified. ([GH-117][])
- Prevent spurious bold fontification. Thanks to Kévin Le
Gouguec. ([GH-124][])
- Keep metadata visible when cycling visibility. ([GH-136][])
- `markdown-syntax-propertize-extend-region` should not
overwrite match-data, which caused issues with
`replace-regexp`, etc. ([GH-104][], [GH-105][])
- Don't list heading-like lines in code blocks or metadata in
imenu. Thanks to Syohei Yoshida. ([GH-145][], [GH-154][])
- Fix an issue where fill paragraph wouldn't work following
unclosed left square brackets. ([GH-148][], [GH-161][])
- Fix default language presented when inserting GFM code blocks.
Thanks to Conal Elliot for a patch. ([GH-152][])
- Backspace now always deletes characters if a region is
specified. Thanks to Syohei Yoshida.
([GH-166][], [GH-167][])
- Fix `markdown-header-face` inherit from nil error, e.g., when
exporting HTML from an Org mode file containing a Markdown
source block. Thanks to Moogen Tian for a patch.
([GH-190][], [GH-193][])
- Inserting a reference link no longer causes an "args out of
range" commit error when the existing reference label is a
single commit character.
- Fix to honor location setting when inserting reference
definitions.
- Fixed an issue where, if there is special markup at the end of
the buffer, deleting a character backward would cause the
font-lock faces to disappear.
- Fix incorrect matching of italic text due to underscores in
math mode. Thanks also to Dave Kleinschmidt.
- Fix italic highlighting issue when each line or both lines are list.
- Handle false positive italics across list items.
[gh-13]: https://github.com/jrblevin/markdown-mode/issues/13
[gh-26]: https://github.com/jrblevin/markdown-mode/issues/26
[gh-66]: https://github.com/jrblevin/markdown-mode/issues/66
[gh-71]: https://github.com/jrblevin/markdown-mode/issues/71
[gh-72]: https://github.com/jrblevin/markdown-mode/issues/72
[gh-73]: https://github.com/jrblevin/markdown-mode/issues/73
[gh-74]: https://github.com/jrblevin/markdown-mode/issues/74
[gh-75]: https://github.com/jrblevin/markdown-mode/issues/75
[gh-76]: https://github.com/jrblevin/markdown-mode/pull/76
[gh-77]: https://github.com/jrblevin/markdown-mode/pull/77
[gh-78]: https://github.com/jrblevin/markdown-mode/pull/78
[gh-79]: https://github.com/jrblevin/markdown-mode/issues/79
[gh-80]: https://github.com/jrblevin/markdown-mode/pull/80
[gh-82]: https://github.com/jrblevin/markdown-mode/pull/82
[gh-83]: https://github.com/jrblevin/markdown-mode/issues/83
[gh-84]: https://github.com/jrblevin/markdown-mode/issues/84
[gh-86]: https://github.com/jrblevin/markdown-mode/pull/86
[gh-85]: https://github.com/jrblevin/markdown-mode/issues/85
[gh-89]: https://github.com/jrblevin/markdown-mode/pull/89
[gh-91]: https://github.com/jrblevin/markdown-mode/pull/91
[gh-95]: https://github.com/jrblevin/markdown-mode/pull/95
[gh-98]: https://github.com/jrblevin/markdown-mode/issues/98
[gh-99]: https://github.com/jrblevin/markdown-mode/pull/99
[gh-100]: https://github.com/jrblevin/markdown-mode/pull/100
[gh-102]: https://github.com/jrblevin/markdown-mode/pull/102
[gh-104]: https://github.com/jrblevin/markdown-mode/issues/104
[gh-105]: https://github.com/jrblevin/markdown-mode/pull/105
[gh-109]: https://github.com/jrblevin/markdown-mode/pull/109
[gh-110]: https://github.com/jrblevin/markdown-mode/pull/110
[gh-115]: https://github.com/jrblevin/markdown-mode/issues/115
[gh-116]: https://github.com/jrblevin/markdown-mode/pull/116
[gh-117]: https://github.com/jrblevin/markdown-mode/issues/117
[gh-118]: https://github.com/jrblevin/markdown-mode/pull/118
[gh-119]: https://github.com/jrblevin/markdown-mode/issues/119
[gh-121]: https://github.com/jrblevin/markdown-mode/issues/121
[gh-122]: https://github.com/jrblevin/markdown-mode/issues/122
[gh-124]: https://github.com/jrblevin/markdown-mode/issues/124
[gh-125]: https://github.com/jrblevin/markdown-mode/pull/125
[gh-127]: https://github.com/jrblevin/markdown-mode/issues/127
[gh-128]: https://github.com/jrblevin/markdown-mode/pull/128
[gh-129]: https://github.com/jrblevin/markdown-mode/issues/129
[gh-132]: https://github.com/jrblevin/markdown-mode/pull/132
[gh-135]: https://github.com/jrblevin/markdown-mode/issues/135
[gh-136]: https://github.com/jrblevin/markdown-mode/issues/136
[gh-137]: https://github.com/jrblevin/markdown-mode/issues/137
[gh-139]: https://github.com/jrblevin/markdown-mode/issues/139
[gh-142]: https://github.com/jrblevin/markdown-mode/pull/142
[gh-143]: https://github.com/jrblevin/markdown-mode/issues/143
[gh-145]: https://github.com/jrblevin/markdown-mode/issues/145
[gh-154]: https://github.com/jrblevin/markdown-mode/pull/154
[gh-146]: https://github.com/jrblevin/markdown-mode/pull/146
[gh-147]: https://github.com/jrblevin/markdown-mode/issues/147
[gh-148]: https://github.com/jrblevin/markdown-mode/issues/148
[gh-152]: https://github.com/jrblevin/markdown-mode/issues/152
[gh-155]: https://github.com/jrblevin/markdown-mode/issues/155
[gh-156]: https://github.com/jrblevin/markdown-mode/issues/156
[gh-157]: https://github.com/jrblevin/markdown-mode/pull/157
[gh-159]: https://github.com/jrblevin/markdown-mode/issues/159
[gh-161]: https://github.com/jrblevin/markdown-mode/issues/161
[gh-162]: https://github.com/jrblevin/markdown-mode/pull/162
[gh-166]: https://github.com/jrblevin/markdown-mode/issues/166
[gh-167]: https://github.com/jrblevin/markdown-mode/pull/167
[gh-168]: https://github.com/jrblevin/markdown-mode/pull/168
[gh-169]: https://github.com/jrblevin/markdown-mode/issues/169
[gh-170]: https://github.com/jrblevin/markdown-mode/issues/170
[gh-174]: https://github.com/jrblevin/markdown-mode/issues/174
[gh-179]: https://github.com/jrblevin/markdown-mode/issues/179
[gh-184]: https://github.com/jrblevin/markdown-mode/issues/184
[gh-186]: https://github.com/jrblevin/markdown-mode/issues/186
[gh-188]: https://github.com/jrblevin/markdown-mode/pull/188
[gh-190]: https://github.com/jrblevin/markdown-mode/pull/190
[gh-193]: https://github.com/jrblevin/markdown-mode/issues/193
# Markdown Mode 2.1
*January 9, 2016*
Version 2.1 is a major new stable release and all users are encouraged
to upgrade. The many new features and bug fixes included are
described below.
Markdown Mode is developed and tested primarily for compatibility with
GNU Emacs versions 24.3 and later. It requires `cl-lib` version 0.5
or later. This library has been bundled with GNU Emacs since version
24.3. Users of GNU Emacs 24.1 and 24.2 can install `cl-lib` using
`M-x package-install RET cl-lib`.
This release of Markdown Mode contains patches written by many
individuals including Masayuki Ataka, Jonas Bernoulli, Roger Bolsius,
Daniel Brotsky, Julien Danjou, Samuel Freilich, David Glasser, Marijn
Haverbeke, Antonis Kanouras, Keshav Kini, Vasily Korytov, Danny
McClanahan, Matt McClure, Howard Melman, Makoto Motohashi, Jon
Mountjoy, Pierre Neidhardt, Spanti Nicola, Paul W. Rankin, Christophe
Rhodes, Tim Visher, and Syohei Yoshida. Many others also submitted
bug reports. Thanks to everyone for your contributions.
* **Breaking changes:**
- In GFM Mode, `visual-line-mode` is no longer enabled by
default. A `gfm-mode-hook` was added, which could be used to
keep `visual-line-mode` on by default in `gfm-mode`.
([GH-31][])
* New features:
- Add automatically updating live preview functionality
(C-c C-c l) via the native `eww` browser.
([GH-36][], [GH-53][], [GH-57][], [GH-58][], [GH-63][])
- Use `autoload` to enable `markdown-mode` in `auto-mode-alist`
for files with `.text`, `.markdown`, and `.md` extensions.
- Use Travis CI for automated build testing.
- ATX heading subtree promotion and demotion via
M-S-LEFT, and M-S-RIGHT.
- ATX heading subtree moving up and down via M-S-UP
and M-S-DOWN.
- Convert inline links to reference links when
`markdown-insert-reference-link-dwim` is used when the point
is at an inline link.
- Allow linking to multiple stylesheets in `markdown-css-paths`
list. Use stylesheets for both preview and export. Previous
`markdown-css-path` (singular) is now deprecated.
- Customizable default unordered list marker via
`markdown-unordered-list-item-prefix`.
- Add asymmetric ATX heading adornment option
`markdown-asymmetric-header`.
- Font lock for `` tags.
- Support GFM-style code blocks in `markdown-mode` (as well as
`gfm-mode`). ([GH-2][])
- New function `markdown-electric-backquote` will prompt for a
language name for GFM code blocks. This can be disabled by
customizing the variable
`markdown-gfm-use-electric-backquote`. ([GH-9][])
- Completion of programming language names for GFM code blocks.
A list of pre-defined languages is included, but this can be
augmented by setting `markdown-gfm-additional-languages`.
([GH-38][], [GH-54][], [GH-59][], [GH-60][], [GH-64][])
- Strikethrough support in `gfm-mode`.
- Support for GFM toggling checkboxes `mouse-1` or
RET. This is controlled by a new custom variable,
`markdown-make-gfm-checkboxes-buttons`. Thanks to Howard
Melman for a patch. ([GH-7][])
- Font lock and filling for Pandoc "fancy lists," which use `#`
as the list marker. ([GH-3][])
- Basic support for filling of definition lists. ([GH-20][])
- Support [Ikiwiki](http://ikiwiki.info/)-style search for wiki links that allows
links relative to parent directories. Enable this by setting
`markdown-wiki-link-search-parent-directories`.
([GH-8][], [GH-21][])
* Improvements:
- General font lock improvements for comments, code blocks,
blockquotes, headings, horizontal rules, bold, and italics.
([GH-67][], [GH-68][])
- Separate highlighting for Markdown markup characters
(asterisks, underscores, backquotes, etc.) to aid in
readability.
- Font lock for bold, italics, and LaTeX math work inside block
elements such as headings and blockquotes. ([GH-39][])
- Display a link to the GitHub repository in the MELPA
description. ([GH-37][])
* Bug fixes:
- Fix bug in `markdown-complete-region/buffer` where level-two
Setext headings could be confused with horizontal rules.
Includes a unit test. Thanks to Gunnar Franke for the report.
- Fix filling when a decimal number appears at column zero,
which could be confused with an ordered list item.
- Fix buffer-wide markup completion.
- Fix font-lock for GFM code blocks without language keywords.
- Improved Setext header insertion to support wide characters.
- Fix expensive `paragraph-separate` regular expression.
- Make `comment-auto-fill-only-comments` a buffer-local
variable, which allows for better default filling behavior in
cases where the global variable is non-`nil`.
- Fix Emacs 23 compatibility by checking for
`font-lock-refresh-defaults` before calling it.
- Handle reference definitions when filling paragraphs.
- Improve filling of list items with indentation.
- Properly handle footnotes when filling.
- Fix issues with markdown-footnote-kill and related functions.
- Improve font lock for fenced code blocks.
- Avoid avoid overwriting source file when exporting if source
file has `.html` extension.
- Fix and improve ordered list behavior to preserve digit
spacing and avoid an infinite loop in certain cases. Adjust
ordered list whitespace when marker digit count increases.
- Improve reference definition regular expression to avoid
matching multiple reference links in one line.
- Allow spaces in fenced code language identifiers. ([GH-22][])
- Improve font lock for preformatted blocks and fenced code
blocks.
- Fix out-of-order HTML output. ([GH-14][])
- Add console-friendly backspace and tab bindings. ([GH-15][])
- Better treatment of files without extensions for wiki links.
When files have no extensions, don't append a lone period.
([GH-23][])
- Call `looking-back` with two arguments for compatibility with
Emacs 25.1.
- Make `(beginning-of-defun -1)` go to next title when point is
at beginning of defun. ([GH-34][])
- Ignore headings in code blocks for font lock, movement, and
visibility cycling.
([GH-27][], [GH-33][], [GH-35][], [GH-40][], [GH-41][])
- Don't highlight wiki links in code blocks. ([GH-17][])
- Don't move to links in code blocks with C-c C-p and
C-c C-n.
- Fix hanging indentation for list items and single-line
preformatted blocks. ([GH-16][], [GH-28][], [GH-30][])
- Better rejection of false positives for italics with respect
to other inline elements (inline code and bold).
- Predicate functions should not modify match data.
- Use correct list marker from previous list level when using
C-u M-RET to insert a dedented list item. Prevent
an infinite loop in some cases. ([GH-4][])
- Reduce lag when scrolling or inserting text into large files.
([GH-30][], [GH-101][])
- Avoid confusing tramp errors with malformed wiki links.
([GH-65][])
[gh-2]: https://github.com/jrblevin/markdown-mode/pull/2
[gh-3]: https://github.com/jrblevin/markdown-mode/pull/3
[gh-4]: https://github.com/jrblevin/markdown-mode/issues/4
[gh-7]: https://github.com/jrblevin/markdown-mode/issues/7
[gh-8]: https://github.com/jrblevin/markdown-mode/issues/8
[gh-9]: https://github.com/jrblevin/markdown-mode/issues/9
[gh-14]: https://github.com/jrblevin/markdown-mode/issues/14
[gh-15]: https://github.com/jrblevin/markdown-mode/issues/15
[gh-16]: https://github.com/jrblevin/markdown-mode/issues/16
[gh-17]: https://github.com/jrblevin/markdown-mode/issues/17
[gh-18]: https://github.com/jrblevin/markdown-mode/issues/18
[gh-20]: https://github.com/jrblevin/markdown-mode/issues/20
[gh-21]: https://github.com/jrblevin/markdown-mode/issues/21
[gh-22]: https://github.com/jrblevin/markdown-mode/issues/22
[gh-23]: https://github.com/jrblevin/markdown-mode/issues/23
[gh-27]: https://github.com/jrblevin/markdown-mode/issues/27
[gh-28]: https://github.com/jrblevin/markdown-mode/issues/28
[gh-30]: https://github.com/jrblevin/markdown-mode/issues/30
[gh-31]: https://github.com/jrblevin/markdown-mode/issues/31
[gh-32]: https://github.com/jrblevin/markdown-mode/pull/32
[gh-33]: https://github.com/jrblevin/markdown-mode/issues/33
[gh-34]: https://github.com/jrblevin/markdown-mode/pull/34
[gh-35]: https://github.com/jrblevin/markdown-mode/pull/35
[gh-36]: https://github.com/jrblevin/markdown-mode/pull/36
[gh-37]: https://github.com/jrblevin/markdown-mode/issues/37
[gh-38]: https://github.com/jrblevin/markdown-mode/issues/38
[gh-39]: https://github.com/jrblevin/markdown-mode/issues/39
[gh-40]: https://github.com/jrblevin/markdown-mode/pull/40
[gh-41]: https://github.com/jrblevin/markdown-mode/pull/41
[gh-53]: https://github.com/jrblevin/markdown-mode/pull/53
[gh-54]: https://github.com/jrblevin/markdown-mode/pull/54
[gh-57]: https://github.com/jrblevin/markdown-mode/pull/57
[gh-58]: https://github.com/jrblevin/markdown-mode/pull/58
[gh-59]: https://github.com/jrblevin/markdown-mode/pull/59
[gh-60]: https://github.com/jrblevin/markdown-mode/pull/60
[gh-63]: https://github.com/jrblevin/markdown-mode/pull/63
[gh-64]: https://github.com/jrblevin/markdown-mode/pull/64
[gh-65]: https://github.com/jrblevin/markdown-mode/pull/65
[gh-67]: https://github.com/jrblevin/markdown-mode/pull/67
[gh-68]: https://github.com/jrblevin/markdown-mode/pull/68
[gh-101]: https://github.com/jrblevin/markdown-mode/issues/101
# Markdown Mode 2.0
*March 24, 2013*
Version 2.0 is a major new stable release with many new features,
including some changes to keybindings for element insertion and
outline navigation. In summary, Markdown Mode now has improved
keybindings, smarter markup insertion commands, a general markup
removal command, markup completion (normalization), markup promotion
and demotion, list and region editing, many syntax highlighting
improvements, new and improved movement commands, and generalized link
following and movement.
* **Breaking changes:**
- Physical style element insertion commands prefixed by
C-c C-p have been removed in favor of their
logical style counterparts prefixed by C-c C-s.
- Shift is now the preferred way to distinguish keybindings for
two related elements. For example, you can insert an inline
link with C-c C-a l or a reference link with
C-c C-a L. The latter keybinding is new and
preferred over C-c C-a r, which is deprecated.
- Footnote keybindings have been moved away from the
C-c C-f n prefix.
- Several other new keybindings have been introduced and are
described in more detail below.
- Removed wiki link following with `RET` and
`markdown-follow-wiki-link-on-enter` setting. Use the
unified following (open link) command C-c C-o
instead.
* New features:
- Fast heading insertion with a single command which
automatically calculates the type (atx or setext) and level.
Prefix with C-u to promote the heading by one
level or C-u C-u to demote the heading by one
level. Headings with a specific level or type can still be
inserted quickly with specific keybindings.
- Easily kill an element (e.g., a link or reference definition)
at the point with C-c C-k and store the most
important part in the kill ring (e.g., the link text or URL).
- Markup completion (C-c C-]) normalizes the markup
for an element (e.g., it balances hash marks and removing
extra whitespace for atx headings).
- Markup promotion and demotion via C-c C-- and
C-c C-=, respectively. The sequences
M-UP and M-DOWN may
also be used.
- List editing: move list items up and down with
M-UP and M-DOWN.
Indent and exdent list items with M-LEFT
and M-RIGHT.
- Region editing: indent and exdent regions, with tab stops
determined by context, using C-c < and
C-c > (as in `python-mode`).
- Smart list item insertion with M-RET, with
indentation and marker determined by the surrounding context.
Prefix with C-u to decrease the indentation by one
level or C-u C-u to increase the indentation one
level.
- Quickly jump between reference definitions and
reference-style links and between footnote markers and
footnote text with C-c C-j. Create undefined
references when jumping from a reference link. When jumping
back, present a buffer with buttons for selecting which link
to jump to.
- Revised outline navigation commands, following `org-mode`.
This frees up the sexp navigation keys C-M-f and
C-M-b which can be useful in Markdown documents
which have many matching delimiters, as well as the defun
navigation keys C-M-a and C-M-e.
- Previous/next section movement with C-M-a and
C-M-e (in Emacs parlance, this is movement by
defun). Mark the current section with C-M-h.
- Previous/next paragraph movement via M-{ and
M-}.
- Previous/next block movement with C-u M-{ and
C-u M-}.
- Customizable reference link location via
`markdown-reference-location`.
- Font lock for title strings in inline links.
- Subtle syntax highlighting for hard line breaks.
- In GFM Mode, change italic font lock behavior to match GFM
specification regarding underscores in words.
- Insertion command (C-c C-s P) for GFM quoted code
blocks.
- Syntax highlighting for MultiMarkdown metadata and Pandoc
title blocks.
- Added before and after export hooks
`markdown-before-export-hook` and
`markdown-after-export-hook`.
- Added a library of regression tests which currently contains
160 unit tests.
* Improvements:
- ATX heading insertion will use current line as heading text
if not blank and there is no active region.
- Setext heading insertion will prompt for heading title when
there is no active region.
- When the point is at a heading, the heading insertion
commands will replace the heading at point with a heading of
the requested level and type.
- When there is no active region, the bold, italic, code, link,
and image insertion commands will operate on the word at
point, if any, so that you don't have to have an active
selection for simple modifications.
- Repeating the bold, italic, or code insertion commands when
the point is at an element of the corresponding type will
remove the markup.
- Indentation of preformatted text and blockquotes will be
adjusted automatically in contexts where more indentation is
required, as in nested lists. (For example, in Markdown, a
preformatted text block inside a first-level list item must
have eight spaces of indentation.)
- Improved reference link insertion with label completion:
+ Use word at point as link text, if possible, when there
is no active region.
+ Tab completion of reference labels from the set of
currently defined references.
+ Reference link insertion no longer prompts for a URL or
title if the label is already defined.
+ If no URL is given, create an empty reference definition
and move the point there.
- Basic reference-style image markup insertion.
- Multiple horizontal rule styles, `markdown-hr-strings`,
customizable as a list of strings, which can be cycled
through.
- New URL insertion command for inserting plain URLs delimited
by angle brackets (C-c C-a u). Works on URL at
point, if any, when there is no active region.
- Generally improved insertion commands with respect to
insertion of surrounding whitespace and point position after
insertion (e.g., ensuring blank lines before and after newly
inserted headings and horizontal rules).
- Unified link following: open links in a browser and wiki
links in a new buffer with the same keybinding (C-c
C-o). This supersedes the separate wiki link following
command (C-c C-w).
- Generalized link movement and following: move between and
open all link types (inline, reference, wiki, angle URIs)
using the same key bindings (M-n and
M-p). Previously, these commands only moved
between wiki links, but with the above following enhancement,
moving between hyperlinks of all types is more useful.
- Syntax highlighting for GFM quoted code blocks with an
optional language keyword.
- Dynamic loading and unloading for math support with
refontification.
- Allow underscores and colons in equation labels in math mode.
- Syntax highlighting improvements: faster identification of
preformatted blocks. Markdown Mode adheres to the four space
rule for nested list items: in a list item of level _n_,
preformatted text must be indented at least 4(_n_ + 1)
spaces.
- More inclusive blockquote regular expression highlights
blockquotes with leading indentation, when appropriate.
- Regular expression optimization for URI matching.
- Numerous other improvements for more accurate syntax
highlighting.
- Respect hard line breaks when filling paragraphs.
- Add indentation positions: preceding list markers and pre
block position.
- Use button-map for navigating undefined references, so that
references can be navigated via the keyboard by pressing
TAB and S-TAB.
- Use newer `use-region-p` when possible to check for active
region, with fallbacks for older Emacsen and Xemacs.
- Clean up whitespace after deleting footnote text.
- Use adaptive filling for list items and blockquotes.
- Treat all list items (any marker type) the same way with respect
to filling.
- Retain the `>` prefix when filling blockquotes.
- Fill list items inside of blockquotes.
- Numerous other internal improvements to make the code base
more robust.
* Bug fixes:
- Fix bug in heading visibility cycling introduced in version
1.9 where the level of headings was being calculated
incorrectly.
- Fix problems inserting ATX headings at end of buffer.
- Support small Setext headings (with fewer than three
characters).
- Several improvements to inline code syntax highlighting.
- Fix some edge cases regarding escaping, spaces, etc. for bold
and italic font lock.
- Prohibit newlines and tabs immediately after opening bold and
italic delimiters. This fixes a bug where italics would not
be highlighted following a horizontal rule
- Improved multi-line font lock performance for large files.
- Improved multi-line font lock at beginning of buffer.
- List items with any of the three markers are filled in the
same way (previously list items starting with `+` were not
filled with hanging indentation).
- Fix end detection for empty list items. Don't skip over the
whitespace following the marker on the same line.
Previously, empty list items were not being detected properly
by `markdown-cur-list-item-bounds` as a result of this.
- Don't exclude `[^]`, which is a valid reference tag (but
let's please stick to alphanumeric characters).
- No longer highlight escaped wiki links.
- Fix line number buttons for reference checking and make all
buttons clickable.
- Fix killing of footnotes with no text.
- Fix escaping in `markdown-xhtml-standalone-regexp`.
- Fix a font-lock edge case involving footnote markers
preceding inline links.
- More accurate font-lock for ATX headings in edge cases.
- Fix killing of footnotes from footnote text.
--- ---
# Markdown Mode 1.9
*January 1, 2013*
Version 1.9 is a major new stable release with important bug fixes.
* New features:
- Support for setext-style headers in `outline-mode`. Thanks
to Shigeru Fukaya.
- Font lock for tilde-fenced code blocks.
- Reference link insertion (C-c C-a r).
- Support two forms of aliased wiki links:
`[[link text|PageName]]` and `[[PageName|link text]]`
(`markdown-wiki-link-alias-first`).
- Footnote support: font lock and insertion, deletion, and
navigation functions for footnotes (prefixed by
C-c C-f; following for wiki links is now
C-c C-w). Thanks to Joost Kremers.
- Improved preview and export commands. Thanks to Donald
Ephraim Curtis.
- `imenu` support. Thanks to Akinori Musha.
- Added autoload token for `gfm-mode`. Thanks to Max Penet and
Peter Eisentraut for the suggestion.
- Optional character set declaration in XHTML output. Thanks
to François Gannaz for the suggestion.
- Smart unindentation when pressing delete at the beginning of
a line. Thanks to Zhenlei Jia.
- Optional prefix argument to C-c C-w for opening
wiki links in another window.
- Open inline and reference links and inline URIs in browser
(C-c C-o). Thanks to Peter Jones.
- Open files in a standalone previewer or editor
(C-c C-c o).
- Clean up numbered/ordered lists (C-c C-c n).
Thanks to Donald Ephraim Curtis.
- Save Markdown output to kill ring (copy to clipboard)
(C-c C-c w). Thanks to Donald Ephraim Curtis.
* Improvements:
- Improve `markdown-mode-hook` docstring. Thanks to Shigeru
Fukaya for the more precise description.
- Don't require Common Lisp extensions at run time. Thanks to
Shigeru Fukaya.
- Prefer `visual-line-mode`, the replacement for
`longlines-mode`, when in `gfm-mode`. Thanks to Christopher
J. Madsen.
- Proper GitHub wiki link handling in `gfm-mode`. Thanks to
Kevin Porter.
- XEmacs compatibility:
- Avoid malformed list errors during font definitions.
- Handle replace-regexp-in-string.
- Use text properties instead of overlays.
- Fall back to `set-buffer-modified-p` when
`restore-buffer-modified-p` is unavailable.
- Many additional fixes. Thanks to Michael Sperber.
- Handle wiki links in buffers not associated with a file.
- Update autoload documentation to support byte compilation.
- Option to use `-` instead of `_` for wiki links in
`gfm-mode`.
- Add two tab stops to possible indentation positions following
list items.
* Bug fixes:
- Fixed a bug which caused unusual behavior in functions
performing search, replace, and/or matching operations.
Thanks to Christopher J. Madsen for the patch.
- Fixed a bug which caused an incompatibility with
`orgtbl-mode`. Thanks to Vegard Vesterheim for the report
and to Carsten Dominik for a patch.
- Fixed a bug where reference links at the beginning of a line
would be mistaken for reference definitions.
- Improved font lock for headers.
- Improved font lock for reference definitions. Thanks to Ian
Yang.
- Avoid byte compiler warning about `region-exists-p` in GNU
Emacs.
- Additional key bindings for cross-platform header cycling
compatibility.
- Fix problem with externally modified files on disk where the
user would get stuck in a loop answering "really edit the
buffer?" Thanks to Bryan Fink for a detailed report.
- Font lock fix for URLs with underscores.
- Escape shell commands to handle filenames with spaces, etc.
Thanks to Marcin Kasperski for a patch.
- Use `:slant` instead of unsupported `:italic` in font spec.
- Fix typo in `paragraph-fill` regexp.
# Markdown Mode 1.8.1
*August 15, 2011*
Version 1.8.1 is a bugfix version which addresses some minor issues in
version 1.8.
* New features:
- Wiki link features now support aliased or piped wiki links of
the form `[[PageName|link text]]`.
* Bug fixes:
- Fixed an issue, reported by Werner Dittmann, where the
default indentation position would be skipped over when
`auto-fill-mode` was on. This meant that when writing a
normal paragraph, for example, the line would wrap to column
4 instead of column 1.
- Require the `cl` package for `multiple-value-bind`. Thanks
to Werner Dittman for noticing this.
- Remove a leftover debug print message which would announce
"ENTER" in the minibuffer when the enter key was pressed.
# Markdown Mode 1.8
*August 12, 2011*
* New features:
- Add support for following wiki links in a buffer, either with
C-c C-f or, optionally, RET, when the
point is at a wiki link.
- Support Markdown processors which do not accept input from
stdin (i.e, Python-Markdown) by adding the
`markdown-command-needs-filename` custom option. Thanks to
Jeremiah Dodds for a patch.
- GitHub-Flavored Markdown mode (`gfm-mode`) turns on
`longlines-mode` and `auto-fill-mode`. Thanks to Edward
O'Connor for the patch.
- Add outline-mode-like keybindings for fast outline navigation
of atx-style headers (see the updated documentation for
details).
- Arbitrary content may to be added to the `` block during
HTML output to allow for flexible local customizations. See
`markdown-xhtml-header-content`.
- New HTML export options: export to a file with
C-c C-c e or export to a file and view with
C-c C-c v.
- Support Markdown processors which produce standalone output
(i.e., complete HTML documents). If this is detected, by
matching `markdown-xhtml-standalone-regexp` in the first five
lines of output, then omit the `markdown-mode` header and
footer. Thanks to Philippe Ivaldi for this and the previous
HTML-output-related patches.
- Customizable wiki link following behavior using
`markdown-follow-wiki-link-on-enter`.
- Quick navigation to the previous and next wiki links using
M-p and M-n.
- Wiki links to non-existent files (missing links) are
highlighted differently. Based on functionality from
`wiki-mode` by Alex Schroeder. Thanks to Eric Merritt for
patches.
* Improvements:
- Improve syntax highlighting of preformatted text blocks to
better distinguish them from list items with hanging
indentation and nested list items.
- Match italic and bold text and inline code fragments across
line breaks, within a single block, but prevent them from
matching across blocks.
- Generally improve multi-line font lock by extending the search
region to include full blocks.
- Make indentation work when the previous line is not indented.
- Set tab width to 4, the natural tab width for Markdown
documents.
- Stop announcing "TAB" in the minibuffer when tab is pressed.
- Use `html-mode` for viewing Markdown output.
- Ensure Markdown output buffer is always raised, even when the
output is short.
- Make sure horizontal rules inserted by C-c -
(`markdown-insert-hr`) are surrounded by blank lines.
- Added an `autoload` cookie. Thanks to Peter S. Galbraith for
the patch.
- Support a customizable horizontal rule string
`markdown-hr-string`. This replaces the previous but less
flexible custom option `markdown-hr-length`, which has been
removed.
- Followed wiki links are opened using `markdown-mode`.
* Bug fixes:
- Fixed an issue, reported by Joost Kremners, where for
multi-line lists, the position of the list marker was not
being added to the list of possible indentation levels.
- Avoid a problem where indentation positions were getting
skipped over when tab cycling.
- Fixed an issue when column 0 is the natural automatic
indentation stop.
- Prevent infinite loops in blockquote (C-c C-s b)
and preformatted (C-c C-s p) block insertion while
at the beginning or end of the buffer.
# Markdown Mode 1.7
*October 1, 2009*
* New features:
- Support filling of list items.
- Allow customization of font-lock faces (thanks to intrigeri
for the patch).
- Automatic indentation when pressing enter or tab (with
cycling upon subsequent tab presses) (thanks to Bryan Kyle).
- Generate real XHTML for previewing (thanks to Hilko Bengen
for the patch). This fixes [Debian bug #490865](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490865). The CSS
stylesheet for XHTML output is customizable via
`markdown-css-path` (thanks to Ankit Solanki for the patch).
- Better URL matching (protocols are customizable through
`markdown-uri-types`).
- LaTeX syntax highlighting can be enabled or disabled using
the customize system (`markdown-enable-math`).
- Support for HTML comments (font lock, `comment-dwim`, etc.).
- Support filling of definition lists (thanks to Peter Williams
for the patch).
* Improvements:
- Add support level 5 and 6 atx-style headers (thanks to Alec
Resnick for the report).
- Fill-paragraph no longer breaks lines inside of square
brackets (thanks to Peter Williams for the patch).
* Bug fixes:
- Fixed several font lock issues.
- Fixed a bug where pressing enter did nothing in
longlines-mode (thanks to Ankit Solanki for the patch).
- Fixed a problem where Emacs snapshot would hang during
`markdown-enter` and `markdown-cycle` (thanks to Alec Resnick
for the report).
- Fixed an issue with auto-fill-mode and markdown-mode's
indentation (thanks to Joost Kremers for the report and
analysis).
# Markdown Mode 1.6
*June 4, 2008*
* **Breaking changes:**
- Rename `blockquote-region` to `markdown-blockquote-region` in
accordance with the Emacs major mode coding conventions.
- Several new keybindings.
- Reverted to using colors instead of bold, italic, and
fixed-width faces.
* New features:
- Implemented org-mode style visibility cycling.
- Support outline minor mode.
- Undefined reference checking (via `C-c C-c c`, using code by
Dmitry Dzhus).
- Wiki links: syntax highlighting and element insertion
(`C-c C-a w`).
- Allow syntax highlighting faces to be customized.
- Insertion of preformatted text sections (`C-c C-s p`).
- Font locking for inline URIs and email addresses.
- Markdown mode menu (thanks to Greg Bognar for the initial
code).
* Improvements:
- Markdown customize group moved to `wp` (word processing).
- Derive from `text-mode` instead of `fundamental-mode`.
- Properly prefix regex definitions and `wrap-or-insert`
function.
* Bug fixes:
- Highlight wrapped inline link definitions (thanks to Blake
Winton).
- Fix adjacent wiki link font lock bug.
- Support escaping of backticks.
- Many other small font lock tweaks.
- Don't check for `transient-mark-mode` in
`markdown-blockquote-region`. This fixes Debian bug #456592
(thanks to Daniel Burrows for the report).
- Apply Greg Bognar's fix for `markdown` with an active region.
- Don't use the kill ring to store wrapped text.
# Markdown Mode 1.5
*October 11, 2007*
Version 1.5 is a major revision compared to previous releases. The
functionality has not changed very much, all of the keybindings are
the same, but it is internally quite different.
Most of the changes involve syntax highlighting. The regular
expressions have been significantly improved and the corresponding
font lock faces have been tweaked (hopefully for the better, but feel
free to customize them). Various other small bugs have been fixed and
the documentation and website have been updated.
The two changes in functionality, both of which are optional, are
syntax highlighting for embedded mathematics via LaTeX-like
expressions, and highlighting for bracketed wiki links.
[itex]: http://golem.ph.utexas.edu/~distler/blog/itex2MMLcommands.html
# Markdown Mode 1.4
*June 29, 2007*
Version 1.4 includes a small fix to the regular expression syntax to
fix the Emacs 21 "Invalid escape character syntax." error. Thanks to
Edward O'Connor for the fix.
# Markdown Mode 1.3
*June 5, 2007*
Version 1.3 provides syntax highlighting, insertion commands for all
basic HTML elements, and preview commands for viewing the resulting
HTML in a new buffer of an external browser.
# Markdown Mode 1.2
*May 25, 2007*
Version 1.2 adds element insertion commands and keys for links,
horizontal rules, headers, inline code, and bold and italic text.
Added element insertion commands and keys for links, horizontal rules, headers, inline code, and bold and italic text.
# Markdown Mode 1.1
*May 24, 2007*
Version 1.1 is the initial release of Markdown Mode for Emacs, a major
mode to edit Markdown files in Emacs. This version provides basic
syntax highlighting and element insertion commands for Markdown files.
markdown-mode-2.3+154/CONTRIBUTING.md 0000664 0000000 0000000 00000003234 13217531627 0016671 0 ustar 00root root 0000000 0000000 # Contributing Guidelines
## Pull Requests
For pull requests, it is recommended to create a new feature branch
(e.g., `feat/my-new-feature`) and submit the pull request from that
branch. If instead you add the commit(s) directly to the `master`
branch in your own repository, then it can be more difficult to get
back in sync if changes are required to the patch.
To have your pull request accepted quickly, please try to follow these
guidelines:
* Markdown mode contributions should adhere to both the
[GNU Emacs Lisp coding conventions](https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-Conventions.html) and the
[Major Mode Conventions](https://www.gnu.org/software/emacs/manual/html_node/elisp/Major-Mode-Conventions.html#Major-Mode-Conventions).
* Test cases are needed for significant changes. Markdown Mode uses
the `ert` (Emacs Lisp Regression Testing) library. If you are not
familiar with writing tests, there are hundreds of examples in
`tests/markdown-test.el` that you can use as a starting point for
new tests.
* You can confirm that your tests pass by either typing `make test`
from the command line or by issuing a GitHub pull request and
letting the Travis CI integration on GitHub run the tests for you.
* Please be sure to update the documentation at the top of
`markdown-mode.el` and the docstrings for related variables or
functions.
* If your patch involves changes to the documentation, you can
update the `README.md` file by running the `webpage.sh` script.
* It's also helpful if you update the `CHANGES.md` file to reflect
the bug you fixed or the feature you added or improved.
markdown-mode-2.3+154/LICENSE.md 0000664 0000000 0000000 00000104142 13217531627 0016044 0 ustar 00root root 0000000 0000000 ### GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
### Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS
#### 0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
#### 1. Source Code.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same
work.
#### 2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
#### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
#### 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
#### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively state
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
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 .
Also add information on how to contact you by electronic and paper
mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands \`show w' and \`show c' should show the
appropriate parts of the General Public License. Of course, your
program's commands might be different; for a GUI interface, you would
use an "about box".
You should also get your employer (if you work as a programmer) or
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. For more information on this, and how to apply and follow
the GNU GPL, see .
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Lesser General Public License instead of this License. But first,
please read .
markdown-mode-2.3+154/Makefile 0000664 0000000 0000000 00000001547 13217531627 0016105 0 ustar 00root root 0000000 0000000 EMACS=emacs
PACKAGE=markdown-mode
SOURCE=markdown-mode.el
COMPILED=markdown-mode.elc
VERSION=$(shell cat $(SOURCE) | sed -n 's/^;; Version: \(.*\)/\1/p')
TEST_FILES=tests/Makefile tests/*.el tests/*.text tests/*.md
.el.elc:
$(EMACS) -q -no-site-file -no-init-file -batch -f batch-byte-compile $<
all: $(COMPILED)
.PHONY: dist test
test:
SELECTOR=$(SELECTOR)
export SELECTOR
make -C tests test
clean:
rm -f $(COMPILED)
make -C tests clean
dist:
DIR=$$(mktemp -d -t "$(PACKAGE)"); \
DESTDIR="$$DIR/$(PACKAGE)-$(VERSION)"; \
mkdir -p $$DESTDIR; \
cp -a $(SOURCE) $$DESTDIR; \
mkdir -p $$DESTDIR/tests; \
cp -a $(TEST_FILES) $$DESTDIR/tests; \
tar zcf $(CURDIR)/$(PACKAGE)-$(VERSION).tar.gz -C $$DIR .; \
rm -r $$DIR; \
echo "$(PACKAGE)-$(VERSION).tar.gz has been created"
update: $(COMPILED)
cp -a $(SOURCE) $(COMPILED) $(HOME)/.emacs.d/site-lisp
markdown-mode-2.3+154/README.md 0000664 0000000 0000000 00000145545 13217531627 0015733 0 ustar 00root root 0000000 0000000 # Emacs Markdown Mode [![MELPA badge][melpa-badge]][melpa-link] [![MELPA stable badge][melpa-stable-badge]][melpa-stable-link] [![Travis CI Build Status][travis-badge]][travis-link] [![Guide to Markdown Mode for Emacs][leanpub-badge]][leanpub-link]
[melpa-link]: https://melpa.org/#/markdown-mode
[melpa-stable-link]: https://stable.melpa.org/#/markdown-mode
[melpa-badge]: https://melpa.org/packages/markdown-mode-badge.svg
[melpa-stable-badge]: https://stable.melpa.org/packages/markdown-mode-badge.svg
[travis-link]: https://travis-ci.org/jrblevin/markdown-mode
[travis-badge]: https://travis-ci.org/jrblevin/markdown-mode.svg?branch=master
[leanpub-link]: https://leanpub.com/markdown-mode
[leanpub-badge]: https://img.shields.io/badge/leanpub-guide-orange.svg
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]: 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
: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: ``.
* 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. Large
images may be scaled down to fit in the buffer using
`markdown-max-image-size`, a cons cell of the form
`(max-width . max-height)`. Resizing requires Emacs to be
built with ImageMagick support.
* 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 point
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).
- Re-aligns table columns.
* 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.
* Table Editing:
Markdown Mode includes support for editing tables, which
have the following basic format:
| Right | Left | Center | Default |
|------:|:-----|:------:|---------|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
The first line contains column headers. The second line
contains a separator line between the headers and the content.
Each following line is a row in the table. Columns are always
separated by the pipe character. The colons indicate column
alignment.
A table is re-aligned automatically each time you press TAB
or RET inside the table. TAB also moves to the next
field (RET to the next row) and creates new table rows at
the end of the table or before horizontal separator lines. The
indentation of the table is set by the first line. Column
centering inside Emacs is not supported.
Beginning pipe characters are required for proper detection of
table borders inside Emacs. Any line starting with `|-` or `|:`
is considered as a horizontal separator line and will be
expanded on the next re-align to span the whole table width. No
padding is allowed between the beginning pipe character and
header separator symbol. So, to create the above table, you
would only type
|Right|Left|Center|Default|
|-
and then press TAB to align the table and start filling in
cells.
Then you can jump with TAB from one cell to the next or with
S-TAB to the previous one. RET will jump to the to the
next cell in the same column, and create a new row if there is
no such cell or if the next row is beyond a separator line.
You can also convert selected region to a table. Basic editing
capabilities include inserting, deleting, and moving of columns
and rows, and table re-alignment, sorting, transposition:
- C-c UP or C-c DOWN - Move the current row up or down.
- C-c LEFT or C-c RIGHT - Move the current column left or right.
- C-c S-UP - Kill the current row.
- C-c S-DOWN - Insert a row above the current row. With a
prefix argument, row line is created below the current one.
- C-c S-LEFT - Kill the current column.
- C-c S-RIGHT - Insert a new column to the left of the current one.
- C-c C-d - Re-align the current table (`markdown-do`).
- C-c C-c ^ - Sort the rows of a table by a specified column.
This command prompts you for the column number and a sort
method (alphabetical or numerical, optionally in reverse).
- C-c C-c | - Convert the region to a table. This function
attempts to recognize comma, tab, and space separated data
and then splits the data into cells accordingly.
- C-c C-c t - Transpose table at point.
The table editing functions try to handle markup hiding
correctly when calculating column widths, however, columns
containing hidden markup may not always be aligned properly.
* Viewing Modes:
Read-only viewing modes, `markdown-view-mode` and `gfm-view-mode`
are provided for viewing Markdown content. These modes provide
simplified keybindings for navigating the buffer. Many of these
are like `help-mode` and `view-mode`, such as SPC,
DEL, <, and > for scrolling,
q for quitting, and ? or h for
help. Other keys are provided that mirror the outline navigation
commands when editing: n, p, f,
b, and u. Both of these modes enable markup
hiding by default, but this can be customized by setting
`markdown-hide-markup-in-view-modes`.
* 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. You can
also give a prefix argument to the insertion command, as in
C-u C-c C-s C, to edit the code block in an indirect buffer
upon insertion.
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. It can
also be a function; in this case `markdown` will call it with three
arguments: the beginning and end of the region to process, and
a buffer to write the output to.
* `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. If
`markdown-command` is a function, `markdown-command-needs-filename`
is ignored.
* `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).
This variable can also be a function; in this case `markdown-open`
will call it without arguments to preview the current buffer.
* `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-marginalize-headers` - put opening atx header markup
in the left margin when non-nil (default: `nil`).
* `markdown-marginalize-headers-margin-width` - width of margin
used for marginalized headers (default: 6).
* `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-enable-html` - font lock for HTML tags and attributes
(default: `t`).
* `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\\|C-c C-x C-l
(`markdown-toggle-url-hiding`)
or from the Markdown | Links & Images menu.
* `markdown-hide-markup` - Determines whether all possible markup
is hidden or otherwise beautified (default: `nil`). The actual
buffer text remains unchanged, but the display will be altered.
Brackets and URLs for links will be hidden, asterisks and
underscores for italic and bold text will be hidden, text
bullets for unordered lists will be replaced by Unicode
bullets, and so on. Since this includes URLs and reference
labels, when non-nil this setting supersedes `markdown-hide-urls`.
Markup hiding can be toggled using C-c C-x C-m
(`markdown-toggle-markup-hiding`) or from the Markdown | Show &
Hide menu.
Unicode bullets are used to replace ASCII list item markers.
The list of characters used, in order of list level, can be
specified by setting the variable `markdown-list-item-bullets`.
The placeholder characters used to replace other markup can
be changed by customizing the corresponding variables:
`markdown-blockquote-display-char`,
`markdown-hr-display-char`, and
`markdown-definition-display-char`.
* `markdown-fontify-code-blocks-natively` - Whether to fontify
code in code blocks using the native major mode. This only
works for fenced code blocks where the language is specified
where we can automatically determine the appropriate mode to
use. The language to mode mapping may be customized by setting
the variable `markdown-code-lang-modes`. This can be toggled
interactively by pressing C-c C-x C-f
(`markdown-toggle-fontify-code-blocks-natively`).
* `markdown-gfm-uppercase-checkbox` - When non-nil, complete GFM
task list items with `[X]` instead of `[x]` (default: `nil`).
This is useful for compatibility with `org-mode`, which doesn't
recognize the lowercase variant.
* `markdown-translate-filename-function` - A function to be used to
translate filenames in links.
Additionally, the faces used for syntax highlighting can be modified to
your liking by issuing M-x customize-group RET markdown-faces
or by using the "Markdown Faces" link at the bottom of the mode
customization screen.
[Marked 2]: https://itunes.apple.com/us/app/marked-2/id890031187?mt=12&uo=4&at=11l5Vs&ct=mm
## Extensions
Besides supporting the basic Markdown syntax, Markdown Mode also
includes syntax highlighting for `[[Wiki Links]]`. This can be
enabled by setting `markdown-enable-wiki-links` to a non-nil value.
Wiki links may be followed by pressing C-c C-o when the point
is at a wiki link. Use M-p and M-n to quickly jump to the
previous and next links (including links of other types).
Aliased or piped wiki links of the form `[[link text|PageName]]`
are also supported. Since some wikis reverse these components, set
`markdown-wiki-link-alias-first` to nil to treat them as
`[[PageName|link text]]`. If `markdown-wiki-link-fontify-missing`
is also non-nil, Markdown Mode will highlight wiki links with
missing target file in a different color. By default, Markdown
Mode only searches for target files in the current directory.
Search in subdirectories can be enabled by setting
`markdown-wiki-link-search-subdirectories` to a non-nil value.
Sequential parent directory search (as in [Ikiwiki][]) can be
enabled by setting `markdown-wiki-link-search-parent-directories`
to a non-nil value.
[Ikiwiki]: https://ikiwiki.info
[SmartyPants][] support is possible by customizing `markdown-command`.
If you install `SmartyPants.pl` at, say, `/usr/local/bin/smartypants`,
then you can set `markdown-command` to `"markdown | smartypants"`.
You can do this either by using M-x customize-group markdown
or by placing the following in your `.emacs` file:
```lisp
(setq markdown-command "markdown | smartypants")
```
[SmartyPants]: http://daringfireball.net/projects/smartypants/
Syntax highlighting for mathematical expressions written
in LaTeX (only expressions denoted by `$..$`, `$$..$$`, or `\[..\]`)
can be enabled by setting `markdown-enable-math` to a non-nil value,
either via customize or by placing `(setq markdown-enable-math t)`
in `.emacs`, and then restarting Emacs or calling
`markdown-reload-extensions`.
## GitHub Flavored Markdown (GFM)
A [GitHub Flavored Markdown][GFM] mode, `gfm-mode`, is also
available. The GitHub implementation differs slightly from
standard Markdown in that it supports things like different
behavior for underscores inside of words, automatic linking of
URLs, strikethrough text, and fenced code blocks with an optional
language keyword.
The GFM-specific features above apply to `README.md` files, wiki
pages, and other Markdown-formatted files in repositories on
GitHub. GitHub also enables [additional features][GFM comments] for
writing on the site (for issues, pull requests, messages, etc.)
that are further extensions of GFM. These features include task
lists (checkboxes), newlines corresponding to hard line breaks,
auto-linked references to issues and commits, wiki links, and so
on. To make matters more confusing, although task lists are not
part of [GFM proper][GFM], [since 2014][] they are rendered (in a
read-only fashion) in all Markdown documents in repositories on the
site. These additional extensions are supported to varying degrees
by `markdown-mode` and `gfm-mode` as described below.
* **URL autolinking:** Both `markdown-mode` and `gfm-mode` support
highlighting of URLs without angle brackets.
* **Multiple underscores in words:** You must enable `gfm-mode` to
toggle support for underscores inside of words. In this mode
variable names such as `a_test_variable` will not trigger
emphasis (italics).
* **Fenced code blocks:** Code blocks quoted with backquotes, with
optional programming language keywords, are highlighted in
both `markdown-mode` and `gfm-mode`. They can be inserted with
C-c C-s C. If there is an active region, the text in the
region will be placed inside the code block. You will be
prompted for the name of the language, but may press enter to
continue without naming a language.
* **Strikethrough:** Strikethrough text is supported in both
`markdown-mode` and `gfm-mode`. It can be inserted (and toggled)
using C-c C-s s.
* **Task lists:** GFM task lists will be rendered as checkboxes
(Emacs buttons) in both `markdown-mode` and `gfm-mode` when
`markdown-make-gfm-checkboxes-buttons` is set to a non-nil value
(and it is set to t by default). These checkboxes can be
toggled by clicking `mouse-1`, pressing RET over the button,
or by pressing C-c C-d (`markdown-do`) with the point anywhere
in the task list item. A normal list item can be turned to a
check list item by the same command, or more specifically
C-c C-s [ (`markdown-insert-gfm-checkbox`).
* **Wiki links:** Generic wiki links are supported in
`markdown-mode`, but in `gfm-mode` specifically they will be
treated as they are on GitHub: spaces will be replaced by hyphens
in filenames and the first letter of the filename will be
capitalized. For example, `[[wiki link]]` will map to a file
named `Wiki-link` with the same extension as the current file.
If a file with this name does not exist in the current directory,
the first match in a subdirectory, if any, will be used instead.
* **Newlines:** Neither `markdown-mode` nor `gfm-mode` do anything
specifically with respect to newline behavior. If you use
`gfm-mode` mostly to write text for comments or issues on the
GitHub site--where newlines are significant and correspond to
hard line breaks--then you may want to enable `visual-line-mode`
for line wrapping in buffers. You can do this with a
`gfm-mode-hook` as follows:
```lisp
;; Use visual-line-mode in gfm-mode
(defun my-gfm-mode-hook ()
(visual-line-mode 1))
(add-hook 'gfm-mode-hook 'my-gfm-mode-hook)
```
* **Preview:** GFM-specific preview can be powered by setting
`markdown-command` to use [Docter][]. This may also be
configured to work with [Marked 2][] for `markdown-open-command`.
[GFM]: http://github.github.com/github-flavored-markdown/
[GFM comments]: https://help.github.com/articles/writing-on-github/
[since 2014]: https://github.com/blog/1825-task-lists-in-all-markdown-documents
[Docter]: https://github.com/alampros/Docter
## Acknowledgments
markdown-mode has benefited greatly from the efforts of the many
volunteers who have sent patches, test cases, bug reports,
suggestions, helped with packaging, etc. Thank you for your
contributions! See the [contributors graph][contrib] for details.
[contrib]: https://github.com/jrblevin/markdown-mode/graphs/contributors
## Bugs
markdown-mode is developed and tested primarily for compatibility
with GNU Emacs 24.4 and later. If you find any bugs in
markdown-mode, please construct a test case or a patch and open a
ticket on the [GitHub issue tracker][issues]. See the
contributing guidelines in `CONTRIBUTING.md` for details on
creating pull requests.
[issues]: https://github.com/jrblevin/markdown-mode/issues
## History
markdown-mode was written and is maintained by Jason Blevins. The
first version was released on May 24, 2007.
* 2007-05-24: [Version 1.1][]
* 2007-05-25: [Version 1.2][]
* 2007-06-05: [Version 1.3][]
* 2007-06-29: [Version 1.4][]
* 2007-10-11: [Version 1.5][]
* 2008-06-04: [Version 1.6][]
* 2009-10-01: [Version 1.7][]
* 2011-08-12: [Version 1.8][]
* 2011-08-15: [Version 1.8.1][]
* 2013-01-25: [Version 1.9][]
* 2013-03-24: [Version 2.0][]
* 2016-01-09: [Version 2.1][]
* 2017-05-26: [Version 2.2][]
* 2017-08-31: [Version 2.3][]
[Version 1.1]: https://jblevins.org/projects/markdown-mode/rev-1-1
[Version 1.2]: https://jblevins.org/projects/markdown-mode/rev-1-2
[Version 1.3]: https://jblevins.org/projects/markdown-mode/rev-1-3
[Version 1.4]: https://jblevins.org/projects/markdown-mode/rev-1-4
[Version 1.5]: https://jblevins.org/projects/markdown-mode/rev-1-5
[Version 1.6]: https://jblevins.org/projects/markdown-mode/rev-1-6
[Version 1.7]: https://jblevins.org/projects/markdown-mode/rev-1-7
[Version 1.8]: https://jblevins.org/projects/markdown-mode/rev-1-8
[Version 1.8.1]: https://jblevins.org/projects/markdown-mode/rev-1-8-1
[Version 1.9]: https://jblevins.org/projects/markdown-mode/rev-1-9
[Version 2.0]: https://jblevins.org/projects/markdown-mode/rev-2-0
[Version 2.1]: https://jblevins.org/projects/markdown-mode/rev-2-1
[Version 2.2]: https://jblevins.org/projects/markdown-mode/rev-2-2
[Version 2.3]: https://jblevins.org/projects/markdown-mode/rev-2-3
markdown-mode-2.3+154/markdown-mode.el 0000664 0000000 0000000 00001412232 13217531627 0017531 0 ustar 00root root 0000000 0000000 ;;; 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.4-dev
;; Package-Requires: ((emacs "24.4") (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:
;; See the README.md file for details.
;;; Code:
(require 'easymenu)
(require 'outline)
(require 'thingatpt)
(require 'cl-lib)
(require 'url-parse)
(require 'button)
(require 'color)
(require 'rx)
(defvar jit-lock-start)
(defvar jit-lock-end)
(defvar flyspell-generic-check-word-predicate)
(declare-function eww-open-file "eww")
(declare-function url-path-and-query "url-parse")
;;; Constants =================================================================
(defconst markdown-mode-version "2.4-dev"
"Markdown mode version number.")
(defconst markdown-output-buffer-name "*markdown-output*"
"Name of temporary buffer for markdown command output.")
;;; Global Variables ==========================================================
(defvar markdown-reference-label-history nil
"History of used reference labels.")
(defvar markdown-live-preview-mode nil
"Sentinel variable for command `markdown-live-preview-mode'.")
(defvar markdown-gfm-language-history nil
"History list of languages used in the current buffer in GFM code blocks.")
;;; Customizable Variables ====================================================
(defvar markdown-mode-hook nil
"Hook run when entering Markdown mode.")
(defvar markdown-before-export-hook nil
"Hook run before running Markdown to export XHTML output.
The hook may modify the buffer, which will be restored to it's
original state after exporting is complete.")
(defvar markdown-after-export-hook nil
"Hook run after XHTML output has been saved.
Any changes to the output buffer made by this hook will be saved.")
(defgroup markdown nil
"Major mode for editing text files in Markdown format."
:prefix "markdown-"
:group 'wp
:link '(url-link "https://jblevins.org/projects/markdown-mode/"))
(defcustom markdown-command "markdown"
"Command to run markdown."
:group 'markdown
:type '(choice (string :tag "Shell command") function))
(defcustom markdown-command-needs-filename nil
"Set to non-nil if `markdown-command' does not accept input from stdin.
Instead, it will be passed a filename as the final command line
option. As a result, you will only be able to run Markdown from
buffers which are visiting a file."
:group 'markdown
:type 'boolean)
(defcustom markdown-open-command nil
"Command used for opening Markdown files directly.
For example, a standalone Markdown previewer. This command will
be called with a single argument: the filename of the current
buffer. It can also be a function, which will be called without
arguments."
:group 'markdown
:type '(choice file function (const :tag "None" nil)))
(defcustom markdown-hr-strings
'("-------------------------------------------------------------------------------"
"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
"---------------------------------------"
"* * * * * * * * * * * * * * * * * * * *"
"---------"
"* * * * *")
"Strings to use when inserting horizontal rules.
The first string in the list will be the default when inserting a
horizontal rule. Strings should be listed in decreasing order of
prominence (as in headings from level one to six) for use with
promotion and demotion functions."
:group 'markdown
:type '(repeat string))
(defcustom markdown-bold-underscore nil
"Use two underscores when inserting bold text instead of two asterisks."
:group 'markdown
:type 'boolean)
(defcustom markdown-italic-underscore nil
"Use underscores when inserting italic text instead of asterisks."
:group 'markdown
:type 'boolean)
(defcustom markdown-marginalize-headers nil
"When non-nil, put opening atx header markup in a left margin.
This setting goes well with `markdown-asymmetric-header'. But
sadly it conflicts with `linum-mode' since they both use the
same margin."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.4"))
(defcustom markdown-marginalize-headers-margin-width 6
"Character width of margin used for marginalized headers.
The default value is based on there being six heading levels
defined by Markdown and HTML. Increasing this produces extra
whitespace on the left. Decreasing it may be preferred when
fewer than six nested heading levels are used."
:group 'markdown
:type 'natnump
:safe 'natnump
:package-version '(markdown-mode . "2.4"))
(defcustom markdown-asymmetric-header nil
"Determines if atx header style will be asymmetric.
Set to a non-nil value to use asymmetric header styling, placing
header markup only at the beginning of the line. By default,
balanced markup will be inserted at the beginning and end of the
line around the header title."
:group 'markdown
:type 'boolean)
(defcustom markdown-indent-function 'markdown-indent-line
"Function to use to indent."
:group 'markdown
:type 'function)
(defcustom markdown-indent-on-enter t
"Determines indentation behavior when pressing \\[newline].
Possible settings are nil, t, and 'indent-and-new-item.
When non-nil, pressing \\[newline] will call `newline-and-indent'
to indent the following line according to the context using
`markdown-indent-function'. In this case, note that
\\[electric-newline-and-maybe-indent] can still be used to insert
a newline without indentation.
When set to 'indent-and-new-item and the point is in a list item
when \\[newline] is pressed, the list will be continued on the next
line, where a new item will be inserted.
When set to nil, simply call `newline' as usual. In this case,
you can still indent lines using \\[markdown-cycle] and continue
lists with \\[markdown-insert-list-item].
Note that this assumes the variable `electric-indent-mode' is
non-nil (enabled). When it is *disabled*, the behavior of
\\[newline] and `\\[electric-newline-and-maybe-indent]' are
reversed."
:group 'markdown
:type '(choice (const :tag "Don't automatically indent" nil)
(const :tag "Automatically indent" t)
(const :tag "Automatically indent and insert new list items" indent-and-new-item)))
(defcustom markdown-enable-wiki-links nil
"Syntax highlighting for wiki links.
Set this to a non-nil value to turn on wiki link support by default.
Support can be toggled later using the `markdown-toggle-wiki-links'
function or \\[markdown-toggle-wiki-links]."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.2"))
(defcustom markdown-wiki-link-alias-first t
"When non-nil, treat aliased wiki links like [[alias text|PageName]].
Otherwise, they will be treated as [[PageName|alias text]]."
:group 'markdown
:type 'boolean
:safe 'booleanp)
(defcustom markdown-wiki-link-search-subdirectories nil
"When non-nil, search for wiki link targets in subdirectories.
This is the default search behavior for GitHub and is
automatically set to t in `gfm-mode'."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.2"))
(defcustom markdown-wiki-link-search-parent-directories nil
"When non-nil, search for wiki link targets in parent directories.
This is the default search behavior of Ikiwiki."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.2"))
(defcustom markdown-wiki-link-fontify-missing nil
"When non-nil, change wiki link face according to existence of target files.
This is expensive because it requires checking for the file each time the buffer
changes or the user switches windows. It is disabled by default because it may
cause lag when typing on slower machines."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.2"))
(defcustom markdown-uri-types
'("acap" "cid" "data" "dav" "fax" "file" "ftp"
"gopher" "http" "https" "imap" "ldap" "mailto"
"mid" "message" "modem" "news" "nfs" "nntp"
"pop" "prospero" "rtsp" "service" "sip" "tel"
"telnet" "tip" "urn" "vemmi" "wais")
"Link types for syntax highlighting of URIs."
:group 'markdown
:type '(repeat (string :tag "URI scheme")))
(defcustom markdown-url-compose-char
'(?∞ ?… ?⋯ ?# ?★ ?⚓)
"Placeholder character for hidden URLs.
This may be a single character or a list of characters. In case
of a list, the first one that satisfies `char-displayable-p' will
be used."
:type '(choice
(character :tag "Single URL replacement character")
(repeat :tag "List of possible URL replacement characters"
character))
:package-version '(markdown-mode . "2.3"))
(defcustom markdown-blockquote-display-char
'("▌" "┃" ">")
"String to display when hiding blockquote markup.
This may be a single string or a list of string. In case of a
list, the first one that satisfies `char-displayable-p' will be
used."
:type 'string
:type '(choice
(string :tag "Single blockquote display string")
(repeat :tag "List of possible blockquote display strings" string))
:package-version '(markdown-mode . "2.3"))
(defcustom markdown-hr-display-char
'(?─ ?━ ?-)
"Character for hiding horizontal rule markup.
This may be a single character or a list of characters. In case
of a list, the first one that satisfies `char-displayable-p' will
be used."
:group 'markdown
:type '(choice
(character :tag "Single HR display character")
(repeat :tag "List of possible HR display characters" character))
:package-version '(markdown-mode . "2.3"))
(defcustom markdown-definition-display-char
'(?⁘ ?⁙ ?≡ ?⌑ ?◊ ?:)
"Character for replacing definition list markup.
This may be a single character or a list of characters. In case
of a list, the first one that satisfies `char-displayable-p' will
be used."
:type '(choice
(character :tag "Single definition list character")
(repeat :tag "List of possible definition list characters" character))
: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-enable-html t
"Enable font-lock support for HTML tags and attributes."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.4"))
(defcustom markdown-css-paths nil
"URL of CSS file to link to in the output XHTML."
:group 'markdown
:type '(repeat (string :tag "CSS File Path")))
(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-export-kill-buffer t
"Kill output buffer after HTML export.
When non-nil, kill the HTML output buffer after
exporting with `markdown-export'."
:group 'markdown
:type 'boolean
:safe 'booleanp
:package-version '(markdown-mode . "2.4"))
(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)
(defcustom markdown-translate-filename-function #'identity
"Function to use to translate filenames when following links.
\\\\[markdown-follow-thing-at-point] and \\[markdown-follow-link-at-point]
call this function with the filename as only argument whenever
they encounter a filename (instead of a URL) to be visited and
use its return value instead of the filename in the link. For
example, if absolute filenames are actually relative to a server
root directory, you can set
`markdown-translate-filename-function' to a function that
prepends the root directory to the given filename."
:group 'markdown
:type 'function
:risky t
:package-version '(markdown-mode . "2.4"))
(defcustom markdown-max-image-size nil
"Maximum width and height for displayed inline images.
This variable may be nil or a cons cell (MAX-WIDTH . MAX-HEIGHT).
When nil, use the actual size. Otherwise, use ImageMagick to
resize larger images to be of the given maximum dimensions. This
requires Emacs to be built with ImageMagick support."
:group 'markdown
:package-version '(markdown-mode . "2.4")
:type '(choice
(const :tag "Use actual image width" nil)
(cons (choice (sexp :tag "Maximum width in pixels")
(const :tag "No maximum width" nil))
(choice (sexp :tag "Maximum height in pixels")
(const :tag "No maximum height" nil)))))
;;; Markdown-Specific `rx' Macro
;; Based on python-rx from python.el.
(eval-and-compile
(defconst markdown-rx-constituents
`((newline . ,(rx "\n"))
(indent . ,(rx (or (repeat 4 " ") "\t")))
(block-end . ,(rx (and (or (one-or-more (zero-or-more blank) "\n") line-end))))
(numeral . ,(rx (and (one-or-more (any "0-9#")) ".")))
(bullet . ,(rx (any "*+:-")))
(list-marker . ,(rx (or (and (one-or-more (any "0-9#")) ".")
(any "*+:-"))))
(checkbox . ,(rx "[" (any " xX") "]")))
"Markdown-specific sexps for `markdown-rx'")
(defun markdown-rx-to-string (form &optional no-group)
"Markdown mode specialized `rx-to-string' function.
This variant supports named Markdown expressions in FORM.
NO-GROUP non-nil means don't put shy groups around the result."
(let ((rx-constituents (append markdown-rx-constituents rx-constituents)))
(rx-to-string form no-group)))
(defmacro markdown-rx (&rest regexps)
"Markdown mode specialized rx macro.
This variant of `rx' supports common Markdown named REGEXPS."
(cond ((null regexps)
(error "No regexp"))
((cdr regexps)
(markdown-rx-to-string `(and ,@regexps) t))
(t
(markdown-rx-to-string (car regexps) t)))))
;;; Regular Expressions =======================================================
(defconst markdown-regex-comment-start
"")
(setq-local comment-start-skip "
"
(markdown-insert-reference-link "link" "" "http://jblevins.org/")
(should (equal (buffer-substring-no-properties 1 (point-max))
"[link][]
\[link]: http://jblevins.org/
"))
(should (equal (point) 9))))
(ert-deftest test-markdown-insertion/inline-to-reference-link ()
"Inline link to reference link conversion with tab completion."
(markdown-test-string "[text](http://jblevins.org/ \"title\")"
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET M-DEL M-DEL M-DEL [1] RET RET h TAB RET RET"))
(should (string-equal (buffer-string) "[text][1]\n\n[1]: http://jblevins.org/ \"title\"\n"))))
(ert-deftest test-markdown-insertion/inline-to-reference-link-2 ()
"Inline link to reference link conversion with existing reference links."
(markdown-test-string "[text](http://jblevins.org/ \"title\")\n\n[1]: https://www.gnu.org"
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET M-DEL M-DEL M-DEL [1] RET RET"))
(should (string-equal (buffer-string) "[text][1]\n\n[1]: https://www.gnu.org"))))
(ert-deftest test-markdown-insertion/inline-link-angle-url-at-point ()
"Test `markdown-insert-link' with angle URL at point."
(markdown-test-string ""
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET RET GNU RET RET"))
(should (string-equal (buffer-string) "[GNU](https://www.gnu.org/)"))))
(ert-deftest test-markdown-insertion/inline-link-plain-url-at-point ()
"Test `markdown-insert-link' with plain URL at point."
(markdown-test-string "https://www.gnu.org/"
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET RET GNU RET RET"))
(should (string-equal (buffer-string) "[GNU](https://www.gnu.org/)"))))
(ert-deftest test-markdown-insertion/inline-link-reference-link-at-point ()
"Test `markdown-insert-link' with reference link at point."
(markdown-test-string ""
(markdown-insert-reference-link "link" "label" "http://jblevins.org/")
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET DEL DEL DEL DEL DEL DEL DEL http://example.com/ RET RET RET"))
(should (string-equal (buffer-substring 1 28) "[link](http://example.com/)"))
(should (= (point) 28))))
(ert-deftest test-markdown-insertion/inline-link-active-region ()
"Test `markdown-insert-link' with active region."
(markdown-test-string "abc def ghi"
(let ((tmm-orig transient-mark-mode))
(transient-mark-mode 1)
(push-mark (point) t t)
(forward-word 2)
(execute-kbd-macro (read-kbd-macro "M-x markdown-insert-link RET http://example.com/ RET RET RET"))
(should (string-equal (buffer-string) "[abc def](http://example.com/) ghi"))
(should (= (point) 31))
(transient-mark-mode tmm-orig))))
;;; Footnote tests:
(ert-deftest test-markdown-footnote/basic-end ()
"Basic footnote insertion and deletion tests for 'end location."
(let ((markdown-footnote-location 'end))
(markdown-test-string "first line\nsecond line\n"
;; new buffer with no footnotes
(should (= markdown-footnote-counter 0))
;; footnote insertion
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 35))
(should (= markdown-footnote-counter 1))
(should (looking-back "\\[^1\\]: " nil))
;; kill with point in footnote definition
(insert "footnote text")
(let (kill-ring)
(markdown-footnote-kill))
(should (= (point) 24))
(should (bolp))
(should (string-equal (buffer-string) "first line\nsecond line\n"))
;; insertion, counter should increment
(goto-char (point-min))
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 35))
(should (= markdown-footnote-counter 2))
(should (looking-back "\\[^2\\]: " nil))
(insert "footnote text")
;; return to marker
(markdown-footnote-return)
(should (= (point) 15))
(should (looking-back "\\[^2\\]" nil))
;; kill with point at marker
(let (kill-ring)
(markdown-footnote-kill))
(should (= (point) 11))
(should (eolp))
(should (string-equal (buffer-string) "first line\nsecond line\n")))))
(ert-deftest test-markdown-footnote/basic-immediately ()
"Basic footnote insertion and deletion tests for 'immediately location."
(let ((markdown-footnote-location 'immediately))
(markdown-test-string "first paragraph\n\nsecond paragraph\n"
;; new buffer with no footnotes
(should (= markdown-footnote-counter 0))
;; footnote insertion
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 28))
(should (= markdown-footnote-counter 1))
(should (looking-back "\\[^1\\]: " nil))
;; kill with point in footnote definition
(insert "footnote text")
(let (kill-ring)
(markdown-footnote-kill))
(should (= (point) 18))
(should (bolp))
(should (string-equal (buffer-string)
"first paragraph\n\nsecond paragraph\n")))))
(ert-deftest test-markdown-footnote/basic-header ()
"Basic footnote insertion and deletion tests for 'header location."
(let ((markdown-footnote-location 'header))
(markdown-test-string "par one\n\npar two\n\n### header\n"
;; new buffer with no footnotes
(should (= markdown-footnote-counter 0))
;; footnote insertion
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 29))
(should (= markdown-footnote-counter 1))
(should (looking-back "\\[^1\\]: " nil))
;; kill with point in footnote definition
(insert "footnote text")
(let (kill-ring)
(markdown-footnote-kill))
(should (= (point) 19))
(should (bolp))
(should (string-equal (buffer-string)
"par one\n\npar two\n\n### header\n"))
;; insertion, counter should increment
(goto-char (point-min))
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 29))
(should (= markdown-footnote-counter 2))
(should (looking-back "\\[^2\\]: " nil))
(insert "footnote text")
;; return to marker
(markdown-footnote-return)
(should (= (point) 12))
(should (looking-back "\\[^2\\]" nil))
;; kill with point at marker
(let (kill-ring)
(markdown-footnote-kill))
(should (= (point) 8))
(should (eolp))
(should (string-equal (buffer-string)
"par one\n\npar two\n\n### header\n")))))
(ert-deftest test-markdown-footnote/basic-subtree ()
"Basic footnote insertion and deletion tests for 'subtree location."
(let ((markdown-footnote-location 'subtree))
(markdown-test-string "# h1\n\nfoo\n\n## h2\n\nbar\n"
;; new buffer with no footnotes
(should (= markdown-footnote-counter 0))
;; footnote insertion
(forward-line 2)
(end-of-line)
(markdown-insert-footnote)
(should (= (point) 34))
(should (= markdown-footnote-counter 1))
(should (looking-back "\\[^1\\]: " nil)))))
(ert-deftest test-markdown-footnote/kill-empty-text ()
"Test killing a footnote with marker but no text."
(markdown-test-string "no text[^1]\n\n[^1]: \n"
(end-of-line)
(markdown-footnote-goto-text)
(should (looking-back "\\[^1\\]: " nil))
(let (kill-ring)
(markdown-footnote-kill))
(should (string-equal (buffer-string) "no text\n"))))
(ert-deftest test-markdown-footnote/kill-empty-after ()
"Test killing an empty footnote after one with text (previously killed the
footnote with text above)."
(markdown-test-string "[^with-text][^no-text]\n\n[^with-text]: Text\n[^no-text]:"
(let (kill-ring)
(forward-line 3)
(should (looking-at "\\[\\^no-text\\]:$"))
(markdown-footnote-kill)
(should (string-equal (current-kill 0) "")))))
(ert-deftest test-markdown-footnote/kill-hanging-paras ()
"Test killing a footnote where block text starts after the label (previously
killed the footnote above)."
(markdown-test-string "[^1][^2]\n\n[^1]: Foo\n\n[^2]:\n Text\n\n More text\n\n\nNot indented"
(let (kill-ring)
(forward-line 4)
(should (looking-at "\\[\\^2\\]:$"))
(markdown-footnote-kill)
;; We want to include the leading space on hanging footnote paragraphs,
;; even if a hanging paragraph is the first item in the footnote.
(should (string-equal (current-kill 0) "Text\n\n More text\n")))))
(ert-deftest test-markdown-footnote/text-positions-buffer-top ()
"Test markdown-footnote-text-positions on footnote adjacent to buffer top
(was infinite loop)."
(markdown-test-string "[^label]: text\n more text"
(should (equal (markdown-footnote-text-positions) (list "^label" 1 29)))))
(ert-deftest test-markdown-footnote/text-positions-buffer-top-one-line ()
"Test markdown-footnote-text-positions on one-line footnote adjacent to
buffer top (failed to find positions)."
(markdown-test-string "[^label]: text\n"
(should (equal (markdown-footnote-text-positions) (list "^label" 1 16)))))
(ert-deftest test-markdown-footnote/text-positions-buffer-top-not-footnote ()
"Test markdown-footnote-text-positions on plain paragraph adjacent to buffer
top (was infinite loop)."
(markdown-test-string "text\n more text\n"
(should (eq (markdown-footnote-text-positions) nil))))
(ert-deftest test-markdown-footnote/text-positions-buffer-bottom ()
"Test markdown-footnote-text-positions on footnote adjacent to buffer bottom
(was infinite loop)."
(markdown-test-string "\n[^label]: text\n more text"
(forward-line 1)
(should (equal (markdown-footnote-text-positions) (list "^label" 2 30)))))
(ert-deftest test-markdown-footnote/kill-adjacent-footnote ()
"Test killing a footnote adjacent to other one-line footnotes (previously
killed the wrong one)."
(markdown-test-string "Text[^1] with[^2] footnotes[^3]\n\n[^1]: foo\n[^2]: bar\n[^3]: baz"
(let (kill-ring)
(forward-line 3)
(should (looking-at "\\[\\^2\\]: bar"))
(markdown-footnote-kill)
(should (string-equal (current-kill 0) "bar\n")))))
(ert-deftest test-markdown-footnote/kill-adjacent-markers ()
"Test killing a footnote where the labels are adjacent (previously, the wrong
footnote would be killed because the attempt to jump to the marker would jump to
the opening bracket of [^2], and then subsequent functions would kill [^2])."
(markdown-test-string "Text with footnotes[^1][^2]\n\n[^1]: foo\n\n[^2]: bar\n"
(let (kill-ring)
(forward-line 2)
(should (looking-at "\\[\\^1\\]: foo"))
(markdown-footnote-kill)
(should (string-equal (current-kill 0) "foo\n")))))
(ert-deftest test-markdown-footnote-reference/jump ()
"Test `markdown-do' for footnotes and reference links."
(markdown-test-string
"body[^1], [link 1][ref],
[link 2][ref]
[^1]: footnote
[ref]: https://duckduckgo.com/"
(goto-char 5) ; start of [^1]
(markdown-do) ; markdown-footnote-goto-text
(should (looking-at "footnote"))
(markdown-do) ; markdown-footnote-return
(should (= (point) 9)) ; just after [^1]
(markdown-next-link) ; beginning of [link 1][]
(markdown-do)
(should (looking-at "https://duckduckgo.com/"))
(should (equal (markdown-reference-find-links "ref")
(list (list "link 2" 26 2) (list "link 1" 11 1))))
(markdown-do) ; opens a reference link buffer
(should (string= (buffer-string) "Links using reference ref:\n\nlink 1 (line 1)\nlink 2 (line 2)\n"))
(should (looking-at "link 1")) ; in reference link popop buffer
(execute-kbd-macro (read-kbd-macro "RET")) ; jump to "link 1"
(should (looking-at "\\[link 1\\]")) ; back in main buffer
(should (= (point) 11))))
;;; Element removal tests:
(ert-deftest test-markdown-kill/simple ()
"Simple tests for `markdown-kill-thing-at-point'."
(let ((kill-ring nil)
(tests (list '("`foo`" . "foo")
'("## foo ##" . "foo")
'("## foo" . "foo")
'("foo\n---" . "foo")
'("foo\n===" . "foo")
'("* * * * *" . "* * * * *")
'("[foo](http://bar.com/)" . "foo")
'("" . "foo")
'("[foo][bar]" . "foo")
'("![foo][bar]" . "foo")
'("" . "http://foo.com/")
'("" . "foo@bar.com")
'("**foo**" . "foo")
'("__foo__" . "foo")
'("*foo*" . "foo")
'("_foo_" . "foo")
'(" [foo]: http://bar.com/" . "http://bar.com/")
'(" [foo]: http://bar.com/ \"title\"" . "http://bar.com/")
'("foo[^bar]\n\n[^bar]: baz" . "baz")
'("[^bar]: baz" . "baz")
'(" * foo\n bar" . " * foo\n bar"))))
(dolist (test tests)
;; Load test string (the car), move to end of first line, kill
;; thing at point, and then verify that the kill ring contains cdr.
(markdown-test-string (car test)
(end-of-line)
(call-interactively 'markdown-kill-thing-at-point)
(should (string-equal (current-kill 0) (cdr test)))))))
(ert-deftest test-markdown-kill/footnote-text ()
"Test killing a footnote with point at footnote text."
(markdown-test-string "some text[^1]\n\n[^1]: footnote\n"
(end-of-line)
(markdown-footnote-goto-text)
(let (kill-ring)
(markdown-footnote-kill))
(should (string-equal (buffer-string) "some text\n"))))
(ert-deftest test-markdown-kill/code ()
"Test killing with code regex.."
(let ((kill-ring nil))
(markdown-test-string "Lorem `ipsum` dolor `sit` `amet`."
(goto-char 22) ; position point at s in `sit`
(call-interactively 'markdown-kill-thing-at-point)
(should (string-equal (current-kill 0) "sit")))))
;;; Completion:
(ert-deftest test-markdown-complete/atx-header-incomplete ()
"Test `markdown-incomplete-atx-p'."
(markdown-test-string "### ###"
(should (looking-at markdown-regex-header-atx))
(should-not (markdown-incomplete-atx-p)))
(markdown-test-string "###abc###"
(should-not (looking-at markdown-regex-header-atx)))
(markdown-test-string "### ###"
(should (looking-at markdown-regex-header-atx))
(should (markdown-incomplete-atx-p))))
(ert-deftest test-markdown-complete/atx-header ()
"Test `markdown-complete' for atx headers."
(markdown-test-string "##### test"
(call-interactively 'markdown-complete)
(should (string-equal (buffer-string) "##### test #####"))))
(ert-deftest test-markdown-complete/setext-header-incomplete ()
"Test `markdown-incomplete-setext-p'."
(markdown-test-string "abc\n===\n"
(should (looking-at markdown-regex-header-setext))
(should-not (markdown-incomplete-setext-p)))
(markdown-test-string "abc\n==\n"
(should (looking-at markdown-regex-header-setext))
(should (markdown-incomplete-setext-p)))
(markdown-test-string "abc\n====\n"
(should (looking-at markdown-regex-header-setext))
(should (markdown-incomplete-setext-p))))
(ert-deftest test-markdown-complete/setext-header ()
"Test `markdown-complete' for setext headers."
(markdown-test-string "test \n=="
(call-interactively 'markdown-complete)
(should (string-equal (buffer-string) "test\n===="))))
(ert-deftest test-markdown-complete/hr-incomplete ()
"Test `markdown-incomplete-hr-p'."
(dolist (i (number-sequence 0 (1- (length markdown-hr-strings))))
(markdown-test-string (nth i markdown-hr-strings)
(should (looking-at markdown-regex-hr))
(should-not (markdown-incomplete-hr-p))
(should-error (call-interactively 'markdown-complete)))))
(ert-deftest test-markdown-complete/hr ()
"Test completion via `markdown-complete' for horizontal rules."
(markdown-test-string "- - - - -"
(call-interactively 'markdown-complete)
(should (string-equal (buffer-string) (car markdown-hr-strings)))))
(ert-deftest test-markdown-complete/buffer-setext-2 ()
"Test `markdown-complete-buffer' for level two setext heading."
;; Ensure markdown-complete-buffer doesn't mistake this for a horizontal rule
(markdown-test-string "Subheading\n--\n"
(call-interactively 'markdown-complete-buffer)
(should (string-equal (buffer-string) "Subheading\n----------\n\n")))
(markdown-test-string "Abc\n--\n\nDef\n--\n"
(call-interactively 'markdown-complete-buffer)
(should (string-equal (buffer-string) "Abc\n---\n\nDef\n---\n\n"))))
;;; Promotion and demotion tests:
(ert-deftest test-markdown-promote/atx-header ()
"Test `markdown-promote' for atx headers."
(markdown-test-string "###### test ######"
(markdown-promote)
(should (string-equal (buffer-string) "##### test #####"))
(markdown-promote)
(should (string-equal (buffer-string) "#### test ####"))
(markdown-promote)
(should (string-equal (buffer-string) "### test ###"))
(markdown-promote)
(should (string-equal (buffer-string) "## test ##"))
(markdown-promote)
(should (string-equal (buffer-string) "# test #"))))
(ert-deftest test-markdown-demote/atx-header ()
"Test `markdown-demote' for atx headers."
(markdown-test-string "# test #"
(markdown-demote)
(should (string-equal (buffer-string) "## test ##"))
(markdown-demote)
(should (string-equal (buffer-string) "### test ###"))
(markdown-demote)
(should (string-equal (buffer-string) "#### test ####"))
(markdown-demote)
(should (string-equal (buffer-string) "##### test #####"))
(markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))))
(ert-deftest test-markdown-promote/setext-header ()
"Test `markdown-promote' for setext headers."
(markdown-test-string "test\n----"
(markdown-promote)
(should (string-equal (buffer-string) "test\n===="))))
(ert-deftest test-markdown-demote/setext-header ()
"Test `markdown-demote' for setext headers."
(markdown-test-string "test\n===="
(markdown-demote)
(should (string-equal (buffer-string) "test\n----"))
(markdown-demote)
(should (string-equal (buffer-string) "### test ###"))
(markdown-demote)
(should (string-equal (buffer-string) "#### test ####"))
(markdown-demote)
(should (string-equal (buffer-string) "##### test #####"))
(markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))))
(ert-deftest test-markdown-promote/hr ()
"Test `markdown-promote' for horizontal rules."
(markdown-test-string (car (reverse markdown-hr-strings))
(dolist (n (number-sequence 4 0 -1))
(markdown-promote)
(should (string-equal (buffer-string) (nth n markdown-hr-strings))))))
(ert-deftest test-markdown-demote/hr ()
"Test `markdown-demote' for horizontal rules."
(markdown-test-string (car markdown-hr-strings)
(dolist (n (number-sequence 1 5))
(markdown-demote)
(should (string-equal (buffer-string) (nth n markdown-hr-strings))))))
(ert-deftest test-markdown-promote/bold ()
"Test `markdown-promote' for bold markup."
(markdown-test-string "__bold__"
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) "**bold**"))))
(ert-deftest test-markdown-demote/bold ()
"Test `markdown-demote' for bold markup."
(markdown-test-string "**bold**"
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) "__bold__"))))
(ert-deftest test-markdown-promote/italic ()
"Test `markdown-promote' for italic markup."
(markdown-test-string "_italic_"
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) "*italic*"))))
(ert-deftest test-markdown-demote/italic ()
"Test `markdown-demote' for italic markup."
(markdown-test-string "*italic*"
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) "_italic_"))))
;;; Subtree editing tests:
(ert-deftest test-markdown-subtree/promote ()
"Test `markdown-promote-subtree'."
(markdown-test-string "# h1 #\n\n## h2 ##\n\n### h3 ###\n\n## h2 ##\n\n# h1 #\n"
;; The first h1 should get promoted away.
;; The second h1 should not be promoted.
(markdown-promote-subtree)
(should (string-equal (buffer-string) "h1\n\n# h2 #\n\n## h3 ##\n\n# h2 #\n\n# h1 #\n"))
;; Second call should do nothing since point is no longer at a heading.
(markdown-promote-subtree)
(should (string-equal (buffer-string) "h1\n\n# h2 #\n\n## h3 ##\n\n# h2 #\n\n# h1 #\n"))
;; Move to h2 and promote again.
(forward-line 2)
(markdown-promote-subtree)
(should (string-equal (buffer-string) "h1\n\nh2\n\n# h3 #\n\n# h2 #\n\n# h1 #\n"))))
(ert-deftest test-markdown-subtree/promote-single-section ()
"Test `markdown-promote-subtree' on a single or last section.
Should not cause an infinite loop."
(markdown-test-string "foo\n\n## h2 ##\n\nbar\n"
;; The h2 should get promoted to h1 away.
(markdown-test-goto-heading "h2")
(markdown-promote-subtree)
(should (string-equal (buffer-string) "foo\n\n# h2 #\n\nbar\n"))))
(ert-deftest test-markdown-subtree/demote ()
"Test `markdown-demote-subtree'."
(markdown-test-string "# h1 #\n\n## h2 ##\n\n### h3 ###\n\n## h2 ##\n\n# h1 #\n"
;; The second h1 should not be demoted
(markdown-demote-subtree)
(should (string-equal (buffer-string) "## h1 ##\n\n### h2 ###\n\n#### h3 ####\n\n### h2 ###\n\n# h1 #\n"))
(markdown-demote-subtree)
(should (string-equal (buffer-string) "### h1 ###\n\n#### h2 ####\n\n##### h3 #####\n\n#### h2 ####\n\n# h1 #\n"))
(markdown-demote-subtree)
(should (string-equal (buffer-string) "#### h1 ####\n\n##### h2 #####\n\n###### h3 ######\n\n##### h2 #####\n\n# h1 #\n"))
;; Stop demoting at level six
(markdown-demote-subtree)
(should (string-equal (buffer-string) "##### h1 #####\n\n###### h2 ######\n\n###### h3 ######\n\n###### h2 ######\n\n# h1 #\n"))
(markdown-demote-subtree)
(should (string-equal (buffer-string) "###### h1 ######\n\n###### h2 ######\n\n###### h3 ######\n\n###### h2 ######\n\n# h1 #\n"))))
(ert-deftest test-markdown-subtree/move-up ()
"Test `markdown-move-subtree-up'."
;; Note that prior to Emacs 24.5, this does not work for the last subtree in
;; the buffer due to Emacs bug #19102:
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19102
;; https://github.com/emacs-mirror/emacs/commit/b3910f
;; That also corrects the type of the "Cannot move pase superior level" error
;; from 'error to 'user-error.
(markdown-test-string "# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# 2 #\n# Extra\n"
(re-search-forward "^# 2")
(markdown-move-subtree-up)
(should (string-equal (buffer-string) "# 2 #\n# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# Extra\n"))
;; Second attempt should fail, leaving buffer unchanged.
;; (This way of asserting the contents of the error
;; message is a bit convoluted and more fragile than
;; ideal. But prior to Emacs 24.5, the type of this
;; error is just 'error, and a bare "should-error" is
;; really overly broad.)
(should (string-equal
"Cannot move past superior level"
(cl-second (should-error (markdown-move-subtree-up)))))))
(ert-deftest test-markdown-subtree/move-down ()
"Test `markdown-move-subtree-down'."
(markdown-test-string "# 1 #\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n# 2 #\n"
(re-search-forward "^## 1\.1")
(markdown-move-subtree-down)
(should (string-equal (buffer-string) "# 1 #\n\n## 1.2 ##\n\n### 1.2.1 ###\n\n## 1.1 ##\n\n### 1.1.1 ###\n\n# 2 #\n"))))
(ert-deftest test-markdown-subtree/mark ()
"Test `markdown-mark-subtree'."
(markdown-test-file "outline.text"
(markdown-next-visible-heading 1)
(should-not mark-active)
(markdown-mark-subtree)
(should (= (point) 19))
(should (= (mark) 349))
(should mark-active)
(deactivate-mark)
(should-not mark-active)
(markdown-forward-same-level 1)
(markdown-mark-subtree)
(should (= (point) 351))
(should (= (mark) 515))
(should mark-active)))
(ert-deftest test-markdown-subtree/narrow ()
"Test `markdown-narrow-to-subtree'."
(markdown-test-file "outline.text"
(markdown-next-visible-heading 1)
(markdown-forward-same-level 1)
(widen)
(should (= (point-min) 1))
(should (= (point-max) 553))
(markdown-narrow-to-subtree)
(should (= (point-min) 351))
(should (= (point-max) 515))))
;;; Cycling:
(ert-deftest test-markdown-cycle/atx-header ()
"Test `markdown-demote' cycling for atx headers."
(markdown-test-string "# test"
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "## test ##"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "### test ###"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "#### test ####"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "##### test #####"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))))
(ert-deftest test-markdown-cycle/setext-header ()
"Test `markdown-demote' cycling for setext headers."
(markdown-test-string "test\n===="
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "test\n----"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "### test ###"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "#### test ####"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "##### test #####"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "###### test ######"))))
(ert-deftest test-markdown-cycle/hr ()
"Test cycling of horizontal rules."
;; Cycle using markdown-demote
(markdown-test-string (car markdown-hr-strings)
(dolist (n (number-sequence 1 5))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) (nth n markdown-hr-strings))))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) (car markdown-hr-strings))))
;; Cycle using markdown-promote
(markdown-test-string (car (reverse markdown-hr-strings))
(dolist (n (number-sequence 4 0 -1))
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) (nth n markdown-hr-strings))))
(call-interactively 'markdown-promote)
(should (string-equal (buffer-string) (car (reverse markdown-hr-strings))))))
(ert-deftest test-markdown-cycle/bold ()
"Test cycling of bold markup."
(markdown-test-string "**bold**"
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "__bold__"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "**bold**"))))
(ert-deftest test-markdown-cycle/italic ()
"Test cycling of italic markup."
(markdown-test-string "*italic*"
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "_italic_"))
(call-interactively 'markdown-demote)
(should (string-equal (buffer-string) "*italic*"))))
;;; Indentation tests:
(ert-deftest test-markdown-indentation/calc-indents ()
"Test `markdown-calc-indents' a nested list context."
(markdown-test-file "nested-list.text"
(goto-char (point-max))
(let ((indents (markdown-calc-indents)))
(should (= (car indents) 17)) ; indentation of previous line first
(should (equal (sort indents '<)
(list
0 ; beginning of line
3 ; first-level list marker
7 ; second-level list marker
11 ; third-level list marker
13 ; previous list item text
16 ; pre-block indentation
17 ; indentation of previous line
21 ; previous line plus tab-width
))))))
(ert-deftest test-markdown-indentation/indent-region ()
"Test `markdown-indent-region'."
;; Basic test with multiple lines
(markdown-test-string "abc\ndef\nghi\n"
(markdown-indent-region (point-min) (point-max) nil)
(should (string-equal (buffer-string) " abc\n def\n ghi\n")))
;; Following a list item
(markdown-test-string " * abc\ndef\n"
(forward-line)
(markdown-indent-region (line-beginning-position) (line-end-position) nil)
(should (string-equal (buffer-string) " * abc\n def\n"))
(markdown-indent-region (line-beginning-position) (line-end-position) nil)
(should (string-equal (buffer-string) " * abc\n def\n"))))
(ert-deftest test-markdown-indentation/indent-list-hanging ()
"Test `markdown-indent-line' with hanging list item."
(markdown-test-string
"- list
- nested list with long lines which need to be
hard wrapped"
(goto-char (point-max))
(markdown-enter-key)
(should (eq (point) 78))))
(ert-deftest test-markdown-indentation/indent-list-single ()
"Test `markdown-indent-line' with single list item."
(let ((markdown-indent-on-enter 'indent-and-new-item))
(markdown-test-string " * item 1"
(end-of-line)
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) " * item 1\n * "))
(should (eq (point) 16))
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) " * item 1\n\n"))
(should (eq (point) 13)))))
(ert-deftest test-markdown-indentation/indent-nested-list ()
"Test `markdown-enter-key' with a nested list item."
(let ((markdown-indent-on-enter 'indent-and-new-item))
(markdown-test-string "* foo\n* bar\n * baz"
(goto-char (point-max))
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) "* foo\n* bar\n * baz\n * "))
(should (eq (point) 25))
(call-interactively #'markdown-enter-key)
(should (string-equal (buffer-string) "* foo\n* bar\n * baz\n\n"))
(should (eq (point) 22)))))
(ert-deftest test-markdown-indentation/indent-pre ()
"Test `markdown-indent-line' with a pre block."
(markdown-test-string
"I'm gonna write a code block:
my first line of code"
(goto-char (point-max))
(markdown-enter-key)
(should (eq (point) 62))
(should (looking-back "^ "))))
(ert-deftest test-markdown-indentation/indent-hanging-line ()
"Test `markdown-indent-line' with hanging indentation.
See GH-245."
(markdown-test-string "Stuff
More"
(forward-line)
(should (looking-at "^ More"))
(should (= (current-column) 0))
(should (= (current-indentation) 2))
(let ((last-command this-command)
(this-command 'markdown-cycle))
(call-interactively #'markdown-cycle))
(should (= (current-column) 0))
(should (= (current-indentation) 0))))
(ert-deftest test-markdown-indentation/continue-gfm-task-lists ()
(markdown-test-string " - [X] item"
(end-of-line)
(let ((markdown-indent-on-enter 'indent-and-new-item))
(call-interactively #'markdown-enter-key))
(should (string-equal (buffer-string) " - [X] item\n - [ ] "))
(should (= (point) 28))))
;;; Markup hiding tests:
(ert-deftest test-markdown-markup-hiding/italics-1 ()
"Test hiding markup for italics."
(markdown-test-file "inline.text"
(goto-char 9)
(should (looking-at "\*italic\*"))
(markdown-test-range-has-property (point) (point) 'invisible 'markdown-markup)
(should-not (invisible-p (point)))
(should-not (invisible-p (+ 1 (point))))
(markdown-toggle-markup-hiding t)
(should (invisible-p (point)))
(should-not (invisible-p (+ 1 (point))))))
(ert-deftest test-markdown-markup-hiding/bold-1 ()
"Test hiding markup for bold."
(markdown-test-file "inline.text"
(goto-char 27)
(should (looking-at "\*\*bold\*\*"))
(markdown-test-range-has-property (point) (1+ (point)) 'invisible 'markdown-markup)
(should-not (invisible-p (point)))
(should-not (invisible-p (+ 1 (point))))
(should-not (invisible-p (+ 2 (point))))
(markdown-toggle-markup-hiding t)
(should (invisible-p (point)))
(should (invisible-p (+ 1 (point))))
(should-not (invisible-p (+ 2 (point))))))
(ert-deftest test-markdown-markup-hiding/code-1 ()
"Test hiding markup for inline code."
(markdown-test-file "inline.text"
(goto-char 45)
(should (looking-at "`code`"))
(markdown-test-range-has-property (point) (point) 'invisible 'markdown-markup)
(should-not (invisible-p (point)))
(should-not (invisible-p (1+ (point))))
(markdown-toggle-markup-hiding t)
(should (invisible-p (point)))
(should-not (invisible-p (1+ (point))))))
(ert-deftest test-markdown-markup-hiding/kbd-1 ()
"Test hiding markup for tags."
(markdown-test-string "C-c C-x C-m"
(markdown-test-range-has-property (point) (+ 4 (point)) 'invisible 'markdown-markup)
(should-not (invisible-p (point))) ;; part of
(should-not (invisible-p (+ 4 (point)))) ;; part of
(should-not (invisible-p (+ 5 (point)))) ;; inside
(markdown-toggle-markup-hiding t)
(should (invisible-p (point))) ;; part of
(should (invisible-p (+ 4 (point)))) ;; part of
(should-not (invisible-p (+ 5 (point)))))) ;; inside
(ert-deftest test-markdown-markup-hiding/inline-links ()
"Test hiding markup for inline links."
(markdown-test-file "inline.text"
(goto-char 925)
(should (looking-at "\\[text\\](http://www.w3.org/ \"title\")"))
(markdown-test-range-has-property 925 925 'invisible 'markdown-markup) ; [
(markdown-test-range-has-property 930 958 'invisible 'markdown-markup) ; ](...)
(should-not (invisible-p 925))
(should-not (invisible-p 958))
(markdown-toggle-markup-hiding t)
(should (invisible-p 925))
(should-not (invisible-p 926))
(should (invisible-p 958))))
(ert-deftest test-markdown-markup-hiding/reference-links ()
"Test hiding markup for reference links."
(markdown-test-string "[text][ref]"
(markdown-test-range-has-property 1 1 'invisible 'markdown-markup) ; [
(markdown-test-range-has-property 6 11 'invisible 'markdown-markup) ; ][ref]
(should-not (invisible-p 1))
(should-not (invisible-p 6))
(markdown-toggle-markup-hiding t)
(should (invisible-p 1))
(should-not (invisible-p 2))
(should (invisible-p 6))))
(ert-deftest test-markdown-markup-hiding/angle-urls ()
"Test hiding markup for angle urls."
(markdown-test-string ""
(markdown-test-range-has-property 1 1 'invisible 'markdown-markup) ; <
(markdown-test-range-has-property 45 45 'invisible 'markdown-markup) ; >
(should-not (invisible-p 1))
(should-not (invisible-p 2))
(should-not (invisible-p 45))
(markdown-toggle-markup-hiding t)
(should (invisible-p 1))
(should-not (invisible-p 2))
(should (invisible-p 45))))
(ert-deftest test-markdown-markup-hiding/list-items ()
"Test hiding markup for list items."
(let ((markdown-hide-markup t))
(markdown-test-file "nested-list.text"
(markdown-test-range-has-property 4 4 'display (nth 0 markdown-list-item-bullets))
(markdown-test-range-has-property 194 194 'display (nth 0 markdown-list-item-bullets))
(markdown-test-range-has-property 224 224 'display (nth 1 markdown-list-item-bullets))
(markdown-test-range-has-property 525 525 'display (nth 2 markdown-list-item-bullets)))))
(ert-deftest test-markdown-markup-hiding/gfm-code-blocks ()
"Test hiding markup for GFM code blocks."
(let ((markdown-hide-markup t))
(markdown-test-file "GFM.md"
(markdown-test-range-has-property 1548 1552 'invisible 'markdown-markup)
(should (invisible-p 1548))
(should (invisible-p 1552))
(markdown-test-range-has-property 1607 1609 'invisible 'markdown-markup)
(should (invisible-p 1607))
(should (invisible-p 1609)))))
(ert-deftest test-markdown-markup-hiding/fenced-code-blocks ()
"Test hiding markup for tilde fenced code blocks."
(let ((markdown-hide-markup t))
(markdown-test-file "outline-code.text"
(markdown-test-range-has-property 83 93 'invisible 'markdown-markup)
(should (invisible-p 83))
(should (invisible-p 93))
(markdown-test-range-has-property 154 156 'invisible 'markdown-markup)
(should (invisible-p 154))
(should (invisible-p 156)))))
;;; Font lock tests:
(ert-deftest test-markdown-font-lock/italics-1 ()
"A simple italics test."
(markdown-test-file "inline.text"
(goto-char 9)
(should (looking-at "\*"))
;; Check face of char before leading asterisk
(markdown-test-range-has-face 8 8 nil)
;; Check face of italic range
(markdown-test-range-has-face 9 9 'markdown-markup-face)
(markdown-test-range-has-face 10 16 'markdown-italic-face)
(markdown-test-range-has-face 17 17 'markdown-markup-face)
;; Check face of point past leading asterisk
(markdown-test-range-has-face 18 18 nil)))
(ert-deftest test-markdown-font-lock/italics-2 ()
"Test space after leading asterisk or underscore."
(markdown-test-string
"This is * not italic*, nor _ is this_."
(markdown-test-range-has-face (point-min) (point-max) nil)))
(ert-deftest test-markdown-font-lock/italics-3 ()
"Test that slash inside asterisks is not italic."
(markdown-test-string
"not italic *\\*"
(markdown-test-range-has-face (point-min) (point-max) nil)))
(ert-deftest test-markdown-font-lock/italics-4 ()
"Test escaped asterisk inside italics."
(markdown-test-string
"italic *\\**"
(markdown-test-range-has-face 1 7 nil)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 9 10 'markdown-italic-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-5 ()
"Test italic single letter."
(markdown-test-string
"*a*"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 2 'markdown-italic-face)
(markdown-test-range-has-face 3 3 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-6 ()
"Test multiline italics across list items."
(markdown-test-string
"* something about function foo_bar
* something else about foo_bar"
(markdown-test-range-has-face 31 34 nil)
(markdown-test-range-has-face 38 62 nil)))
(ert-deftest test-markdown-font-lock/italics-8 ()
"Test multiline italics across list items."
(markdown-test-string
"* something about function
foo_bar
* something else about
foo_bar"
(markdown-test-range-has-face 30 36 nil)
(markdown-test-range-has-face 63 69 nil)))
(ert-deftest test-markdown-font-lock/italics-9 ()
"Test multiline italics across list items."
(markdown-test-string
"foo_bar
* foo_bar"
(markdown-test-range-has-face 4 7 nil)
(markdown-test-range-has-face 11 14 nil)))
(ert-deftest test-markdown-font-lock/italics-10 ()
"Underscores in URLs should not trigger italics."
(markdown-test-string
""
(markdown-test-range-face-equals 2 50 'markdown-plain-url-face)
(should-not (markdown-range-property-any 43 43 'face '(markdown-italic-face)))))
(ert-deftest test-markdown-font-lock/italics-11 ()
"Underscores in URLs should not trigger italics."
(markdown-test-string
"[1]: http://jblevins.org/research/centroid/cd_z_path.m"
(markdown-test-range-face-equals 6 54 'markdown-url-face)))
(ert-deftest test-markdown-font-lock/italics-12 ()
"Underscores in URLs should not trigger italics."
(markdown-test-string
"[cd\\_z\\_path.m](http://jblevins.org/research/centroid/cd_z_path.m)"
(markdown-test-range-face-equals 17 65 'markdown-url-face)))
(ert-deftest test-markdown-font-lock/italics-after-hr ()
"Test italics after a horizontal rule with asterisks."
(markdown-test-string "* * *\n\n*italic*\n"
(markdown-test-range-has-face 1 5 'markdown-hr-face)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 9 14 'markdown-italic-face)
(markdown-test-range-has-face 15 15 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-in-heading ()
"Test italic overlay in a heading."
(markdown-test-string
"# *Italics* in a Heading"
(markdown-test-range-has-face 3 3 'markdown-markup-face)
(markdown-test-range-has-face 4 10 'markdown-italic-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-link ()
"Test italic overlay in an inline link."
(markdown-test-string
"*[italic link](http://www.link.com/)*"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 36 'markdown-italic-face)
(markdown-test-range-has-face 37 37 'markdown-markup-face))
(markdown-test-string
"[*italic link*](http://www.link.com/)"
(markdown-test-range-has-face 2 2 'markdown-markup-face)
(markdown-test-range-has-face 3 13 'markdown-italic-face)
(markdown-test-range-has-face 14 14 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-in-blockquote ()
"Test italics overlay in a blockquote."
(markdown-test-string
"> *italics* inside a blockquote"
(markdown-test-range-has-face 3 3 'markdown-markup-face)
(markdown-test-range-has-face 4 10 'markdown-italic-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-in-pre ()
"Test italics overlay in a blockquote."
(markdown-test-string
" *italics* inside a pre block"
(markdown-test-range-has-face (point-min) (1- (point-max))
'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/italics-and-code ()
"Test seeming italics mixed with code."
(markdown-test-string
"define `var_1` and `var_2` inline code"
(markdown-test-range-has-face 9 13 'markdown-inline-code-face)
(markdown-test-range-has-face 21 25 'markdown-inline-code-face))
(markdown-test-string
"`var_1` and var_2"
(markdown-test-range-has-face 2 6 'markdown-inline-code-face)
(markdown-test-range-has-face 8 17 nil))
(markdown-test-string
"var_1 and `var_2`"
(markdown-test-range-has-face 1 10 nil)
(markdown-test-range-has-face 12 16 'markdown-inline-code-face)))
(ert-deftest test-markdown-font-lock/code-in-italics ()
"Test inline code inside italics.
See GH-275."
(markdown-test-string
"*text `code` text*"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 17 'markdown-italic-face)
(markdown-test-range-has-face 7 7 'markdown-markup-face)
(markdown-test-range-has-face 8 11 'markdown-inline-code-face)
(markdown-test-range-has-face 12 12 'markdown-markup-face)
(markdown-test-range-has-face 18 18 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/italics-in-reference-definitions ()
"Test not matching italics in reference definitions across lines."
(markdown-test-string
"[lg]: twilight_sm.png\n[sm]: twilight_lg.png"
(markdown-test-range-has-face 7 21 'markdown-url-face)
(markdown-test-range-has-face 22 22 nil)
(markdown-test-range-has-face 29 43 'markdown-url-face)
(markdown-test-range-has-face 28 28 nil)))
(ert-deftest test-markdown-font-lock/italics-in-comment ()
"Test not matching italics in comments."
(markdown-test-string
""
(markdown-test-range-has-face 1 30 'markdown-comment-face)
(should-not (markdown-range-property-any 1 30 'face '(markdown-italic-face)))))
(ert-deftest test-markdown-font-lock/italics-after-bold ()
"Test bold and italics on the same line.
See GH-223."
(markdown-test-string
"**foo** is a *bar*"
(markdown-test-range-has-face 1 2 'markdown-markup-face)
(markdown-test-range-has-face 3 5 'markdown-bold-face)
(markdown-test-range-has-face 6 7 'markdown-markup-face)
(should-not
(markdown-range-property-any 8 13 'face '(markdown-italic-face)))
(markdown-test-range-has-face 14 14 'markdown-markup-face)
(markdown-test-range-has-face 15 17 'markdown-italic-face)
(markdown-test-range-has-face 18 18 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-1 ()
"A simple bold test."
(markdown-test-file "inline.text"
(goto-char 27)
(should (looking-at "\*\*"))
;; Check face of char before leading asterisk
(markdown-test-range-has-face 26 26 nil)
;; Check face of opening asterisks
(markdown-test-range-has-face 27 28 'markdown-markup-face)
;; Check face of bold range
(markdown-test-range-has-face 29 33 'markdown-bold-face)
;; Check face of closing asterisks
(markdown-test-range-has-face 34 35 'markdown-markup-face)
;; Check face of point past leading asterisk
(markdown-test-range-has-face 36 36 nil)))
(ert-deftest test-markdown-font-lock/bold-2 ()
"Test space after leading asterisks or underscores."
(markdown-test-string
"This is ** not bold**, nor __ is this__."
(should-not
(markdown-range-property-any
(point-min) (point-max) 'face '(markdown-bold-face)))))
(ert-deftest test-markdown-font-lock/bold-3 ()
"Test escaped asterisk inside bold."
(markdown-test-string
"bold **\\***"
(markdown-test-range-has-face 1 5 nil)
(markdown-test-range-has-face 6 7 'markdown-markup-face)
(markdown-test-range-has-face 8 9 'markdown-bold-face)
(markdown-test-range-has-face 10 11 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-4 ()
"Test bold single letter."
(markdown-test-string
"**a**"
(markdown-test-range-has-face 1 2 'markdown-markup-face)
(markdown-test-range-has-face 3 3 'markdown-bold-face)
(markdown-test-range-has-face 4 5 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-after-hr ()
"Test bold after a horizontal rule with asterisks."
(markdown-test-string "* * *\n\n**bold**\n"
(markdown-test-range-has-face 1 5 'markdown-hr-face)
(markdown-test-range-has-face 8 9 'markdown-markup-face)
(markdown-test-range-has-face 10 13 'markdown-bold-face)
(markdown-test-range-has-face 14 15 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-link ()
"Test bold overlay in an inline link."
(markdown-test-string
"**[bold link](http://www.link.com/)**"
(markdown-test-range-has-face 1 2 'markdown-markup-face)
(markdown-test-range-has-face 3 35 'markdown-bold-face)
(markdown-test-range-has-face 36 37 'markdown-markup-face))
(markdown-test-string
"[**bold link**](http://www.link.com/)"
(markdown-test-range-has-face 2 3 'markdown-markup-face)
(markdown-test-range-has-face 4 12 'markdown-bold-face)
(markdown-test-range-has-face 13 14 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-in-blockquote ()
"Test bold overlay in a blockquote."
(markdown-test-string
"> **bold** inside a blockquote"
(markdown-test-range-has-face 3 4 'markdown-markup-face)
(markdown-test-range-has-face 5 8 'markdown-bold-face)
(markdown-test-range-has-face 9 10 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-in-pre ()
"Test bold overlay in a blockquote."
(markdown-test-string
" **bold** inside a pre block"
(markdown-test-range-has-face (point-min) (1- (point-max))
'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/no-bold-in-code ()
"Bold markers in inline code should not trigger bold."
(markdown-test-string
"`def __init__(self):`"
(markdown-test-range-has-face 8 11 'markdown-inline-code-face)
(should-not (markdown-range-property-any
(point-min) (point-max) 'face '(markdown-bold-face))))
(markdown-test-string
"`**foo` bar `baz**`"
(markdown-test-range-has-face 2 6 'markdown-inline-code-face)
(markdown-test-range-face-equals 9 11 nil)
(markdown-test-range-has-face 14 18 'markdown-inline-code-face)
(should-not (markdown-range-property-any
(point-min) (point-max) 'face '(markdown-bold-face)))))
(ert-deftest test-markdown-font-lock/code-in-bold ()
"Test inline code inside bold."
(markdown-test-string
"**text `code` text**"
(markdown-test-range-has-face 1 2 'markdown-markup-face)
(markdown-test-range-has-face 3 18 'markdown-bold-face)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 9 12 'markdown-inline-code-face)
(markdown-test-range-has-face 13 13 'markdown-markup-face)
(markdown-test-range-has-face 19 20 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/bold-in-comment ()
"Test not matching bold in comments."
(markdown-test-string
""
(markdown-test-range-has-face 1 21 'markdown-comment-face)
(should-not
(markdown-range-property-any 1 21 'face '(markdown-bold-face)))))
(ert-deftest test-markdown-font-lock/no-bold-in-url ()
"Test not matching bold in plain URL links."
(markdown-test-string
""
(should-not (markdown-range-property-any 23 30 'face '(markdown-bold-face)))))
(ert-deftest test-markdown-font-lock/code-1 ()
"A simple inline code test."
(markdown-test-file "inline.text"
(goto-char 45)
(should (looking-at "`"))
;; Regular code span
(markdown-test-range-has-face 45 45 'markdown-markup-face)
(markdown-test-range-has-face 46 49 'markdown-inline-code-face)
(markdown-test-range-has-face 50 50 'markdown-markup-face)
;; Code containing backticks
(markdown-test-range-has-face 61 62 'markdown-markup-face)
(markdown-test-range-has-face 63 87 'markdown-inline-code-face)
(markdown-test-range-has-face 88 89 'markdown-markup-face)
;; Seven backquotes in a row
(markdown-test-range-has-face 119 125 nil)
;; Backquotes at beginning or end
(markdown-test-range-has-face 228 229 'markdown-markup-face)
(markdown-test-range-has-face 230 237 'markdown-inline-code-face)
(markdown-test-range-has-face 238 239 'markdown-markup-face)
(markdown-test-range-has-face 341 342 'markdown-markup-face)
(markdown-test-range-has-face 343 349 'markdown-inline-code-face)
(markdown-test-range-has-face 350 351 'markdown-markup-face)
;; Backslash as final character
(markdown-test-range-has-face 460 460 'markdown-markup-face)
(markdown-test-range-has-face 461 467 'markdown-inline-code-face)
(markdown-test-range-has-face 468 468 'markdown-markup-face)
;; Escaping of leading backquotes
(markdown-test-range-has-face 586 592 nil)
(markdown-test-range-has-face 597 603 nil)
;; A code span crossing lines
(markdown-test-range-has-face 652 656 nil)
(markdown-test-range-has-face 657 657 'markdown-markup-face)
(markdown-test-range-has-face 658 665 'markdown-inline-code-face)
(markdown-test-range-has-face 666 666 'markdown-markup-face)
;; Three backquotes: same line, across lines, not across blocks
(markdown-test-range-has-face 695 748 nil)
(markdown-test-range-has-face 749 750 'markdown-markup-face)
(markdown-test-range-has-face 751 755 'markdown-inline-code-face)
(markdown-test-range-has-face 756 757 'markdown-markup-face)
(markdown-test-range-has-face 758 805 nil)
(markdown-test-range-has-face 806 807 'markdown-markup-face)
(markdown-test-range-has-face 808 812 'markdown-inline-code-face)
(markdown-test-range-has-face 813 814 'markdown-markup-face)
(markdown-test-range-has-face 815 891 nil)
))
(ert-deftest test-markdown-font-lock/code-2 ()
"Multiple code spans in a row and on different lines."
(markdown-test-string "`foo` `bar` `baz`"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 4 'markdown-inline-code-face)
(markdown-test-range-has-face 5 5 'markdown-markup-face)
(markdown-test-range-has-face 6 6 nil)
(markdown-test-range-has-face 7 7 'markdown-markup-face)
(markdown-test-range-has-face 8 10 'markdown-inline-code-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)
(markdown-test-range-has-face 12 12 nil)
(markdown-test-range-has-face 13 13 'markdown-markup-face)
(markdown-test-range-has-face 14 16 'markdown-inline-code-face)
(markdown-test-range-has-face 17 17 'markdown-markup-face))
(markdown-test-string "`a`\n`b`\n`c`\n"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 2 'markdown-inline-code-face)
(markdown-test-range-has-face 3 3 'markdown-markup-face)
(markdown-test-range-has-face 4 4 nil)
(markdown-test-range-has-face 5 5 'markdown-markup-face)
(markdown-test-range-has-face 6 6 'markdown-inline-code-face)
(markdown-test-range-has-face 7 7 'markdown-markup-face)
(markdown-test-range-has-face 8 8 nil)
(markdown-test-range-has-face 9 9 'markdown-markup-face)
(markdown-test-range-has-face 10 10 'markdown-inline-code-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)
(markdown-test-range-has-face 12 12 nil))
(markdown-test-string "a`foo`b`bar`c`baz`d"
(markdown-test-range-has-face 1 1 nil)
(markdown-test-range-has-face 2 2 'markdown-markup-face)
(markdown-test-range-has-face 3 5 'markdown-inline-code-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(markdown-test-range-has-face 7 7 nil)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 9 11 'markdown-inline-code-face)
(markdown-test-range-has-face 12 12 'markdown-markup-face)
(markdown-test-range-has-face 13 13 nil)
(markdown-test-range-has-face 14 14 'markdown-markup-face)
(markdown-test-range-has-face 15 17 'markdown-inline-code-face)
(markdown-test-range-has-face 18 18 'markdown-markup-face)
(markdown-test-range-has-face 19 19 nil)))
(ert-deftest test-markdown-font-lock/code-3 ()
"Backslashes don't escape backticks inside of inline code strings."
(markdown-test-string
"`foo\\`bar`"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 5 'markdown-inline-code-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(markdown-test-range-has-face 7 10 nil)))
(ert-deftest test-markdown-font-lock/code-link-precedence ()
"Test that inline code takes precedence over inline links."
(markdown-test-string
"[not a `link](/foo`)"
(markdown-test-range-has-face 1 7 nil)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 9 18 'markdown-inline-code-face)
(markdown-test-range-has-face 19 19 'markdown-markup-face)
(markdown-test-range-has-face 20 20 nil)))
(ert-deftest test-markdown-font-lock/code-in-link-text ()
"Test that inline code in link text is fontified properly"
(markdown-test-string
"[`this is a` link](/foo)"
(markdown-test-range-has-face 1 2 'markdown-markup-face)
(markdown-test-range-has-face 3 11 'markdown-inline-code-face)
(markdown-test-range-has-face 12 12 'markdown-markup-face)
(markdown-test-range-has-face 3 17 'markdown-link-face)
(markdown-test-range-has-face 18 19 'markdown-markup-face)
(markdown-test-range-has-face 20 23 'markdown-url-face)
(markdown-test-range-has-face 24 24 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/code-italics-precedence ()
"Test that inline code takes precedence over italics.
Test currently fails because this case isn't handled properly."
(markdown-test-string
"*text `code* text`"
(markdown-test-range-has-face 1 6 nil)
(markdown-test-range-has-face 7 7 'markdown-markup-face)
(markdown-test-range-has-face 8 17 'markdown-inline-code-face)
(markdown-test-range-has-face 18 18 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/code-in-comment ()
"Test that inline code is not matched inside a comment."
(markdown-test-string
""
(markdown-test-range-has-face 1 19 'markdown-comment-face)
(should-not (markdown-range-property-any 1 19 'face '(markdown-inline-code-face)))))
(ert-deftest test-markdown-font-lock/kbd ()
"Test font lock for tags."
(markdown-test-string "C-c <"
(markdown-test-range-has-face 1 5 'markdown-markup-face)
(markdown-test-range-has-face 6 10 'markdown-inline-code-face)
(markdown-test-range-has-face 11 16 'markdown-markup-face))
(markdown-test-string "To quit Emacs, press C-x C-c."
(markdown-test-range-has-face 1 21 nil)
(markdown-test-range-has-face 22 26 'markdown-markup-face)
(markdown-test-range-has-face 27 33 'markdown-inline-code-face)
(markdown-test-range-has-face 34 39 'markdown-markup-face)
(markdown-test-range-has-face 40 40 nil)))
(ert-deftest test-markdown-font-lock/lists-1 ()
"A simple list marker font lock test."
(markdown-test-file "lists.text"
(dolist (loc (list 1063 1283 1659 1830 1919 2150 2393 2484
2762 2853 3097 3188 3700 3903 4009))
(goto-char loc)
(should (looking-at "[*+-]"))
(markdown-test-range-has-face loc loc 'markdown-list-face))))
(ert-deftest test-markdown-font-lock/definition-list ()
"A simple definition list marker font lock test."
(markdown-test-file "definition-list.text"
(markdown-test-range-has-face 7 7 'markdown-list-face)
(markdown-test-range-has-face 29 52 'markdown-pre-face)
(markdown-test-range-has-face 55 55 'markdown-list-face)))
(ert-deftest test-markdown-font-lock/pre-1 ()
"Nested list and pre block font lock test."
(markdown-test-file "nested-list.text"
(dolist (loc (list 4 29 194 224 491 525))
(markdown-test-range-has-face loc loc 'markdown-list-face))
(markdown-test-range-has-face 6 25 nil)
(markdown-test-range-has-face 31 83 nil)
(markdown-test-range-has-face 85 154 'markdown-pre-face)
(markdown-test-range-has-face 157 189 nil)
(markdown-test-range-has-face 196 215 nil)
(markdown-test-range-has-face 226 403 nil)
(markdown-test-range-has-face 405 481 'markdown-pre-face)
(markdown-test-range-has-face 493 512 nil)
(markdown-test-range-has-face 527 546 nil)
(markdown-test-range-has-face 548 580 'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/pre-2 ()
(markdown-test-string "* item\n\nreset baseline\n\n pre block\n"
(markdown-test-range-has-face 1 1 'markdown-list-face)
(markdown-test-range-has-face 2 23 nil)
(markdown-test-range-has-face 29 37 'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/pre-3 ()
(markdown-test-string "It is interesting to see what happens when one queries
`social upheaval` and `protopalatial era`.
* `social upheaval`: the follwing queries have been tried:
social upheaval subClassOf"
(markdown-test-range-has-face 160 190 nil)))
(ert-deftest test-markdown-font-lock/pre-4 ()
"Pre blocks must be preceded by a blank line"
(markdown-test-string "Paragraph
for (var i = 0; i < 10; i++) {
console.log(i);
}"
(markdown-test-range-has-face (point-min) (point-max) nil)))
(ert-deftest test-markdown-font-lock/fenced-1 ()
"Test fenced code blocks containing four-space indents."
(markdown-test-string "Fenced code block
~~~
if (x)
foo();
if (y)
bar();
~~~
"
(markdown-test-range-has-face 1 19 nil)
(markdown-test-range-has-face 20 22 'markdown-markup-face)
(markdown-test-range-has-face 24 59 'markdown-pre-face)
(markdown-test-range-has-face 61 63 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/gfm-fenced-1 ()
"Test GFM-style fenced code blocks (1)."
(let ((markdown-fontify-code-blocks-natively t))
(markdown-test-string "```ruby
require 'redcarpet'
markdown = Redcarpet.new('Hello World!')
puts markdown.to_html
```"
(markdown-test-range-has-face 1 3 'markdown-markup-face) ; ```
(markdown-test-range-has-face 4 7 'markdown-language-keyword-face) ; ruby
(markdown-test-range-has-face 9 90 'markdown-code-face) ; entire code block
(markdown-test-range-has-face 9 15 'font-lock-builtin-face) ; require
(markdown-test-range-has-face 17 27 'font-lock-string-face) ; 'redcarpet'
(markdown-test-range-has-face 40 48 'font-lock-type-face) ; Redcarpet
(markdown-test-range-has-face 70 72 'font-lock-builtin-face) ; puts
(markdown-test-range-has-face 92 94 'markdown-markup-face)))) ; ```
(ert-deftest test-markdown-font-lock/gfm-fenced-2 ()
"Test GFM-style fenced code blocks (2)."
(markdown-test-string "```{r sum}\n2+2\n```"
(markdown-test-range-has-face 1 3 'markdown-markup-face) ; ```
(markdown-test-range-has-face 4 4 'markdown-markup-face) ; {
(markdown-test-range-has-face 5 5 'markdown-language-keyword-face) ; r
(markdown-test-range-has-face 7 9 'markdown-language-info-face) ; sum
(markdown-test-range-has-face 10 10 'markdown-markup-face) ; }
(markdown-test-range-has-face 12 14 'markdown-pre-face) ; 2+2
(markdown-test-range-has-face 16 18 'markdown-markup-face))) ; ```
(ert-deftest test-markdown-font-lock/gfm-fenced-3 ()
"GFM-style code blocks need not be preceded by a blank line."
(markdown-test-string "Paragraph
```js
for (var i = 0; i < 10; i++) {
console.log(i);
}
```"
(markdown-test-range-has-face 1 10 nil) ; Paragraph
(markdown-test-range-has-face 11 13 'markdown-markup-face) ; ```
(markdown-test-range-has-face 14 15 'markdown-language-keyword-face) ; js
(markdown-test-range-has-face 17 68 'markdown-pre-face)
(markdown-test-range-has-face 70 72 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/gfm-fenced-4 ()
"Test GFM-style fenced code blocks (2)."
(markdown-test-string "```scalaFiddle libraries=\"Java8 Time-0.1.0\"\nimport java.time._\n\nval hour = LocalTime.now().getHour()\n\nprintln(hour)\n```"
(markdown-test-range-has-face 1 3 'markdown-markup-face) ; ```
(markdown-test-range-has-face 4 14 'markdown-language-keyword-face) ; scalaFiddle
(markdown-test-range-has-face 16 43 'markdown-language-info-face) ; libraries="Java8 Time-0.1.0"
(markdown-test-range-has-face 45 115 'markdown-pre-face) ; [code]
(markdown-test-range-has-face 117 119 'markdown-markup-face))) ; ```
(ert-deftest test-markdown-font-lock/tilde-fenced-1 ()
"Test native fontification of tilde fenced code blocks."
(let ((markdown-fontify-code-blocks-natively t))
(markdown-test-string "~~~ruby
require 'redcarpet'
markdown = Redcarpet.new('Hello World!')
puts markdown.to_html
~~~"
(markdown-test-range-has-face 1 3 'markdown-markup-face) ; ```
(markdown-test-range-has-face 4 7 'markdown-language-keyword-face) ; ruby
(markdown-test-range-has-face 9 90 'markdown-code-face) ; entire code block
(markdown-test-range-has-face 9 15 'font-lock-builtin-face) ; require
(markdown-test-range-has-face 17 27 'font-lock-string-face) ; 'redcarpet'
(markdown-test-range-has-face 40 48 'font-lock-type-face) ; Redcarpet
(markdown-test-range-has-face 70 72 'font-lock-builtin-face) ; puts
(markdown-test-range-has-face 92 94 'markdown-markup-face)))) ; ```
(ert-deftest test-markdown-font-lock/atx-no-spaces ()
"Test font-lock for atx headers with no spaces."
(markdown-test-string "##abc##"
(markdown-test-range-has-face 1 7 nil))
(markdown-test-string "##"
(markdown-test-range-has-face 1 2 nil))
(markdown-test-string "###"
(markdown-test-range-has-face 1 3 nil)))
(ert-deftest test-markdown-font-lock/setext-1-letter ()
"An edge case for level-one setext headers."
(markdown-test-string "a\n=\n"
(markdown-test-range-has-face 1 1 'markdown-header-face-1)
(markdown-test-range-has-face 3 3 'markdown-header-rule-face)))
(ert-deftest test-markdown-font-lock/setext-2-letter ()
"An edge case for level-two setext headers."
(markdown-test-string "b\n-\n"
(markdown-test-range-has-face 1 1 'markdown-header-face-2)
(markdown-test-range-has-face 3 3 'markdown-header-rule-face)))
(ert-deftest test-markdown-font-lock/inline-links ()
"Test font lock for inline links."
(let ((markdown-hide-urls nil))
(markdown-test-file "inline.text"
(markdown-test-range-has-face 925 925 'markdown-markup-face)
(markdown-test-range-has-face 926 929 'markdown-link-face)
(markdown-test-range-has-face 930 931 'markdown-markup-face)
(markdown-test-range-has-face 932 949 'markdown-url-face)
(markdown-test-range-has-face 951 957 'markdown-link-title-face)
(markdown-test-range-has-face 958 958 'markdown-markup-face))))
(ert-deftest test-markdown-font-lock/inline-links-with-parentheses ()
"Test font lock for inline links with nested parentheses.
See ."
(let ((markdown-hide-urls nil))
(markdown-test-string "[foo](bar(baz)qux)"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 4 'markdown-link-face)
(markdown-test-range-has-face 5 6 'markdown-markup-face)
(markdown-test-range-has-face 7 17 'markdown-url-face)
(markdown-test-range-has-face 18 18 'markdown-markup-face))))
(ert-deftest test-markdown-font-lock/pre-comment ()
"Test comments inside of a pre block."
(markdown-test-string " "
(markdown-test-range-has-face (point-min) (1- (point-max)) 'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/inline-code-comment ()
"Test comments inside of inline code."
(markdown-test-string "` `"
(markdown-test-range-has-face (1+ (point-min)) (- (point-max) 2) 'markdown-inline-code-face)))
(ert-deftest test-markdown-font-lock/inline-code-link ()
"Test links inside of inline code."
(markdown-test-string "`[text](url)`"
(markdown-test-range-has-face (1+ (point-min)) (- (point-max) 2) 'markdown-inline-code-face)
(should-not (markdown-range-property-any
(1+ (point-min)) (- (point-max) 2) 'face
'(markdown-markup-face markdown-link-face markdown-url-face)))))
(ert-deftest test-markdown-font-lock/comment-hanging-indent ()
"Test comments with hanging indentation."
(markdown-test-string ""
(markdown-test-range-has-face (point-min) (1- (point-max)) 'markdown-comment-face)))
(ert-deftest test-markdown-font-lock/comment-multiple ()
"Test multiple single-line comments in arow."
(markdown-test-string "\n"
(markdown-test-range-has-face
(point-at-bol) (1- (point-at-eol)) 'markdown-comment-face)
(forward-line)
(markdown-test-range-has-face
(point-at-bol) (1- (point-at-eol)) 'markdown-comment-face)))
(ert-deftest test-markdown-font-lock/comment-list-items ()
"Test comment with list inside."
(markdown-test-string
""
(markdown-test-range-face-equals (point-min) (1- (point-max))
'markdown-comment-face)))
(ert-deftest test-markdown-font-lock/comment-angle-bracket ()
"Regression test for GH-117."
(markdown-test-string ""
(markdown-test-range-face-equals (point-min) (1- (point-max))
'markdown-comment-face)))
(ert-deftest test-markdown-font-lock/comment-link ()
"Test links inside of comments."
(markdown-test-string ""
(markdown-test-range-has-face (+ (point-min) 5) (- (point-max) 4) 'markdown-comment-face)
(should-not (markdown-range-property-any
(+ (point-min) 5) (- (point-max) 4) 'face
'(markdown-markup-face markdown-link-face markdown-url-face)))))
(ert-deftest test-markdown-font-lock/footnote-markers-links ()
"Test an edge case involving footnote markers and inline reference links."
(markdown-test-string "Harvard[^1] [tuition][]"
(markdown-test-range-has-face 1 7 nil)
(markdown-test-range-has-face 8 8 'markdown-markup-face)
(markdown-test-range-has-face 10 10 'markdown-footnote-marker-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)
(markdown-test-range-has-face 12 12 nil)
(markdown-test-range-has-face 13 13 'markdown-markup-face)
(markdown-test-range-has-face 14 20 'markdown-link-face)
(markdown-test-range-has-face 21 21 'markdown-markup-face)
(markdown-test-range-has-face 22 23 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/mmd-metadata ()
"Basic MultMarkdown metadata tests."
(markdown-test-string "Title: peg-multimarkdown User's Guide
Author: Fletcher T. Penney
Base Header Level: 2"
(markdown-test-range-has-face 1 5 'markdown-metadata-key-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(markdown-test-range-has-face 8 37 'markdown-metadata-value-face)
(markdown-test-range-has-face 39 44 'markdown-metadata-key-face)
(markdown-test-range-has-face 46 46 'markdown-markup-face)
(markdown-test-range-has-face 47 64 'markdown-metadata-value-face)
(markdown-test-range-has-face 66 82 'markdown-metadata-key-face)
(markdown-test-range-has-face 83 83 'markdown-markup-face)
(markdown-test-range-has-face 85 85 'markdown-metadata-value-face))
;; Avoid triggering when a title contains a colon (e.g., Markdown: Syntax)
(markdown-test-file "syntax.text"
(markdown-test-range-has-face 1 16 'markdown-header-face-1)))
(ert-deftest test-markdown-font-lock/mmd-metadata-after-header ()
"Ensure that similar lines are not matched after the header."
(markdown-test-string "Title: peg-multimarkdown User's Guide
Author: Fletcher T. Penney
Base Header Level: 2"
(markdown-test-range-has-face 1 5 'markdown-metadata-key-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(markdown-test-range-has-face 8 37 'markdown-metadata-value-face)
(markdown-test-range-has-face 40 65 nil)
(markdown-test-range-has-face 67 86 nil)))
(ert-deftest test-markdown-font-lock/mmd-metadata-after-header-with-whitespace ()
"Ensure that similar lines are not matched after the header.
The blank line here has two spaces, which should not change how
it is parsed."
(markdown-test-string
"Title: peg-multimarkdown User's Guide\n \nAuthor: Fletcher T. Penney\nBase Header Level: 2\n"
(markdown-test-range-has-face 1 5 'markdown-metadata-key-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(markdown-test-range-has-face 8 37 'markdown-metadata-value-face)
(markdown-test-range-has-face 42 67 nil)
(markdown-test-range-has-face 69 88 nil)))
(ert-deftest test-markdown-font-lock/pandoc-metadata ()
"Basic Pandoc metadata tests."
(markdown-test-string "% title
two-line title
% first author;
second author
% date
body"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 3 24 'markdown-metadata-value-face)
(markdown-test-range-has-face 26 26 'markdown-markup-face)
(markdown-test-range-has-face 28 56 'markdown-metadata-value-face)
(markdown-test-range-has-face 58 58 'markdown-markup-face)
(markdown-test-range-has-face 60 63 'markdown-metadata-value-face)
(markdown-test-range-has-face 64 69 nil)))
(ert-deftest test-markdown-font-lock/yaml-metadata ()
"Basic YAML metadata tests."
(markdown-test-string
"---
layout: post
date: 2015-08-13 11:35:25 EST
---
"
(markdown-test-range-has-face 1 3 'markdown-markup-face)
(markdown-test-range-has-face 5 10 'markdown-metadata-key-face)
(markdown-test-range-has-face 11 11 'markdown-markup-face)
(markdown-test-range-has-face 13 16 'markdown-metadata-value-face)
(markdown-test-range-has-face 18 21 'markdown-metadata-key-face)
(markdown-test-range-has-face 22 22 'markdown-markup-face)
(markdown-test-range-has-face 24 46 'markdown-metadata-value-face)
(markdown-test-range-has-face 48 50 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/toml-metadata ()
"Basic TOML metadata tests."
(markdown-test-string
"---
layout = post
date = 2015-08-13 11:35:25 EST
---
"
(markdown-test-range-has-face 1 3 'markdown-markup-face)
(markdown-test-range-has-face 5 10 'markdown-metadata-key-face)
(markdown-test-range-has-face 12 12 'markdown-markup-face)
(markdown-test-range-has-face 14 17 'markdown-metadata-value-face)
(markdown-test-range-has-face 19 22 'markdown-metadata-key-face)
(markdown-test-range-has-face 24 24 'markdown-markup-face)
(markdown-test-range-has-face 26 48 'markdown-metadata-value-face)
(markdown-test-range-has-face 50 52 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/pandoc-yaml-metadata ()
"Basic yaml metadata tests, with pandoc syntax."
(let ((markdown-use-pandoc-style-yaml-metadata t))
(markdown-test-string
"some text
---
layout: post
date: 2015-08-13 11:35:25 EST
...
more text
---
layout: post
date: 2015-08-13 11:35:25 EST
---
But this is merely a code block
```
---
layout: post
date: 2015-08-13 11:35:25 EST
---
```
"
;; first section
(markdown-test-range-has-face 12 14 'markdown-markup-face)
(markdown-test-range-has-face 16 21 'markdown-metadata-key-face)
(markdown-test-range-has-face 22 22 'markdown-markup-face)
(markdown-test-range-has-face 24 27 'markdown-metadata-value-face)
(markdown-test-range-has-face 29 32 'markdown-metadata-key-face)
(markdown-test-range-has-face 33 33 'markdown-markup-face)
(markdown-test-range-has-face 35 57 'markdown-metadata-value-face)
(markdown-test-range-has-face 59 61 'markdown-markup-face)
;; second section
(markdown-test-range-has-face 75 77 'markdown-markup-face)
(markdown-test-range-has-face 79 84 'markdown-metadata-key-face)
(markdown-test-range-has-face 85 85 'markdown-markup-face)
(markdown-test-range-has-face 87 90 'markdown-metadata-value-face)
(markdown-test-range-has-face 92 95 'markdown-metadata-key-face)
(markdown-test-range-has-face 96 96 'markdown-markup-face)
(markdown-test-range-has-face 98 120 'markdown-metadata-value-face)
(markdown-test-range-has-face 122 124 'markdown-markup-face)
;; third section
(markdown-test-range-has-face 160 162 'markdown-markup-face)
(markdown-test-range-has-face 164 213 'markdown-pre-face)
(markdown-test-range-has-face 215 217 'markdown-markup-face))))
(ert-deftest test-markdown-font-lock/line-break ()
"Basic line break tests."
(markdown-test-string " \nasdf \n"
(markdown-test-range-has-face 1 9 nil)
(markdown-test-range-has-face 10 11 'markdown-line-break-face)))
(ert-deftest test-markdown-font-lock/blockquote-bold ()
"Test font lock for bold inside of a blockquote."
(markdown-test-string
"> **bold**"
(markdown-test-range-has-face 1 10 'markdown-blockquote-face)
(markdown-test-range-has-face 5 8 'markdown-bold-face)))
(ert-deftest test-markdown-font-lock/blockquote-italic ()
"Test font lock for italic inside of a blockquote."
(markdown-test-string
"> *italic*"
(markdown-test-range-has-face 1 10 'markdown-blockquote-face)
(markdown-test-range-has-face 4 9 'markdown-italic-face)))
(ert-deftest test-markdown-font-lock/blockquote-code ()
"Test font lock for inline code inside of a blockquote."
(markdown-test-string
"> `code`"
(markdown-test-range-has-face 1 8 'markdown-blockquote-face)
(markdown-test-range-has-face 3 3 'markdown-markup-face)
(markdown-test-range-has-face 4 7 'markdown-inline-code-face)
(markdown-test-range-has-face 8 8 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/blockquote-link ()
"Test font lock for links inside of a blockquote.
This test will fail until font lock for inline links inside
blockquotes is implemented (at present, the blockquote face
takes precedence)."
(markdown-test-string
"> [link](url)"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 13 'markdown-blockquote-face)
(markdown-test-range-has-face 3 3 'markdown-markup-face)
(markdown-test-range-has-face 4 7 'markdown-link-face)
(markdown-test-range-has-face 8 9 'markdown-markup-face)
(markdown-test-range-has-face 10 12 'markdown-url-face)
(markdown-test-range-has-face 13 13 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/blockquote-comment ()
"Test font lock for comments inside of a blockquote."
(markdown-test-string
"> "
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 3 18 'markdown-comment-face)))
(ert-deftest test-markdown-font-lock/pre-override ()
"Test that font lock for pre blocks overrides everything else."
(markdown-test-string
" **bold**
_italic_
[link](url)
* list"
(markdown-test-range-has-face 1 73 'markdown-pre-face)))
(ert-deftest test-markdown-font-lock/gfm-code-block-font-lock ()
"GFM code block font lock test. Now in base markdown-mode as well!"
(markdown-test-file "gfm.text"
(markdown-test-range-has-face 2639 2641 'markdown-markup-face) ; ```
(markdown-test-range-has-face 2642 2645 'markdown-language-keyword-face) ; lang
(markdown-test-range-has-face 2647 2728 'markdown-pre-face) ; code
(markdown-test-range-has-face 2730 2732 'markdown-markup-face))) ; ```
(ert-deftest test-markdown-font-lock/reference-definition ()
"Reference definitions should not include ]."
(let ((markdown-hide-urls nil))
(markdown-test-string "[1]: http://daringfireball.net/ \"title\""
(markdown-test-range-has-face 2 2 'markdown-reference-face) ; 1
(markdown-test-range-has-face 6 31 'markdown-url-face) ; URL
(markdown-test-range-has-face 34 38 'markdown-link-title-face)) ; title
(markdown-test-string "[foo][1] and [bar][2]: not a reference definition"
(markdown-test-range-has-face 2 4 'markdown-link-face) ; foo
(markdown-test-range-has-face 7 7 'markdown-reference-face) ; 1
(markdown-test-range-has-face 9 13 nil) ; [ ]and[ ]
(markdown-test-range-has-face 15 17 'markdown-link-face) ; bar
(markdown-test-range-has-face 20 20 'markdown-reference-face) ; 2
(markdown-test-range-has-face 22 49 nil)))) ; [ ]and[ ]
(ert-deftest test-markdown-font-lock/subscripts ()
"Test font lock for subscripts."
(markdown-test-string "H~2~0"
(markdown-test-range-has-face 2 2 'markdown-markup-face) ; First ~
(markdown-test-range-has-face 3 3 nil) ; 2
(markdown-test-range-has-face 4 4 'markdown-markup-face))) ; Second ~
(ert-deftest test-markdown-font-lock/superscripts ()
"Test font lock for subscripts."
(markdown-test-string "334^10^"
(markdown-test-range-has-face 1 3 nil) ; 334
(markdown-test-range-has-face 4 4 'markdown-markup-face) ; First ^
(markdown-test-range-has-face 5 6 nil) ; 10
(markdown-test-range-has-face 7 7 'markdown-markup-face))) ; Second ^
(ert-deftest test-markdown-font-lock/hidden-urls-inline ()
"Test URL hiding and toggling."
(let ((markdown-hide-urls t))
(markdown-test-file "inline.text"
(markdown-test-range-has-face 925 925 'markdown-markup-face)
(markdown-test-range-has-face 926 929 'markdown-link-face)
(markdown-test-range-has-face 930 931 'markdown-markup-face)
(markdown-test-range-has-face 932 949 'markdown-url-face)
(markdown-test-range-has-face 951 957 'markdown-link-title-face)
(markdown-test-range-has-face 958 958 'markdown-markup-face)
(should (get-text-property 932 'composition)))))
(ert-deftest test-markdown-font-lock/hidden-urls-reference ()
"Test URL hiding and toggling."
(let ((markdown-hide-urls t))
(markdown-test-string "[link][15]"
;; Two-character reference labels shouldn't get composed.
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 5 'markdown-link-face)
(markdown-test-range-has-face 6 7 'markdown-markup-face)
(markdown-test-range-has-face 8 9 'markdown-reference-face)
(markdown-test-range-has-face 10 10 'markdown-markup-face)
(should-not (get-text-property 8 'composition)))
(markdown-test-string "[link][long-reference-label]"
;; Longer reference labels should be composed
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 5 'markdown-link-face)
(markdown-test-range-has-face 6 7 'markdown-markup-face)
(markdown-test-range-has-face 8 27 'markdown-reference-face)
(markdown-test-range-has-face 28 28 'markdown-markup-face)
(should (get-text-property 8 'composition)))))
(ert-deftest test-markdown-font-lock/snake-case-code-in-heading ()
"Test underscores in inline code in headings."
(markdown-test-string "# Title with `snake_case_code`"
(should-not (markdown-range-property-any 21 24 'face '(markdown-italic-face)))
(markdown-test-range-has-face 15 29 'markdown-inline-code-face)))
(ert-deftest test-markdown-font-lock/stars-in-code-in-heading ()
"Test asterisks in inline code in headings."
(markdown-test-string "# Title with `char** foo, int* bar`"
(should-not (markdown-range-property-any 20 29 'face '(markdown-italic-face)))
(markdown-test-range-has-face 15 34 'markdown-inline-code-face)))
(ert-deftest test-markdown-font-lock/stars-in-code-in-blockquote ()
"Test asterisks in inline code in blockquote."
(markdown-test-string "> Quote with `**stars**`"
(should-not (markdown-range-property-any
17 21 'face '(markdown-italic-face markdown-bold-face)))
(markdown-test-range-has-face 15 23 'markdown-inline-code-face)))
(ert-deftest test-markdown-font-lock/two-bold-words-after-list ()
"Test two bold words after a list marker."
(markdown-test-string "- **foo** **bar**"
(should-not (markdown-range-property-any
(point-min) (point-max) 'face '(markdown-italic-face)))))
(ert-deftest test-markdown-font-lock/heading-with-italics-and-bold ()
"Test two bold words after a list marker."
(markdown-test-string "# Title with *italics* and **bold**"
(markdown-test-range-has-face 15 21 'markdown-italic-face)
(markdown-test-range-has-face 30 33 'markdown-bold-face)
(should-not (markdown-range-property-any 30 33 'face '(markdown-italic-face)))))
(ert-deftest test-markdown-font-lock/heading-with-italics-and-bold ()
"Test that HRs are distinguished from setext H2 markup."
(markdown-test-file "outline.text"
(goto-char 485)
(should (markdown-on-heading-p))
(beginning-of-line)
(should (markdown-on-heading-p))
(should-not (markdown-range-property-any 453 484 'face '(markdown-hr-face)))))
(ert-deftest test-markdown-font-lock/heading-code-block-no-whitespace ()
"Headings immediately before code blocks should be identified correctly.
See GH-234."
(markdown-test-string
"#### code snippet
```javascript
const styles = require('gadgets/dist/styles.css');
```"
(goto-char (point-min))
(forward-word)
(should (markdown-on-heading-p))
(should (markdown-match-propertized-text 'markdown-heading (point-at-eol)))
(goto-char (match-beginning 0))
(should (markdown-outline-level))
(should (= (markdown-outline-level) 4))
(markdown-test-range-has-face 6 17 'markdown-header-face-4)
(end-of-line)
(should-not (markdown-code-block-at-point-p))))
(ert-deftest test-markdown-font-lock/hr-underscore-with-spaces ()
"Test font-lock for HR with spaced underscores."
(markdown-test-string "_ _ _ _ _ _ _\n"
(markdown-test-range-face-equals (point-min) (- (point-max) 2) 'markdown-hr-face)))
(ert-deftest test-markdown-font-lock/hr-underscore-no-spaces ()
"Test font-lock for HR with underscores and no spaces."
(markdown-test-string "_____________\n"
(markdown-test-range-face-equals (point-min) (- (point-max) 2) 'markdown-hr-face)))
(ert-deftest test-markdown-font-lock/inline-attributes ()
"Test inline attributes before a fenced code block."
(markdown-test-file "Leanpub.md"
;; Inline attributes for a heading
(markdown-test-range-has-face 38 42 'markdown-markup-face)
;; Inline attributes inside an aside block
(markdown-test-range-has-face 123 141 'markdown-markup-face)
;; Inline attributes before a fenced code block
(markdown-test-range-has-face 632 696 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/leanpub-sections ()
"Test Leanpub section markers."
(markdown-test-file "Leanpub.md"
;; {frontmatter}
(markdown-test-range-has-face 12 24 'markdown-markup-face)
;; {mainmatter}
(markdown-test-range-has-face 69 80 'markdown-markup-face)
;; {pagebreak}
(markdown-test-range-has-face 427 437 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/leanpub-include ()
"Test Leanpub include syntax."
(markdown-test-file "Leanpub.md"
;; no title
(markdown-test-range-has-face 561 563 'markdown-markup-face)
(markdown-test-range-has-face 564 577 'markdown-url-face)
(markdown-test-range-has-face 578 578 'markdown-markup-face)
;; title
(markdown-test-range-has-face 581 583 'markdown-markup-face)
(markdown-test-range-has-face 584 611 'markdown-link-title-face)
(markdown-test-range-has-face 612 613 'markdown-markup-face)
(markdown-test-range-has-face 614 628 'markdown-url-face)
(markdown-test-range-has-face 629 629 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/curly-brace-include ()
"Test curly brace include syntax."
(markdown-test-string "<<{file}"
(markdown-test-range-has-face 1 3 'markdown-markup-face)
(markdown-test-range-has-face 4 7 'markdown-url-face)
(markdown-test-range-has-face 8 8 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/square-bracket-include ()
"Test square bracket include syntax."
(markdown-test-string "<<[file]"
(markdown-test-range-has-face 1 3 'markdown-markup-face)
(markdown-test-range-has-face 4 7 'markdown-url-face)
(markdown-test-range-has-face 8 8 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/pandoc-inline-footnote ()
"Test font lock for Pandoc inline footnotes."
(markdown-test-string "Here is an inline note.^[Inline notes are easier to write, since
you don't have to pick an identifier and move down to type the
note.] And then you can close it and continue writing."
(markdown-test-range-has-face 1 23 nil)
(markdown-test-range-has-face 24 25 'markdown-markup-face)
(markdown-test-range-has-face 26 133 'markdown-footnote-text-face)
(markdown-test-range-has-face 134 134 'markdown-markup-face)))
(ert-deftest test-markdown-font-lock/pandoc-inline-footnote-across-block ()
"Test font lock for Pandoc inline footnotes."
(markdown-test-string "Inline notes should not^[match
across blocks]"
(markdown-test-range-has-face (point-min) (point-max) nil)))
(ert-deftest test-markdown-font-lock/html-entity-named ()
"Test basic font-lock support for named HTML entities."
(markdown-test-string " "
(markdown-test-range-has-face 1 6 'markdown-html-entity-face)))
(ert-deftest test-markdown-font-lock/html-entity-hex ()
"Test basic font-lock support for hexadecimal HTML entities."
(markdown-test-string "✪"
(markdown-test-range-has-face 1 8 'markdown-html-entity-face)))
(ert-deftest test-markdown-font-lock/html-entity-decimal ()
"Test basic font-lock support for decimal HTML entities."
(markdown-test-string " "
(markdown-test-range-has-face 1 4 'markdown-html-entity-face)))
(ert-deftest test-markdown-font-lock/html-entity-in-inline-code ()
"Test that HTML entities are not matched inside inline code."
(markdown-test-string "` `"
(markdown-test-range-has-face 1 1 'markdown-markup-face)
(markdown-test-range-has-face 2 5 'markdown-inline-code-face)
(markdown-test-range-has-face 6 6 'markdown-markup-face)
(should-not (markdown-range-property-any 1 6 'face '(markdown-html-entity-face)))))
(ert-deftest test-markdown-font-lock/html-entity-in-gfm-code-block ()
"Test that HTML entities are not matched inside GFM code blocks."
(markdown-test-string "```\n \n✪\n \n```"
(should-not
(markdown-range-property-any
(point-min) (point-max) 'face '(markdown-html-entity-face)))))
(ert-deftest test-markdown-font-lock/html-tags-in-syntax-file ()
"Test matching HTML tags in syntax.text."
(markdown-test-file "syntax.text"
;;