emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* html-encode in mathjax latex fragments
@ 2014-06-29 18:41 Eric Schulte
  2014-06-29 19:46 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-29 18:41 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

I noticed equations with "<"'s weren't displaying correctly in HTML
export using mathjax.  The attached patch fixes this by html-encoding
latex fragments for mathjax HTML export.  I imagine this change would be
generally useful and could be applied to master.

Best,
Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-html-encode-text-in-mathjax-latex-fragments.patch --]
[-- Type: text/x-diff, Size: 1024 bytes --]

From 8c4efca17f2a6fbc836c5a8b6b0f628b6c9fff33 Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Sun, 29 Jun 2014 14:38:03 -0400
Subject: [PATCH] html-encode text in mathjax latex fragments

* lisp/ox-html.el (org-html-format-latex): Html-encode text in mathjax
  latex fragments.
---
 lisp/ox-html.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index df392a9..03037f5 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2610,7 +2610,8 @@ a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
 and t.  See `org-html-with-latex' for more information.  INFO is
 a plist containing export properties."
   (let ((cache-relpath "") (cache-dir ""))
-    (unless (eq processing-type 'mathjax)
+    (if (eq processing-type 'mathjax)
+	(setq latex-frag (org-html-encode-plain-text latex-frag))
       (let ((bfn (or (buffer-file-name)
 		     (make-temp-name
 		      (expand-file-name "latex" temporary-file-directory))))
-- 
2.0.0


[-- Attachment #3: Type: text/plain, Size: 90 bytes --]


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-29 18:41 html-encode in mathjax latex fragments Eric Schulte
@ 2014-06-29 19:46 ` Nicolas Goaziou
  2014-06-30  3:12   ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-29 19:46 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode Mailing List

Hello,

Eric Schulte <schulte.eric@gmail.com> writes:

> I noticed equations with "<"'s weren't displaying correctly in HTML
> export using mathjax.  The attached patch fixes this by html-encoding
> latex fragments for mathjax HTML export.  I imagine this change would be
> generally useful and could be applied to master.

I am a bit puzzled. I just tried exporting the following buffer:

  \(1 < 2\)

and the result looked good. Could you provide an example of a failed
export?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-29 19:46 ` Nicolas Goaziou
@ 2014-06-30  3:12   ` Nick Dokos
  2014-06-30  9:47     ` Eric Schulte
  2014-06-30 10:55     ` Nicolas Goaziou
  0 siblings, 2 replies; 8+ messages in thread
From: Nick Dokos @ 2014-06-30  3:12 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Eric Schulte <schulte.eric@gmail.com> writes:
>
>> I noticed equations with "<"'s weren't displaying correctly in HTML
>> export using mathjax.  The attached patch fixes this by html-encoding
>> latex fragments for mathjax HTML export.  I imagine this change would be
>> generally useful and could be applied to master.
>
> I am a bit puzzled. I just tried exporting the following buffer:
>
>   \(1 < 2\)
>
> and the result looked good. Could you provide an example of a failed
> export?
>
>

See 

   http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents

for some gotchas.

-- 
Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-30  3:12   ` Nick Dokos
@ 2014-06-30  9:47     ` Eric Schulte
  2014-06-30 10:54       ` Nicolas Goaziou
  2014-06-30 10:55     ` Nicolas Goaziou
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2014-06-30  9:47 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> Hello,
>>
>> Eric Schulte <schulte.eric@gmail.com> writes:
>>
>>> I noticed equations with "<"'s weren't displaying correctly in HTML
>>> export using mathjax.  The attached patch fixes this by html-encoding
>>> latex fragments for mathjax HTML export.  I imagine this change would be
>>> generally useful and could be applied to master.
>>
>> I am a bit puzzled. I just tried exporting the following buffer:
>>
>>   \(1 < 2\)
>>
>> and the result looked good. Could you provide an example of a failed
>> export?
>>
>>
>
> See 
>
>    http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents
>
> for some gotchas.

Thanks, the link does describe the problem well.  My particular problem
formula included "i<d" in part of a larger equation.

From the link above it sounds like replacing just "<", ">" and "&"
should be sufficient, if the full html encoding in my previous patch was
too heavy weight.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-30  9:47     ` Eric Schulte
@ 2014-06-30 10:54       ` Nicolas Goaziou
  2014-07-01 14:08         ` Rick Frankel
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-30 10:54 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Nick Dokos, emacs-orgmode

Hello,

Eric Schulte <schulte.eric@gmail.com> writes:

> From the link above it sounds like replacing just "<", ">" and "&"
> should be sufficient, if the full html encoding in my previous patch was
> too heavy weight.

By default, `org-html-encode-plain-text' just takes care about "<", ">"
and "&", which is what you're looking. However, it is configurable
through `org-html-protect-char-alist', which may cause trouble.

FWIW I think a hard-coded function dedicated to the task, or simply
a hard-coded replacement within `org-html-format-latex', may be safer in
the long run. Anyway Rick Frankel may have an opinion here.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-30  3:12   ` Nick Dokos
  2014-06-30  9:47     ` Eric Schulte
@ 2014-06-30 10:55     ` Nicolas Goaziou
  1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2014-06-30 10:55 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Hello,

Nick Dokos <ndokos@gmail.com> writes:

> See 
>
>    http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents
>
> for some gotchas.

Thank you.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-06-30 10:54       ` Nicolas Goaziou
@ 2014-07-01 14:08         ` Rick Frankel
  2014-07-27 17:56           ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Rick Frankel @ 2014-07-01 14:08 UTC (permalink / raw)
  To: Eric Schulte, Nick Dokos, emacs-orgmode

On 2014-06-30 06:54, Nicolas Goaziou wrote:
> Hello,
> 
> Eric Schulte <schulte.eric@gmail.com> writes:
> 
> From the link above it sounds like replacing just "<", ">" and "&"
> should be sufficient, if the full html encoding in my previous patch 
> was
> too heavy weight.
> 
> By default, `org-html-encode-plain-text' just takes care about "<", ">"
> and "&", which is what you're looking. However, it is configurable
> through `org-html-protect-char-alist', which may cause trouble.
> 
> FWIW I think a hard-coded function dedicated to the task, or simply
> a hard-coded replacement within `org-html-format-latex', may be safer 
> in
> the long run. Anyway Rick Frankel may have an opinion here.

Not sure why `org-html-protect-char-alist' is a custom and not just a
var, but IMHO, `org-html-encode-plain-text' is the correct solution.

rick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: html-encode in mathjax latex fragments
  2014-07-01 14:08         ` Rick Frankel
@ 2014-07-27 17:56           ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2014-07-27 17:56 UTC (permalink / raw)
  To: Rick Frankel; +Cc: Nick Dokos, emacs-orgmode, Eric Schulte

Hi Rick,

Rick Frankel <rick@rickster.com> writes:

> Not sure why `org-html-protect-char-alist' is a custom and not just a
> var, but IMHO, `org-html-encode-plain-text' is the correct solution.

I made `org-html-protect-char-alist' a defvar.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-28 17:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-29 18:41 html-encode in mathjax latex fragments Eric Schulte
2014-06-29 19:46 ` Nicolas Goaziou
2014-06-30  3:12   ` Nick Dokos
2014-06-30  9:47     ` Eric Schulte
2014-06-30 10:54       ` Nicolas Goaziou
2014-07-01 14:08         ` Rick Frankel
2014-07-27 17:56           ` Bastien
2014-06-30 10:55     ` 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).