Maven plugin and Math

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Maven plugin and Math

Niklas
Hi all,
I'm using the Asciidoctor Maven plugin quite a while and now I need to insert a lot of math.
I tried asciimath and latexmath but both don't work for me.
I'm using windows and don't have a clue what I've to do for getting my math rendered into the html files.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

abelsromero
Welcome,

I see that asciimath (https://rubygems.org/gems/asciimath/) is written in ruby, so to use it from the maven plugin you need to add some extra code into the maven configuration.
It's the same for any extra Ruby extension you want to use*, it's not hard, just cumbersome.

You can take this example as template https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/.
Once you have the name of the gem and the version you want to use (https://rubygems.org/gems/asciimath/), just add them as a ruby dependency:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L33,L34
And then, tell asciidoctor that you want to load it changing the name here:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L91

This should work, if it doesn't please, let us know.

* There are some extentions which are embedded with asciidoctorj adn don't require this configuration...but let's skip that for now to keep things simple ^^

PS: I guess latexmath is not asciidoctro right? I cannot find it.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

mojavelinux
Administrator
Actually, before we go down that road, this may just be a simple matter of loading MathJax. I think the question to be asked is what format are you producing? If you are producing standalone HTML files that are generated by Asciidoctor, then you simply need to enable the stem attribute in your document.

= Document Title
Author Name
:stem:

You can also enable the stem attribute in the Maven configuration, though I recommend having it in the document if the document contains stem (i.e., math) because it's semantic.

The asciimath gem is for converting AsciiMath blocks to MathML for DocBook output. It should not be needed if you are creating HTML directly.

Cheers,

-Dan

On Sun, Oct 25, 2015 at 4:03 PM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Welcome,

I see that asciimath (https://rubygems.org/gems/asciimath/) is written in ruby, so to use it from the maven plugin you need to add some extra code into the maven configuration.
It's the same for any extra Ruby extension you want to use*, it's not hard, just cumbersome.

You can take this example as template https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/.
Once you have the name of the gem and the version you want to use (https://rubygems.org/gems/asciimath/), just add them as a ruby dependency:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L33,L34
And then, tell asciidoctor that you want to load it changing the name here:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L91

This should work, if it doesn't please, let us know.

* There are some extentions which are embedded with asciidoctorj adn don't require this configuration...but let's skip that for now to keep things simple ^^

PS: I guess latexmath is not asciidoctro right? I cannot find it.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Maven-plugin-and-Math-tp3895p3896.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

mojavelinux
Administrator
In reply to this post by abelsromero
...and to clarify, all math in HTML is handled by MathJax (though Asciidoctor does do some things to prepare it).


-Dan

On Mon, Oct 26, 2015 at 2:03 AM, Dan Allen <[hidden email]> wrote:
Actually, before we go down that road, this may just be a simple matter of loading MathJax. I think the question to be asked is what format are you producing? If you are producing standalone HTML files that are generated by Asciidoctor, then you simply need to enable the stem attribute in your document.

= Document Title
Author Name
:stem:

You can also enable the stem attribute in the Maven configuration, though I recommend having it in the document if the document contains stem (i.e., math) because it's semantic.

The asciimath gem is for converting AsciiMath blocks to MathML for DocBook output. It should not be needed if you are creating HTML directly.

Cheers,

-Dan

On Sun, Oct 25, 2015 at 4:03 PM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Welcome,

I see that asciimath (https://rubygems.org/gems/asciimath/) is written in ruby, so to use it from the maven plugin you need to add some extra code into the maven configuration.
It's the same for any extra Ruby extension you want to use*, it's not hard, just cumbersome.

You can take this example as template https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/.
Once you have the name of the gem and the version you want to use (https://rubygems.org/gems/asciimath/), just add them as a ruby dependency:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L33,L34
And then, tell asciidoctor that you want to load it changing the name here:
· https://github.com/asciidoctor/asciidoctor-maven-examples/blob/master/asciidoctor-diagram-example/pom.xml#L91

This should work, if it doesn't please, let us know.

* There are some extentions which are embedded with asciidoctorj adn don't require this configuration...but let's skip that for now to keep things simple ^^

PS: I guess latexmath is not asciidoctro right? I cannot find it.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Maven-plugin-and-Math-tp3895p3896.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

Niklas
Thanks guys,
Both just worked fine.
The second one with :stem: is for me the best to get it done.
I'm sorry that I messed up with latex and latexmath.

My output is only html.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

mojavelinux
Administrator
Perfect! Glad to hear it!

-Dan

On Mon, Oct 26, 2015 at 11:36 AM, Niklas [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks guys,
Both just worked fine.
The second one with :stem: is for me the best to get it done.
I'm sorry that I messed up with latex and latexmath.

My output is only html.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Maven-plugin-and-Math-tp3895p3900.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

abelsromero
In reply to this post by Niklas
Apologies for the miss-information, I jumped to quick conclusions.

But after all, me too, happy it worked and was so simple.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

Alvis
In reply to this post by mojavelinux
Hi, im sorry to revive this old thread, but I'm tryinh to generate PDFs, så the stem attribute won't work for me.

I tried to add MathJax as dependency:

<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>mathjax</artifactId>
    <version>3.0.5</version>
</dependency>

I also tried to add a require-section:

<requires>
    <require>mathjax</require>
</requires>

This is where it stops tho. I don't know where to go from here to tell maven to load it. When I run this in maven, I get the following:

 Execution generate-pdf-doc of goal org.asciidoctor:asciidoctor-maven-plugin:2.0.0:process-asciidoc failed: (LoadError) no such file to load -- mathjax

Regards,
Kristian
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

abelsromero
The error is because `require` is used to load Ruby gems, and mathJax is pure javascript. So it's not finding the expected files.
As far as I know mathJax uses a script post-processing to render the images in HTML, so it may not be suited for PDF. Not at least with `asciidoctor-pdf`.

If you explain what are you trying to achieve maybe we can work some alternative. For example, is maven and mathjax a must?
Also someone at the gitter channel could help https://gitter.im/asciidoctor/asciidoctor.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

mojavelinux
Administrator
> As far as I know mathJax uses a script post-processing to render the images in HTML, so it may not be suited for PDF. Not at least with `asciidoctor-pdf`.

That's correct. MathJax does not apply in this context.

-Dan

On Fri, Sep 11, 2020 at 5:00 AM abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
The error is because `require` is used to load Ruby gems, and mathJax is pure javascript. So it's not finding the expected files.
As far as I know mathJax uses a script post-processing to render the images in HTML, so it may not be suited for PDF. Not at least with `asciidoctor-pdf`.

If you explain what are you trying to achieve maybe we can work some alternative. For example, is maven and mathjax a must?
Also someone at the gitter channel could help https://gitter.im/asciidoctor/asciidoctor.


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Maven-plugin-and-Math-tp3895p8237.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

Alvis
In reply to this post by abelsromero
That's good to know. Maven is a must since it's in our project build pipeline. MathJax is just the tool tried to use for solving the [latexmath] paragraphs to render formulas.

We have our user manual newly converted from MS Word to AsciiDoc, and we're building the user manual PDF together with the rest of the application and release it through mvn deploy command.

I'm usig the asciidotor maven plugin versions and dependencies:

        <asciidoctor.maven.plugin.version>2.0.0</asciidoctor.maven.plugin.version>
        <asciidoctorj.pdf.version>1.5.3</asciidoctorj.pdf.version>
        <asciidoctorj.version>2.4.0</asciidoctorj.version>
        <jruby.version>9.2.11.1</jruby.version>

I was hoping to be able to just add the dependency to include support for formulas.
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

mojavelinux
Administrator


I was hoping to be able to just add the dependency to include support for formulas.

The only solutions for PDF currently are to use asciidoctor-mathematical or generate DocBook and use the DocBook toolchain. Since asciidoctor-mathematical uses a native gem (mathematical), it does not work in JRuby (to my knowledge). It's possible to develop an extension for Asciidoctor that uses MathJax at build time, but as of yet no one has come forward to develop such an extension. There are other possible paths as well.

Best Regards,

-Dan

--
Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Maven plugin and Math

Alvis
Ok thank you both for your answers.

There are not too many formulas, so I have resorted to making images that I use instead.

Regards,
Kristian