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. |
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. |
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, Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
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). For details, see http://asciidoctor.org/docs/user-manual/#activating-stem-support -Dan On Mon, Oct 26, 2015 at 2:03 AM, Dan Allen <[hidden email]> wrote:
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
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. |
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, Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen |
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. |
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 |
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. |
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. -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
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. |
Administrator
|
Best Regards, -Dan -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Free forum by Nabble | Edit this page |