Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the stem macros (math support) #45

Closed
jxxcarlson opened this issue Sep 9, 2014 · 117 comments
Closed

Support the stem macros (math support) #45

jxxcarlson opened this issue Sep 9, 2014 · 117 comments

Comments

@jxxcarlson
Copy link

No description provided.

@mojavelinux
Copy link
Member

👍

@mojavelinux mojavelinux added this to the v1.5.0 milestone Sep 9, 2014
@mojavelinux mojavelinux self-assigned this Sep 9, 2014
@mojavelinux mojavelinux changed the title Be able to generate good PDF when the asciiidoctor source has math text Support the stem macros (math support) Sep 21, 2014
@tstumm
Copy link

tstumm commented Jun 24, 2015

For LaTeX this could be done by handing the equation/formula to a LaTeX to SVG parser, whose output can easily be embedded. This shouldn't be that much work.

@mojavelinux
Copy link
Member

The best LaTeX to SVG parser that I'm aware of is MathJax. Unfortunately, it only works in a browser. But, we have figured out a way to use it as a utility to generate an SVG by delegating to mathoid. See /~https://github.com/asciidoctor/asciidoctor-extensions-lab/tree/master/lib/mathoid-treeprocessor. I was planning on integrating this utility into Asciidoctor PDF.

If you know of a simpler utility, I'm all for exploring it. Ideally, we want to keep external dependencies and tools to an absolute minimum.

@mojavelinux
Copy link
Member

The first step to solving this issue might just be to document how to use the aforementioned extension. I'm able to use it, but that doesn't mean anyone else can figure it out easily unless we document it :)

@tstumm
Copy link

tstumm commented Jun 25, 2015

How about using Mathematical?
Most of it's dependencies (pango, cairo) should be covered by GTK libs afaik.
It's a native ruby library which would make it easy to implement.

@mojavelinux
Copy link
Member

Interesting. That looks like what GitHub is (or is planning) to use to support Math expressions on GitHub (given who is committing to it). Let's definitely consider it!

@tstumm
Copy link

tstumm commented Jun 25, 2015

I just build a library wrapper for it here. I don't know if it's working, so we should run some tests with it.

@tstumm
Copy link

tstumm commented Jun 25, 2015

I've written a sample file and a test-case and it seems to be working pretty good.

@mojavelinux
Copy link
Member

Cool! Super exciting!

I welcome you to send a pull request for your extension into the extensions lab (/~https://github.com/asciidoctor/asciidoctor-extensions-lab). That helps get it exposure and a stop towards official integration.

@jxxcarlson
Copy link
Author

Fantastic!!

On Jun 25, 2015, at 3:59 AM, tstumm notifications@github.com wrote:

I just build a library wrapper for it here /~https://github.com/tstumm/asciidoctor-lib-mathematical. I don't know if it's working, so we should run some tests with it.


Reply to this email directly or view it on GitHub #45 (comment).

@tstumm
Copy link

tstumm commented Jun 26, 2015

@mojavelinux As you may have seen I've sent a pull request. No response yet, but I'm looking forward for a fast implemetation of this feature in asciidoctor-pdf (no more LaTeX for pdfs yeah!)

@jxxcarlson
Copy link
Author

When we get this working, I will open a bottle!

On Jun 26, 2015, at 8:08 AM, tstumm notifications@github.com wrote:

@mojavelinux /~https://github.com/mojavelinux As you may have seen I've sent a pull request. No response yet, but I'm looking forward for a fast implemetation of this feature in asciidoctor-pdf (no more LaTeX for pdfs yeah!)


Reply to this email directly or view it on GitHub #45 (comment).

@mojavelinux mojavelinux mentioned this issue Jul 2, 2015
@mojavelinux
Copy link
Member

I apologize for the delay. This has been a crazy busy week. I'll be sure to
get to it by the weekend at the latest. If not, you can nudge me :)

Cheers,

-Dan

On Fri, Jun 26, 2015 at 6:08 AM, tstumm notifications@github.com wrote:

@mojavelinux /~https://github.com/mojavelinux As you may have seen I've
sent a pull request. No response yet, but I'm looking forward for a fast
implemetation of this feature in asciidoctor-pdf (no more LaTeX for pdfs
yeah!)


