emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* MathJax is now the default for HTML math
@ 2010-08-14  6:09 Carsten Dominik
  2010-08-14 19:37 ` Jan Böcker
  2010-08-16 17:50 ` MathJax is now the default for HTML math Bastien
  0 siblings, 2 replies; 20+ messages in thread
From: Carsten Dominik @ 2010-08-14  6:09 UTC (permalink / raw)
  To: emacs-orgmode List

Good morning everyone.

If you do you daily pull today, something important will have
changed in Org-mode.  From now on, the default settings will
use the incredible MathJax library to display math in
exported HTML.  If you had never turned on LaTeX snipped
math publishing, this will now magically work all by itself.

So the default is now

    (setq org-export-with-LaTeX-fragments t)

and it means that MathJax is used.  This is an incompatible change -  
the same
setting used to mean to transform math expressions into png images  
which are
then inlined into the Web pages.

I believe that the MathJax solution is superior in every way, which
is why I am making this change without prior discussion.  If you still
find a reason to go back to the images, you can do so with

    (setq org-export-with-LaTeX-fragments 'dvipng)

or with

    #+OPTIONS: LaTeX:dvipng

The reason why we can make MathJax work without any additional work by
either author or reader is that Bastien has agreed to serve MathJax from
http://orgmode.org/mathjax/MathJax.js.  This is brilliant.  However,
if many people use this, this will put pressure on his server, and we  
have
no idea how big the demand will be as time goes by.  We will have to  
monitor
the resulting server load and see how tis works.  If you are going to  
use
math in webpages frequently or on pages with many views, we are asking
you to install your own version of MathJax on your server - it is as
simple as unpacking a zip file.  Detailed instructions will be posted
on Worg some time soon.

If you have your own installation, or if you want to configure other  
aspects
of MathJax, take a look at the variable
org-export-html-mathjax-options.

I am really, really excited about this change.  Using MathJax makes  
Org-mode
a tool without peer for scientific note taking, I believe.  It will
also drastically improve the quality of printed web pages, because
the web pages will not use fixed-resolution images, but scaleable fonts.

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-14  6:09 MathJax is now the default for HTML math Carsten Dominik
@ 2010-08-14 19:37 ` Jan Böcker
  2010-08-14 20:39   ` Detlef Steuer
                     ` (2 more replies)
  2010-08-16 17:50 ` MathJax is now the default for HTML math Bastien
  1 sibling, 3 replies; 20+ messages in thread
From: Jan Böcker @ 2010-08-14 19:37 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode List

On 08/14/2010 08:09 AM, Carsten Dominik wrote:
> From now on, the default settings will
> use the incredible MathJax library to display math in
> exported HTML.  If you had never turned on LaTeX snipped
> math publishing, this will now magically work all by itself.

Yes, indeed it does!

Since I read the announcement this morning, I have been playing with
MathJax. I found that when an HTML file on the local hard disk uses
MathJax from the web, MathJax reverts to image fonts in Firefox (this is
caused by a security feature of Firefox and mentioned in the MathJax
FAQ). Using a local MathJax installation in a subdirectory fixes this.

Most of my time was spent messing around with XULRunner to load the
exported HTML page, wait until MathJax has done its magic, then
serialize the result back to XHTML.

And replace the file:// URLs pointing to the fonts of my local MathJax
installation with data: URIs, thus embedding the fonts within the HTML
file itself, just because I can.

The result is a single HTML file which does not require JavaScript to be
viewed (and incurs no delay while the math is being rendered). However,
as no MathJax code is present, the zoom and view source functions of
MathJax are not available.

I have put an example online.

Normal org-mode export using MathJax from orgmode.org:
http://www.jboecker.de/2010/08/14/mathjax-example.html

Single-file no-javascript version:
http://www.jboecker.de/2010/08/14/mathjax-example-nojs.html

Internet Explorer will not use the correct font, AFAIK because it only
supports the EOT fonts (MathJax uses OTF for other browsers), and in
this case also because I embedded the fonts using data: URIs and IE
limits the size of data: URIs to 32 KB.

In browsers other than Firefox (I tested with Firefox and Opera), the
font size and spacing will differ slightly between the two versions.

If people are interested, I can try to make the program take the name of
a file to operate on as a command line argument, so this could be run as
part of an org-mode export process or something. Of course, the
embedding of fonts in data: URIs would be optional.

> I am really, really excited about this change.  Using MathJax makes
> Org-mode
> a tool without peer for scientific note taking, I believe.  It will
> also drastically improve the quality of printed web pages, because
> the web pages will not use fixed-resolution images, but scaleable fonts.

And don't forget that on modern high resolution displays, it is common
to zoom in just to be able to decipher math in images, especially if you
want sub- and superscripts to be legible.

-- Jan

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

* Re: MathJax is now the default for HTML math
  2010-08-14 19:37 ` Jan Böcker
@ 2010-08-14 20:39   ` Detlef Steuer
  2010-08-14 20:59   ` Carsten Dominik
  2010-09-03  3:07   ` sand
  2 siblings, 0 replies; 20+ messages in thread
From: Detlef Steuer @ 2010-08-14 20:39 UTC (permalink / raw)
  To: emacs-orgmode

The results look just GREAT. 

Could you post the org file to give dummies like me a head start?
Especially the serializing back to HTML? How is it done? 

Thank you in advance!

Detlef


On Sat, 14 Aug 2010 21:37:26 +0200
Jan Böcker <jan.boecker@jboecker.de> wrote:

> On 08/14/2010 08:09 AM, Carsten Dominik wrote:
> > From now on, the default settings will
> > use the incredible MathJax library to display math in
> > exported HTML.  If you had never turned on LaTeX snipped
> > math publishing, this will now magically work all by itself.
> 
> Yes, indeed it does!
> 
> Since I read the announcement this morning, I have been playing with
> MathJax. I found that when an HTML file on the local hard disk uses
> MathJax from the web, MathJax reverts to image fonts in Firefox (this is
> caused by a security feature of Firefox and mentioned in the MathJax
> FAQ). Using a local MathJax installation in a subdirectory fixes this.
> 
> Most of my time was spent messing around with XULRunner to load the
> exported HTML page, wait until MathJax has done its magic, then
> serialize the result back to XHTML.
> 
> And replace the file:// URLs pointing to the fonts of my local MathJax
> installation with data: URIs, thus embedding the fonts within the HTML
> file itself, just because I can.
> 
> The result is a single HTML file which does not require JavaScript to be
> viewed (and incurs no delay while the math is being rendered). However,
> as no MathJax code is present, the zoom and view source functions of
> MathJax are not available.
> 
> I have put an example online.
> 
> Normal org-mode export using MathJax from orgmode.org:
> http://www.jboecker.de/2010/08/14/mathjax-example.html
> 
> Single-file no-javascript version:
> http://www.jboecker.de/2010/08/14/mathjax-example-nojs.html
> 
> Internet Explorer will not use the correct font, AFAIK because it only
> supports the EOT fonts (MathJax uses OTF for other browsers), and in
> this case also because I embedded the fonts using data: URIs and IE
> limits the size of data: URIs to 32 KB.
> 
> In browsers other than Firefox (I tested with Firefox and Opera), the
> font size and spacing will differ slightly between the two versions.
> 
> If people are interested, I can try to make the program take the name of
> a file to operate on as a command line argument, so this could be run as
> part of an org-mode export process or something. Of course, the
> embedding of fonts in data: URIs would be optional.
> 
> > I am really, really excited about this change.  Using MathJax makes
> > Org-mode
> > a tool without peer for scientific note taking, I believe.  It will
> > also drastically improve the quality of printed web pages, because
> > the web pages will not use fixed-resolution images, but scaleable fonts.
> 
> And don't forget that on modern high resolution displays, it is common
> to zoom in just to be able to decipher math in images, especially if you
> want sub- and superscripts to be legible.
> 
> -- Jan
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

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

* Re: MathJax is now the default for HTML math
  2010-08-14 19:37 ` Jan Böcker
  2010-08-14 20:39   ` Detlef Steuer
@ 2010-08-14 20:59   ` Carsten Dominik
  2010-08-14 22:16     ` Jan Böcker
  2010-09-03  3:07   ` sand
  2 siblings, 1 reply; 20+ messages in thread
From: Carsten Dominik @ 2010-08-14 20:59 UTC (permalink / raw)
  To: Jan Böcker; +Cc: emacs-orgmode List


On Aug 14, 2010, at 9:37 PM, Jan Böcker wrote:

> On 08/14/2010 08:09 AM, Carsten Dominik wrote:
>> From now on, the default settings will
>> use the incredible MathJax library to display math in
>> exported HTML.  If you had never turned on LaTeX snipped
>> math publishing, this will now magically work all by itself.
>
> Yes, indeed it does!
>
> Since I read the announcement this morning, I have been playing with
> MathJax. I found that when an HTML file on the local hard disk uses
> MathJax from the web, MathJax reverts to image fonts in Firefox  
> (this is
> caused by a security feature of Firefox and mentioned in the MathJax
> FAQ). Using a local MathJax installation in a subdirectory fixes this.
>
> Most of my time was spent messing around with XULRunner to load the
> exported HTML page, wait until MathJax has done its magic, then
> serialize the result back to XHTML.

Hi Jan,

can you expand a bit on why this is interesting to do?  What are the  
advantages?

Thanks!

- Carsten

>
> And replace the file:// URLs pointing to the fonts of my local MathJax
> installation with data: URIs, thus embedding the fonts within the HTML
> file itself, just because I can.
>
> The result is a single HTML file which does not require JavaScript  
> to be
> viewed (and incurs no delay while the math is being rendered).  
> However,
> as no MathJax code is present, the zoom and view source functions of
> MathJax are not available.
>
> I have put an example online.
>
> Normal org-mode export using MathJax from orgmode.org:
> http://www.jboecker.de/2010/08/14/mathjax-example.html
>
> Single-file no-javascript version:
> http://www.jboecker.de/2010/08/14/mathjax-example-nojs.html
>
> Internet Explorer will not use the correct font, AFAIK because it only
> supports the EOT fonts (MathJax uses OTF for other browsers), and in
> this case also because I embedded the fonts using data: URIs and IE
> limits the size of data: URIs to 32 KB.
>
> In browsers other than Firefox (I tested with Firefox and Opera), the
> font size and spacing will differ slightly between the two versions.
>
> If people are interested, I can try to make the program take the  
> name of
> a file to operate on as a command line argument, so this could be  
> run as
> part of an org-mode export process or something. Of course, the
> embedding of fonts in data: URIs would be optional.
>
>> I am really, really excited about this change.  Using MathJax makes
>> Org-mode
>> a tool without peer for scientific note taking, I believe.  It will
>> also drastically improve the quality of printed web pages, because
>> the web pages will not use fixed-resolution images, but scaleable  
>> fonts.
>
> And don't forget that on modern high resolution displays, it is common
> to zoom in just to be able to decipher math in images, especially if  
> you
> want sub- and superscripts to be legible.
>
> -- Jan

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-14 20:59   ` Carsten Dominik
@ 2010-08-14 22:16     ` Jan Böcker
  2010-08-15  7:25       ` Carsten Dominik
  2010-08-15 13:24       ` Jan Böcker
  0 siblings, 2 replies; 20+ messages in thread
From: Jan Böcker @ 2010-08-14 22:16 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: detlef.steuer, emacs-orgmode List

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

On 08/14/2010 10:59 PM, Carsten Dominik wrote:
> Hi Jan,
> 
> can you expand a bit on why this is interesting to do?  What are the
> advantages?
> 
> Thanks!
> 
> - Carsten

Advantages are:
- The user is not required to have JavaScript enabled
- In some cases, there is a speed advantage, because
  there is no rendering stage. This is especially
  noticeable on high-latency connections when the MathJax files
  are not already cached.
- Fonts can be embedded into the HTML file itself, so it feels
  more 'document-like' (no need to move additional files around)
- The approach might be interesting for HTML email, because it
  would require neither JavaScript nor attachments

Of course, there are disadvantages too:
- No interactive MathJax features (zoom, view source, switch rendering
backend)
- no fallback to image fonts (although AFAIK, all current versions
  of major browsers support CSS3 custom fonts)
- slightly different spacing and font sizes in non-Firefox browsers
- if fonts are embedded within the HTML file:
  * IE will not show the correct font (but in my test the
    formatting was still correct and readable)
  * The HTML file will be larger (my small example grew by 436 KB).
    Bandwidth is wasted because the fonts are base64-encoded.

I would not recommend this for regular publishing on the web. As long as
JavaScript is enabled (as it is in most cases), the disadvantages
outweigh the advantages. It might come in handy if you want to send
someone a single file (although you can always use PDF for that) or if
you want to provide an alternative for users who have JavaScript disabled.

Ideally, there would be some sort of graceful degradation, so that users
without JavaScript see the non-JS version, but if JavaScript is enabled,
the math gets re-rendered and all MathJax features are available. I have
not explored the feasibility of that.


On 08/14/2010 10:39 PM, Detlef Steuer wrote:
> Could you post the org file to give dummies like me a head start?
> Especially the serializing back to HTML? How is it done?

I have attached the (very simple) example org file to this email. The
first example is the result of exporting this file with C-c C-e h (like
Carsten said, it Just Works). The second example is the result of
processing the first one with a xulrunner application I hacked together
(which is independent of emacs). I'll try to get that application into a
publishable form tomorrow (remove hard-coded values, make embedding
fonts into the HTML file optional, etc).

My aim is to provide an elisp function to be called from an export hook
which makes the appropriate call to create the non-JS version.

-- Jan

[-- Attachment #2: mathjaxtest.org --]
[-- Type: text/plain, Size: 90 bytes --]



* Testing MathJax:  $2^4 = 16 \le 16$

\(
exp(z) = \sum_{k=0}^\infty \frac{z^k}{k!}
\)


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

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: MathJax is now the default for HTML math
  2010-08-14 22:16     ` Jan Böcker
@ 2010-08-15  7:25       ` Carsten Dominik
  2010-08-15 13:24       ` Jan Böcker
  1 sibling, 0 replies; 20+ messages in thread
From: Carsten Dominik @ 2010-08-15  7:25 UTC (permalink / raw)
  To: Jan Böcker; +Cc: detlef.steuer, emacs-orgmode List


On Aug 15, 2010, at 12:16 AM, Jan Böcker wrote:

> On 08/14/2010 10:59 PM, Carsten Dominik wrote:
>> Hi Jan,
>>
>> can you expand a bit on why this is interesting to do?  What are the
>> advantages?
>>
>> Thanks!
>>
>> - Carsten
>
> Advantages are:
> - The user is not required to have JavaScript enabled
> - In some cases, there is a speed advantage, because
>  there is no rendering stage. This is especially
>  noticeable on high-latency connections when the MathJax files
>  are not already cached.
> - Fonts can be embedded into the HTML file itself, so it feels
>  more 'document-like' (no need to move additional files around)
> - The approach might be interesting for HTML email, because it
>  would require neither JavaScript nor attachments
>
> Of course, there are disadvantages too:
> - No interactive MathJax features (zoom, view source, switch rendering
> backend)
> - no fallback to image fonts (although AFAIK, all current versions
>  of major browsers support CSS3 custom fonts)
> - slightly different spacing and font sizes in non-Firefox browsers
> - if fonts are embedded within the HTML file:
>  * IE will not show the correct font (but in my test the
>    formatting was still correct and readable)
>  * The HTML file will be larger (my small example grew by 436 KB).
>    Bandwidth is wasted because the fonts are base64-encoded.

Hi Jan,

thanks for these explanations.

- Carsten

>
> I would not recommend this for regular publishing on the web. As  
> long as
> JavaScript is enabled (as it is in most cases), the disadvantages
> outweigh the advantages. It might come in handy if you want to send
> someone a single file (although you can always use PDF for that) or if
> you want to provide an alternative for users who have JavaScript  
> disabled.
>
> Ideally, there would be some sort of graceful degradation, so that  
> users
> without JavaScript see the non-JS version, but if JavaScript is  
> enabled,
> the math gets re-rendered and all MathJax features are available. I  
> have
> not explored the feasibility of that.
>
>
> On 08/14/2010 10:39 PM, Detlef Steuer wrote:
>> Could you post the org file to give dummies like me a head start?
>> Especially the serializing back to HTML? How is it done?
>
> I have attached the (very simple) example org file to this email. The
> first example is the result of exporting this file with C-c C-e h  
> (like
> Carsten said, it Just Works). The second example is the result of
> processing the first one with a xulrunner application I hacked  
> together
> (which is independent of emacs). I'll try to get that application  
> into a
> publishable form tomorrow (remove hard-coded values, make embedding
> fonts into the HTML file optional, etc).
>
> My aim is to provide an elisp function to be called from an export  
> hook
> which makes the appropriate call to create the non-JS version.
>
> -- Jan
> <mathjaxtest.org>

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-14 22:16     ` Jan Böcker
  2010-08-15  7:25       ` Carsten Dominik
@ 2010-08-15 13:24       ` Jan Böcker
  2010-08-16  8:59         ` Carsten Dominik
  1 sibling, 1 reply; 20+ messages in thread
From: Jan Böcker @ 2010-08-15 13:24 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: detlef.steuer, emacs-orgmode List

I have now published the code used to create the static version:
http://www.jboecker.de/2010/08/15/staticmathjax.html

Below is a first stab at HTML export integration fresh out of my
*scratch* buffer (which lacks the possibility to configure this for each
file).

-- Jan


(defun jb/static-mathjax-hook-installer ()
  "adds jb/static-mathjax-process to the local after-save hook"
  (add-hook 'after-save-hook 'jb/static-mathjax-process nil t))

(defun jb/static-mathjax-process ()
  (let ((app-ini-path "/home/jan/work/staticmathjax/application.ini")
		(output-file-name (concat (file-name-sans-extension buffer-file-name)
								  "-static.html")))
  (call-process "xulrunner" nil nil nil app-ini-path buffer-file-name
output-file-name "--embed-fonts")))

(add-hook 'org-export-html-final-hook 'jb/static-mathjax-hook-installer)

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

* Re: MathJax is now the default for HTML math
  2010-08-15 13:24       ` Jan Böcker
@ 2010-08-16  8:59         ` Carsten Dominik
  2010-08-16 10:05           ` Detlef Steuer
  2010-08-16 10:09           ` Jan Böcker
  0 siblings, 2 replies; 20+ messages in thread
From: Carsten Dominik @ 2010-08-16  8:59 UTC (permalink / raw)
  To: Jan Böcker; +Cc: detlef.steuer, emacs-orgmode List


On Aug 15, 2010, at 3:24 PM, Jan Böcker wrote:

> I have now published the code used to create the static version:
> http://www.jboecker.de/2010/08/15/staticmathjax.html
>
> Below is a first stab at HTML export integration fresh out of my
> *scratch* buffer (which lacks the possibility to configure this for  
> each
> file).
>
> -- Jan
>
>
> (defun jb/static-mathjax-hook-installer ()
>  "adds jb/static-mathjax-process to the local after-save hook"
>  (add-hook 'after-save-hook 'jb/static-mathjax-process nil t))
>
> (defun jb/static-mathjax-process ()
>  (let ((app-ini-path "/home/jan/work/staticmathjax/application.ini")
> 		(output-file-name (concat (file-name-sans-extension buffer-file- 
> name)
> 								  "-static.html")))
>  (call-process "xulrunner" nil nil nil app-ini-path buffer-file-name
> output-file-name "--embed-fonts")))
>
> (add-hook 'org-export-html-final-hook 'jb/static-mathjax-hook- 
> installer)
>


Hi,

should something like this go into org itself, or would it be enough to
put this up on worg, in org-hacks or so?

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-16  8:59         ` Carsten Dominik
@ 2010-08-16 10:05           ` Detlef Steuer
  2010-08-16 17:55             ` Bastien
  2010-08-16 10:09           ` Jan Böcker
  1 sibling, 1 reply; 20+ messages in thread
From: Detlef Steuer @ 2010-08-16 10:05 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: List


[-- Attachment #1.1: Type: text/plain, Size: 1583 bytes --]

On Mon, 16 Aug 2010 10:59:05 +0200
Carsten Dominik <carsten.dominik@gmail.com> wrote:

> 
> On Aug 15, 2010, at 3:24 PM, Jan Böcker wrote:
> 
> > I have now published the code used to create the static version:
> > http://www.jboecker.de/2010/08/15/staticmathjax.html
> >
> > Below is a first stab at HTML export integration fresh out of my
> > *scratch* buffer (which lacks the possibility to configure this for  
> > each
> > file).
> >
> > -- Jan
> >
> >
> > (defun jb/static-mathjax-hook-installer ()
> >  "adds jb/static-mathjax-process to the local after-save hook"
> >  (add-hook 'after-save-hook 'jb/static-mathjax-process nil t))
> >
> > (defun jb/static-mathjax-process ()
> >  (let ((app-ini-path "/home/jan/work/staticmathjax/application.ini")
> > 		(output-file-name (concat (file-name-sans-extension buffer-file- 
> > name)
> > 								  "-static.html")))
> >  (call-process "xulrunner" nil nil nil app-ini-path buffer-file-name
> > output-file-name "--embed-fonts")))
> >
> > (add-hook 'org-export-html-final-hook 'jb/static-mathjax-hook- 
> > installer)
> >
> 
> 
> Hi,
> 
> should something like this go into org itself, or would it be enough to
> put this up on worg, in org-hacks or so?

I would like the possibility to export to static but nice math in HTML directly
out of org.
So, worg alone would be a little far away from the core, anything else would feel fine. 

But this is not an important opinion, more important where you feel the conceptually correct location is.

Detlef




> 
> - Carsten
> 
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: MathJax is now the default for HTML math
  2010-08-16  8:59         ` Carsten Dominik
  2010-08-16 10:05           ` Detlef Steuer
@ 2010-08-16 10:09           ` Jan Böcker
  2010-08-16 10:33             ` Carsten Dominik
  1 sibling, 1 reply; 20+ messages in thread
From: Jan Böcker @ 2010-08-16 10:09 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: detlef.steuer, emacs-orgmode List

On 08/16/2010 10:59 AM, Carsten Dominik wrote:

> Hi,
> 
> should something like this go into org itself, or would it be enough to
> put this up on worg, in org-hacks or so?
> 
> - Carsten

Hi Carsten,

Org-hacks sounds like the appropriate place. It is, after all, exactly
that: a hack/proof of concept with some useful applications.

I'll update worg as soon as I have written an export hook which is
configurable on a per-file basis.

-- Jan

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

* Re: MathJax is now the default for HTML math
  2010-08-16 10:09           ` Jan Böcker
@ 2010-08-16 10:33             ` Carsten Dominik
  2010-08-17 10:44               ` Jan Böcker
  0 siblings, 1 reply; 20+ messages in thread
From: Carsten Dominik @ 2010-08-16 10:33 UTC (permalink / raw)
  To: Jan Böcker; +Cc: detlef.steuer, emacs-orgmode List


On Aug 16, 2010, at 12:09 PM, Jan Böcker wrote:

> On 08/16/2010 10:59 AM, Carsten Dominik wrote:
>
>> Hi,
>>
>> should something like this go into org itself, or would it be  
>> enough to
>> put this up on worg, in org-hacks or so?
>>
>> - Carsten
>
> Hi Carsten,
>
> Org-hacks sounds like the appropriate place. It is, after all, exactly
> that: a hack/proof of concept with some useful applications.
>
> I'll update worg as soon as I have written an export hook which is
> configurable on a per-file basis.


Sounds good, thanks1

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-14  6:09 MathJax is now the default for HTML math Carsten Dominik
  2010-08-14 19:37 ` Jan Böcker
@ 2010-08-16 17:50 ` Bastien
  1 sibling, 0 replies; 20+ messages in thread
From: Bastien @ 2010-08-16 17:50 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode List

Hi all,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> The reason why we can make MathJax work without any additional work by
> either author or reader is that Bastien has agreed to serve MathJax
> from http://orgmode.org/mathjax/MathJax.js.  This is brilliant.
> However, if many people use this, this will put pressure on his
> server, and we have no idea how big the demand will be as time goes
> by.  We will have to monitor the resulting server load and see how tis
> works.  If you are going to use math in webpages frequently or on
> pages with many views, we are asking you to install your own version
> of MathJax on your server - it is as simple as unpacking a zip file.
> Detailed instructions will be posted on Worg some time soon.

Moreover, if you cannot install MathJax on your server and plan to use
the orgmode.org script on a page that will have many views, please just
drop me an email saying so -- it will help me monitor the charge on the
server.

Thanks!

-- 
 Bastien

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

* Re: MathJax is now the default for HTML math
  2010-08-16 10:05           ` Detlef Steuer
@ 2010-08-16 17:55             ` Bastien
  0 siblings, 0 replies; 20+ messages in thread
From: Bastien @ 2010-08-16 17:55 UTC (permalink / raw)
  To: Detlef Steuer; +Cc: emacs-orgmode, List, Carsten Dominik

Hi Detlef,

Detlef Steuer <detlef.steuer@gmx.de> writes:

> I would like the possibility to export to static but nice math in HTML
> directly out of org.  So, worg alone would be a little far away from
> the core, anything else would feel fine.

Maybe let's have this on Worg first, then see if people want it "closer"
to Org.  It seems easier to go that route than the other way around...

-- 
 Bastien

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

* Re: MathJax is now the default for HTML math
  2010-08-16 10:33             ` Carsten Dominik
@ 2010-08-17 10:44               ` Jan Böcker
  2010-08-17 11:01                 ` Carsten Dominik
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Böcker @ 2010-08-17 10:44 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: detlef.steuer, emacs-orgmode List

Static MathJax v0.2 contains org-static-mathjax.el, which integrates it
into the Org export process. The comments in that file explain how it
can be used.

Download it at:
http://www.jboecker.de/2010/08/15/staticmathjax.html

I have added a note to org-hacks.org in Worg, which should show up when
Worg is next exported to HTML on the server.

-- Jan

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

* Re: MathJax is now the default for HTML math
  2010-08-17 10:44               ` Jan Böcker
@ 2010-08-17 11:01                 ` Carsten Dominik
  2010-08-17 15:17                   ` Jan Böcker
  0 siblings, 1 reply; 20+ messages in thread
From: Carsten Dominik @ 2010-08-17 11:01 UTC (permalink / raw)
  To: Jan Böcker; +Cc: detlef.steuer, emacs-orgmode List


On Aug 17, 2010, at 12:44 PM, Jan Böcker wrote:

> Static MathJax v0.2 contains org-static-mathjax.el, which integrates  
> it
> into the Org export process. The comments in that file explain how it
> can be used.
>
> Download it at:
> http://www.jboecker.de/2010/08/15/staticmathjax.html
>
> I have added a note to org-hacks.org in Worg, which should show up  
> when
> Worg is next exported to HTML on the server.

And, since you made it into a nice little package, I think
it could go into the contrib directory as well - if you want, of course.
>

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-17 11:01                 ` Carsten Dominik
@ 2010-08-17 15:17                   ` Jan Böcker
  2010-08-20 16:14                     ` Carsten Dominik
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Böcker @ 2010-08-17 15:17 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: detlef.steuer, emacs-orgmode List

On 08/17/2010 01:01 PM, Carsten Dominik wrote:
> 
> On Aug 17, 2010, at 12:44 PM, Jan Böcker wrote:
> 
>> Static MathJax v0.2 contains org-static-mathjax.el, which integrates it
>> into the Org export process. The comments in that file explain how it
>> can be used.
>>
>> Download it at:
>> http://www.jboecker.de/2010/08/15/staticmathjax.html
>>
>> I have added a note to org-hacks.org in Worg, which should show up when
>> Worg is next exported to HTML on the server.
> 
> And, since you made it into a nice little package, I think
> it could go into the contrib directory as well - if you want, of course.
>>
> 
> - Carsten
> 

Feel free to include it!

I guess org-static-mathjax.el should go to contrib/lisp and everything
else to contrib/scripts/staticmathjax/ ?

Maybe add a pointer to contrib/scripts/staticmathjax/README.org in the
comments of the lisp file.

-- Jan

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

* Re: MathJax is now the default for HTML math
  2010-08-17 15:17                   ` Jan Böcker
@ 2010-08-20 16:14                     ` Carsten Dominik
  0 siblings, 0 replies; 20+ messages in thread
From: Carsten Dominik @ 2010-08-20 16:14 UTC (permalink / raw)
  To: Jan Böcker; +Cc: detlef.steuer, emacs-orgmode List


On Aug 17, 2010, at 5:17 PM, Jan Böcker wrote:

> On 08/17/2010 01:01 PM, Carsten Dominik wrote:
>>
>> On Aug 17, 2010, at 12:44 PM, Jan Böcker wrote:
>>
>>> Static MathJax v0.2 contains org-static-mathjax.el, which  
>>> integrates it
>>> into the Org export process. The comments in that file explain how  
>>> it
>>> can be used.
>>>
>>> Download it at:
>>> http://www.jboecker.de/2010/08/15/staticmathjax.html
>>>
>>> I have added a note to org-hacks.org in Worg, which should show up  
>>> when
>>> Worg is next exported to HTML on the server.
>>
>> And, since you made it into a nice little package, I think
>> it could go into the contrib directory as well - if you want, of  
>> course.
>>>
>>
>> - Carsten
>>
>
> Feel free to include it!
>
> I guess org-static-mathjax.el should go to contrib/lisp and everything
> else to contrib/scripts/staticmathjax/ ?
>
> Maybe add a pointer to contrib/scripts/staticmathjax/README.org in the
> comments of the lisp file.

I have added it thanks.

The only modification I made is to initialize your first variable like  
this:

(defcustom org-static-mathjax-app-ini-path
   (or (expand-file-name
        "../scripts/staticmatchjax/application.ini"
        (file-name-directory (or load-file-name buffer-file-name)))
       "")
   "Path to \"application.ini\" of the Static MathJax XULRunner  
application.
If you have extracted StaticMathJax to e.g. ~/.local/staticmathjax, set
this to ~/.local/staticmathjax/application.ini"
   :type 'string)

This should then point to to the right place in an Org distribution.

Thanks!

- Carsten

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

* Re: MathJax is now the default for HTML math
  2010-08-14 19:37 ` Jan Böcker
  2010-08-14 20:39   ` Detlef Steuer
  2010-08-14 20:59   ` Carsten Dominik
@ 2010-09-03  3:07   ` sand
  2010-09-03 15:53     ` Embedding images as data: URIs in the HTML exporter (was: MathJax is now the default for HTML math) Jan Böcker
  2 siblings, 1 reply; 20+ messages in thread
From: sand @ 2010-09-03  3:07 UTC (permalink / raw)
  To: Jan Böcker; +Cc: emacs-orgmode List, Carsten Dominik

Jan Böcker writes:
> Since I read the announcement this morning, I have been playing with
> MathJax. I found that when an HTML file on the local hard disk uses
> MathJax from the web, MathJax reverts to image fonts in Firefox (this is
> caused by a security feature of Firefox and mentioned in the MathJax
> FAQ). Using a local MathJax installation in a subdirectory fixes this.
> 
> Most of my time was spent messing around with XULRunner to load the
> exported HTML page, wait until MathJax has done its magic, then
> serialize the result back to XHTML.
> 
> And replace the file:// URLs pointing to the fonts of my local MathJax
> installation with data: URIs, thus embedding the fonts within the HTML
> file itself, just because I can.
> 
> The result is a single HTML file which does not require JavaScript to be
> viewed (and incurs no delay while the math is being rendered). However,
> as no MathJax code is present, the zoom and view source functions of
> MathJax are not available.

How about doing the same data: URI embedding for images in the HTML
exporter?  It should be possible to implement it entirely inside
Emacs.  It would have to be optional, of course.

Derek

-- 
Derek Upham
sand@blarg.net

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

* Re: Embedding images as data: URIs in the HTML exporter (was: MathJax is now the default for HTML math)
  2010-09-03  3:07   ` sand
@ 2010-09-03 15:53     ` Jan Böcker
  2010-09-26 18:51       ` David Maus
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Böcker @ 2010-09-03 15:53 UTC (permalink / raw)
  To: sand; +Cc: emacs-orgmode List, Carsten Dominik

On 09/03/2010 05:07 AM, sand@blarg.net wrote:
> How about doing the same data: URI embedding for images in the HTML
> exporter?  It should be possible to implement it entirely inside
> Emacs.  It would have to be optional, of course.
> 
> Derek
> 

This is certainly possible, the following patch would do this to *every*
image. Maybe someone who knows the HTML exporter code better than I do
can make it configurable and submit a patch.

Bonus points for an extra option which only embeds images smaller than
32 KB to keep it compatible with Internet Explorer.

Maybe something like this configuration variable:


(defcustom org-export-html-embed-images-as-data-uris 'never
"Controls if references to inlined images (see
`org-export-html-inline-images') are replaced with their contents as a
data: URI.

Possible values:
'never (default)   All images are inlined using normal URL references.
'always            Embed all images as data: URIs.
'up-to-32KB        Use data: URIs only for images up to 32 KByte
                   (Internet Explorer does not allow bigger data: URIs)

See also: http://en.wikipedia.org/wiki/Data_URI_scheme"
:group org-export-html
:type (choice (const never) (const always) (const up-to-32KB)))



-- Jan


---
 lisp/org-html.el |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index eecda0d..5e5ec95 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1820,7 +1820,7 @@ lang=\"%s\" xml:lang=\"%s\">
                    (if org-par-open "</p>\n" "")
                    (if label (format "id=\"%s\" " label) "")))
        (format "<img src=\"%s\"%s />"
-               src
+               (org-export-html-image-to-data-uri src)
                (if (string-match "\\<alt=" (or attr ""))
                    (concat " " attr )
                  (concat " " attr " alt=\"" src "\"")))
@@ -1830,6 +1830,16 @@ lang=\"%s\" xml:lang=\"%s\">
                (concat "\n<p>" caption "</p>")
                (if org-par-open "\n<p>" ""))))))))

+(defun org-export-html-image-to-data-uri (src)
+  "Load an image file and convert it to a data: URI.
+See http://en.wikipedia.org/wiki/Data_URI_scheme"
+  (with-temp-buffer
+    (insert-file-contents src)
+    (base64-encode-region (point-min) (point-max))
+    (goto-char 1)
+    (insert "data:;base64,")
+    (buffer-string)))
+
 (defun org-export-html-get-bibliography ()
   "Find bibliography, cut it out and return it."
   (catch 'exit
-- 
1.7.0.4

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

* Re: Embedding images as data: URIs in the HTML exporter (was: MathJax is now the default for HTML math)
  2010-09-03 15:53     ` Embedding images as data: URIs in the HTML exporter (was: MathJax is now the default for HTML math) Jan Böcker
@ 2010-09-26 18:51       ` David Maus
  0 siblings, 0 replies; 20+ messages in thread
From: David Maus @ 2010-09-26 18:51 UTC (permalink / raw)
  To: Jan Böcker; +Cc: emacs-orgmode List, Carsten Dominik


[-- Attachment #1.1: Type: text/plain, Size: 1793 bytes --]

Jan Böcker wrote:
>On 09/03/2010 05:07 AM, sand@blarg.net wrote:
>> How about doing the same data: URI embedding for images in the HTML
>> exporter?  It should be possible to implement it entirely inside
>> Emacs.  It would have to be optional, of course.
>> 
>> Derek
>> 

>This is certainly possible, the following patch would do this to *every*
>image. Maybe someone who knows the HTML exporter code better than I do
>can make it configurable and submit a patch.

>Bonus points for an extra option which only embeds images smaller than
>32 KB to keep it compatible with Internet Explorer.

The main problem I see here is, that it is not very well supported.
Especially IE below 8 does not support it at all and IE8 seems to
support data URIs in CSS style sheets, only.
 
Quote from https://developer.mozilla.org/en/data_URIs (Common
problems):

"The data scheme is supported by Opera 7.20 and above, as well as
Safari and Konqueror. Internet Explorer 7 and below, however, do not
currently support it. Internet Explorer 8 and above only supports data
URIs for images in CSS."

Moreover this technique is somewhat problematic because it defeats
some caching mechanism, and will enlarge the resulting page -- not
very kind for people with small bandwith and/or paying by traffic.

I think something supporting this could go to hacks or contrib with a
big red warning about the consequences and a careful discussion of
when to use this and when best not to use it.

Best,

 -- David

PS: There is
http://www-archive.mozilla.org/quality/networking/testing/datatests.html
that lets you test your browser for the support of content included in
data URIs.

-- 
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2010-09-26 18:51 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-14  6:09 MathJax is now the default for HTML math Carsten Dominik
2010-08-14 19:37 ` Jan Böcker
2010-08-14 20:39   ` Detlef Steuer
2010-08-14 20:59   ` Carsten Dominik
2010-08-14 22:16     ` Jan Böcker
2010-08-15  7:25       ` Carsten Dominik
2010-08-15 13:24       ` Jan Böcker
2010-08-16  8:59         ` Carsten Dominik
2010-08-16 10:05           ` Detlef Steuer
2010-08-16 17:55             ` Bastien
2010-08-16 10:09           ` Jan Böcker
2010-08-16 10:33             ` Carsten Dominik
2010-08-17 10:44               ` Jan Böcker
2010-08-17 11:01                 ` Carsten Dominik
2010-08-17 15:17                   ` Jan Böcker
2010-08-20 16:14                     ` Carsten Dominik
2010-09-03  3:07   ` sand
2010-09-03 15:53     ` Embedding images as data: URIs in the HTML exporter (was: MathJax is now the default for HTML math) Jan Böcker
2010-09-26 18:51       ` David Maus
2010-08-16 17:50 ` MathJax is now the default for HTML math Bastien

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).