Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode
This commit is contained in:
commit
b39f3ec692
25
doc/org.texi
25
doc/org.texi
|
@ -8653,13 +8653,24 @@ Here is an example
|
|||
@cindex formatting source code, markup rules
|
||||
If the example is source code from a programming language, or any other text
|
||||
that can be marked up by font-lock in Emacs, you can ask for the example to
|
||||
look like the fontified Emacs buffer@footnote{Currently this works for the
|
||||
HTML backend, and requires the @file{htmlize.el} package version 1.34 or
|
||||
later. It also works for LaTeX with the listings package, if you turn on the
|
||||
option @code{org-export-latex-listings} and make sure that the listings
|
||||
package is included by the LaTeX header.}. This is done with the @samp{src}
|
||||
block, where you also need to specify the name of the major mode that should
|
||||
be used to fontify the example:
|
||||
look like the fontified Emacs buffer@footnote{This works automatically for
|
||||
the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
|
||||
which is distributed with Org.) Fontified code chunks in LaTeX can be
|
||||
achieved using either the listings or the
|
||||
@url{http://code.google.com/p/minted, minted,} package. To use listings, turn
|
||||
on the variable @code{org-export-latex-listings} and ensure that the listings
|
||||
package is included by the LaTeX header (e.g. by configuring
|
||||
@code{org-export-latex-packages-alist}). See the listings documentation for
|
||||
configuration options, including obtaining colored output. For minted it is
|
||||
necessary to install the program @url{http://pygments.org, pygments}, in
|
||||
addition to setting @code{org-export-latex-minted}, ensuring that the minted
|
||||
package is included by the LaTeX header, and ensuring that the
|
||||
@code{-shell-escape} option is passed to @file{pdflatex} (see
|
||||
@code{org-latex-to-pdf-process}). See the documentation of the variables
|
||||
@code{org-export-latex-listings} and @code{org-export-latex-minted} for
|
||||
further details.}. This is done with the @samp{src} block, where you also
|
||||
need to specify the name of the major mode that should be used to fontify the
|
||||
example:
|
||||
@cindex #+BEGIN_SRC
|
||||
|
||||
@example
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python)
|
||||
"Preferred python mode for use in running python interactively.")
|
||||
|
||||
(defvar org-src-preserve-indentation)
|
||||
(defun org-babel-expand-body:python (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(concat
|
||||
|
|
|
@ -607,6 +607,7 @@ table.el tables."
|
|||
(:TeX-macros "TeX" org-export-with-TeX-macros)
|
||||
(:LaTeX-fragments "LaTeX" org-export-with-LaTeX-fragments)
|
||||
(:latex-listings nil org-export-latex-listings)
|
||||
(:latex-minted nil org-export-latex-minted)
|
||||
(:skip-before-1st-heading "skip" org-export-skip-text-before-1st-heading)
|
||||
(:fixed-width ":" org-export-with-fixed-width)
|
||||
(:timestamps "<" org-export-with-timestamps)
|
||||
|
@ -2208,6 +2209,9 @@ in the list) and remove property and value from the list in LISTVAR."
|
|||
(defvar org-export-latex-listings) ;; defined in org-latex.el
|
||||
(defvar org-export-latex-listings-langs) ;; defined in org-latex.el
|
||||
(defvar org-export-latex-listings-w-names) ;; defined in org-latex.el
|
||||
(defvar org-export-latex-minted) ;; defined in org-latex.el
|
||||
(defvar org-export-latex-minted-langs) ;; defined in org-latex.el
|
||||
(defvar org-export-latex-minted-with-line-numbers) ;; defined in org-latex.el
|
||||
|
||||
(defun org-export-format-source-code-or-example
|
||||
(backend lang code &optional opts indent caption)
|
||||
|
@ -2337,35 +2341,55 @@ INDENT was the original indentation of the block."
|
|||
(setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt))
|
||||
(concat "#+BEGIN_LaTeX\n"
|
||||
(org-add-props
|
||||
(if org-export-latex-listings
|
||||
(concat
|
||||
(if lang
|
||||
(let*
|
||||
((lang-sym (intern lang))
|
||||
(lstlang
|
||||
(or (cadr
|
||||
(assq
|
||||
lang-sym
|
||||
org-export-latex-listings-langs))
|
||||
lang)))
|
||||
(format "\\lstset{language=%s}\n" lstlang))
|
||||
"\n")
|
||||
(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)
|
||||
rtn (cdr org-export-latex-verbatim-wrap)))
|
||||
'(org-protected t org-example t))
|
||||
"#+END_LaTeX\n"))
|
||||
((eq backend 'ascii)
|
||||
;; This is not HTML or LaTeX, so just make it an example.
|
||||
(setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt))
|
||||
(concat caption "\n"
|
||||
"#+BEGIN_ASCII\n"
|
||||
(cond
|
||||
(org-export-latex-listings
|
||||
(concat
|
||||
(if lang
|
||||
(let*
|
||||
((lang-sym (intern lang))
|
||||
(lstlang
|
||||
(or (cadr
|
||||
(assq
|
||||
lang-sym
|
||||
org-export-latex-listings-langs))
|
||||
lang)))
|
||||
(format "\\lstset{language=%s}\n" lstlang))
|
||||
"\n")
|
||||
(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"))
|
||||
(org-export-latex-minted
|
||||
(if lang
|
||||
(let*
|
||||
((lang-sym (intern lang))
|
||||
(minted-lang
|
||||
(or (cadr
|
||||
(assq
|
||||
lang-sym
|
||||
org-export-latex-minted-langs))
|
||||
(downcase lang))))
|
||||
(concat
|
||||
(when (and caption
|
||||
org-export-latex-listings-w-names)
|
||||
(format "\n%s $\\equiv$ \n"
|
||||
(replace-regexp-in-string
|
||||
"_" "\\\\_" caption)))
|
||||
(format
|
||||
"\\begin{minted}[mathescape,%s\nnumbersep=5pt,\nframe=lines,\nframesep=2mm]{%s}\n" (if org-export-latex-minted-with-line-numbers "\nlinenos," "") minted-lang)
|
||||
rtn "\\end{minted}\n"))))
|
||||
(t (concat (car org-export-latex-verbatim-wrap)
|
||||
rtn (cdr org-export-latex-verbatim-wrap))))
|
||||
'(org-protected t org-example t))
|
||||
"#+END_LaTeX\n"))
|
||||
((eq backend 'ascii)
|
||||
;; This is not HTML or LaTeX, so just make it an example.
|
||||
(setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt))
|
||||
(concat caption "\n"
|
||||
"#+BEGIN_ASCII\n"
|
||||
(org-add-props
|
||||
(concat
|
||||
(mapconcat
|
||||
|
|
|
@ -411,6 +411,52 @@ of noweb."
|
|||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-export-latex-minted nil
|
||||
"Non-nil means export source code using the minted package.
|
||||
This package will fontify source code with color.
|
||||
If you want to use this, you need to make LaTeX use the
|
||||
minted package. Add this to `org-export-latex-packages-alist',
|
||||
for example using customize, or with something like
|
||||
|
||||
(require 'org-latex)
|
||||
(add-to-list 'org-export-latex-packages-alist '(\"\" \"minted\"))
|
||||
|
||||
In addition, it is neccessary to configure
|
||||
`org-latex-to-pdf-process' so that the -shell-escape option is
|
||||
passed to pdflatex."
|
||||
:group 'org-export-latex
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-export-latex-minted-langs
|
||||
'((emacs-lisp "common-lisp")
|
||||
(cc "c++")
|
||||
(cperl "perl")
|
||||
(shell-script "bash")
|
||||
(caml "ocaml"))
|
||||
"Alist mapping languages to their minted language counterpart.
|
||||
The key is a symbol, the major mode symbol without the \"-mode\".
|
||||
The value is the string that should be inserted as the language parameter
|
||||
for the minted package. If the mode name and the listings name are
|
||||
the same, the language does not need an entry in this list - but it does not
|
||||
hurt if it is present.
|
||||
|
||||
Note that minted uses all lower case for language identifiers,
|
||||
and that the full list of language identifiers can be obtained
|
||||
with:
|
||||
pygmentize -L lexers
|
||||
"
|
||||
:group 'org-export-latex
|
||||
:type '(repeat
|
||||
(list
|
||||
(symbol :tag "Major mode ")
|
||||
(string :tag "Listings language"))))
|
||||
|
||||
(defcustom org-export-latex-minted-with-line-numbers nil
|
||||
"Should source code line numbers be included when exporting
|
||||
with the latex minted package?"
|
||||
: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.
|
||||
|
|
Loading…
Reference in New Issue