diff options
author | Sean Allred <code@seanallred.com> | 2014-11-27 13:03:00 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-27 13:03:00 -0500 |
commit | ef6a16eece42f1b2bdbd0270f197964dddb5818d (patch) | |
tree | 04fd5795519eaec5be83ffb9dd5a5d24a5581693 | |
parent | 2576521ee0ecb2831356fb21c9eb4698832d82cc (diff) | |
parent | de0f242552610ed2dcca537bd9843c4d798bfc8f (diff) |
Merge branch 'master' into hotfix
-rw-r--r-- | sx-question-mode.el | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el index 3cc06b5..6dc8395 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -387,12 +387,34 @@ where `value' is given `face' as its face. (goto-char (point-min)) (while (null (eobp)) ;; Don't fill pre blocks. - (unless (sx-question-mode--move-over-pre) + (unless (sx-question-mode--dont-fill-here) (skip-chars-forward "\r\n[:blank:]") (fill-paragraph) (forward-paragraph))) (buffer-string))) +(defvar sx-question-mode--reference-regexp + (rx line-start (0+ blank) "[%s]:" (0+ blank) + (group-n 1 (1+ (not blank)))) + "Regexp used to find the url of labeled links. +E.g.: + [1]: https://...") + +(defun sx-question-mode--dont-fill-here () + "If text shouldn't be filled here, return t and skip over it." + (or (sx-question-mode--move-over-pre) + ;; Skip headers and references + (let ((pos (point))) + (skip-chars-forward "\r\n[:blank:]") + (goto-char (line-beginning-position)) + (if (or (looking-at-p (format sx-question-mode--reference-regexp ".+")) + (looking-at-p "^#")) + ;; Returns non-nil + (forward-paragraph) + ;; Go back and return nil + (goto-char pos) + nil)))) + (defvar sx-question-mode--link-regexp ;; Done at compile time. (rx "[" (group-n 1 (1+ (not (any "]")))) "]" @@ -454,8 +476,7 @@ If ID is nil, use FALLBACK-ID instead." (save-match-data (goto-char (point-min)) (when (search-forward-regexp - (format (rx line-start (0+ blank) "[%s]:" (0+ blank) - (group-n 1 (1+ (not blank)))) + (format sx-question-mode--reference-regexp (or id fallback-id)) nil t) (match-string-no-properties 1))))) |