Browse Source

Protect target-like strings in verbatim emphasis

Martin G. Skjaeveland writes:

> Then I write
>
> some text some text ~<<some_scr_block_name>>~.
>
> because I want "<<some_scr_block_name>>" 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.
Carsten Dominik 15 years ago
parent
commit
2ab5c21f61
4 changed files with 27 additions and 7 deletions
  1. 11 0
      lisp/ChangeLog
  2. 5 1
      lisp/org-docbook.el
  3. 10 5
      lisp/org-html.el
  4. 1 1
      lisp/org-latex.el

+ 11 - 0
lisp/ChangeLog

@@ -1,3 +1,14 @@
+2009-11-08  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* 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  <carsten.dominik@gmail.com>
 
 	* org-clock.el (org-show-notification): Handle messages that

+ 5 - 1
lisp/org-docbook.el

@@ -736,8 +736,12 @@ publishing directory."
 	  ;; Make targets to anchors.  Note that currently FOP does not
 	  ;; seem to support <anchor> 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 "@<anchor xml:id=\"%s\"/>"

+ 10 - 5
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 "@<span class=\"target\">" (match-string 1 line) "@</span> ")
-;			  (concat "@<i>" (match-string 1 line) "@</i> ")
+			  (concat "@<span class=\"target\">"
+				  (match-string 1 line) "@</span> ")
+			  ;; (concat "@<i>" (match-string 1 line) "@</i> ")
 			  t t line)))
 	     (t
 	      (setq line (replace-match
 			  (concat "@<a name=\""
 				  (org-solidify-link-text (match-string 1 line))
-				  "\" class=\"target\">" (match-string 1 line) "@</a> ")
+				  "\" class=\"target\">" (match-string 1 line)
+				  "@</a> ")
 			  t t line)))))
-
+	    
 	  (setq line (org-html-handle-time-stamps line))
 
 	  ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"

+ 1 - 1
lisp/org-latex.el

@@ -1785,7 +1785,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   (while (re-search-forward
 	  (concat "<<<?" org-export-latex-all-targets-re
 		  ">>>?\\((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