Re: [O] Annotating org exporters
Hi Sebastian and all, Sebastian Fischmeisterwrites: > 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
Re: [O] Annotating org exporters
Sebastian Fischmeisterwrites: >> >> 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
Re: [O] Annotating org exporters
> > 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
Re: [O] Annotating org exporters
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
Re: [O] Annotating org exporters
Rainer M Krugwrites: > Rasmus writes: > >> Sebastian Fischmeister 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
Re: [O] Annotating org exporters
Rasmuswrites: > Sebastian Fischmeister 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: Rainerkrugsde PGP: 0x0F52F982 signature.asc Description: PGP signature
Re: [O] Annotating org exporters
Sebastian Fischmeisterwrites: > 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?
Re: [O] Annotating org exporters
Hi Sebasitan, Sebastian Fischmeisterwrites: > 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
Re: [O] Annotating org exporters
Sebastian Fischmeisterwrites: > 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: Rainerkrugsde PGP: 0x0F52F982 signature.asc Description: PGP signature