From 2ab5c21f61ceff894c54cc06a3a5fa19c9ba9d05 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sun, 8 Nov 2009 11:24:01 +0100 Subject: [PATCH] Protect target-like strings in verbatim emphasis Martin G. Skjaeveland writes: > Then I write > > some text some text ~<>~. > > because I want "<>" written as verbatim in my latex > export, I get, in latex, > > \texttt{\textbackslash{}label\{some\_src\_block\_name\}some\_src\_block\_name}. > > which gives me the text > > \label{some_src_block_name}some_src_block_name > > in verbatim. --- lisp/ChangeLog | 11 +++++++++++ lisp/org-docbook.el | 6 +++++- lisp/org-html.el | 15 ++++++++++----- lisp/org-latex.el | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1590b603c..192f42b23 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2009-11-08 Carsten Dominik + + * org-latex.el (org-export-latex-preprocess): Protect targets in + verbatim emphasis. + + * org-html.el (org-export-as-html): Protect targets in verbatim + emphasis. + + * org-docbook.el (org-export-as-docbook): Protect targets in + verbatim emphasis. + 2009-11-06 Carsten Dominik * org-clock.el (org-show-notification): Handle messages that diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index e3696229e..cad476fdf 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -736,8 +736,12 @@ publishing directory." ;; Make targets to anchors. Note that currently FOP does not ;; seem to support tags when generating PDF output, ;; but this can be used in DocBook --> HTML conversion. - (while (string-match "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) + (setq start 0) + (while (string-match + "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start) (cond + ((get-text-property (match-beginning 1) 'org-protected line) + (setq start (match-end 1))) ((match-end 2) (setq line (replace-match (format "@" diff --git a/lisp/org-html.el b/lisp/org-html.el index 25f53d7da..42bfedf0e 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -972,9 +972,12 @@ lang=\"%s\" xml:lang=\"%s\"> (setq line (concat line "\\\\"))))) ;; make targets to anchors + (setq start 0) (while (string-match - "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) + "<<]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start) (cond + ((get-text-property (match-beginning 1) 'org-protected line) + (setq start (match-end 1))) ((match-end 2) (setq line (replace-match (format @@ -985,16 +988,18 @@ lang=\"%s\" xml:lang=\"%s\"> ((and org-export-with-toc (equal (string-to-char line) ?*)) ;; FIXME: NOT DEPENDENT on TOC????????????????????? (setq line (replace-match - (concat "@" (match-string 1 line) "@ ") -; (concat "@" (match-string 1 line) "@ ") + (concat "@" + (match-string 1 line) "@ ") + ;; (concat "@" (match-string 1 line) "@ ") t t line))) (t (setq line (replace-match (concat "@" (match-string 1 line) "@ ") + "\" class=\"target\">" (match-string 1 line) + "@ ") t t line))))) - + (setq line (org-html-handle-time-stamps line)) ;; replace "&" by "&", "<" and ">" by "<" and ">" diff --git a/lisp/org-latex.el b/lisp/org-latex.el index fa340a4f3..19e42c7c7 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1785,7 +1785,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (while (re-search-forward (concat "<<>>?\\((INVISIBLE)\\)?") nil t) - (org-if-unprotected + (org-if-unprotected-at (+ (match-beginning 0) 2) (replace-match (org-export-latex-protect-string (format "\\label{%s}%s" (save-match-data (org-solidify-link-text