diff --git a/lisp/org-element.el b/lisp/org-element.el index 0faf1fd..131b442 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -2612,6 +2612,11 @@ Assume point is at the first star marker." CONTENTS is the contents of the object." (format "*%s*" contents)) +(defvar org-element--marker->type + (loop for markers in (mapcar 'car org-emphasis-alist) + for element-type in '(bold italic underline verbatim code strike-through) + collect (cons markers element-type))) + (defun org-element-text-markup-successor () "Search for the next text-markup object. @@ -2622,15 +2627,10 @@ and CDR is beginning position." (unless (bolp) (backward-char)) (when (re-search-forward org-emph-re nil t) (let ((marker (match-string 3))) - (cons (cond - ((equal marker "*") 'bold) - ((equal marker "/") 'italic) - ((equal marker "_") 'underline) - ((equal marker "+") 'strike-through) - ((equal marker "~") 'code) - ((equal marker "=") 'verbatim) - (t (error "Unknown marker at %d" (match-beginning 3)))) - (match-beginning 2)))))) + (cons + (or (assoc-default marker org-element--marker->type) + (error "Unknown marker at %d" (match-beginning 3))) + (match-beginning 2)))))) ;;;; Code diff --git a/lisp/org.el b/lisp/org.el index f2bb99f..24f07f9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4191,10 +4191,14 @@ After a match, the match groups contain these elements: (body (nth 3 e)) (nl (nth 4 e)) (body1 (concat body "*?")) - (markers (mapconcat 'car org-emphasis-alist "")) + (markers (mapconcat (lambda (em) + (regexp-quote (car em)) + ) + org-emphasis-alist "\\|")) (vmarkers (mapconcat - (lambda (x) (if (eq (nth 2 x) 'verbatim) (car x) "")) - org-emphasis-alist ""))) + (lambda (x) + (regexp-quote (if (eq (nth 2 x) 'verbatim) (car x) ""))) + org-emphasis-alist "\\|"))) ;; make sure special characters appear at the right position in the class (if (string-match "\\^" markers) (setq markers (concat (replace-match "" t t markers) "^"))) @@ -4211,7 +4215,7 @@ After a match, the match groups contain these elements: (setq org-emph-re (concat "\\([" pre "]\\|^\\)" "\\(" - "\\([" markers "]\\)" + "\\(" markers "\\)" "\\(" "[^" border "]\\|" "[^" border "]" @@ -4223,7 +4227,7 @@ After a match, the match groups contain these elements: (setq org-verbatim-re (concat "\\([" pre "]\\|^\\)" "\\(" - "\\([" vmarkers "]\\)" + "\\(" vmarkers "\\)" "\\(" "[^" border "]\\|" "[^" border "]"