jirutka / asciidoctor-katex

Asciidoctor extension for converting latexmath using KaTeX at build time
MIT License
17 stars 5 forks source link

Automatically include the katex style or document how to do it #4

Open cirosantilli opened 5 years ago

cirosantilli commented 5 years ago

This is how it can be done automatically from the script: https://github.com/cirosantilli/cirosantilli.github.io/blob/28c4ae178359a0fc760fd8608499d321be705467/katex.rb#L88

Hi there,

a.adoc

= bla
:stem:

[latexmath]
++++
\sqrt{1+1} = 2
++++

then:

asciidoctor -r asciidoctor-katex bench.adoc

with asciidoctor-katex (0.3.0) generates the katex markup, but the formula does not show correctly because the stylesheet was not added.

If I manually add:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">

to the HTML then it works, but it would be better if that was done automatically by the plugin.

Or at least document how to include it in the README of the project.

cirosantilli commented 5 years ago

OK, after 20 total minutes of manual grepping I found the docinfo mechanism:

docinfo.html

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">

and add to adoc document attributes:

:docinfo: shared

as in:

= bla
:stem:
:docinfo: shared

[latexmath]
++++
\sqrt{1+1} = 2
++++
danyill commented 5 years ago

@cirosantilli I had a look at this. If I modify your example above to set stem to latexmath then the KaTeX stylesheet is correctly included

= bla
:stem: latexmath
:docinfo: shared

[latexmath]
++++
\sqrt{1+1} = 2
++++

The readme does indicate that AsciiMath is not supported only LaTeX style math.

cirosantilli commented 5 years ago

This is how it can be done automatically from the script: https://github.com/cirosantilli/cirosantilli.github.io/blob/28c4ae178359a0fc760fd8608499d321be705467/katex.rb#L88