From b5cc49f539aab7a1685bbcbdb089916ecfd5476f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 22:14:29 -0200 Subject: Change regexps to defconst --- sx-question-print.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sx-question-print.el b/sx-question-print.el index e2db76f..02e14c8 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -322,14 +322,14 @@ where `value' is given `face' as its face. 'face 'markdown-list-face) "String to be displayed as the bullet of markdown list items.") -(defvar sx-question-mode--reference-regexp +(defconst 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://...") -(defvar sx-question-mode--link-regexp +(defconst sx-question-mode--link-regexp ;; Done at compile time. (rx "[" (group-n 1 (1+ (not (any "]")))) "]" (or (and "(" (group-n 2 (1+ (not (any ")")))) ")") -- cgit v1.2.3 From 9344809abe4b6b1b73038bd02b466900f1340bc3 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 7 Jan 2015 22:14:51 -0200 Subject: Enable raw links. Fix #214 --- sx-question-print.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sx-question-print.el b/sx-question-print.el index 02e14c8..d74a162 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -331,9 +331,13 @@ E.g.: (defconst sx-question-mode--link-regexp ;; Done at compile time. - (rx "[" (group-n 1 (1+ (not (any "]")))) "]" - (or (and "(" (group-n 2 (1+ (not (any ")")))) ")") - (and "[" (group-n 3 (1+ (not (any "]")))) "]"))) + (rx (or (and "[" (group-n 1 (1+ (not (any "]")))) "]" + (or (and "(" (group-n 2 (1+ (not (any ")")))) ")") + (and "[" (group-n 3 (1+ (not (any "]")))) "]"))) + (group-n 4 (and (or (and "http" (opt "s") "://") "") + (+ (any alnum "_%")) + "." + (+ (any alnum "/._%&#?=;")))))) "Regexp matching markdown links.") (defun sx-question-mode--fill-and-fontify (text) @@ -377,6 +381,7 @@ E.g.: (while (search-forward-regexp sx-question-mode--link-regexp nil t) (let* ((text (match-string-no-properties 1)) (url (or (match-string-no-properties 2) + (match-string-no-properties 4) (sx-question-mode-find-reference (match-string-no-properties 3) text))) @@ -384,7 +389,7 @@ E.g.: (when (stringp url) (replace-match "") (sx-question-mode--insert-link - (if sx-question-mode-pretty-links text full-text) + (or (if sx-question-mode-pretty-links text full-text) url) url)))))) (defun sx-question-mode--insert-link (text url) -- cgit v1.2.3