diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-28 14:10:13 +0100 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-04-28 14:10:13 +0100 |
| commit | 986151b157b8d88328eba5b638252525352e35db (patch) | |
| tree | 0965310f5ec451608839a512c143f6a8d8bc4445 /helpful.el | |
| parent | 38dacc2f28a09e3d68a5f85e03439892285b0959 (diff) | |
Ensure we don't linkify escaped backticks
Fixes #93
Diffstat (limited to 'helpful.el')
| -rw-r--r-- | helpful.el | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -609,12 +609,15 @@ blank line afterwards." "Convert `foo' in docstrings to buttons (if bound) or else highlight." (replace-regexp-in-string ;; Replace all text of the form `foo'. - (rx "`" (+? (not (any "`" "'"))) "'") + (rx (? "\\=") "`" (+? (not (any "`" "'"))) "'") (lambda (it) (let* ((sym-name (s-chop-prefix "`" (s-chop-suffix "'" it))) (sym (intern sym-name))) (cond + ;; If the quote is escaped, don't modify it. + ((s-starts-with-p "\\=" it) + it) ;; Only create a link if this is a symbol that is bound as a ;; variable or callable. ((or (boundp sym) (fboundp sym)) @@ -831,13 +834,15 @@ unescaping too." (defun helpful--format-docstring (docstring) "Replace cross-references with links in DOCSTRING." (-> docstring - (helpful--format-command-keys) (helpful--split-first-line) (helpful--propertize-info) (helpful--propertize-links) (helpful--propertize-bare-links) (helpful--propertize-keywords) (helpful--propertize-quoted) + ;; This needs to happen after we've replaced quoted chars, so we + ;; don't confuse \\=` with `. + (helpful--format-command-keys) (s-trim))) (define-button-type 'helpful-link-button |
