Browse Source

improve latex listings code block name export

* lisp/org-exp.el (org-export-format-source-code-or-example): escape
  underscores in code block names on latex listings export

* lisp/org-latex.el (org-export-latex-listings-w-names): make export
  of code block names to latex optional
Eric Schulte 14 years ago
parent
commit
717c73cc7a
2 changed files with 13 additions and 2 deletions
  1. 5 2
      lisp/org-exp.el
  2. 8 0
      lisp/org-latex.el

+ 5 - 2
lisp/org-exp.el

@@ -2288,8 +2288,11 @@ INDENT was the original indentation of the block."
 					     lang)))
                                      (format "\\lstset{language=%s}\n" lstlang))
                                  "\n")
-                               (when caption
-                                 (format "\n%s $\\equiv$ \n" caption))
+                               (when (and caption
+					  org-export-latex-listings-w-names)
+                                 (format "\n%s $\\equiv$ \n"
+					 (replace-regexp-in-string
+					  "_" "\\\\_" caption)))
                                "\\begin{lstlisting}\n"
                                rtn "\\end{lstlisting}\n")
                             (concat (car org-export-latex-verbatim-wrap)

+ 8 - 0
lisp/org-latex.el

@@ -398,6 +398,14 @@ hurt if it is present."
 	   (symbol :tag "Major mode       ")
 	   (string :tag "Listings language"))))
 
+(defcustom org-export-latex-listings-w-names t
+  "Non-nil means export names of named code blocks.
+Code blocks exported with the listings package (controlled by the
+`org-export-latex-listings' variable) can be named in the style
+of noweb."
+  :group 'org-export-latex
+  :type 'boolean)
+
 (defcustom org-export-latex-remove-from-headlines
   '(:todo nil :priority nil :tags nil)
   "A plist of keywords to remove from headlines.  OBSOLETE.