Minor refactoring

Also tighten the regexp for matching the special block type with an
element from HUGO_PAIRED_SHORTCODES.
master
Kaushal Modi 8 years ago
parent ad1b513c08
commit d997c27a86
  1. 14
      ox-hugo.el

@ -2105,6 +2105,7 @@ INFO is a plist holding export options."
(str-list (when (org-string-nw-p str)
(split-string str " "))))
str-list))
(sc-regexp "\\`%%?%s\\'") ;Regexp to match an element from `paired-shortcodes'
(contents (org-trim contents)))
(cond
((string= block-type "description")
@ -2115,12 +2116,10 @@ INFO is a plist holding export options."
;; If `block-type' is "foo", check if any of the
;; elements in `paired-shortcodes' is "foo" or
;; "%foo".
:test (lambda (item list-elem)
(string-match-p (format "%%?%s" item)
list-elem)))
:test (lambda (b sc) ;`sc' would be an element from `paired-shortcodes'
(string-match-p (format sc-regexp b) sc)))
(let* ((attr-sc-raw (let* ((raw-list (org-element-property :attr_shortcode special-block))
(raw-str (mapconcat #'identity
raw-list " ")))
(raw-str (mapconcat #'identity raw-list " ")))
(org-string-nw-p raw-str)))
(attr-sc (org-export-read-attribute :attr_shortcode special-block))
;; Positional arguments
@ -2133,9 +2132,8 @@ INFO is a plist holding export options."
" "))
(matched-sc-str (car
(cl-member block-type paired-shortcodes
:test (lambda (item list-item)
(string-match-p (format "%%?%s" item)
list-item)))))
:test (lambda (b sc) ;`sc' would be an element from `paired-shortcodes'
(string-match-p (format sc-regexp b) sc)))))
(sc-open-char (if (string-prefix-p "%" matched-sc-str)
"%"
"<"))

Loading…
Cancel
Save