* Annotating org exporters
@ 2016-05-10 13:56 Sebastian Fischmeister
2016-05-10 15:04 ` Rainer M Krug
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Sebastian Fischmeister @ 2016-05-10 13:56 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Is there a simple way to build regex-based extensions to the exporters?
For example, I would like to convert this string "=>" to $\rightarrow$
when converting the document to latex.
There are lots of other uses, where I could create my shortcuts and
insert them in orgmode files without creating a lot of clutter in the
file.
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 13:56 Annotating org exporters Sebastian Fischmeister
@ 2016-05-10 15:04 ` Rainer M Krug
2016-05-10 15:19 ` Richard Lawrence
2016-05-10 15:55 ` Rasmus
2 siblings, 0 replies; 10+ messages in thread
From: Rainer M Krug @ 2016-05-10 15:04 UTC (permalink / raw)
To: Sebastian Fischmeister; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
> Hi,
>
> Is there a simple way to build regex-based extensions to the exporters?
> For example, I would like to convert this string "=>" to $\rightarrow$
> when converting the document to latex.
>
> There are lots of other uses, where I could create my shortcuts and
> insert them in orgmode files without creating a lot of clutter in the
> file.
I like this idea. It would be ideal if one could define these in the
header of the org document - easy to maintain and to edit.
Cheers,
Rainer
>
> Sebastian
>
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 13:56 Annotating org exporters Sebastian Fischmeister
2016-05-10 15:04 ` Rainer M Krug
@ 2016-05-10 15:19 ` Richard Lawrence
2016-05-11 5:31 ` Sebastian Fischmeister
2016-05-10 15:55 ` Rasmus
2 siblings, 1 reply; 10+ messages in thread
From: Richard Lawrence @ 2016-05-10 15:19 UTC (permalink / raw)
To: sfischme, emacs-orgmode
Hi Sebasitan,
Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
> Is there a simple way to build regex-based extensions to the exporters?
> For example, I would like to convert this string "=>" to $\rightarrow$
> when converting the document to latex.
There's an example of how to do something like this in the "Advanced
Configuration" section of the Export section in the manual. Maybe you
could adapt it like this?
(defun my-latex-filter-rightarrow (text backend info)
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "=>" "$\rightarrow$" text)))
(add-to-list 'org-export-filter-plain-text-functions
'my-latex-filter-rightarrow)
Hope that helps!
Best,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 15:19 ` Richard Lawrence
@ 2016-05-11 5:31 ` Sebastian Fischmeister
2016-05-11 15:01 ` Richard Lawrence
0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Fischmeister @ 2016-05-11 5:31 UTC (permalink / raw)
To: Richard Lawrence, emacs-orgmode
Hi Richard,
> There's an example of how to do something like this in the "Advanced
> Configuration" section of the Export section in the manual. Maybe you
> could adapt it like this?
>
> (defun my-latex-filter-rightarrow (text backend info)
> (when (org-export-derived-backend-p backend 'latex)
> (replace-regexp-in-string "=>" "$\rightarrow$" text)))
>
> (add-to-list 'org-export-filter-plain-text-functions
> 'my-latex-filter-rightarrow)
That works very well. Thank you very much. The only adjustment is to set
LITERAL to non-nil for replace-regexp-in-string and use double backslash.
(defun my-latex-filter-rightarrow (text backend info)
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "=>" "$\\rightarrow$" text nil t)))
I'm still undecided between a regex replace and org-entities. Is there
a straightforward way to define own directives for orgmode to then
support something like the following?
#+LaTeX_EXPORT: "=>":"$\rightarrow$"
or more generic
#+EXPORT_EXPAND: latex:"=>":"$\rightarrow$"
Then I could just make these expansions part of the standard header in
my org files.
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-11 5:31 ` Sebastian Fischmeister
@ 2016-05-11 15:01 ` Richard Lawrence
0 siblings, 0 replies; 10+ messages in thread
From: Richard Lawrence @ 2016-05-11 15:01 UTC (permalink / raw)
To: sfischme, emacs-orgmode
Hi Sebastian and all,
Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
> I'm still undecided between a regex replace and org-entities. Is there
> a straightforward way to define own directives for orgmode to then
> support something like the following?
>
> #+LaTeX_EXPORT: "=>":"$\rightarrow$"
>
> or more generic
>
> #+EXPORT_EXPAND: latex:"=>":"$\rightarrow$"
>
> Then I could just make these expansions part of the standard header in
> my org files.
Well, there are macros, which do something very similar. As far as I
know, they are the only way to achieve this kind of thing without some
Elisp.
You could do something like:
#+MACRO: => @@latex:$\rightarrow$@@
but that actually doesn't seem to work as is, I suspect because "=>" is
not an allowable macro name. (It works fine with an alphabetic name
like "ARR".) But even if you got it to work, you'd then have to type
Some text {{{=>}}} other text after the arrow
in your document, which sort of defeats the point of the nice, simple
"=>". If it were me, I'd opt for the regex replacement, and avoid
typing all the braces.
Best,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 13:56 Annotating org exporters Sebastian Fischmeister
2016-05-10 15:04 ` Rainer M Krug
2016-05-10 15:19 ` Richard Lawrence
@ 2016-05-10 15:55 ` Rasmus
2016-05-10 18:10 ` Rainer M Krug
2016-05-11 5:31 ` Sebastian Fischmeister
2 siblings, 2 replies; 10+ messages in thread
From: Rasmus @ 2016-05-10 15:55 UTC (permalink / raw)
To: emacs-orgmode
Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
> Is there a simple way to build regex-based extensions to the exporters?
Yeah, filters. But I don’t think this is the best way to go about it.
> For example, I would like to convert this string "=>" to $\rightarrow$
> when converting the document to latex.
>
> There are lots of other uses, where I could create my shortcuts and
> insert them in orgmode files without creating a lot of clutter in the
> file.
This sounds a bit like org-entities. I use this together with cdlatex for
quickly inserting such things.
Try to type \Rightarrow and type C-c C-x \
Also try to export to text (non-unicode). You will get the desired symbol.
Alternatively, you can use one of the many input methods such as TeX or
rfc1345 in which case you can get the ‘⇒’ by typing ‘\Rightarrow’ or
‘&=>’, respectively. In latex, you can setup unicode-math.
Hope it helps,
Rasmus
--
What will be next?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 15:55 ` Rasmus
@ 2016-05-10 18:10 ` Rainer M Krug
2016-05-10 22:29 ` Rasmus
2016-05-11 5:31 ` Sebastian Fischmeister
1 sibling, 1 reply; 10+ messages in thread
From: Rainer M Krug @ 2016-05-10 18:10 UTC (permalink / raw)
To: Rasmus; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
Rasmus <rasmus@gmx.us> writes:
> Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
>
>> Is there a simple way to build regex-based extensions to the exporters?
>
> Yeah, filters. But I don’t think this is the best way to go about it.
>
>> For example, I would like to convert this string "=>" to $\rightarrow$
>> when converting the document to latex.
>>
>> There are lots of other uses, where I could create my shortcuts and
>> insert them in orgmode files without creating a lot of clutter in the
>> file.
>
> This sounds a bit like org-entities. I use this together with cdlatex for
> quickly inserting such things.
Great - learned something. Never knew about org-entities.
Would it be possible to generate *easily* a pdf with all the org-entities?
Possibly include it in org as a kind of a cheat-sheet for org-entities?
Reading the help in this case is possible but not easy...
Rainer
>
> Try to type \Rightarrow and type C-c C-x \
> Also try to export to text (non-unicode). You will get the desired symbol.
>
> Alternatively, you can use one of the many input methods such as TeX or
> rfc1345 in which case you can get the ‘⇒’ by typing ‘\Rightarrow’ or
> ‘&=>’, respectively. In latex, you can setup unicode-math.
>
> Hope it helps,
> Rasmus
--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 454 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 18:10 ` Rainer M Krug
@ 2016-05-10 22:29 ` Rasmus
0 siblings, 0 replies; 10+ messages in thread
From: Rasmus @ 2016-05-10 22:29 UTC (permalink / raw)
To: rainer; +Cc: emacs-orgmode
Rainer M Krug <Rainer@krugs.de> writes:
> Rasmus <rasmus@gmx.us> writes:
>
>> Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
>>
>>> Is there a simple way to build regex-based extensions to the exporters?
>>
>> Yeah, filters. But I don’t think this is the best way to go about it.
>>
>>> For example, I would like to convert this string "=>" to $\rightarrow$
>>> when converting the document to latex.
>>>
>>> There are lots of other uses, where I could create my shortcuts and
>>> insert them in orgmode files without creating a lot of clutter in the
>>> file.
>>
>> This sounds a bit like org-entities. I use this together with cdlatex for
>> quickly inserting such things.
>
> Great - learned something. Never knew about org-entities.
>
> Would it be possible to generate *easily* a pdf with all the org-entities?
> Possibly include it in org as a kind of a cheat-sheet for org-entities?
Might be nice... The styling would be essential.
For personal use you might experiment with the below function?
(I didn't try the resulting latex file).
(defun rasmus-org-entities-as-latex (file)
(with-current-buffer (or (get-file-buffer file)
(find-file file))
(erase-buffer)
(insert (mapconcat (lambda (e)
(format "- =\\%s= :: \\%s \n"
(nth 0 e)
(nth 0 e)))
(remove-if-not 'listp
(append org-entities-user org-entities))
""))
(save-buffer)))
(rasmus-org-entities-as-latex "/tmp/entities.org")
Rasmus
--
Together we'll stand, divided we'll fall
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-10 15:55 ` Rasmus
2016-05-10 18:10 ` Rainer M Krug
@ 2016-05-11 5:31 ` Sebastian Fischmeister
2016-05-11 9:49 ` Rasmus
1 sibling, 1 reply; 10+ messages in thread
From: Sebastian Fischmeister @ 2016-05-11 5:31 UTC (permalink / raw)
To: Rasmus, emacs-orgmode
>
> This sounds a bit like org-entities. I use this together with cdlatex for
> quickly inserting such things.
>
> Try to type \Rightarrow and type C-c C-x \
> Also try to export to text (non-unicode). You will get the desired symbol.
>
> Alternatively, you can use one of the many input methods such as TeX or
> rfc1345 in which case you can get the ‘⇒’ by typing ‘\Rightarrow’ or
> ‘&=>’, respectively. In latex, you can setup unicode-math.
That's interesting, because it's more robust to add something to the
org-entities-user list than to regexp replace a portion of the whole
document.
However, there are two disadvantages to org-entities: (1) they have to
start with a backslash (e.g., \Rightarrow) and (2) they don't seem to
support alphabet-based names, so this doesn't work:
(add-to-list 'org-entities-user '("=>" "\\rightarrow" t "=>" "=>" "»" "»"))
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Annotating org exporters
2016-05-11 5:31 ` Sebastian Fischmeister
@ 2016-05-11 9:49 ` Rasmus
0 siblings, 0 replies; 10+ messages in thread
From: Rasmus @ 2016-05-11 9:49 UTC (permalink / raw)
To: emacs-orgmode
Sebastian Fischmeister <sfischme@uwaterloo.ca> writes:
>>
>> This sounds a bit like org-entities. I use this together with cdlatex for
>
>> quickly inserting such things.
>>
>> Try to type \Rightarrow and type C-c C-x \
>> Also try to export to text (non-unicode). You will get the desired symbol.
>>
>> Alternatively, you can use one of the many input methods such as TeX or
>> rfc1345 in which case you can get the ‘⇒’ by typing ‘\Rightarrow’ or
>> ‘&=>’, respectively. In latex, you can setup unicode-math.
>
> That's interesting, because it's more robust to add something to the
> org-entities-user list than to regexp replace a portion of the whole
> document.
>
> However, there are two disadvantages to org-entities: (1) they have to
> start with a backslash (e.g., \Rightarrow) and (2) they don't seem to
> support alphabet-based names, so this doesn't work:
>
> (add-to-list 'org-entities-user '("=>" "\\rightarrow" t "=>" "=>" "»" "»"))
Correct.
You can add a hook to ‘org-export-before-parsing-hook’ to have a list of
non-standard entities that are to be changed into "correct" entities
beforehand, e.g. (("=>" . "\\rightarrow")).
Or you can use something like cdlatex to quickly insert the "correct"
entities, e.g. "\Rightarrow" is inserted with "’]" in my setup. The added
benefit is that entities work out of the box so when I’m exporting on
another computer it just works.
Rasmus
--
Sådan en god dansk lagereddike kan man slet ikke bruge mere
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-05-11 15:00 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10 13:56 Annotating org exporters Sebastian Fischmeister
2016-05-10 15:04 ` Rainer M Krug
2016-05-10 15:19 ` Richard Lawrence
2016-05-11 5:31 ` Sebastian Fischmeister
2016-05-11 15:01 ` Richard Lawrence
2016-05-10 15:55 ` Rasmus
2016-05-10 18:10 ` Rainer M Krug
2016-05-10 22:29 ` Rasmus
2016-05-11 5:31 ` Sebastian Fischmeister
2016-05-11 9:49 ` Rasmus
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).