* [patch, ox-latex] better hyperref and title options
@ 2015-02-12 0:39 Rasmus
2015-02-12 23:59 ` Nicolas Goaziou
0 siblings, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-02-12 0:39 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
Hi,
This patch does two things.
1. Add better format-spec to ox-latex hyperref and title-command.
2. Use this to extend basic hyperref formatting to include title,
author, language etc.
Wrt the title-command, this is useful if you need one-off "custom"
formatting of a header in LaTeX, e.g. in ox-publish projects.
—Rasmus
--
There are known knowns; there are things we know that we know
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-Format-spec-for-hyperref-and-title.patch --]
[-- Type: text/x-diff, Size: 4684 bytes --]
From d011059ef326827bd944b7949c4a14e7bdf215dd Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Wed, 11 Feb 2015 02:18:09 +0100
Subject: [PATCH] ox-latex: Format-spec for hyperref and title
* ox-latex.el (org-latex-format-spec): New function with format-specs.
(org-latex-template): Use org-latex-format-spec.
(org-latex-hyperref-template): New defaults and use
org-latex-format-spec.
(org-latex-title-command): Use org-latex-format-spec.
* ORG-NEWS: Mention change.
---
etc/ORG-NEWS | 3 +++
lisp/ox-latex.el | 51 ++++++++++++++++++++++++++++++++++-----------------
2 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 103828b..cc2c49a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -227,6 +227,9 @@ Exact heading search for links now ignore spaces and cookies. This is
the case for links of the form ~file:projects.org::*task title~, as
well as links of the form ~file:projects.org::some words~
when ~org-link-search-must-match-exact-headline~ is not nil.
+*** ~org-latex-hyperref-template~, ~org-latex-title-command~ formatting
+New formatting keys are supported. See ~org-latex-format-spec~.
+Further, ~org-latex-hyperref-template~ has new default value.
* Version 8.2
** Incompatible changes
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index d7514aa..5210447 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -383,9 +383,9 @@ are written as utf8 files."
(defcustom org-latex-title-command "\\maketitle"
"The command used to insert the title just after \\begin{document}.
-If this string contains the formatting specification \"%s\" then
-it will be used as a formatting string, passing the title as an
-argument."
+
+A number of formatting keys can be used to construct the command.
+See `org-latex-format-spec'."
:group 'org-export-latex
:type 'string)
@@ -397,14 +397,11 @@ the toc:nil option, not to those generated with #+TOC keyword."
:type 'string)
(defcustom org-latex-hyperref-template
- "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n"
+ "\\hypersetup{\n pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k},
+ pdfsubject={%d},\n pdfcreator={%c}, \n pdflang={%l}}\n"
"Template for hyperref package options.
-Value is a format string, which can contain the following placeholders:
-
- %k for KEYWORDS line
- %d for DESCRIPTION line
- %c for CREATOR line
+See `org-latex-format-spec' for placeholder keys.
Set it to the empty string to ignore the command completely."
:group 'org-export-latex
@@ -1193,6 +1190,26 @@ just outside of it."
INFO is a plist used as a communication channel."
(org-export-translate s :latex info))
+(defun org-latex-format-spec (info)
+ "Create a format-spec for e.g. `org-latex-hyperref-template'.
+
+Value is a format string, which can contain the following placeholders:
+
+ %a for AUTHOR keyword
+ %t for TITLE keyword
+ %k for KEYWORDS line
+ %d for DESCRIPTION line
+ %c for CREATOR line
+ %l for Language keyword
+ %D for DATE keyword"
+
+ `((?a . ,(or (org-export-data (plist-get info :author) info) ""))
+ (?t . ,(or (org-export-data (plist-get info :title) info) ""))
+ (?k . ,(or (plist-get info :keywords) ""))
+ (?d . ,(or (plist-get info :description) ""))
+ (?c . ,(if (plist-get info :with-creator) (plist-get info :creator) ""))
+ (?l . ,(or (plist-get info :language) ""))
+ (?D . ,(org-export-data (org-export-get-date info) info))))
\f
;;; Template
@@ -1248,17 +1265,17 @@ holding export options."
;; Title
(format "\\title{%s}\n" title)
;; Hyperref options.
- (format-spec (plist-get info :latex-hyperref-template)
- (format-spec-make
- ?k (or (plist-get info :keywords) "")
- ?d (or (plist-get info :description)"")
- ?c (if (plist-get info :with-creator)
- (plist-get info :creator)
- "")))
+ (let ((template (plist-get info :latex-hyperref-template)))
+ (and (stringp template)
+ (format-spec template
+ (org-latex-format-spec info))))
;; Document start.
"\\begin{document}\n\n"
;; Title command.
- (let ((command (plist-get info :latex-title-command)))
+ (let* ((title-command (plist-get info :latex-title-command))
+ (command (and (stringp title-command)
+ (format-spec title-command
+ (org-latex-format-spec info)))))
(org-element-normalize-string
(cond ((string= "" title) nil)
((not (stringp command)) nil)
--
2.3.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-12 0:39 [patch, ox-latex] better hyperref and title options Rasmus
@ 2015-02-12 23:59 ` Nicolas Goaziou
2015-02-15 1:53 ` Rasmus
0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-02-12 23:59 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
Hello,
Rasmus <rasmus@gmx.us> writes:
> This patch does two things.
>
> 1. Add better format-spec to ox-latex hyperref and title-command.
> 2. Use this to extend basic hyperref formatting to include title,
> author, language etc.
>
> Wrt the title-command, this is useful if you need one-off "custom"
> formatting of a header in LaTeX, e.g. in ox-publish projects.
OK.
> (defcustom org-latex-title-command "\\maketitle"
> "The command used to insert the title just after \\begin{document}.
> -If this string contains the formatting specification \"%s\" then
> -it will be used as a formatting string, passing the title as an
> -argument."
> +
> +A number of formatting keys can be used to construct the command.
> +See `org-latex-format-spec'."
Since this is a defcustom, I think formatting keys should be listed in
full in its docstring.
> (defcustom org-latex-hyperref-template
> - "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n"
> + "\\hypersetup{\n pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k},
> + pdfsubject={%d},\n pdfcreator={%c}, \n pdflang={%l}}\n"
> "Template for hyperref package options.
>
> -Value is a format string, which can contain the following placeholders:
> -
> - %k for KEYWORDS line
> - %d for DESCRIPTION line
> - %c for CREATOR line
> +See `org-latex-format-spec' for placeholder keys.
Ditto.
> +(defun org-latex-format-spec (info)
> + "Create a format-spec for e.g. `org-latex-hyperref-template'.
> +
> +Value is a format string, which can contain the following placeholders:
> +
> + %a for AUTHOR keyword
> + %t for TITLE keyword
> + %k for KEYWORDS line
> + %d for DESCRIPTION line
> + %c for CREATOR line
> + %l for Language keyword
> + %D for DATE keyword"
> +
> + `((?a . ,(or (org-export-data (plist-get info :author) info) ""))
> + (?t . ,(or (org-export-data (plist-get info :title) info) ""))
> + (?k . ,(or (plist-get info :keywords) ""))
> + (?d . ,(or (plist-get info :description) ""))
> + (?c . ,(if (plist-get info :with-creator) (plist-get info :creator) ""))
> + (?l . ,(or (plist-get info :language) ""))
> + (?D . ,(org-export-data (org-export-get-date info) info))))
Please rename it `org-latex--format-spec', this is clearly an internal
function.
Also, its docstring should refer to INFO parameter.
> + (let ((template (plist-get info :latex-hyperref-template)))
> + (and (stringp template)
> + (format-spec template
> + (org-latex-format-spec info))))
> ;; Document start.
> "\\begin{document}\n\n"
> ;; Title command.
> - (let ((command (plist-get info :latex-title-command)))
> + (let* ((title-command (plist-get info :latex-title-command))
> + (command (and (stringp title-command)
> + (format-spec title-command
> + (org-latex-format-spec info)))))
This is sub-optimal: you're building the spec twice. I suggest to use a
(let ((spec (org-latex--format-spec info))))
somewhere above.
You can apply the changes once these issues are resolved.
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-12 23:59 ` Nicolas Goaziou
@ 2015-02-15 1:53 ` Rasmus
2015-02-15 10:49 ` Nicolas Goaziou
0 siblings, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-02-15 1:53 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>> + (?k . ,(or (plist-get info :keywords) ""))
>> + (?d . ,(or (plist-get info :description) ""))
So it occurred to me that these should also be exported to proper syntax
so we don't end up with e.g. a raw $ or & in our latex document. Hyperref
will actually handle it, but usually by discarding offending characters.
However, since they are plain strings something like \alpha will be
exported as $\backslash$lpha. I can kind of get it interpreting using
org-element-parse-secondary-string, but this is not the right approach.
Is there a reason why DESCRIPTION and KEYWORDS can't have formatting?
—Rasmus
PS: I hope I didn't send this twice if so I apologize.
--
Lasciate ogni speranza o voi che entrate: siete nella mani di'machellaio
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 1:53 ` Rasmus
@ 2015-02-15 10:49 ` Nicolas Goaziou
2015-02-15 11:42 ` Rasmus
0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-02-15 10:49 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
Hello,
Rasmus <rasmus@gmx.us> writes:
> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>>> + (?k . ,(or (plist-get info :keywords) ""))
>>> + (?d . ,(or (plist-get info :description) ""))
>
> So it occurred to me that these should also be exported to proper syntax
> so we don't end up with e.g. a raw $ or & in our latex document. Hyperref
> will actually handle it, but usually by discarding offending characters.
>
> However, since they are plain strings something like \alpha will be
> exported as $\backslash$lpha. I can kind of get it interpreting using
> org-element-parse-secondary-string, but this is not the right
> approach.
Why isn't it the right approach?
> Is there a reason why DESCRIPTION and KEYWORDS can't have formatting?
DESCRIPTION could be moved to `org-element-document-properties'. But
then, we need to introduce `org-export-with-description', which implies
export back-ends have to deal with it somehow (ATM "ox-ascii" ignores
it).
Another option is to simply remove DESCRIPTION from "ox.el" and let
export back-ends in need of it to add it to their definition.
However, I don't see why KEYWORDS should accept markup. I also think it
should be moved to back-end definitions instead of "ox.el".
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 10:49 ` Nicolas Goaziou
@ 2015-02-15 11:42 ` Rasmus
2015-02-15 12:57 ` Nicolas Goaziou
0 siblings, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-02-15 11:42 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>> However, since they are plain strings something like \alpha will be
>> exported as $\backslash$lpha. I can kind of get it interpreting using
>> org-element-parse-secondary-string, but this is not the right
>> approach.
>
> Why isn't it the right approach?
'Cause usually org-export-data gives you the right value automatically.
Anyway, I don't mind using org-element-parse-secondary-string.
>> Is there a reason why DESCRIPTION and KEYWORDS can't have formatting?
>
> DESCRIPTION could be moved to `org-element-document-properties'. But
> then, we need to introduce `org-export-with-description', which implies
> export back-ends have to deal with it somehow (ATM "ox-ascii" ignores
> it).
> Another option is to simply remove DESCRIPTION from "ox.el" and let
> export back-ends in need of it to add it to their definition.
I don't oppose that.
> However, I don't see why KEYWORDS should accept markup. I also think it
> should be moved to back-end definitions instead of "ox.el".
Keywords should also be printed in the document as well IMO, e.g. after
the abstract. An example of where you need markup: σ-algebra.
—Rasmus
--
Slowly unravels in a ball of yarn and the devil collects it
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 11:42 ` Rasmus
@ 2015-02-15 12:57 ` Nicolas Goaziou
2015-02-15 13:11 ` Rasmus
2015-02-19 1:26 ` Rasmus
0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2015-02-15 12:57 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
Rasmus <rasmus@gmx.us> writes:
> 'Cause usually org-export-data gives you the right value automatically.
> Anyway, I don't mind using org-element-parse-secondary-string.
`org-element-parse-secondary-string' is meant for cases like this one.
>> DESCRIPTION could be moved to `org-element-document-properties'. But
>> then, we need to introduce `org-export-with-description', which implies
>> export back-ends have to deal with it somehow (ATM "ox-ascii" ignores
>> it).
>
>> Another option is to simply remove DESCRIPTION from "ox.el" and let
>> export back-ends in need of it to add it to their definition.
>
> I don't oppose that.
>
>> However, I don't see why KEYWORDS should accept markup. I also think it
>> should be moved to back-end definitions instead of "ox.el".
>
> Keywords should also be printed in the document as well IMO, e.g. after
> the abstract. An example of where you need markup: σ-algebra.
Good point.
Since KEYWORDS and DESCRIPTION are really back-end dependant, I vote for
moving them from `org-export-options-alist' to back-end definitions.
Using `org-element-parse-secondary-string' will be required in this
case.
WDYT? Also, supposing you agree, do you want to do a patch (caveat:
there's "org.texi" messing involved)?
Regards,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 12:57 ` Nicolas Goaziou
@ 2015-02-15 13:11 ` Rasmus
2015-02-15 15:57 ` Nicolas Goaziou
2015-02-19 1:26 ` Rasmus
1 sibling, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-02-15 13:11 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Since KEYWORDS and DESCRIPTION are really back-end dependant, I vote for
> moving them from `org-export-options-alist' to back-end definitions.
> Using `org-element-parse-secondary-string' will be required in this
> case.
OK.
So are there any /other/ uses of DESCRIPTION but adding summaries to
meta-data?
> WDYT? Also, supposing you agree, do you want to do a patch (caveat:
> there's "org.texi" messing involved)?
Sure, I'll add it to my TODO. You'll suffer through the reviewing, so in
either case the lion share of work will fall on you.
Without much thought, these are the back-ends where it might make sense:
ox-latex, ox-html, ox-texi, ox-odt, maybe ox-groff.
In a second round, I might add a :with-keywords as well. When non-nil
keywords are inserted at the location of keywords. Like #+TOC. So you'd
have:
#+begin_abstract
Read my paper, pretty please.
#+end_abstract
#+keywords: topic1, ⋯, topicN
→ (If using ox-latex)
\begin{abstract} read me \end{abstract}
\keywords{topic1, ⋯, topicN}
Where \keywords{·} is some function that I don't know yet.
—Rasmus
--
C is for Cookie
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 13:11 ` Rasmus
@ 2015-02-15 15:57 ` Nicolas Goaziou
2015-02-15 16:55 ` Rasmus
0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-02-15 15:57 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
Rasmus <rasmus@gmx.us> writes:
> So are there any /other/ uses of DESCRIPTION but adding summaries to
> meta-data?
I can't think of any.
> Without much thought, these are the back-ends where it might make sense:
> ox-latex, ox-html, ox-texi, ox-odt, maybe ox-groff.
>
> In a second round, I might add a :with-keywords as well.
It isn't necessary to add :with-description and :with-keywords
since :description and :keywords will not belong to "ox.el" anymore.
Regards,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 15:57 ` Nicolas Goaziou
@ 2015-02-15 16:55 ` Rasmus
0 siblings, 0 replies; 13+ messages in thread
From: Rasmus @ 2015-02-15 16:55 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> It isn't necessary to add :with-description and :with-keywords
> since :description and :keywords will not belong to "ox.el" anymore.
:With-keywords is still needed if they can be printed in both the text and
the meta data.
Keywords are also useful for weblogs, another thing that I'd like to
improve. This amounts to provide a couple of extra :sitemap functions:
one for generating an index based on summaries in files, e.g. abstract
blocks, and partial indexes based on keywords. The output structure would
be
./index.html
./keyword1/index.html.
Anyway, I don't have any code for this yet. But the point is keywords are
important and Org can leverage them better and :with-keywords (even if
implemented in ox-WHATEVER.el) is important.
—Rasmus
--
Sådan en god dansk lagereddike kan man slet ikke bruge mere
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-15 12:57 ` Nicolas Goaziou
2015-02-15 13:11 ` Rasmus
@ 2015-02-19 1:26 ` Rasmus
2015-02-19 9:24 ` Nicolas Goaziou
1 sibling, 1 reply; 13+ messages in thread
From: Rasmus @ 2015-02-19 1:26 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Since KEYWORDS and DESCRIPTION are really back-end dependant, I vote for
> moving them from `org-export-options-alist' to back-end definitions.
> Using `org-element-parse-secondary-string' will be required in this
> case.
> WDYT? Also, supposing you agree, do you want to do a patch (caveat:
> there's "org.texi" messing involved)?
So irrespective of this, here's an updated patch that uses
secondary-string parsing. Should I add it to master before or after I get
done with this moving description and keywords?
—Rasmus
--
This is the kind of tedious nonsense up with which I will not put
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-Format-spec-for-hyperref-and-title.patch --]
[-- Type: text/x-diff, Size: 6588 bytes --]
From 30334b0bf1d68fcc4479e26d51296099505657cd Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Wed, 11 Feb 2015 02:18:09 +0100
Subject: [PATCH] ox-latex: Format-spec for hyperref and title
* ox-latex.el (org-latex-format-spec): New function with format-specs.
(org-latex-template): Use org-latex-format-spec.
(org-latex-hyperref-template): New defaults and use
org-latex-format-spec.
(org-latex-title-command): Use org-latex-format-spec.
* ORG-NEWS: Mention change.
---
etc/ORG-NEWS | 3 ++
lisp/ox-latex.el | 88 +++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 74 insertions(+), 17 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 03fcfb2..4e1bc42 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -233,6 +233,9 @@ Exact heading search for links now ignore spaces and cookies. This is
the case for links of the form ~file:projects.org::*task title~, as
well as links of the form ~file:projects.org::some words~
when ~org-link-search-must-match-exact-headline~ is not nil.
+*** ~org-latex-hyperref-template~, ~org-latex-title-command~ formatting
+New formatting keys are supported. See ~org-latex-format-spec~.
+Further, ~org-latex-hyperref-template~ has new default value.
* Version 8.2
** Incompatible changes
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 6eddad0..27daf8f 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -383,11 +383,25 @@ are written as utf8 files."
(defcustom org-latex-title-command "\\maketitle"
"The command used to insert the title just after \\begin{document}.
-If this string contains the formatting specification \"%s\" then
-it will be used as a formatting string, passing the title as an
-argument."
+
+This format string may contain these elements:
+
+ %a for AUTHOR keyword
+ %t for TITLE keyword
+ %k for KEYWORDS line
+ %d for DESCRIPTION line
+ %c for CREATOR line
+ %l for Language keyword
+ %L for capitalized language keyword
+ %D for DATE keyword
+
+If you need to use a \"%\" character, you need to escape it
+like that: \"%%\".
+
+Setting :latex-title-command in publishing projects will take
+precedence over this variable."
:group 'org-export-latex
- :type 'string)
+ :type '(string :tag "Format string"))
(defcustom org-latex-toc-command "\\tableofcontents\n\n"
"LaTeX command to set the table of contents, list of figures, etc.
@@ -397,20 +411,30 @@ the toc:nil option, not to those generated with #+TOC keyword."
:type 'string)
(defcustom org-latex-hyperref-template
- "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n"
+ "\\hypersetup{\n pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k},
+ pdfsubject={%d},\n pdfcreator={%c}, \n pdflang={%L}}\n"
"Template for hyperref package options.
-Value is a format string, which can contain the following placeholders:
+This format string may contain these elements:
+ %a for AUTHOR keyword
+ %t for TITLE keyword
%k for KEYWORDS line
%d for DESCRIPTION line
%c for CREATOR line
+ %l for Language keyword
+ %L for capitalized language keyword
+ %D for DATE keyword
+
+If you need to use a \"%\" character, you need to escape it
+like that: \"%%\".
-Set it to the empty string to ignore the command completely."
+Setting :latex-hyperref-template in publishing projects will take
+precedence over this variable."
:group 'org-export-latex
:version "25.1"
:package-version '(Org . "8.3")
- :type 'string)
+ :type '(string :tag "Format string"))
;;;; Headline
@@ -1193,6 +1217,35 @@ just outside of it."
INFO is a plist used as a communication channel."
(org-export-translate s :latex info))
+(defun org-latex--format-spec (info)
+ "Create a format-spec for e.g. `org-latex-hyperref-template'.
+Also used by `org-latex-title-command'
+
+INFO is a plist used as a communication channel."
+ (let ((objects '(bold code entity export-snippet inline-babel-call
+ inline-src-block italic latex-fragment
+ latex-math-block link macro strike-through
+ subscript superscript timestamp underline
+ verbatim))
+ (language (let ((lang (plist-get info :language)))
+ (or (cdr (assoc lang org-latex-babel-language-alist))
+ lang ""))))
+ `((?a . ,(or (org-export-data (plist-get info :author) info) ""))
+ (?t . ,(or (org-export-data (plist-get info :title) info) ""))
+ (?k . ,(org-export-data (org-latex--wrap-latex-math-block
+ (org-element-parse-secondary-string
+ (plist-get info :keywords) objects)
+ info)
+ info))
+ (?d . ,(org-export-data (org-latex--wrap-latex-math-block
+ (org-element-parse-secondary-string
+ (plist-get info :description) objects)
+ info)
+ info))
+ (?c . ,(if (plist-get info :with-creator) (plist-get info :creator) ""))
+ (?l . ,language)
+ (?L . ,(capitalize language))
+ (?D . ,(org-export-get-date info)))))
\f
;;; Template
@@ -1201,7 +1254,10 @@ INFO is a plist used as a communication channel."
"Return complete document string after LaTeX conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
- (let ((title (org-export-data (plist-get info :title) info)))
+ (let ((title (org-export-data (plist-get info :title) info))
+ (spec (when (org-some 'stringp (list org-latex-hyperref-template
+ org-latex-title-command))
+ (org-latex--format-spec info))))
(concat
;; Time-stamp.
(and (plist-get info :time-stamp-file)
@@ -1248,17 +1304,15 @@ holding export options."
;; Title
(format "\\title{%s}\n" title)
;; Hyperref options.
- (format-spec (plist-get info :latex-hyperref-template)
- (format-spec-make
- ?k (or (plist-get info :keywords) "")
- ?d (or (plist-get info :description)"")
- ?c (if (plist-get info :with-creator)
- (plist-get info :creator)
- "")))
+ (let ((template (plist-get info :latex-hyperref-template)))
+ (and (stringp template)
+ (format-spec template spec)))
;; Document start.
"\\begin{document}\n\n"
;; Title command.
- (let ((command (plist-get info :latex-title-command)))
+ (let* ((title-command (plist-get info :latex-title-command))
+ (command (and (stringp title-command)
+ (format-spec title-command spec))))
(org-element-normalize-string
(cond ((not (plist-get info :with-title)) nil)
((string= "" title) nil)
--
2.3.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [patch, ox-latex] better hyperref and title options
2015-02-19 1:26 ` Rasmus
@ 2015-02-19 9:24 ` Nicolas Goaziou
2015-02-19 21:43 ` Rasmus
0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-02-19 9:24 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
Rasmus <rasmus@gmx.us> writes:
> So irrespective of this, here's an updated patch that uses
> secondary-string parsing. Should I add it to master before or after I get
> done with this moving description and keywords?
You can go ahead, after fixing some minor typos. Thanks.
> * ox-latex.el (org-latex-format-spec): New function with format-specs.
Typo in the name.
> (org-latex-template): Use org-latex-format-spec.
> (org-latex-hyperref-template): New defaults and use
> org-latex-format-spec.
> (org-latex-title-command): Use org-latex-format-spec.
Ditto (x3).
> +*** ~org-latex-hyperref-template~, ~org-latex-title-command~ formatting
> +New formatting keys are supported. See ~org-latex-format-spec~.
See docstrings for more information (no need to talk about
`org-latex--format-spec').
> +(defun org-latex--format-spec (info)
> + "Create a format-spec for e.g. `org-latex-hyperref-template'.
> +Also used by `org-latex-title-command'
"Create a format-spec for document meta-data.
INFO is.."
is enough IMO.
> - (let ((title (org-export-data (plist-get info :title) info)))
> + (let ((title (org-export-data (plist-get info :title) info))
> + (spec (when (org-some 'stringp (list org-latex-hyperref-template
> + org-latex-title-command))
> + (org-latex--format-spec info))))
Nitpick: #'stringp
Anyway, both `org-latex-hyperref-template' and `org-latex-title-command'
are always strings, per defcustom type. So you can drop the `when' part:
(spec (org-latex--format-spec info))
Regards,
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-02-19 22:57 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 0:39 [patch, ox-latex] better hyperref and title options Rasmus
2015-02-12 23:59 ` Nicolas Goaziou
2015-02-15 1:53 ` Rasmus
2015-02-15 10:49 ` Nicolas Goaziou
2015-02-15 11:42 ` Rasmus
2015-02-15 12:57 ` Nicolas Goaziou
2015-02-15 13:11 ` Rasmus
2015-02-15 15:57 ` Nicolas Goaziou
2015-02-15 16:55 ` Rasmus
2015-02-19 1:26 ` Rasmus
2015-02-19 9:24 ` Nicolas Goaziou
2015-02-19 21:43 ` Rasmus
2015-02-19 22:58 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).