* Inserting LaTex expressions using a filter fails
@ 2021-01-05 18:33 Mart van de Wege
2021-01-05 21:58 ` Juan Manuel Macías
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Mart van de Wege @ 2021-01-05 18:33 UTC (permalink / raw)
To: Org Mode ML
I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
export to LaTex, and obviously I'm doing something wrong, or I don't
understand the documentation.
I use the following code to set up the filter:
#+BIND: org-export-filter-item-functions (latex-replace-half)
#+BEGIN_SRC emacs-lisp :exports results :results none
(defun latex-replace-half (text backend info)
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string "½" "\\sfrac{1}{2}" text)))
#+END_SRC
Down the line in the document there is this example line:
- 1½ eetl. gehakte peterselie, ½ eetl. azijn, 4 eetl. olie
Or this one:
Laat de gewassen en gebroken vermicelli met de foelie ½ uur in de
But neither of them get replaced. I tried plain-text, item, and
final-output filters.
What am I missing?
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-05 18:33 Inserting LaTex expressions using a filter fails Mart van de Wege
@ 2021-01-05 21:58 ` Juan Manuel Macías
2021-01-06 7:50 ` Mart van de Wege
2021-01-05 22:31 ` Nick Dokos
2021-01-06 15:48 ` Maxim Nikulin
2 siblings, 1 reply; 13+ messages in thread
From: Juan Manuel Macías @ 2021-01-05 21:58 UTC (permalink / raw)
To: Mart van de Wege; +Cc: orgmode
Hello,
Mart van de Wege <mvdwege@gmail.com> writes:
> I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
> export to LaTex, and obviously I'm doing something wrong, or I don't
> understand the documentation.
>
> I use the following code to set up the filter:
>
> #+BIND: org-export-filter-item-functions (latex-replace-half)
> #+BEGIN_SRC emacs-lisp :exports results :results none
>
> (defun latex-replace-half (text backend info)
> (when (org-export-derived-backend-p backend 'latex)
> (replace-regexp-in-string "½" "\\sfrac{1}{2}" text)))
> #+END_SRC
You must add a double escape character to the backslash:
...
(replace-regexp-in-string "½" "\\\\sfrac{1}{2}" text)))
...
Regards,
Juan Manuel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-05 21:58 ` Juan Manuel Macías
@ 2021-01-06 7:50 ` Mart van de Wege
2021-01-06 11:51 ` Juan Manuel Macías
0 siblings, 1 reply; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 7:50 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode
On Tue, 05 Jan 2021 22:58:33 +0100
Juan Manuel Macías <maciaschain@posteo.net> wrote:
> Hello,
>
> Mart van de Wege <mvdwege@gmail.com> writes:
>
> > I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2}
> > during export to LaTex, and obviously I'm doing something wrong, or
> > I don't understand the documentation.
> >
> > I use the following code to set up the filter:
> >
> > #+BIND: org-export-filter-item-functions (latex-replace-half)
> > #+BEGIN_SRC emacs-lisp :exports results :results none
> >
> > (defun latex-replace-half (text backend info)
> > (when (org-export-derived-backend-p backend 'latex)
> > (replace-regexp-in-string "½" "\\sfrac{1}{2}" text)))
> > #+END_SRC
>
> You must add a double escape character to the backslash:
>
> ...
> (replace-regexp-in-string "½" "\\\\sfrac{1}{2}" text)))
> ...
>
Thanks!
But see my answer to Nick Dokos on the list, that does not do anything
either.
Regards,
Mart
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 7:50 ` Mart van de Wege
@ 2021-01-06 11:51 ` Juan Manuel Macías
2021-01-06 12:00 ` Mart van de Wege
0 siblings, 1 reply; 13+ messages in thread
From: Juan Manuel Macías @ 2021-01-06 11:51 UTC (permalink / raw)
To: Mart van de Wege; +Cc: orgmode
Mart van de Wege <mvdwege@gmail.com> writes:
> Thanks!
>
> But see my answer to Nick Dokos on the list, that does not do anything
> either.
Try putting this variable in your .emacs with non-nil value:
(setq org-export-allow-bind-keywords t)
Regards,
Juan Manuel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 11:51 ` Juan Manuel Macías
@ 2021-01-06 12:00 ` Mart van de Wege
2021-01-06 12:24 ` Juan Manuel Macías
0 siblings, 1 reply; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 12:00 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode
On Wed, 06 Jan 2021 12:51:00 +0100
Juan Manuel Macías <maciaschain@posteo.net> wrote:
> Mart van de Wege <mvdwege@gmail.com> writes:
>
> > Thanks!
> >
> > But see my answer to Nick Dokos on the list, that does not do
> > anything either.
>
> Try putting this variable in your .emacs with non-nil value:
>
> (setq org-export-allow-bind-keywords t)
>
Well whaddayaknow? That works.
Kind of weird it's not mentioned in the docs though (at least not in
the same section as export filters); if you're going to tell people that
you can bind local functions to an org file, then it might be nice to
point out that you do need to turn that on.
Regards,
Mart
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 12:00 ` Mart van de Wege
@ 2021-01-06 12:24 ` Juan Manuel Macías
2021-01-06 15:17 ` Mart van de Wege
0 siblings, 1 reply; 13+ messages in thread
From: Juan Manuel Macías @ 2021-01-06 12:24 UTC (permalink / raw)
To: Mart van de Wege; +Cc: orgmode
Mart van de Wege <mvdwege@gmail.com> writes:
> Kind of weird it's not mentioned in the docs though (at least not in
> the same section as export filters); if you're going to tell people that
> you can bind local functions to an org file, then it might be nice to
> point out that you do need to turn that on.
You're right. I think an addition could be proposed in the
documentation: for example, a footnote in the section `Defining filters
for individual files', since by default the variable
`org-export-allow-bind-keywords' has value nil.
Regards,
Juan Manuel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 12:24 ` Juan Manuel Macías
@ 2021-01-06 15:17 ` Mart van de Wege
2021-01-06 15:58 ` Juan Manuel Macías
0 siblings, 1 reply; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 15:17 UTC (permalink / raw)
To: Juan Manuel Macías, Mart van de Wege; +Cc: orgmode
On Wed, 2021-01-06 at 13:24 +0100, Juan Manuel Macías wrote:
> Mart van de Wege <mvdwege@gmail.com> writes:
>
> > Kind of weird it's not mentioned in the docs though (at least not
> > in
> > the same section as export filters); if you're going to tell people
> > that
> > you can bind local functions to an org file, then it might be nice
> > to
> > point out that you do need to turn that on.
>
> You're right. I think an addition could be proposed in the
> documentation: for example, a footnote in the section `Defining
> filters
> for individual files', since by default the variable
> `org-export-allow-bind-keywords' has value nil.
You're right. I looked up the variable, and there is only one mention
in the docs, and that is about binding emacs variables locally to the
org file buffer.
Can I just clone the repo and prepare a patch?
Regards,
Mart van de Wege
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 15:17 ` Mart van de Wege
@ 2021-01-06 15:58 ` Juan Manuel Macías
2021-01-06 16:00 ` Mart van de Wege
0 siblings, 1 reply; 13+ messages in thread
From: Juan Manuel Macías @ 2021-01-06 15:58 UTC (permalink / raw)
To: Mart van de Wege; +Cc: orgmode
Mart van de Wege <mart@vdwege.eu> writes:
> You're right. I looked up the variable, and there is only one mention
> in the docs, and that is about binding emacs variables locally to the
> org file buffer.
>
> Can I just clone the repo and prepare a patch?
As far as I know, you can create a diff and propose the patch here in
the list, opening a new thread, that includes in the mail subject
something like "[patch] etc"
Regards,
Juan Manuel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 15:58 ` Juan Manuel Macías
@ 2021-01-06 16:00 ` Mart van de Wege
0 siblings, 0 replies; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 16:00 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: orgmode
On Wed, 2021-01-06 at 16:58 +0100, Juan Manuel Macías wrote:
> Mart van de Wege <mart@vdwege.eu> writes:
> > Can I just clone the repo and prepare a patch?
>
> As far as I know, you can create a diff and propose the patch here in
> the list, opening a new thread, that includes in the mail subject
> something like "[patch] etc"
Nice. I will make some time then this week. Should my mail follow the
guidelines for commit messages?
Regards,
Mart
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-05 18:33 Inserting LaTex expressions using a filter fails Mart van de Wege
2021-01-05 21:58 ` Juan Manuel Macías
@ 2021-01-05 22:31 ` Nick Dokos
2021-01-06 7:50 ` Mart van de Wege
2021-01-06 15:48 ` Maxim Nikulin
2 siblings, 1 reply; 13+ messages in thread
From: Nick Dokos @ 2021-01-05 22:31 UTC (permalink / raw)
To: emacs-orgmode
Mart van de Wege <mvdwege@gmail.com> writes:
> I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
> export to LaTex, and obviously I'm doing something wrong, or I don't
> understand the documentation.
>
> I use the following code to set up the filter:
>
> #+BIND: org-export-filter-item-functions (latex-replace-half)
> #+BEGIN_SRC emacs-lisp :exports results :results none
>
> (defun latex-replace-half (text backend info)
> (when (org-export-derived-backend-p backend 'latex)
> (replace-regexp-in-string "½" "\\sfrac{1}{2}" text)))
> #+END_SRC
>
Try
(replace-regexp-in-string "½" "\\\\sfrac{1}{2}" text)))
> Down the line in the document there is this example line:
>
> - 1½ eetl. gehakte peterselie, ½ eetl. azijn, 4 eetl. olie
>
> Or this one:
>
> Laat de gewassen en gebroken vermicelli met de foelie ½ uur in de
>
> But neither of them get replaced. I tried plain-text, item, and
> final-output filters.
>
"item" will only deal with the first one: an item in a list. You'll need
to use "final-output" probably.
> What am I missing?
>
> Mart
--
Nick
"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-05 22:31 ` Nick Dokos
@ 2021-01-06 7:50 ` Mart van de Wege
0 siblings, 0 replies; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 7:50 UTC (permalink / raw)
To: Org Mode ML; +Cc: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> Mart van de Wege <mvdwege@gmail.com> writes:
>
>> I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
>> export to LaTex, and obviously I'm doing something wrong, or I don't
>> understand the documentation.
>>
>> I use the following code to set up the filter:
>>
>> #+BIND: org-export-filter-item-functions (latex-replace-half)
>> #+BEGIN_SRC emacs-lisp :exports results :results none
>>
>> (defun latex-replace-half (text backend info)
>> (when (org-export-derived-backend-p backend 'latex)
>> (replace-regexp-in-string "½" "\\sfrac{1}{2}" text)))
>> #+END_SRC
>>
>
> Try
>
> (replace-regexp-in-string "½" "\\\\sfrac{1}{2}" text)))
>
Nope. Doesn't do it. Here's the Latex output of the two example lines:
\item 1½ eetl. gehakte peterselie, ½ eetl. azijn, 4 eetl. olie.
Laat de gewassen en gebroken vermicelli met de foelie ½ uur in de
This was run using final-output-functions, btw.
Regards,
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-05 18:33 Inserting LaTex expressions using a filter fails Mart van de Wege
2021-01-05 21:58 ` Juan Manuel Macías
2021-01-05 22:31 ` Nick Dokos
@ 2021-01-06 15:48 ` Maxim Nikulin
2021-01-06 17:56 ` Mart van de Wege
2 siblings, 1 reply; 13+ messages in thread
From: Maxim Nikulin @ 2021-01-06 15:48 UTC (permalink / raw)
To: emacs-orgmode
On 06/01/2021 01:33, Mart van de Wege wrote:
> I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
> export to LaTex, and obviously I'm doing something wrong, or I don't
> understand the documentation.
Do you really need to replace unicode characters? If you are just trying
to avoid LaTeX errors then there is another approach:
#+BEGIN_SRC elisp
(add-to-list 'org-latex-inputenc-alist '("utf8" . "utf8x"))
#+END_SRC
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Inserting LaTex expressions using a filter fails
2021-01-06 15:48 ` Maxim Nikulin
@ 2021-01-06 17:56 ` Mart van de Wege
0 siblings, 0 replies; 13+ messages in thread
From: Mart van de Wege @ 2021-01-06 17:56 UTC (permalink / raw)
To: Org Mode ML; +Cc: emacs-orgmode
Maxim Nikulin <manikulin@gmail.com> writes:
> On 06/01/2021 01:33, Mart van de Wege wrote:
>> I'm trying to replace U+00BD in an org buffer with \sfrac{1}{2} during
>> export to LaTex, and obviously I'm doing something wrong, or I don't
>> understand the documentation.
>
> Do you really need to replace unicode characters? If you are just trying
> to avoid LaTeX errors then there is another approach:
>
Yes. I like the rendering of the xfrac package a lot better than the
default unicode characters.
Regards,
Mart
--
"We will need a longer wall when the revolution comes."
--- AJS, quoting an uncertain source.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-01-06 18:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-05 18:33 Inserting LaTex expressions using a filter fails Mart van de Wege
2021-01-05 21:58 ` Juan Manuel Macías
2021-01-06 7:50 ` Mart van de Wege
2021-01-06 11:51 ` Juan Manuel Macías
2021-01-06 12:00 ` Mart van de Wege
2021-01-06 12:24 ` Juan Manuel Macías
2021-01-06 15:17 ` Mart van de Wege
2021-01-06 15:58 ` Juan Manuel Macías
2021-01-06 16:00 ` Mart van de Wege
2021-01-05 22:31 ` Nick Dokos
2021-01-06 7:50 ` Mart van de Wege
2021-01-06 15:48 ` Maxim Nikulin
2021-01-06 17:56 ` Mart van de Wege
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).