Reply to this email directly or view it on GitHub
#45 (comment)
.

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

@jxxcarlson
Copy link
Author

Yay!!!

Sent from my iPhone

On Jul 2, 2015, at 4:46 AM, Dan Allen notifications@github.com wrote:

I apologize for the delay. This has been a crazy busy week. I'll be sure to
get to it by the weekend at the latest. If not, you can nudge me :)

Cheers,

-Dan

On Fri, Jun 26, 2015 at 6:08 AM, tstumm notifications@github.com wrote:

@mojavelinux /~https://github.com/mojavelinux As you may have seen I've
sent a pull request. No response yet, but I'm looking forward for a fast
implemetation of this feature in asciidoctor-pdf (no more LaTeX for pdfs
yeah!)


Reply to this email directly or view it on GitHub
#45 (comment)
.

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

Reply to this email directly or view it on GitHub.

@jxxcarlson
Copy link
Author

Any chance that Asciidoctor-off will be able to handle Asciidoc-LaTeX files? That would give us another rest selling point in the STEM. Communities.

Sent from my iPhone

On Jul 2, 2015, at 4:46 AM, Dan Allen notifications@github.com wrote:

I apologize for the delay. This has been a crazy busy week. I'll be sure to
get to it by the weekend at the latest. If not, you can nudge me :)

Cheers,

-Dan

On Fri, Jun 26, 2015 at 6:08 AM, tstumm notifications@github.com wrote:

@mojavelinux /~https://github.com/mojavelinux As you may have seen I've
sent a pull request. No response yet, but I'm looking forward for a fast
implemetation of this feature in asciidoctor-pdf (no more LaTeX for pdfs
yeah!)


Reply to this email directly or view it on GitHub
#45 (comment)
.

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

Reply to this email directly or view it on GitHub.

@jxxcarlson
Copy link
Author

Fantastic!!

Sent from my iPhone

On Jun 25, 2015, at 5:14 AM, tstumm notifications@github.com wrote:

I've written a sample file and a test-case and it seems to be working pretty good.


Reply to this email directly or view it on GitHub.

@mojavelinux
Copy link
Member

Any chance that Asciidoctor-pdf will be able to handle Asciidoc-LaTeX files?

In time, I'm sure of it as both mature and LaTeX and PDF have such a close relationship. For now, the focus is just to get Asciidoctor PDF out of alpha so we can start doing interesting things with it :)

@mojavelinux
Copy link
Member

@tstumm This looks really nice. I'm quite impressed by mathematical and the extension that you wrote.

It's important to note that right now, this will only handle stem blocks. We'll need to add another extension to handle inline. That's a bit trickier since it's not yet possible to override a built-in inline macro. We'll need to think about the best way to approach that, or perhaps we need a change to core to allow us to tap into the stem inline macro.

In order to use this extension or the mathoid one in Asciidoctor PDF, we'll need to graduate it from the extensions lab. I think a first step is just to document how someone can use the extension in the extensions lab so we get some feedback and testing. That way, no one is waiting for the graduation to happen. In the meantime, we can start to think about where we want to put it. Perhaps a gem named asciidoctor-mathematical.

@mojavelinux
Copy link
Member

I forgot to mention that I sent revisions to your pull request. Once you look those over and merge or revise, I'll merge in the pull request.

@tstumm
Copy link

tstumm commented Jul 3, 2015

@mojavelinux Thank your for the commendation. I'm a ruby first-timer though.
I think changing the core would be the best solution, since this should be overridable anway.

Maybe we can reuse the readme as documentation. The code itself is rather trivial, so we should mainly document the needed dependencies (fonts etc.).

@mojavelinux
Copy link
Member

Yes, for right now the README is the user manual. In the future, each component (e.g., asciidoctor-pdf) will have it's own user manual under the docs folder to keep the README can stay lean. However, not yet :)

@tstumm You did a nice job for a Ruby first timer. This is a great start and the rest will come quickly now that the ball is rolling. I think the biggest challenge for most users will be installing mathematical...because a lot of people have no development libraries installed. For me, I only had to install "flex" (whatever that is).

