Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode

This commit is contained in:
Carsten Dominik 2010-01-05 18:20:54 +01:00
commit 70f28cbfc8
2 changed files with 22 additions and 25 deletions

View File

@ -135,22 +135,10 @@ options are taken from `org-babel-default-header-args'."
(case type
('inline (format "=%s=" (second info)))
('block
(when args
(unless (string-match "-i\\>" switches)
(setq switches (concat switches " -i")))
(setq body (with-temp-buffer
(insert body)
(indent-code-rigidly (point-min) (point-max) org-babel-function-def-export-indent)
(buffer-string)))
(setq args (mapconcat #'identity
(delq nil (mapcar (lambda (el) (and (length (cdr el)) (cdr el))) args))
", "))
(setq function-def-line
(format "#+BEGIN_SRC org-babel-lob\n%s %s(%s):\n#+END_SRC\n"
org-babel-function-def-export-keyword name args)))
(concat function-def-line
(format "#+BEGIN_SRC %s %s\n%s%s#+END_SRC" lang switches body
(let ((str (format "#+BEGIN_SRC %s %s\n%s%s#+END_SRC\n" lang switches body
(if (string-match "\n$" body) "" "\n"))))
(add-text-properties 0 (length str) (list 'org-caption name) str)
str))
('lob (save-excursion
(re-search-backward org-babel-lob-one-liner-regexp)
(format "#+BEGIN_SRC org-babel-lob\n%s\n#+END_SRC"

View File

@ -2295,7 +2295,7 @@ in the list) and remove property and value from the list in LISTVAR."
"Replace source code segments with special code for export."
(setq org-export-last-code-line-counter-value 0)
(let ((case-fold-search t)
lang code trans opts indent)
lang code trans opts indent caption)
(goto-char (point-min))
(while (re-search-forward
"\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
@ -2305,14 +2305,16 @@ in the list) and remove property and value from the list in LISTVAR."
(setq lang (match-string 3)
opts (match-string 4)
code (match-string 5)
indent (length (match-string 2)))
indent (length (match-string 2))
caption (get-text-property 0 'org-caption (match-string 0)))
(setq lang nil
opts (match-string 8)
code (match-string 9)
indent (length (match-string 7))))
indent (length (match-string 7))
caption (get-text-property 0 'org-caption (match-string 0))))
(setq trans (org-export-format-source-code-or-example
backend lang code opts indent))
backend lang code opts indent caption))
(replace-match trans t t))))
(defvar htmlp) ;; dynamically scoped
@ -2322,7 +2324,7 @@ in the list) and remove property and value from the list in LISTVAR."
(defvar org-export-latex-listings-langs) ;; defined in org-latex.el
(defun org-export-format-source-code-or-example
(backend lang code &optional opts indent)
(backend lang code &optional opts indent caption)
"Format CODE from language LANG and return it formatted for export.
If LANG is nil, do not add any fontification.
OPTS contains formatting options, like `-n' for triggering numbering lines,
@ -2410,9 +2412,14 @@ INDENT was the original indentation of the block."
(org-export-htmlize-region-for-paste
(point-min) (point-max))))
(if (string-match "<pre\\([^>]*\\)>\n*" rtn)
(setq rtn (replace-match
(setq rtn
(concat
(if caption
(format "<label class=\"org-src-name\">%s</label>\n" caption)
"")
(replace-match
(format "<pre class=\"src src-%s\">\n" lang)
t t rtn))))
t t rtn)))))
(if textareap
(setq rtn (concat
(format "<p>\n<textarea cols=\"%d\" rows=\"%d\" overflow-x:scroll >\n"
@ -2448,9 +2455,10 @@ INDENT was the original indentation of the block."
lang-sym
org-export-latex-listings-langs))
lang)))
(format "\\lstset{language=%s}\n" lstlang))
(format "\\lstset{language=%s}" lstlang))
"")
"\\begin{lstlisting}\n"
"\\begin{lstlisting}"
(if caption (format "[title={%s}]\n" caption) "\n")
rtn "\\end{lstlisting}\n")
(concat (car org-export-latex-verbatim-wrap)
rtn (cdr org-export-latex-verbatim-wrap)))
@ -2459,7 +2467,8 @@ INDENT was the original indentation of the block."
((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 "#+BEGIN_ASCII\n"
(concat caption "\n"
"#+BEGIN_ASCII\n"
(org-add-props
(concat
(mapconcat