From 0b0460703a69e47ef7e86741316f484febe2f5f3 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 24 Aug 2009 11:13:00 +0200 Subject: [PATCH] Fix plain link export --- lisp/ChangeLog | 4 ++++ lisp/org-exp.el | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 866f30435..8be4d9fd6 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2009-08-24 Carsten Dominik + * org-exp.el (org-export-protect-sub-super): New function. + (org-export-normalize-links): Protect the url of plain links from + supscript and superscript processing. + * org-remember.el (org-remember-escaped-%): New function. (org-remember-apply-template): Use `org-remember-escaped-%' to detect escaped % signs. diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 195a1cba6..32cf5f25e 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1846,6 +1846,12 @@ When it is nil, all comments will be removed." (point-at-eol)) (end-of-line 1)))) +(defun org-export-protect-sub-super (s) + (save-match-data + (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s) + (setq s (replace-match "\\1\\\\\\2" nil nil s))) + s)) + (defun org-export-normalize-links () "Convert all links to bracket links, and expand link abbreviations." (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re)) @@ -1855,8 +1861,11 @@ When it is nil, all comments will be removed." (while (re-search-forward re-plain-link nil t) (goto-char (1- (match-end 0))) (org-if-unprotected-at (1+ (match-beginning 0)) - (let* ((s (concat (match-string 1) "[[" (match-string 2) - ":" (match-string 3) "]]"))) + (let* ((s (concat (match-string 1) + "[[" (match-string 2) ":" (match-string 3) + "][" (match-string 2) ":" (org-export-protect-sub-super + (match-string 3)) + "]]"))) ;; added 'org-link face to links (put-text-property 0 (length s) 'face 'org-link s) (replace-match s t t)))) @@ -1864,8 +1873,11 @@ When it is nil, all comments will be removed." (while (re-search-forward re-angle-link nil t) (goto-char (1- (match-end 0))) (org-if-unprotected - (let* ((s (concat (match-string 1) "[[" (match-string 2) - ":" (match-string 3) "]]"))) + (let* ((s (concat (match-string 1) + "[[" (match-string 2) ":" (match-string 3) + "][" (match-string 2) ":" (org-export-protect-sub-super + )(match-string 3) + "]]"))) (put-text-property 0 (length s) 'face 'org-link s) (replace-match s t t)))) (goto-char (point-min))