branch: elpa/markdown-mode commit 8fd66014cc49bcb080bca5e8650c4452d8719efa Author: Joe Reinhart <joseph.reinh...@gmail.com> Commit: Joe Reinhart <joseph.reinh...@gmail.com>
Use face to show missing wiki links when enabled; remove additional unused code --- README.md | 42 +++++++++++++++++++++++++++--------------- markdown-mode.el | 34 ++++++++-------------------------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index f0b384243c..41675ed989 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ 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 +```emacs-lisp (require 'package) (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/")) @@ -79,7 +79,7 @@ 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 +```emacs-lisp (use-package markdown-mode :ensure t :mode ("README\\.md\\'" . gfm-mode) @@ -99,7 +99,7 @@ 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 +```emacs-lisp (autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t) (add-to-list 'auto-mode-alist @@ -133,7 +133,7 @@ repository as above or install markdown-mode from If you clone the repository directly, then make sure that Emacs can find it by adding the following line to your startup file: -```lisp +```emacs-lisp (add-to-list 'load-path "/path/to/markdown-mode/repository") ``` @@ -351,7 +351,7 @@ can obtain a list of all keybindings by pressing <kbd>C-c C-h</kbd>. preview window to appear at the bottom or right, you can customize `markdown-split-window-direction`. - ```lisp + ```emacs-lisp ;; Set custom markdown preview function (setq markdown-live-preview-window-function #'my-markdown-preview-function) @@ -950,18 +950,17 @@ customization screen. [Marked 2]: https://itunes.apple.com/us/app/marked-2/id890031187?mt=12&uo=4&at=11l5Vs&ct=mm -## Extensions - +## Wiki Links Customization 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 <kbd>C-c C-o</kbd> when the point -is at a wiki link. Use <kbd>M-p</kbd> and <kbd>M-n</kbd> 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 +are 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` +`[[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. @@ -972,18 +971,31 @@ This value type is a symbol list. Possible values are - `parent-directories` : search in parent directories - `project` : search under project root -[SmartyPants][] support is possible by customizing `markdown-command`. +## Extensions +### SmartyPants + +[SmartyPants][] is a free tool for easily translating plain ASCII punctuation +characters into "smart" typographic punctuation HTML entities. It can perform +the following transformations: +- straight quotes ( " and ' ) into “curly” quote HTML entities +- backticks-style quotes (``like this'') into “curly” quote HTML entities +- dashes (“--” and “---”) into en- and em-dash entities +- three consecutive dots (“...”) into an ellipsis entity + +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 <kbd>M-x customize-group markdown</kbd> or by placing the following in your `.emacs` file: -```lisp +```emacs-lisp (setq markdown-command "markdown | smartypants") ``` [SmartyPants]: http://daringfireball.net/projects/smartypants/ +### LaTeX Mathematical Expressions + 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, @@ -1066,7 +1078,7 @@ by `markdown-mode` and `gfm-mode` as described below. for line wrapping in buffers. You can do this with a `gfm-mode-hook` as follows: - ```lisp + ```emacs-lisp ;; Use visual-line-mode in gfm-mode (defun my-gfm-mode-hook () (visual-line-mode 1)) diff --git a/markdown-mode.el b/markdown-mode.el index fb5fbb2fc9..7bb891c7d2 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -264,9 +264,9 @@ This is the default search behavior of Ikiwiki." (defcustom markdown-wiki-link-search-type nil "Searching type for markdown wiki link. -sub-directories: search for wiki link targets in sub directories -parent-directories: search for wiki link targets in parent directories -project: search for wiki link targets under project root" +`sub-directories': search for wiki link targets in sub directories +`parent-directories': search for wiki link targets in parent directories +`project': search for wiki link targets under project root" :group 'markdown :type '(set (const :tag "search wiki link from subdirectories" sub-directories) @@ -8273,7 +8273,6 @@ Translate filenames using `markdown-filename-translate-function'." ;; Add text properties for hiding markup (progn ;; Propertize opening and closing brackets - (remove-text-properties begin end '(font-lock-face nil)) (add-text-properties beg2 end2 markdown--markup-props) (add-face-text-property beg2 end2 'markdown-markup-face) (add-text-properties beg6 end6 markdown--markup-props) @@ -8292,7 +8291,7 @@ Translate filenames using `markdown-filename-translate-function'." (add-text-properties beg5 end5 '(invisible markdown-markup)) (add-face-text-property beg5 end5 'markdown-url-face) (when (and file-missing-p markdown-wiki-link-fontify-missing) - (put-text-property beg3 end3 'font-lock-face 'markdown-missing-link-face))) + (put-text-property beg3 end3 'face 'markdown-missing-link-face))) (progn ;; Properties URL portion of link (add-text-properties beg3 end3 markdown--url-props) @@ -8301,13 +8300,13 @@ Translate filenames using `markdown-filename-translate-function'." (add-text-properties beg5 end5 (markdown--link-props part1)) (add-face-text-property beg5 end5 'markdown-link-face) (when (and file-missing-p markdown-wiki-link-fontify-missing) - (put-text-property beg5 end5 'font-lock-face 'markdown-missing-link-face))))) + (put-text-property beg5 end5 'face 'markdown-missing-link-face))))) (progn ;; Properties link as link text (add-text-properties beg3 end3 (markdown--link-props part1)) (add-face-text-property beg3 end3 'markdown-link-face) (when (and file-missing-p markdown-wiki-link-fontify-missing) - (put-text-property beg3 end3 'font-lock-face 'markdown-missing-link-face))))) + (put-text-property beg3 end3 'face 'markdown-missing-link-face))))) (set-match-data (list begin end)) t)))) @@ -8412,12 +8411,9 @@ The location of the alias component depends on the value of (defun markdown-convert-wiki-link-to-filename (name) "Generate a filename from the wiki link NAME. Spaces in NAME are replaced with `markdown-link-space-sub-char'. +Search depth is determined by `markdown-wiki-link-search-type'. When in `gfm-mode', follow GitHub's conventions where [[Test Test]] -and [[test test]] both map to Test-test.ext. Look in the current -directory first, then in subdirectories if -`markdown-wiki-link-search-subdirectories' is non-nil, and then -in parent directories if -`markdown-wiki-link-search-parent-directories' is non-nil." +and [[test test]] both map to Test-test.ext." (save-match-data ;; This function must not overwrite match data(PR #590) (let* ((basename (replace-regexp-in-string @@ -8513,20 +8509,6 @@ and disable it otherwise." (if markdown-enable-wiki-links "enabled" "disabled"))) (markdown-reload-extensions)) -(defun markdown-toggle-fontify-missing-wiki-links (&optional arg) - "Toggle wiki link face to show whether or not target file exists. -With a prefix argument ARG, enable missing link fontification if ARG -is positive,and disable it otherwise." - (interactive (list (or current-prefix-arg 'toggle))) - (setq markdown-wiki-link-fontify-missing - (if (eq arg 'toggle) - (not markdown-wiki-link-fontify-missing) - (> (prefix-numeric-value arg) 0))) - (when (called-interactively-p 'interactive) - (message "markdown-mode fontification of missing wiki links %s" - (if markdown-enable-wiki-links "enabled" "disabled"))) - (markdown-reload-extensions)) - ;;; Following & Doing ========================================================= (defun markdown-follow-thing-at-point (arg)