@tstumm
Copy link

tstumm commented Jul 3, 2015

Well, for me I had to install a bunch of libraries (because I hadn't looked up the dependencies, shame on me). On a debian or ubuntu system that should be fulfilled by one apt-get install command.
And on Windows... just kidding.

I think we can now mark this as "in progress"!

@tstumm
Copy link

tstumm commented Sep 22, 2015

@nathany Please open a separate issue at the asciidoctor-mathematical repo.

@tstumm
Copy link

tstumm commented Sep 22, 2015

Discussions related to OS X can be continued here: asciidoctor/asciidoctor-mathematical#3

All other issues can be proclaimed at the issue page.

@tstumm
Copy link

tstumm commented Sep 22, 2015

By the way: asciidoctor-mathematical is now available on RubyGems!

@tstumm
Copy link

tstumm commented Sep 22, 2015

Since the main functionality is now given, I think we can close this issue now @mojavelinux.

@ProgramFan
Copy link

Thanks for all your effort. It's a nice job 👍 @tstumm

@nathany
Copy link

nathany commented Sep 24, 2015

@tstumm For my purposes, I ended up using ⅓ for ⅓ rather than asciidoctor-mathematica, at least for now. Just so you know I haven't tested your latest changes when combined with the -D destination flag.

Thanks for releasing a gem, btw.

@JmyL
Copy link

JmyL commented Jan 22, 2016

imagesoutdir and imagesdir attribute works different in asciidoctor-diagram and asciidoctor-mathematical.

When I set imagesoutdir to outimg and imagesdir to 'img', asciidoctor-diagram generates <img src="img/filename.png" ... > but asciidoctor-mathematical generates <img src="img/outimg/filename.png" ... >.
And 'asciidoctor-diagram' puts it's output image to ./outimg folder, and 'asciidoctor-mathematical' choose ./outimg and ./images folder as it's output destination.
So both extensions are not working well.
I can use asciidoctor-diagram with setting both attribute to same folder name like images, but asciidoctor-mathematical still isn't working because it references ./images/images/....

@mojavelinux Can you suggest a standard with these attributes?

@tstumm
Copy link

tstumm commented Jan 22, 2016

Well, imagesdir describes the main location of image files and imagesoutdir is for generated images. Since the images created by extensions are images used in the output file but maybe need to be saved separately we save it in the imagesoutdir which should be a subdirectory of imagesdir (makes sense).

ltdr; img/outimage should be perfectly right in your case. If you want it to save elsewhere just feed it a relational path (ex. ../teximg) [dunno if this works, I guess it should]

@JmyL
Copy link

JmyL commented Jan 24, 2016

It makes sense. But generated images are saved in outimage folder, not img/outimage.
Andimages folder is also generated when using 'inline math'. It does not depended on the value of attributes.
Math block generates <img src="img/outimage/...> but Inline math generates <img src="img/images/...>.

@amodig
Copy link

amodig commented May 16, 2016

Hello,

I'm on OSX (have installed everything with brew and gem inside rbenv).

$ asciidoctor-pdf -v
Asciidoctor PDF 1.5.0.alpha.11 using Asciidoctor 1.5.4 [http://asciidoctor.org]
Runtime Environment (ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)

When running asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf sample.adoc I get the following error:

/Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mathematical-1.5.12/lib/mathematical/mathematical.bundle (fatal)
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mathematical-1.5.12/lib/mathematical.rb:1:in `<top (required)>'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical/extension.rb:3:in `<top (required)>'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical.rb:1:in `require_relative'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical.rb:1:in `<top (required)>'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/options.rb:219:in `block in parse!'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/options.rb:217:in `each'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.4/lib/asciidoctor/cli/options.rb:217:in `parse!'
    from /Users/amodig/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.11/bin/asciidoctor-pdf:25:in `<top (required)>'
    from /Users/amodig/.rbenv/versions/2.3.0/bin/asciidoctor-pdf:23:in `load'
    from /Users/amodig/.rbenv/versions/2.3.0/bin/asciidoctor-pdf:23:in `<main>'

Installing asciidoctor-mathematical gave errors on creating documentation, but I turned that off. Otherwise successful. I don't know ruby so I don't know where to put my finger on...

@ProgramFan
Copy link

It looks something wrong happes to mathematical. Is it correctly installed?

@amodig
Copy link

amodig commented May 16, 2016

I followed the instructions here. Also checked the mathematical dependencies.

And I said wrong, asciidoctor-mathematical install is good. Just parsing the documentation for mathematical gives MIME errors like this:

Parsing documentation for mathematical-1.5.12
unknown encoding name "'application/x-tex'>" for ext/mathematical/mtex2MML/tests/fixtures/MathJax/LaTeXToMathML-out/above-below/accents-1.html, skipping
...

Otherwise the installation is "good".

I see that the mathematical library doesn't load, so perhaps I need to take this matter there. But if there's any other options (can I render pdf with MathoidTreeprocessor?) or advice, I'm glad to hear.

@igagis
Copy link

igagis commented May 27, 2016

After installing asciidoctor-mathematical gem and trying to run it as

asciidoctor-pdf -r asciidoctor-diagram -r asciidoctor-mathematical mydoc.adoc

I get the following

/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': liblasem.so: cannot open shared object file: No such file or directory - /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/mathematical-1.5.12/mathematical/mathematical.so (LoadError)
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /var/lib/gems/2.1.0/gems/mathematical-1.5.12/lib/mathematical.rb:1:in `<top (required)>'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /var/lib/gems/2.1.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical/extension.rb:3:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical.rb:1:in `require_relative'
    from /var/lib/gems/2.1.0/gems/asciidoctor-mathematical-0.0.5/lib/asciidoctor-mathematical.rb:1:in `<top (required)>'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /var/lib/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:220:in `block in parse!'
    from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:218:in `each'
    from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:218:in `parse!'
    from /var/lib/gems/2.1.0/gems/asciidoctor-pdf-1.5.0.alpha.11/bin/asciidoctor-pdf:25:in `<top (required)>'
    from /usr/local/bin/asciidoctor-pdf:23:in `load'
    from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

@tstumm
Copy link

tstumm commented May 30, 2016

@igagis Seems like you could not install mathematical correctly. You can find further help on /~https://github.com/gjtorikian/mathematical

@igagis
Copy link

igagis commented May 30, 2016

I had to manually copy liblasem.so from /var/lib/gems/2.1.0/gems/mathematical-1.5.12/ext/mathematical/lasem/build to /usr/lib

@mojavelinux
Copy link
Member

Since there are multiple solutions for processing math (aka stem) equations, and those solutions require external dependencies, I think it's safe to say that this processing should be handled by an extension (at least for now).

One solution is asciidoctor-mathematical. The other is the soon to be asciidoctor-mathoid (which now resides in the extensions-lab repository).

We still have some challenges to overcome, but I think we should address those challenges by submitting issues in the respective extension project.

Once we have determined that the extensions are both stable and reliable, we can consider enabling one of the extensions by default.

@mojavelinux
Copy link
Member

I think it's really important that image generation be handled consistently between asciidoctor-diagram, asciidoctor-mathematical, and asciidoctor-mathoid. Since Asciidoctor Diagram is the most mature in this regard, it should be used as the reference.

@mojavelinux
Copy link
Member

I do think it would be a good idea to add information to the README about asciidoctor-mathematical (and perhaps the mathoid extension too). @tstumm or @ProgramFan, would you be willing to submit a PR to the README that introduces asciidoctor-mathematical. I recommend adding a section named "Converting STEM Nodes" before the "Optional Scripts" section.

@mojavelinux
Copy link
Member

I'll close the issue once asciidoctor-mathematical is mentioned in the README. I'll then add an introduction to the mathoid extension (though I'm not recommending it until it gets moved into its own repository and published to RubyGems.org).

@mojavelinux
Copy link
Member

When we mention Asciidoctor Mathematical, we should also mention that it doesn't yet have support for table cells and refer to the issue.

@mojavelinux mojavelinux added this to the v1.5.0.alpha.14 milestone Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants