public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Proposal: Extend math rendering in HTML with --svgtex[=URL]
@ 2015-02-07 23:29 Serge Stroobandt
       [not found] ` <bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Serge Stroobandt @ 2015-02-07 23:29 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

*Proposal details:*
The purpose of this extension is to inject SVG math directly into the 
(X)HTML rendered by Pandoc.
To do so, Pandoc's HTML writer needs to be extended with a --svgtex[=URL] 
option for rendering math with SvgTex,
similar as in 
http://johnmacfarlane.net/pandoc/README.html#math-rendering-in-html

The proposed option would typically set:
--svgtex='http://localhost:16000/'
with 16000 being the port where PhantomJS running SvgTex is listening.
(SvgTex installation instructions are provided at the end of this proposal.)

Here is what Pandoc should do,
...for inline math:
match: <span class="math">$\LaTeX$</span>
replace by: <span style="font-size:100%; 
display:inline-block;">..SVG..</span> 
where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX' 
http://localhost:16000/

...for display math:
match: <span class="math">$$\LaTeX$$</span>
replace by: <span style="text-align: center;">..SVG..</span>
where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX' 
http://localhost:16000/

This information is also available at:
https://github.com/agrbin/svgtex/wiki#how-to-integrate

*Rationale & usefulness:*
All major modern web browsers offer good support for viewing embedded 
scalable vector graphics (SVG). SVG browser support is much better than 
current MathML support. The proposed feature would create self-contained 
(X)HTML files with embedded SVG for math.

Pandoc currently offers support for HTML rendering with MathJax and KaTeX. 
However, both options require the viewer to have a browser with internet 
connection and JavaScript support. Viewing HTML math generated with SvgTex 
only requires a modern browser; an internet connection is optional. Since 
SvgTex uses MathJax, the math rendering quality is equally high and far 
superior to that of MathML.

Mathoid (https://github.com/wikimedia/mathoid), builds on SvgTex and is 
further developed and used by Wikipedia.
Unlike SvgTex, a Mathoid server returns JSON objects, not plain SVG. 
Mathoid installation instructions are not as clear as those of SvgTex. I 
would consider Mathoid support for Pandoc as a separate, slightly more 
complex proposal.

Pandoc generated XHTML with embedded SvgTeX math and CSS layout could serve 
as input for the proprietary Prince XML software (http://www.princexml.com/). 
Prince XML currently only has limited JavaScript support and cannot render 
math with MathJax nor KaTeX.
MathML rendered by Prince XML is of low quality. This proposal would allow 
the extremely fast unattended CSS-typesetting using Prince XML of complex 
PDFs containing high-quality rendered math ---think academic journals. 
Unattended typesetting of complex documents is currently not really 
possible with LaTeX nor ConTeXt. Both have issues with complex page breaks. 
Nor do LaTeX or ConTeXt offer CSS support. Furthermore, rendering with 
LaTeX and ConTeXt is extremely slow compared to Prince XML rendering. 
For an example of using Pandoc in combination with Prince XML (albeit with 
MathML), please, refer to:
http://hamwaves.com/cl-ocfd/en/index.html
This page also contains a link to its own makefile which is very 
instructive to Pandoc users.

*Drawbacks:*
When the --svgtex[=URL] option is enabled for HTML writing, the PhantomJS 
engine needs to be running SvgTex whilst being connected to MathJax.org 
over the Internet.

XHTML containing SVG cannot be validated, simply because it was not 
foreseen in the XHTML specification.
W3C has plans for an XHTML5 specification. Anyhow, the resulting XHTML is 
perfectly usable in browsers and Prince XML.
(See also: http://dh.obdurodon.org/svg-embedding.xhtml)
HTML5 validation should work but is currently experimental.

*Backwards compatibility:*
The proposed HTML writer extension is fully backwards compatible.

*Additional library dependencies:*
A Haskell binding to the libcurl library or similar would be required.

*Performance:*
Pandoc performance without the --svgtex[=URL] option enabled remains 
unaffected.
HTML writing with the --svgtex[=URL] option enabled will be a tad slower.
The main speed limitation will be the internet connection to MathJax.org.
Nevertheless, calls to PhantomJS running SvgTex are inherently fast.
Loading HTML pages containing math generated by SvgTex will be much faster 
than viewing those using MathJax or KaTeX Javascript callbacks.

*SvgTex installation instructions:*
On a Debian-derived GNU/Linux distribution, run the following commands:

$ sudo apt-get install phantomjs
$ cd && git clone https://github.com/agrbin/svgtex/ && cd svgtex

Information is also available 
https://github.com/agrbin/svgtex/wiki

*Starting the PhantomJS engine with SvgTeX:*
$ cd $HOME/svgtex
$ phantomjs main.js &

One might consider adding above lines to a bash script for achieving 
automatic PhantomJS starting at session start.

*Testing the PhantomJS engine with SvgTeX:*
Browsing to http://localhost:16000 should show the svgtex tester interface.

Browsing to:
http://localhost:16000/?type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}
should show a formula in SVG.

On the command line, the following command should render the same formula 
as an SVG object to standard output:
curl -d 'type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}' 
http://localhost:16000/


Finally, to John:
Thank you for giving the world Pandoc and for continuing to make Pandoc 
even greater!

Kind regards,
Serge Y. Stroobandt

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 8135 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found] ` <bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-08  4:16   ` John MacFarlane
       [not found]     ` <20150208041648.GC12050-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
  2015-02-08 10:47   ` Anton Grbin
  2015-02-08 17:39   ` Ghlen Livid
  2 siblings, 1 reply; 12+ messages in thread
From: John MacFarlane @ 2015-02-08  4:16 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

May I suggest (for now) creating a simple program that takes
HTML generated with `pandoc --mathjax` as input, and
performs the transformation you describe?  It would be a
pretty easy thing to write in a scripting language, and
it could be used together with existing versions of pandoc.

Another option would be to create a pandoc filter (see
"Scripting with pandoc" on the website).  This would replace
Math inlines with RawInline (Format "html") (the span with
svg).

IF this were added to pandoc, it would have to be as a
filter (though it could be one that was integral to pandoc
itself), since the HTML writer is "pure" and can't do IO.

+++ Serge Stroobandt [Feb 07 15 15:29 ]:
>   Proposal details:
>   The purpose of this extension is to inject SVG math directly into the
>   (X)HTML rendered by Pandoc.
>   To do so, Pandoc's HTML writer needs to be extended with a
>   --svgtex[=URL] option for rendering math with SvgTex,
>   similar as in
>   [1]http://johnmacfarlane.net/pandoc/README.html#math-rendering-in-html
>   The proposed option would typically set:
>   --svgtex='http://localhost:16000/'
>   with 16000 being the port where PhantomJS running SvgTex is listening.
>   (SvgTex installation instructions are provided at the end of this
>   proposal.)
>   Here is what Pandoc should do,
>   ...for inline math:
>   match: <span class="math">$\LaTeX$</span>
>   replace by: <span style="font-size:100%;
>   display:inline-block;">..SVG..</span>
>   where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX'
>   http://localhost:16000/
>   ...for display math:
>   match: <span class="math">$$\LaTeX$$</span>
>   replace by: <span style="text-align: center;">..SVG..</span>
>   where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX'
>   http://localhost:16000/
>   This information is also available at:
>   [2]https://github.com/agrbin/svgtex/wiki#how-to-integrate
>   Rationale & usefulness:
>   All major modern web browsers offer good support for viewing embedded
>   scalable vector graphics (SVG). SVG browser support is much better than
>   current MathML support. The proposed feature would create
>   self-contained (X)HTML files with embedded SVG for math.
>   Pandoc currently offers support for HTML rendering with MathJax and
>   KaTeX. However, both options require the viewer to have a browser with
>   internet connection and JavaScript support. Viewing HTML math generated
>   with SvgTex only requires a modern browser; an internet connection is
>   optional. Since SvgTex uses MathJax, the math rendering quality is
>   equally high and far superior to that of MathML.
>   Mathoid ([3]https://github.com/wikimedia/mathoid), builds on SvgTex and
>   is further developed and used by Wikipedia.
>   Unlike SvgTex, a Mathoid server returns JSON objects, not plain SVG.
>   Mathoid installation instructions are not as clear as those of SvgTex.
>   I would consider Mathoid support for Pandoc as a separate, slightly
>   more complex proposal.
>   Pandoc generated XHTML with embedded SvgTeX math and CSS layout could
>   serve as input for the proprietary Prince XML software
>   ([4]http://www.princexml.com/). Prince XML currently only has limited
>   JavaScript support and cannot render math with MathJax nor KaTeX.
>   MathML rendered by Prince XML is of low quality. This proposal would
>   allow the extremely fast unattended CSS-typesetting using Prince XML of
>   complex PDFs containing high-quality rendered math ---think academic
>   journals. Unattended typesetting of complex documents is currently not
>   really possible with LaTeX nor ConTeXt. Both have issues with complex
>   page breaks. Nor do LaTeX or ConTeXt offer CSS support. Furthermore,
>   rendering with LaTeX and ConTeXt is extremely slow compared to Prince
>   XML rendering.
>   For an example of using Pandoc in combination with Prince XML (albeit
>   with MathML), please, refer to:
>   [5]http://hamwaves.com/cl-ocfd/en/index.html
>   This page also contains a link to its own makefile which is very
>   instructive to Pandoc users.
>   Drawbacks:
>   When the --svgtex[=URL] option is enabled for HTML writing, the
>   PhantomJS engine needs to be running SvgTex whilst being connected to
>   MathJax.org over the Internet.
>   XHTML containing SVG cannot be validated, simply because it was not
>   foreseen in the XHTML specification.
>   W3C has plans for an XHTML5 specification. Anyhow, the resulting XHTML
>   is perfectly usable in browsers and Prince XML.
>   (See also: [6]http://dh.obdurodon.org/svg-embedding.xhtml)
>   HTML5 validation should work but is currently experimental.
>   Backwards compatibility:
>   The proposed HTML writer extension is fully backwards compatible.
>   Additional library dependencies:
>   A Haskell binding to the libcurl library or similar would be required.
>   Performance:
>   Pandoc performance without the --svgtex[=URL] option enabled remains
>   unaffected.
>   HTML writing with the --svgtex[=URL] option enabled will be a tad
>   slower.
>   The main speed limitation will be the internet connection to
>   MathJax.org.
>   Nevertheless, calls to PhantomJS running SvgTex are inherently fast.
>   Loading HTML pages containing math generated by SvgTex will be much
>   faster than viewing those using MathJax or KaTeX Javascript callbacks.
>   SvgTex installation instructions:
>   On a Debian-derived GNU/Linux distribution, run the following commands:
>   $ sudo apt-get install phantomjs
>   $ cd && git clone https://github.com/agrbin/svgtex/ && cd svgtex
>   Information is also available
>   [7]https://github.com/agrbin/svgtex/wiki
>   Starting the PhantomJS engine with SvgTeX:
>   $ cd $HOME/svgtex
>   $ phantomjs main.js &
>   One might consider adding above lines to a bash script for achieving
>   automatic PhantomJS starting at session start.
>   Testing the PhantomJS engine with SvgTeX:
>   Browsing to [8]http://localhost:16000 should show the svgtex tester
>   interface.
>   Browsing to:
>   [9]http://localhost:16000/?type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{
>   out}}{P_{in}}}
>   should show a formula in SVG.
>   On the command line, the following command should render the same
>   formula as an SVG object to standard output:
>   curl -d 'type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}'
>   http://localhost:16000/
>   Finally, to John:
>   Thank you for giving the world Pandoc and for continuing to make Pandoc
>   even greater!
>   Kind regards,
>   Serge Y. Stroobandt
>
>   --
>   You received this message because you are subscribed to the Google
>   Groups "pandoc-discuss" group.
>   To unsubscribe from this group and stop receiving emails from it, send
>   an email to [10]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [11]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [12]https://groups.google.com/d/msgid/pandoc-discuss/bdf4eaf4-2f55-4c77
>   -b64f-dfca5f4097fc%40googlegroups.com.
>   For more options, visit [13]https://groups.google.com/d/optout.
>
>References
>
>   1. http://johnmacfarlane.net/pandoc/README.html#math-rendering-in-html
>   2. https://github.com/agrbin/svgtex/wiki#how-to-integrate
>   3. https://github.com/wikimedia/mathoid
>   4. http://www.princexml.com/
>   5. http://hamwaves.com/cl-ocfd/en/index.html
>   6. http://dh.obdurodon.org/svg-embedding.xhtml
>   7. https://github.com/agrbin/svgtex/wiki
>   8. http://localhost:16000/
>   9. http://localhost:16000/?type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}
>  10. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>  11. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>  12. https://groups.google.com/d/msgid/pandoc-discuss/bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>  13. https://groups.google.com/d/optout


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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found] ` <bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-02-08  4:16   ` John MacFarlane
@ 2015-02-08 10:47   ` Anton Grbin
  2015-02-08 17:39   ` Ghlen Livid
  2 siblings, 0 replies; 12+ messages in thread
From: Anton Grbin @ 2015-02-08 10:47 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

Hello Serge,

As an author of SvgTex I support I your proposal and I am glad that you 
find this idea useful.

On Sunday, 8 February 2015 00:29:42 UTC+1, Serge Stroobandt wrote:
>
> *Drawbacks:*
> When the --svgtex[=URL] option is enabled for HTML writing, the PhantomJS 
> engine needs to be running SvgTex whilst being connected to MathJax.org 
> over the Internet.
>

Please note the comment 
in https://github.com/agrbin/svgtex/blob/master/index.html#L23 line. Eg. 
you can download local copy of MathJax and have SvgTex server talking with 
that local copy instead of CDN. That way server doesn't require internet 
connection and performance is maximized.

Cheers,
Anton

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a6927236-3422-419b-bb51-50192d965636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1969 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]     ` <20150208041648.GC12050-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
@ 2015-02-08 12:10       ` Serge Stroobandt
       [not found]         ` <214388e6-544c-4721-a96e-eadf519a83ca-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Serge Stroobandt @ 2015-02-08 12:10 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

Dear John,

I concur with your view that a (bash) script could probably do the job.
However, it is especially SvgTeX's broad application potential, also for 
other Pandoc users, 
which spurred me to write this proposal.
So, yes, I am hoping for at least some level of SvgTeX integration into 
Pandoc.

This is why I am rather a proponent of your second suggestion: creating a 
Haskell Pandoc filter.
I have to admit I never dabbled with Pandoc filters before, but the idea of 
using one appeals to me.
(Sorry, I will not be able to write it myself. I am devoid of any Haskell 
knowledge.)
Anyhow, it would imply writing code only once and well.
Furthermore, it would put SvgTeX support on the right development track for 
possible future integration.

Thank you in advance for integrating this feature.
Serge

On Sunday, 8 February 2015 05:17:13 UTC+1, John MacFarlane wrote:
>
> May I suggest (for now) creating a simple program that takes 
> HTML generated with `pandoc --mathjax` as input, and 
> performs the transformation you describe?  It would be a 
> pretty easy thing to write in a scripting language, and 
> it could be used together with existing versions of pandoc. 
>
> Another option would be to create a pandoc filter (see 
> "Scripting with pandoc" on the website).  This would replace 
> Math inlines with RawInline (Format "html") (the span with 
> svg). 
>
> IF this were added to pandoc, it would have to be as a 
> filter (though it could be one that was integral to pandoc 
> itself), since the HTML writer is "pure" and can't do IO. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/214388e6-544c-4721-a96e-eadf519a83ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 2766 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]         ` <214388e6-544c-4721-a96e-eadf519a83ca-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-08 15:13           ` Daniel Staal
  2015-02-08 16:34             ` John MacFarlane
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Staal @ 2015-02-08 15:13 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

--As of February 8, 2015 4:10:15 AM -0800, Serge Stroobandt is alleged to 
have said:

> This is why I am rather a proponent of your second suggestion: creating a
> Haskell Pandoc filter. I have to admit I never dabbled with Pandoc
> filters before, but the idea of using one appeals to me. (Sorry, I will
> not be able to write it myself. I am devoid of any Haskell knowledge.)
> Anyhow, it would imply writing code only once and well. Furthermore, it
> would put SvgTeX support on the right development track for possible
> future integration.

--As for the rest, it is mine.

Filters do not have to be in Haskell, they can be in any language, so don't 
let that stop you.  ;)

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------


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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
  2015-02-08 15:13           ` Daniel Staal
@ 2015-02-08 16:34             ` John MacFarlane
  0 siblings, 0 replies; 12+ messages in thread
From: John MacFarlane @ 2015-02-08 16:34 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ Daniel Staal [Feb 08 15 10:13 ]:
>--As of February 8, 2015 4:10:15 AM -0800, Serge Stroobandt is alleged 
>to have said:
>
>>This is why I am rather a proponent of your second suggestion: creating a
>>Haskell Pandoc filter. I have to admit I never dabbled with Pandoc
>>filters before, but the idea of using one appeals to me. (Sorry, I will
>>not be able to write it myself. I am devoid of any Haskell knowledge.)
>>Anyhow, it would imply writing code only once and well. Furthermore, it
>>would put SvgTeX support on the right development track for possible
>>future integration.
>
>--As for the rest, it is mine.
>
>Filters do not have to be in Haskell, they can be in any language, so 
>don't let that stop you.  ;)

Yes -- there are libraries available to aid writing them in python,
PHP, perl, and javascript.  Links to all of these at
http://johnmacfarlane.net/pandoc/scripting.html#but-i-dont-want-to-learn-haskell


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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found] ` <bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-02-08  4:16   ` John MacFarlane
  2015-02-08 10:47   ` Anton Grbin
@ 2015-02-08 17:39   ` Ghlen Livid
       [not found]     ` <0f834812-ad8c-4289-871f-8d24af8dfc82-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2 siblings, 1 reply; 12+ messages in thread
From: Ghlen Livid @ 2015-02-08 17:39 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

I actually think that writing a nodejs filter 
(using https://github.com/mathjax/mathjax-node for example) would be a much 
cleaner option. It beats having to run a server in background and a 
requiring working Internet connection by a long shot.

воскресенье, 8 февраля 2015 г., 2:29:42 UTC+3 пользователь Serge Stroobandt 
написал:
>
> *Proposal details:*
> The purpose of this extension is to inject SVG math directly into the 
> (X)HTML rendered by Pandoc.
> To do so, Pandoc's HTML writer needs to be extended with a --svgtex[=URL] 
> option for rendering math with SvgTex,
> similar as in 
> http://johnmacfarlane.net/pandoc/README.html#math-rendering-in-html
>
> The proposed option would typically set:
> --svgtex='http://localhost:16000/'
> with 16000 being the port where PhantomJS running SvgTex is listening.
> (SvgTex installation instructions are provided at the end of this 
> proposal.)
>
> Here is what Pandoc should do,
> ...for inline math:
> match: <span class="math">$\LaTeX$</span>
> replace by: <span style="font-size:100%; 
> display:inline-block;">..SVG..</span> 
> where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX' 
> http://localhost:16000/
>
> ...for display math:
> match: <span class="math">$$\LaTeX$$</span>
> replace by: <span style="text-align: center;">..SVG..</span>
> where ..SVG.. is the output of: curl -d 'type=tex&q=\LaTeX' 
> http://localhost:16000/
>
> This information is also available at:
> https://github.com/agrbin/svgtex/wiki#how-to-integrate
>
> *Rationale & usefulness:*
> All major modern web browsers offer good support for viewing embedded 
> scalable vector graphics (SVG). SVG browser support is much better than 
> current MathML support. The proposed feature would create self-contained 
> (X)HTML files with embedded SVG for math.
>
> Pandoc currently offers support for HTML rendering with MathJax and KaTeX. 
> However, both options require the viewer to have a browser with internet 
> connection and JavaScript support. Viewing HTML math generated with SvgTex 
> only requires a modern browser; an internet connection is optional. Since 
> SvgTex uses MathJax, the math rendering quality is equally high and far 
> superior to that of MathML.
>
> Mathoid (https://github.com/wikimedia/mathoid), builds on SvgTex and is 
> further developed and used by Wikipedia.
> Unlike SvgTex, a Mathoid server returns JSON objects, not plain SVG. 
> Mathoid installation instructions are not as clear as those of SvgTex. I 
> would consider Mathoid support for Pandoc as a separate, slightly more 
> complex proposal.
>
> Pandoc generated XHTML with embedded SvgTeX math and CSS layout could 
> serve as input for the proprietary Prince XML software (
> http://www.princexml.com/). Prince XML currently only has limited 
> JavaScript support and cannot render math with MathJax nor KaTeX.
> MathML rendered by Prince XML is of low quality. This proposal would allow 
> the extremely fast unattended CSS-typesetting using Prince XML of complex 
> PDFs containing high-quality rendered math ---think academic journals. 
> Unattended typesetting of complex documents is currently not really 
> possible with LaTeX nor ConTeXt. Both have issues with complex page breaks. 
> Nor do LaTeX or ConTeXt offer CSS support. Furthermore, rendering with 
> LaTeX and ConTeXt is extremely slow compared to Prince XML rendering. 
> For an example of using Pandoc in combination with Prince XML (albeit with 
> MathML), please, refer to:
> http://hamwaves.com/cl-ocfd/en/index.html
> This page also contains a link to its own makefile which is very 
> instructive to Pandoc users.
>
> *Drawbacks:*
> When the --svgtex[=URL] option is enabled for HTML writing, the PhantomJS 
> engine needs to be running SvgTex whilst being connected to MathJax.org 
> over the Internet.
>
> XHTML containing SVG cannot be validated, simply because it was not 
> foreseen in the XHTML specification.
> W3C has plans for an XHTML5 specification. Anyhow, the resulting XHTML is 
> perfectly usable in browsers and Prince XML.
> (See also: http://dh.obdurodon.org/svg-embedding.xhtml)
> HTML5 validation should work but is currently experimental.
>
> *Backwards compatibility:*
> The proposed HTML writer extension is fully backwards compatible.
>
> *Additional library dependencies:*
> A Haskell binding to the libcurl library or similar would be required.
>
> *Performance:*
> Pandoc performance without the --svgtex[=URL] option enabled remains 
> unaffected.
> HTML writing with the --svgtex[=URL] option enabled will be a tad slower.
> The main speed limitation will be the internet connection to MathJax.org.
> Nevertheless, calls to PhantomJS running SvgTex are inherently fast.
> Loading HTML pages containing math generated by SvgTex will be much faster 
> than viewing those using MathJax or KaTeX Javascript callbacks.
>
> *SvgTex installation instructions:*
> On a Debian-derived GNU/Linux distribution, run the following commands:
>
> $ sudo apt-get install phantomjs
> $ cd && git clone https://github.com/agrbin/svgtex/ && cd svgtex
>
> Information is also available 
> https://github.com/agrbin/svgtex/wiki
>
> *Starting the PhantomJS engine with SvgTeX:*
> $ cd $HOME/svgtex
> $ phantomjs main.js &
>
> One might consider adding above lines to a bash script for achieving 
> automatic PhantomJS starting at session start.
>
> *Testing the PhantomJS engine with SvgTeX:*
> Browsing to http://localhost:16000 should show the svgtex tester 
> interface.
>
> Browsing to:
>
> http://localhost:16000/?type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}
> should show a formula in SVG.
>
> On the command line, the following command should render the same formula 
> as an SVG object to standard output:
> curl -d 'type=tex&q=L_{dB}=10\cdot\log_{10}{\frac{P_{out}}{P_{in}}}' 
> http://localhost:16000/
>
>
> Finally, to John:
> Thank you for giving the world Pandoc and for continuing to make Pandoc 
> even greater!
>
> Kind regards,
> Serge Y. Stroobandt
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0f834812-ad8c-4289-871f-8d24af8dfc82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 14596 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]     ` <0f834812-ad8c-4289-871f-8d24af8dfc82-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-08 19:25       ` Serge Stroobandt
       [not found]         ` <a1da5444-4fe7-401a-96bc-79adfff6a2b6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Serge Stroobandt @ 2015-02-08 19:25 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

@Ghlen
I should have mentioned that in the weeks prior to submitting this 
proposal, I tried all different brands of dog food I could find.
This includes in addition to SvgTex, also Mathoid, mathjax-node and a 
couple more which name I have forgotten.

My findings with mathjax-node were:

   1. The project is terribly poorly documented.
   2. Its API is way too difficult.
   3. On Debian-based distributions there is a mix-up between nodejs and 
   nodejs-legacy versions.
   4. For all of the above reasons, I never got mathjax-node to work 
   properly. I just waisted an hour or so of my life.
   
So no, I beg to differ.
Irrespectively of above arguments, I see no gains in using mathjax-node 
over SvgTex (which, by the way, uses PhantomJS in stead of nodejs). Anyhow, 
this shows the importance of properly documenting projects (or enhancement 
requests for that matter).

Serge

On Sunday, 8 February 2015 18:39:49 UTC+1, Ghlen Livid wrote:
>
> I actually think that writing a nodejs filter (using 
> https://github.com/mathjax/mathjax-node for example) would be a much 
> cleaner option. It beats having to run a server in background and a 
> requiring working Internet connection by a long shot.
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a1da5444-4fe7-401a-96bc-79adfff6a2b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 2821 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]         ` <a1da5444-4fe7-401a-96bc-79adfff6a2b6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-08 23:30           ` Ghlen Livid
  2015-02-08 23:46           ` Ghlen Livid
  1 sibling, 0 replies; 12+ messages in thread
From: Ghlen Livid @ 2015-02-08 23:30 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

Oh well... https://github.com/lierdakil/mathjax-pandoc-filter -- or 
something along those lines.

воскресенье, 8 февраля 2015 г., 22:25:10 UTC+3 пользователь Serge 
Stroobandt написал:
>
> @Ghlen
> I should have mentioned that in the weeks prior to submitting this 
> proposal, I tried all different brands of dog food I could find.
> This includes in addition to SvgTex, also Mathoid, mathjax-node and a 
> couple more which name I have forgotten.
>
> My findings with mathjax-node were:
>
>    1. The project is terribly poorly documented.
>    2. Its API is way too difficult.
>    3. On Debian-based distributions there is a mix-up between nodejs and 
>    nodejs-legacy versions.
>    4. For all of the above reasons, I never got mathjax-node to work 
>    properly. I just waisted an hour or so of my life.
>    
> So no, I beg to differ.
> Irrespectively of above arguments, I see no gains in using mathjax-node 
> over SvgTex (which, by the way, uses PhantomJS in stead of nodejs). Anyhow, 
> this shows the importance of properly documenting projects (or enhancement 
> requests for that matter).
>
> Serge
>
> On Sunday, 8 February 2015 18:39:49 UTC+1, Ghlen Livid wrote:
>>
>> I actually think that writing a nodejs filter (using 
>> https://github.com/mathjax/mathjax-node for example) would be a much 
>> cleaner option. It beats having to run a server in background and a 
>> requiring working Internet connection by a long shot.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8fd007a1-e9be-4823-b8fd-a5984f8bd229%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 3198 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]         ` <a1da5444-4fe7-401a-96bc-79adfff6a2b6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-02-08 23:30           ` Ghlen Livid
@ 2015-02-08 23:46           ` Ghlen Livid
       [not found]             ` <448e6862-7143-4a01-80e0-2c3f7e4804df-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 12+ messages in thread
From: Ghlen Livid @ 2015-02-08 23:46 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

And as for gains, using mathjax-node directly removes two drawbacks of 
using SvgTex, namely

   - There is no need to run SvgTex in background
   - There is no need to be connected to MathJax.org

Plus, package is pretty much self-contained. If you want it, you can 
install it via npm and run pandoc with relevant --filter option, e.g.

npm 
install https://github.com/lierdakil/mathjax-pandoc-filter/tarball/master
pandoc --filter ~/node_modules/.bin/mathjax-pandoc-filter < text.md > 
text.html

Note, that this is a proof-of-concept, so it has virtually no 
error-handling and isn't generally production-quality.

воскресенье, 8 февраля 2015 г., 22:25:10 UTC+3 пользователь Serge 
Stroobandt написал:
>
> @Ghlen
> I should have mentioned that in the weeks prior to submitting this 
> proposal, I tried all different brands of dog food I could find.
> This includes in addition to SvgTex, also Mathoid, mathjax-node and a 
> couple more which name I have forgotten.
>
> My findings with mathjax-node were:
>
>    1. The project is terribly poorly documented.
>    2. Its API is way too difficult.
>    3. On Debian-based distributions there is a mix-up between nodejs and 
>    nodejs-legacy versions.
>    4. For all of the above reasons, I never got mathjax-node to work 
>    properly. I just waisted an hour or so of my life.
>    
> So no, I beg to differ.
> Irrespectively of above arguments, I see no gains in using mathjax-node 
> over SvgTex (which, by the way, uses PhantomJS in stead of nodejs). Anyhow, 
> this shows the importance of properly documenting projects (or enhancement 
> requests for that matter).
>
> Serge
>
> On Sunday, 8 February 2015 18:39:49 UTC+1, Ghlen Livid wrote:
>>
>> I actually think that writing a nodejs filter (using 
>> https://github.com/mathjax/mathjax-node for example) would be a much 
>> cleaner option. It beats having to run a server in background and a 
>> requiring working Internet connection by a long shot.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/448e6862-7143-4a01-80e0-2c3f7e4804df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 3892 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]             ` <448e6862-7143-4a01-80e0-2c3f7e4804df-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-15  8:11               ` Serge Stroobandt
       [not found]                 ` <edfac9a6-c015-4cc5-8d28-55fcc077fe8a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Serge Stroobandt @ 2015-02-15  8:11 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

Please note the comment in 
https://github.com/agrbin/svgtex/blob/master/index.html#L23 line. Eg. you 
can download local copy of MathJax and have SvgTex server talking with that 
local copy instead of CDN. That way server doesn't require internet 
connection and performance is maximized.

On Monday, 9 February 2015 00:46:00 UTC+1, Ghlen Livid wrote:
>
> And as for gains, using mathjax-node directly removes two drawbacks of 
> using SvgTex, namely
>
>
>    - There is no need to be connected to MathJax.org
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/edfac9a6-c015-4cc5-8d28-55fcc077fe8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1827 bytes --]

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

* Re: Proposal: Extend math rendering in HTML with --svgtex[=URL]
       [not found]                 ` <edfac9a6-c015-4cc5-8d28-55fcc077fe8a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-02-15  9:36                   ` Serge Stroobandt
  0 siblings, 0 replies; 12+ messages in thread
From: Serge Stroobandt @ 2015-02-15  9:36 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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

This topic continues with a solution at:
https://groups.google.com/forum/#!msg/pandoc-discuss/MJggAXUmOII/PjkR8ILr_58J

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/71f281ca-99a8-4dcf-8176-906ae30ed0fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1110 bytes --]

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

end of thread, other threads:[~2015-02-15  9:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-07 23:29 Proposal: Extend math rendering in HTML with --svgtex[=URL] Serge Stroobandt
     [not found] ` <bdf4eaf4-2f55-4c77-b64f-dfca5f4097fc-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-08  4:16   ` John MacFarlane
     [not found]     ` <20150208041648.GC12050-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
2015-02-08 12:10       ` Serge Stroobandt
     [not found]         ` <214388e6-544c-4721-a96e-eadf519a83ca-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-08 15:13           ` Daniel Staal
2015-02-08 16:34             ` John MacFarlane
2015-02-08 10:47   ` Anton Grbin
2015-02-08 17:39   ` Ghlen Livid
     [not found]     ` <0f834812-ad8c-4289-871f-8d24af8dfc82-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-08 19:25       ` Serge Stroobandt
     [not found]         ` <a1da5444-4fe7-401a-96bc-79adfff6a2b6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-08 23:30           ` Ghlen Livid
2015-02-08 23:46           ` Ghlen Livid
     [not found]             ` <448e6862-7143-4a01-80e0-2c3f7e4804df-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-15  8:11               ` Serge Stroobandt
     [not found]                 ` <edfac9a6-c015-4cc5-8d28-55fcc077fe8a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-02-15  9:36                   ` Serge Stroobandt

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 NNTP newsgroup(s).