From d57b9e84e16b7a9434c5ef0f0728f82c8cb6a9d8 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 20:57:21 +0200 Subject: [PATCH 1/7] ox-latex: Better handling of sub/superscript within sub/superscript * lisp/ox-latex.el (org-latex--script-size): Fix error when using sub/superscript within sub/superscript. --- lisp/ox-latex.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dafb991b1..dd8f77421 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2205,7 +2205,17 @@ holding contextual information." "Transcode a subscript or superscript object. OBJECT is an Org object. INFO is a plist used as a communication channel." - (let ((output "")) + (let ((in-script-p + ;; Non-nil if object is already in a sub/superscript. + (let ((parent object)) + (catch 'exit + (while (setq parent (org-export-get-parent parent)) + (let ((type (org-element-type parent))) + (cond ((memq type '(subscript superscript)) + (throw 'exit t)) + ((memq type org-element-all-elements) + (throw 'exit nil)))))))) + (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) (lambda (obj) @@ -2235,10 +2245,15 @@ channel." (let ((blank (org-element-property :post-blank obj))) (and blank (> blank 0) "\\ "))))))) info nil org-element-recursive-objects) - ;; Result. - (format (if (= (length output) 1) "$%s%s$" "$%s{%s}$") + ;; Result. Do not wrap into math mode if already in a subscript + ;; or superscript. Do not wrap into curly brackets if OUTPUT is + ;; a single character. + (concat (and (not in-script-p) "$") (if (eq (org-element-type object) 'subscript) "_" "^") - output))) + (and (> (length output) 1) "{") + output + (and (> (length output) 1) "}") + (and (not in-script-p) "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. From 99f88219951ca73bfea95e433211f566b354fedc Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 20:56:32 +0200 Subject: [PATCH 2/7] ox-latex: Use \text command for subscript and superscript * lisp/ox-latex.el (org-latex--script-size): Use \text command for subscript and superscript. This is far superior to \mathrm, but it requires "amstext" package. In particular, accented characters are now allowed within sub/superscript. * lisp/org.el (org-latex-default-packages-alist): Add "amstext" package. --- lisp/org.el | 2 ++ lisp/ox-latex.el | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a7570dd4f..1ceeda21c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3810,6 +3810,7 @@ header, or they will be appended." ("" "wasysym" t) ("" "latexsym" t) ("" "amssymb" t) + ("" "amstext" nil) ("" "hyperref" nil) "\\tolerance=1000") "Alist of default packages to be inserted in the header. @@ -3821,6 +3822,7 @@ The packages in this list are needed by one part or another of Org mode to function properly: - inputenc, fontenc: for basic font and character selection +- amstext: for subscript and superscript - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used for interpreting the entities in `org-entities'. You can skip some of these packages if you don't use any of the diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dd8f77421..c6fb9a0fe 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2232,12 +2232,7 @@ channel." (and blank (> blank 0) "\\ ")))))) (plain-text (setq output - (format "%s\\mathrm{%s}" - output - ;; \mathrm command doesn't handle spaces, so - ;; we have to enforce them. - (replace-regexp-in-string - " " "\\\\ " (org-export-data obj info))))) + (format "%s\\text{%s}" output (org-export-data obj info)))) (otherwise (setq output (concat output From f6bf19f898b1e89728db4e3be2b3c176a4067e53 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Wed, 17 Apr 2013 21:38:21 +0200 Subject: [PATCH 3/7] ob-perl: fix result handling * lisp/ob-perl.el (org-babel-perl-wrapper-method): Select output handle only after evaluation so that output is not mixed into results eavaluation. (org-babel-perl-evaluate): Fix the handling of results for ":results output" to also parse tables. Use the same lambda construction as in ob-sh.el to avoid code duplication. --- lisp/ob-perl.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/ob-perl.el b/lisp/ob-perl.el index d90ca181d..43ab9467c 100644 --- a/lisp/ob-perl.el +++ b/lisp/ob-perl.el @@ -101,9 +101,9 @@ specifying a var of the same value." %s }; open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/); - select $BOH; my $rv = &$babel_sub(); my $rt = ref $rv; + select $BOH; if (qq(ARRAY) eq $rt) { local $\\=$/; local $,=qq(\t); @@ -131,19 +131,25 @@ If RESULT-TYPE equals 'output then return a list of the outputs of the statements in BODY, if RESULT-TYPE equals 'value then return the value of the last statement in BODY, as elisp." (when session (error "Sessions are not supported for Perl")) - (let ((body (concat org-babel-perl-preface ibody))) - (case result-type - (output (org-babel-eval org-babel-perl-command body)) - (value (let ((tmp-file (org-babel-temp-file "perl-"))) - (org-babel-eval - org-babel-perl-command - (format org-babel-perl-wrapper-method body - (org-babel-process-file-name tmp-file 'noquote))) - (org-babel-result-cond result-params - (with-temp-buffer - (insert-file-contents tmp-file) - (buffer-string)) - (org-babel-import-elisp-from-file tmp-file '(16)))))))) + (let* ((body (concat org-babel-perl-preface ibody)) + (tmp-file (org-babel-temp-file "perl-")) + (tmp-babel-file (org-babel-process-file-name + tmp-file 'noquote))) + ((lambda (results) + (when results + (org-babel-result-cond result-params + (org-babel-eval-read-file tmp-file) + (org-babel-import-elisp-from-file tmp-file '(16))))) + (case result-type + (output + (with-temp-file tmp-file + (insert + (org-babel-eval org-babel-perl-command body)) + (buffer-string))) + (value + (org-babel-eval org-babel-perl-command + (format org-babel-perl-wrapper-method + body tmp-babel-file))))))) (provide 'ob-perl) From 718e7e8b80c47205c36559dcce482f63e302fdf0 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 21:33:34 +0200 Subject: [PATCH 4/7] org.texi: Small fixes to HTML documentation * doc/org.texi (Math formatting in HTML export): Fix OPTIONS item's name. (Text areas in HTML export): Update text areas. (HTML Export commands): Update export commands. --- doc/org.texi | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index f697284ba..3ec4948c6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10961,26 +10961,15 @@ language, but with additional support for tables. @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export @subsection HTML export commands -@cindex region, active -@cindex active region -@cindex transient-mark-mode @table @kbd @orgcmd{C-c C-e h h,org-html-export-to-html} -@cindex property, EXPORT_FILE_NAME Export as a HTML file. For an Org file @file{myfile.org}, the HTML file will be @file{myfile.html}. The file will be overwritten -without warning. If there is an active region@footnote{This requires -@var{transient-mark-mode} be turned on.}, only the region will be -exported. If the selected region is a single tree@footnote{To select the -current subtree, use @kbd{C-c @@}.}, the tree head will become the document -title. If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME} -property, that name will be used for the export. +without warning. @kbd{C-c C-e h o} Export as a HTML file and immediately open it with a browser. @orgcmd{C-c C-e h H,org-html-export-as-html} Export to a temporary buffer. Do not create a file. -@item C-c C-e C-v h H/h h/h o -Export only the visible part of the document. @end table @c FIXME Exporting sublevels @@ -11170,7 +11159,7 @@ method requires that the @file{dvipng} program is available on your system. You can still get this processing with @example -#+OPTIONS: LaTeX:dvipng +#+OPTIONS: tex:dvipng @end example @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export @@ -11179,15 +11168,16 @@ You can still get this processing with @cindex text areas, in HTML An alternative way to publish literal code examples in HTML is to use text areas, where the example can even be edited before pasting it into an -application. It is triggered by a @code{-t} switch at an @code{example} or -@code{src} block. Using this switch disables any options for syntax and -label highlighting, and line numbering, which may be present. You may also -use @code{-h} and @code{-w} switches to specify the height and width of the -text area, which default to the number of lines in the example, and 80, -respectively. For example +application. It is triggered by @code{:textarea} attribute at an +@code{example} or @code{src} block. + +You may also use @code{:height} and @code{:width} attributes to specify the +height and width of the text area, which default to the number of lines in +the example, and 80, respectively. For example @example -#+BEGIN_EXAMPLE -t -w 40 +#+ATTR_HTML: :textarea t :width 40 +#+BEGIN_EXAMPLE (defun org-xor (a b) "Exclusive or." (if a (not b) b)) From bdde7db20cf5e267e10a97f7e8daccc056b9556b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 21:53:22 +0200 Subject: [PATCH 5/7] org.texi: Improve documentation for export settings * doc/org.texi (Export settings): Improve documentation. --- doc/org.texi | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 3ec4948c6..8d54d1ba5 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -10470,14 +10470,18 @@ A date or a time-stamp@footnote{The variable exported.}. @item DESCRIPTION -The page description, e.g., for the XHTML meta tag. +The document description. Back-ends handle it as they see fit (e.g., for the +XHTML meta tag), if at all. You can use several such keywords for long +descriptions. @item EMAIL @vindex user-mail-address The email address (@var{user-mail-address}). @item KEYWORDS -The keywords defining the contents, e.g., for the XHTML meta tag. +The keywords defining the contents of the document. Back-ends handle it as +they see fit (e.g., for the XHTML meta tag), if at all. You can use several +such keywords if the list is long. @item LANGUAGE @vindex org-export-default-language @@ -10500,7 +10504,8 @@ tag will be unconditionally excluded from the export, even if they have an @code{:export:} tag. @item TITLE -The title to be shown (otherwise derived from buffer's name). +The title to be shown (otherwise derived from buffer's name). You can use +several such keywords for long titles. @end table The @code{#+OPTIONS} keyword is a compact@footnote{If you want to configure @@ -10581,7 +10586,8 @@ Toggle the inclusion of footnotes (@var{org-export-with-footnotes}). @item H: @vindex org-export-headline-levels Set the number of headline levels for export -(@var{org-export-headline-levels}). +(@var{org-export-headline-levels}). Below that level, headlines are treated +differently. In most back-ends, they become list items. @item inline: @vindex org-export-with-inlinetasks @@ -10589,7 +10595,9 @@ Toggle inclusion of inlinetasks (@var{org-export-with-inlinetasks}). @item num: @vindex org-export-with-section-numbers -Toggle section-numbers (@var{org-export-with-section-numbers}). +Toggle section-numbers (@var{org-export-with-section-numbers}). It can also +be set to a number @samp{n}, so only headlines at that level or above will be +numbered. @item p: @vindex org-export-with-planning @@ -10599,7 +10607,7 @@ Toggle export of planning information (@var{org-export-with-planning}). @item pri: @vindex org-export-with-priority -Toggle priority cookies (@var{org-export-with-priority}). +Toggle inclusion of priority cookies (@var{org-export-with-priority}). @item stat: @vindex org-export-with-statistics-cookies @@ -10642,21 +10650,22 @@ Toggle inclusion of TODO keywords into exported text Toggle inclusion of tables (@var{org-export-with-tables}). @end table -@cindex #+BIND -A more general mechanism is also provided. Indeed, Emacs variables can -become buffer-local during export by using the BIND keyword. Its syntax is -@samp{#+BIND: variable value}. This is particularly useful for in-buffer -settings that cannot be changed using specific keywords. +@cindex property, EXPORT_FILE_NAME +When exporting only a subtree, each of the previous keywords@footnote{With +the exception of @samp{SETUPFILE}.} can be overriden locally by special node +properties. These begin with @samp{EXPORT_}, followed by the name of the +keyword they supplant. For example, @samp{DATE} and @samp{OPTIONS} keywords +become, respectively, @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS} +properties. Subtree export also supports the self-explicit +@samp{EXPORT_FILE_NAME} property@footnote{There is no buffer-wide equivalent +for this property. The file name in this case is derived from the file +associated to the buffer, if possible, or asked to the user otherwise.}. -These settings affect all buffer's export processes. Though, it is possible -to override them locally when exporting only a subtree. This is done by -adding a headline property named after the keyword with the @samp{EXPORT_} -prefix. For example, @samp{DATE} and @samp{OPTIONS} keywords become, -respectively @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS} properties. -Subtree export also supports the self-explicit @samp{EXPORT_FILE_NAME} -property@footnote{There is no buffer-wide equivalent for this property. The -file name in this case is derived from the file associated to the buffer, if -possible, or asked to the user otherwise.}. +@cindex #+BIND +Eventually, Emacs variables can become buffer-local during export by using +the BIND keyword. Its syntax is @samp{#+BIND: variable value}. This is +particularly useful for in-buffer settings that cannot be changed using +specific keywords. @node ASCII/Latin-1/UTF-8 export, Beamer export, Export settings, Exporting @section ASCII/Latin-1/UTF-8 export From 58f7e4382101b555fe7d6af460bfa2fb6208adb5 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 17 Apr 2013 22:44:28 +0200 Subject: [PATCH 6/7] ox-org.el: Fix some docstrings * lisp/ox-org.el (org-org-identity): Fix docstring. Tiny refactoring. (org-org-headline, org-org-keyword): Fix docstring. --- lisp/ox-org.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 18925c556..f55b5dc67 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -117,13 +117,13 @@ setting of `org-html-htmlize-output-type' is 'css." (org-open-file (org-org-export-to-org nil s v b)))))))) (defun org-org-identity (blob contents info) - "Transcode BLOB element or object back into Org syntax." - (funcall - (intern (format "org-element-%s-interpreter" (org-element-type blob))) - blob contents)) + "Transcode BLOB element or object back into Org syntax. +CONTENTS is its contents, as a string or nil. INFO is ignored." + (org-export-expand blob contents)) (defun org-org-headline (headline contents info) - "Transcode HEADLINE element back into Org syntax." + "Transcode HEADLINE element back into Org syntax. +CONTENTS is its contents, as a string or nil. INFO is ignored." (unless (plist-get info :with-todo-keywords) (org-element-put-property headline :todo-keyword nil)) (unless (plist-get info :with-tags) @@ -134,7 +134,8 @@ setting of `org-html-htmlize-output-type' is 'css." (defun org-org-keyword (keyword contents info) "Transcode KEYWORD element back into Org syntax. -Ignore keywords targeted at other export back-ends." +CONTENTS is nil. INFO is ignored. This function ignores +keywords targeted at other export back-ends." (unless (member (org-element-property :key keyword) (mapcar (lambda (block-cons) From 77c5710de2256dd19a1b05ea8411e787f611a515 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 18 Apr 2013 00:06:06 +0200 Subject: [PATCH 7/7] ox-latex: Handle consecutive alterning sub and superscript * lisp/ox-latex.el (org-latex--script-size): Handle consecutive alterning sub and superscript. This patch fixes export of "a^b_c" constructs. --- lisp/ox-latex.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index c6fb9a0fe..2a315ef70 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2215,6 +2215,7 @@ channel." (throw 'exit t)) ((memq type org-element-all-elements) (throw 'exit nil)))))))) + (type (org-element-type object)) (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) @@ -2242,13 +2243,29 @@ channel." info nil org-element-recursive-objects) ;; Result. Do not wrap into math mode if already in a subscript ;; or superscript. Do not wrap into curly brackets if OUTPUT is - ;; a single character. - (concat (and (not in-script-p) "$") + ;; a single character. Also merge consecutive subscript and + ;; superscript into the same math snippet. + (concat (and (not in-script-p) + (let ((prev (org-export-get-previous-element object info))) + (or (not prev) + (not (eq (org-element-type prev) + (if (eq type 'subscript) 'superscript + 'subscript))) + (let ((blank (org-element-property :post-blank prev))) + (and blank (> blank 0))))) + "$") (if (eq (org-element-type object) 'subscript) "_" "^") (and (> (length output) 1) "{") output (and (> (length output) 1) "}") - (and (not in-script-p) "$")))) + (and (not in-script-p) + (or (let ((blank (org-element-property :post-blank object))) + (and blank (> blank 0))) + (not (eq (org-element-type + (org-export-get-next-element object info)) + (if (eq type 'subscript) 'superscript + 'subscript)))) + "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX.