GithubHelp home page GithubHelp logo

asciidoctor / asciidoctor-mathematical Goto Github PK

View Code? Open in Web Editor NEW
50.0 6.0 46.0 64 KB

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.

License: MIT License

Ruby 100.00%
asciidoctor

asciidoctor-mathematical's Introduction

asciidoctor-mathematical

Alternative stem processor for asciidoctor based on Mathematical.

Features

asciidoctor-mathematical processes latexmath and stem blocks and inline macros and replaces them with generated SVG or PNG images, thus enables stem contents on a much wider range of asciidoctor backends. Currently, it is tested to works well with the html, docbook, pdf and latex backends. For stem blocks and macros, only the latexmath type is supported.

Package Specific Attributes

These attributes can be set to tweak behaviors of this package:

attribute description valid values default value
mathematical-format format of generated images svg, png png
mathematical-ppi ppi of generated images, only valid for png files any positive number 300.0
mathematical-inline if present will inline equations as svg (only useful for HTML output) true/false false

Usage

asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf sample.adoc

Installation

asciidoctor-mathematical is now available on RubyGems. Installation is done by gem install asciidoctor-mathematical. Install dependencies first.

Dependencies

make, gobject, glib, gio, gdk-pixbuf, gdk, cairo, pangocairo, libxml, bison, flex

For the runtime, the following ttf fonts should be installed: cmr10, cmmi10, cmex10 and cmsy10. They are provided by the lyx-fonts package in fedora, and the fonts-lyx (or previously ttf-lyx) package in debian/ubuntu. In Arch Linux you can install the ttf-computer-modern-fonts package from AUR, you also have the lyx package in extra repo though; both are providing required Computer Modern fonts.

OS X

Make sure you brew install glib gdk-pixbuf cairo pango cmake

You can install the font dependencies by using

cd ~/Library/Fonts
curl -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmex10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmmi10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmr10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/cmsy10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/esint10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/eufm10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msam10.ttf \
     -LO http://mirrors.ctan.org/fonts/cm/ps-type1/bakoma/ttf/msbm10.ttf

If you experience any compilation errors (caused by Mathematical) try running: brew link gettext --force (you can unlink the libraries later if you want).

Ubuntu

sudo apt-get -qq -y install bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev fonts-lyx cmake

Fedora 28

sudo dnf --setopt=install_weak_deps=False install -y \
  bison \
  cairo-devel \
  cmake \
  flex \
  gcc-c++ \
  gdk-pixbuf2-devel \
  libffi-devel \
  libxml2-devel \
  make \
  lyx-fonts \
  pango-devel \
  redhat-rpm-config \
  ruby-devel

The mathematical gem cannot currently be installed on Fedora 29.

Trouble Shooting

The mathematical gem, which is a hard dependency of asciidoctor-mathematical, may fail to build because of its over-writing of strdup. Whether it fail depends on the system. In case it fails, use the following command to install mathematical (see gjtorikian/mathematical#64 for the details):

MATHEMATICAL_SKIP_STRDUP=1 gem install mathematical

asciidoctor-mathematical's People

Contributors

bwittman avatar dalemartin avatar garkgarcia avatar hakandilek avatar jfernandz avatar krooze avatar lschmelzeisen avatar lurch avatar mojavelinux avatar programfan avatar timothypratley avatar tstumm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

asciidoctor-mathematical's Issues

Example needed

Could you give an an example of how you apply asciidoctor-mathematical to a document? Thanks!

Image size in epb3

When trying asciidoctor-mathematical with the epub3 backend, it correctly generates the SVG files, but the fonts are very large which means the equations look very odd. This will be even more problematic for in-line expressions, e.g., "You can see that x \times 3 = 9".

\limits construct not supported?

I'm not sure if this is a problem with asciidoctor-mathematical or the underlying mathematical dependency, but the following expression:

\sum\limits_{w=0}^{cell_width}

(which is legal in LaTeX and handled properly by KaTeX) generates a chain of errors like this:

Line: 4 Error: syntax error, unexpected LIMITS at token \limits
Failed to parse mtexLine: 4 Error: syntax error, unexpected LIMITS at token \limits
Failed to parse mtexasciidoctor: WARNING: could not embed image: /home/tree/git/openvx/docs/specification/out/equations_temp/stem-df25b61a6e10bd50194e5bc21cd2cd23.svg; The data supplied is not a valid SVG document.
asciidoctor: WARNING: could not embed image: /home/tree/git/openvx/docs/specification/out/equations_temp/stem-bbcb3c334a1c2c4ab3173728a4c63455.svg; The data supplied is not a valid SVG document.

Removing the \limits also removes the error, but generate different output in inline mode.

Is there documentation of what LaTeX operators are and are not supported in asciidoctor-mathematical?

gsub!': asciidoctor: FAILED to load AsciiDoc document - can't modify frozen String (FrozenError)

I am getting this error while trying to use asciidoctor-mathematical from the docker image https://github.com/asciidoctor/docker-asciidoctor. wondering if anyone can help with this.

bash-4.4# asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf chap01.adoc --trace
Traceback (most recent call last):
	20: from /usr/bin/asciidoctor-pdf:23:in `<main>'
	19: from /usr/bin/asciidoctor-pdf:23:in `load'
	18: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-pdf-1.5.0.alpha.18/bin/asciidoctor-pdf:31:in `<top (required)>'
	17: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `invoke!'
	16: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:111:in `each'
	15: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:128:in `block in invoke!'
	14: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `convert_file'
	13: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `open'
	12: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:183:in `block in convert_file'
	11: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/convert.rb:78:in `convert'
	10: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/load.rb:83:in `load'
	 9: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:555:in `parse'
	 8: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:555:in `each'
	 7: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:556:in `block in parse'
	 6: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.10/lib/asciidoctor/document.rb:556:in `[]'
	 5: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:40:in `process'
	 4: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:40:in `each'
	 3: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:41:in `block in process'
	 2: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:100:in `handle_prose_block'
	 1: from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:135:in `handle_inline_stem'
/usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:135:in `gsub!': asciidoctor: FAILED: /documents/chap01/chap01.adoc: Failed to load AsciiDoc document - can't modify frozen String (FrozenError)

Indeipherable "wrong constant name default (NameError)" on trivial document

I recently updated some components in my Ruby install in order to use asciidoctor-pdf 1.5.0.alpha.14 , and started seeing a mysterious error. Even on a trivial document foo.txt containing only

= Title

the following command demonstrates the problem:

asciidoctor -b pdf --trace -r asciidoctor-pdf -r asciidoctor-mathematical foo.txt

The traceback says:

/home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/ruby-enum-0.7.1/lib/ruby-enum/enum.rb:34:in `const_set': asciidoctor: FAILED: /tmp/foo.txt: Failed to load AsciiDoc document - wrong constant name default (NameError)
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/ruby-enum-0.7.1/lib/ruby-enum/enum.rb:34:in `define'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mathematical-1.6.7/lib/mathematical/configuration.rb:7:in `<class:Delimiters>'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mathematical-1.6.7/lib/mathematical/configuration.rb:4:in `<class:Configuration>'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mathematical-1.6.7/lib/mathematical/configuration.rb:3:in `<top (required)>'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mathematical-1.6.7/lib/mathematical.rb:3:in `<top (required)>'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-mathematical-0.2.2/lib/asciidoctor-mathematical/extension.rb:23:in `process'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `[]'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `block in parse'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `each'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `parse'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1347:in `load'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1465:in `convert'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:95:in `block in invoke!'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `each'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `invoke!'
    from /home/jon/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/asciidoctor-1.5.5/bin/asciidoctor:14:in `<top (required)>'
    from /home/jon/.rbenv/versions/2.3.3/bin/asciidoctor:22:in `load'
    from /home/jon/.rbenv/versions/2.3.3/bin/asciidoctor:22:in `<main>'

The "wrong constant name" error doesn't turn up at all in a web search, aside from somebody's explanation-free CI output, so I have not the slightest idea what to make of this. Removing -r asciidoctor-mathematical from the build makes the error go away, although I'm not at all sure that it's at fault - I've tried downgrading various components including asciidoctor-mathematical and the error remains. This makes me wonder if I somehow messed up my Ruby install in some other fashion, but as I'm unable to interpret the error I thought I'd start here.

imagesoutdir gets accidentaly formated

imagesoutdir somehow gets accidentaly formated in some cases.

E.g. when I introduce _ in the path, and also after some math in the document.

Repro:

Blah latexmath:[a = b] _x_ blah.

processed with:

asciidoctor -b html5 -r asciidoctor-mathematical -a stem=latexmath \
-a mathematical-format=svg -a imagesoutdir=$PWD/_eq imgoutdir.adoc

produces:

<img src="whatever/<em>eq/stem-e62d239822831122dd571c0d362408f7.svg"

Where the <em> that replaced _ breaks things. I think the path should be taken verbatim. Or am I supposed to decorate the attribute somehow so replacements are not done on it? Though pass:[] or +++ seems to break things even more.

Tested with asciidoctor (1.5.7.1) and asciidoctor-mathematical (0.2.2) and other dependencies are current versions of whatever the ruby-gems provides.

Support for asciidoctor-latex

Could this package be made to work with formulas generated with asciidoctor-latex? I was hoping that something like this would work:

asciidoctor -b html -r asciidoctor-mathematical -r asciidoctor-latex -a stem=latexmath file.adoc

But it only converts the stem expressions generated by stem[x^2], not those by asciidoctor-latex syntax ($x^2$). Would be great if interoperability could be achieved.

Error loading liblasem in Ubuntu

I installed the package via gem, as proposed. Now, trying to generate a PDF, I'm getting this error (in Ubuntu 16.04 with Ruby 2.3.1p112)

/usr/lib/ruby/2.3.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.3.0/gems/mathematical-1.6
.9/lib/mathematical/mathematical.so (LoadError)
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical.rb:1:in `<top (required)>'
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
        from /var/lib/gems/2.3.0/gems/asciidoctor-mathematical-0.2.2/lib/asciidoctor-mathematical/extension.rb:23:in `process'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:478:in `[]'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:478:in `block in parse'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:477:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:477:in `parse'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1344:in `load'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1462:in `convert'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:94:in `block in invoke!'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `invoke!'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/bin/asciidoctor-pdf:31:in `<top (required)>'
        from /usr/local/bin/asciidoctor-pdf:23:in `load'
        from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

I installed mathematical after asciidoctor-mathematical, and I think that's the problem. I probably need to rebuild asciidoctor-mathematical again, against the installed mathematical package, but I can't do it. I uninstall and install again asciidoctor-mathematical, but it takes just a couple of seconds. So, I guess is using any type of cache. I also tried with gem cleanup, to clean that cache, and with gem build, using the .gem file in this repo, but no effect. Getting the same error.

By the way, the missing file, liblasem.so, already exists:

/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lasem/build/liblasem.so
/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.dylib
/var/lib/gems/2.3.0/gems/mathematical-1.6.9/ext/mathematical/lib/liblasem.so

Any clues?

Windows Installation - Enhancemenet

Hi,

it would be awesome, if you could provide instructions about how to install asciidoctor-mathematical on Windows. Are there any plans for this?

Thank you!

Cannot install asciidoctor-mathematical (Windows)

I'm having trouble installing asciidoctor-mathematical on my Windows machine.

This is the log from running >gem install asciidoctor-mathematical:

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mathematical-1.6.11/ext/mathematical
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20180130-292-1o024en.rb extconf.rb
checking for cmake... yes
checking for -lxml2... no
checking for -lpangocairo-1.0... no
checking for libxml/tree.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... no
checking for libxml/parser.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... no
checking for libxml/xpath.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... no
checking for libxml/xpathInternals.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... no
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.16299.
-- The C compiler identification is MSVC 19.10.25017.0
-- The CXX compiler identification is MSVC 19.10.25017.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find BISON (missing: BISON_EXECUTABLE)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.10/Modules/FindBISON.cmake:252 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:61 (find_package)

-- Configuring incomplete, errors occurred!
See also "C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mathematical-1.6.11/ext/mathematical/mtex2MML/build/CMakeFiles/CMakeOutput.log".
make: *** Ingen regel för att skapa målet ”libmtex2MML_static”. Stannar.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)
--with-xml2lib
--without-xml2lib
--with-pangocairo-1.0lib
--without-pangocairo-1.0lib
--use-system-mtex2MML
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1225:in stat': No such file or directory @ rb_file_s_stat - C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mathematical-1.6.11/ext/mathematical/mtex2MML/build/libmtex2MML.a (Errno::ENOENT) from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1225:in lstat'
from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1254:in copy' from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:416:in block in copy_entry'
from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1388:in wrap_traverse' from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:413:in copy_entry'
from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:391:in block in cp_r' from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1461:in block in fu_each_src_dest'
from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1475:in fu_each_src_dest0' from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1459:in fu_each_src_dest'
from C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:390:in cp_r' from extconf.rb:79:in

'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/mathematical-1.6.11/mkmf.log

extconf failed, exit code 1

do not apply imagesdir

the line

image_target_dir = document.attr 'imagesoutdir', (document.attr 'imagesdir')

should not use imagesdir because the image was generated to imagesoutdir only.
So, if document has both

:imagesdir: tmp
:imagesoutdir: tmp

the image is saved to tmp, but resulting document refers to tmp/tmp and does not find the image

Implement inline stem macros using a Treeprocessor

The inline stem macros should be handled using a Treeprocessor instead of a Preprocessor. Generally, using Preprocessors should be avoided, especially for any official extension. The reason is that Preprocessors don't respect the AsciiDoc structure and can end up matching syntax that should not be interpreted.

Using a Treeprocessor does require a bit more work. You need to find all simple blocks in the tree (using find_by), then process the lines, then restore the processed lines. In other words, you are performing the inline substitution early.

If you really want to do it right, you also have to look for inline passthroughs and ignore those. But as a first attempted, I would recommend skipping that detail.

We really need to find a way in core to allow extensions to handle this macro.

Wrong display of brackets in PDF output

Hi,

i'm experiencing some issues when creating PDFs using asciidoctor-pdf and asciidoctor-mathematical.

Brackets are not displayed correctly. They are replaced with other symbols.

Source:

[latexmath]
++++
\dfrac{\text{Vermögen}(GK = AV + UV)}{\text{Schulden} (FK)} = \text{Reinvermögen} (EK)
++++

Issue:
asciidoctor-mathematical-issue

System:

  • Arch Linux - 5.0.9
  • asciidoctor-pdf 1.5.0.alpha.17
  • asciidoctor 2.0.8
  • asciidoctor-mathematical (0.3.0, 0.2.2)

Thanks in advance!

Best regards,
Jan

width and height values should be unitless

At least when outputting to HTML, the width and height values should be unitless. HTML forbids units on the value of the width and height attributes of the <img> tag.

I can understand for PDF output wanting to add units. However, even then, the units are assumed to be pixels (just as the input is) and the converter will deal with them appropriately. So I don't we should add units at all.

Some math symbols get incorrectly rendered

Hey, ran into issues with the renderer aswell. It looks that the default font in asciidoctor-pdf does not support a lot of the unicode math symbols.

stem:[0 \in {0, 1, 2, 3}] gets rendered as
stem-2d450f409d1d8078235bc2ca31ea4e6f
Image taken directly from images/stem-*

I do not have the same issue with sqrt as the OP has though.

stem:[\sqrt 4 = 2] gets rendered correctly

Details on how to reproduce:
Dockerfile of my asciidoctor image

FROM asciidoctor/docker-asciidoctor

RUN gem install asciidoctor-mathematical --no-ri --no-rdoc

CMD ["/bin/bash"]

command that I use to build:
docker run --rm -v ${PWD}:/documents/ asciidoctor_withmath asciidoctor-pdf -r asciidoctor-mathematical test.adoc

Related issues:
asciidoctor/docker-asciidoctor#78
#41

Process inline stem macros inside (non-AsciiDoc) table cells

The Treeprocessor needs to be updated to process inline stem macros inside (non-AsciiDoc) table cells. This change will require descending into the table model and processing the content of each cell.

Since table cells must be handled differently from other blocks, this change may require refactoring common logic out of main processing loop so that it can be reused to accommodate the divergent code.

Output mostly broken with asciidoctor-pdf, less broken with asciidoctor to HTML

Rendering sample.adoc to PDF with asciidoctor-pdf does not convert most of the math at all, and the \sqrt symbol is broken. When rendering to HTML with asciidoctor, most of the math in the sample doc renders correctly, except the \sqrt, which is still an S with a line.

I'm running Ruby 2.5.1 via RVM on OpenSUSE Tumbleweed.

test.pdf
Screenshot of HTML:
html

'asciidoctor-mathematical' could not be loaded

Hello. everyone.

I want to write equations in my document.
When I executed this command:

$ asciidoctor-pdf --trace -r asciidoctor-mathematical -o test.pdf research.asciidoc

I got this error:

harumo@harumo-X250 ~/Documents/research $ asciidoctor-pdf --trace -r asciidoctor-mathematical -o test.pdf research.asciidoc 
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- asciidoctor-mathematical (LoadError)
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:219:in `block in parse!'
	from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:217:in `each'
	from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/options.rb:217:in `parse!'
	from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.13/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>'

I know next to nothing about asciidoc. but I know that it is a great tool for writing.
What am I doing wrong?

Thanks in advance.

Strange artifacts in pdf output

I’ve tried for the better portion of the last two days, but I still can’t get a math-heavy .adoc file to render correctly in pdf, using asciidoctor-pdf and asciidoctor-mathematical.

Below is the image of the best I could get it to look. To the left is HTML, to the right is PDF. HTML rendering is spot on. I’ve highlighted some of the worst artifacts in PDF.

As I slowly give up hope, I’m just asking: is this some sort of known issue, or am I just asking too much from this software?

screenshot

.adoc snippets for the highlighted areas, in order:

Or, taking into account that latexmath:[ q = \integer \left( \frac{x}{y} \right)]:
… rounding method applied to latexmath:[\frac{x}{y}​].
…
+
[latexmath]
++++
q = \left\lfloor \frac{x}{y} \right\rfloor
++++
+
…

Specs

  • macOS 10.14.3
  • Asciidoctor 1.5.8
  • Asciidoctor PDF 1.5.0.alpha.16
  • asciidoctor-mathematical 0.2.2

All installed as per their respective instructions.

undefined method `lines=' for #<Asciidoctor::Table::Cell:0x000055a734095200>

Trying to use inline stem macros inside AsciiDoc table cells with asciidoctor-mathematical-0.3.0.

This is the test.adoc:

|===
| latexmath:[test]
|===

This is the trace output:

asciidoctor-pdf  -r asciidoctor-mathematical test.adoc --trace
/usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:105:in `handle_prose_block': asciidoctor: FAILED: /doc/test.adoc: Failed to load AsciiDoc document - undefined method `lines=' for #<Asciidoctor::Table::Cell:0x00005571234e7638> (NoMethodError)
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:41:in `block in process'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:40:in `each'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-mathematical-0.3.0/lib/asciidoctor-mathematical/extension.rb:40:in `process'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/document.rb:557:in `[]'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/document.rb:557:in `block in parse'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/document.rb:556:in `each'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/document.rb:556:in `parse'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor.rb:1304:in `load'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor.rb:1413:in `convert'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor.rb:1521:in `block in convert_file'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor.rb:1521:in `open'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor.rb:1521:in `convert_file'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/cli/invoker.rb:128:in `block in invoke!'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/cli/invoker.rb:111:in `each'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-2.0.6/lib/asciidoctor/cli/invoker.rb:111:in `invoke!'
        from /usr/lib/ruby/gems/2.5.0/gems/asciidoctor-pdf-1.5.0.alpha.16/bin/asciidoctor-pdf:31:in `<top (required)>'
        from /usr/bin/asciidoctor-pdf:23:in `load'
        from /usr/bin/asciidoctor-pdf:23:in `<main>'

These are the versions:

asciidoctor-pdf  --version
Asciidoctor PDF 1.5.0.alpha.16 using Asciidoctor 2.0.6 [https://asciidoctor.org]
Runtime Environment (ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux-musl]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)
asciidoctor  --version
Asciidoctor 2.0.6 [https://asciidoctor.org]
Runtime Environment (ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux-musl]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

Error on execution

Dear @tstumm, I've encountered on an error when I try to use asciidoctor-mathematical, the message is like below.

/usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': liblase
m.so: cannot open shared object file: No such file or directory - /var/lib/gems/
2.2.0/extensions/x86_64-linux/2.2.0/mathematical-1.5.12/mathematical/mathematica
l.so (LoadError)

So I tried to compile lasem but it doesn't working.
How can I fix it?

Output warnings or errors from Mathematical?

Is there a way to output warnings or errors that Mathematical is giving?

Right now, I'm using asciidoctor-pdf and asciidoctor-mathematical to process a large document. It generates 22 SVG or PNG files for the LaTeX in my document but then crashes, producing no PDF output, printing only the word Killed to the console. It's very hard to diagnose the problem.

I've tried using --verbose --warnings --trace, but none of these appears to be used by asciidoctor-mathematical. I assume the problem is that the underlying Mathematical is having a problem, but I can't tell what it is.

Customize font size and font family for STEM expressions

Hi guys,

I have two questions/issues:

  1. How can I configure the font size of a STEM expression?
    In the screenshot, I am rendering the PDF using asciidoctor-pdf. Also, I customized base.font_size= 15 in a custom theme. As we can see, the size of the text is 15 and is much bigger than the size of the STEM expression.

How can I configure the font size of a STEM expression?

  1. Is it possible to configure the font used for rendering STEM expressions?
    The font used in the STEM expression is different from the font for text. How can I configure the font family for STEM expressions?

Thanks a lot!

Screenshot below:

screen shot 2019-01-03 at 14 25 41

Include a CSV and treat it with “stem” style

Hi! I’d like to display a matrix-like table, thus, containing data that must be typeset in math style. The header contains x^1, x^2 and the content are (possibly negative) numbers. Example here.

I’d also like the CSV file to be as “pure” as possible, i.e.: not containing stem macros, \(, or the like. So that the CSV file can be used as an easily parseable data file as well. Currently I must either enclose the negative numbers in \( \) pairs to activate “math style” or use the unicode minus sign character (−) instead of the hyphen, to make it appear indeed as a minus sign. This goes against easy processing by mathematical libraries, which expect "-1" (hyphen), not "−1" (unicode minus).

Thus, in my asciidoctor file, I’d like to be able to write something like:

[stem, %header, format=csv]
|===
include::1.1.csv[]
|===

where the 1.1.csv file would not contain any stem-activating string, just the raw data.

But no combination I tried works. I suppose that this is because stem requires a passthrough block and a table is not a passthrough bloc.

Can it possibly be made to work?

Process inline stem macros inside section titles

Process inline stem macros inside the text of a section title. This should be pretty much the same logic as processing prose blocks, only the source will need to be retrieved from and assigned to the title instance variable. After assigning the title instance variable, be sure to clear the subbed_title instance variable.

Image paths (sometimes) go wrong with imagesdir variables

Disclaimer: I'm a bit of an asciidoctor novice (only started using it a few days ago), so apologies in advance if I'm doing something stupid... 😉

I've got some existing documentation that I'd like to convert into asciidoc format - everything seemed to be going fine until I started using asciidoctor-mathematical.

I've got my folder-structure setup like this:

.
├── book.adoc
└── chapters
    ├── conclusion
    │   ├── chapter.adoc
    │   └── images
    └── intro
        ├── chapter.adoc
        └── images

so that each chapter has it's own self-contained directory (into which I can place images, CSV files, etc. etc.). Some of the chapters may be re-used in other documentation later, which is why I want to keep them self-contained.

I've (eventually!) managed to narrow down the problem I'm having to a minimal test-case. Using the file-structure above, book.adoc contains:

= Math book
:doctype: book
:math:
:imagesoutdir: generated_images

include::chapters/intro/chapter.adoc[]

include::chapters/conclusion/chapter.adoc[]

chapters/intro/chapter.adoc contains:

:imagesdir: chapters/intro/images

.Equation 1
[latexmath]
++++
a^2 + b^2 = c^2
++++

and chapters/conclusion/chapter.adoc contains:

:imagesdir: chapters/conclusion/images

.Equation 2
[latexmath]
++++
d^3 + e^3 = f^3
++++

If I run asciidoctor-pdf -r asciidoctor-mathematical book.adoc then it all works okay, generated_images/stem-06cc0e32aefea03545983a9c9db6f8bc.png & generated_images/stem-eec5713a36c954c2630d087e912385e3.png get created, and I get both equations nicely displayed in book.pdf.

However if I then delete book.pdf and generated_images and change chapters/intro/chapter.adoc to:

:imagesdir: chapters/intro/images

Introduction

.Equation 1
[latexmath]
++++
a^2 + b^2 = c^2
++++

(i.e. all I've done is add the word Introduction) then when I run asciidoctor-pdf -r asciidoctor-mathematical book.adoc it now says:

asciidoctor: WARNING: image to embed not found or not readable: /home/andrew/asciidoc-test/chapters/intro/images/generated_images/stem-eec5713a36c954c2630d087e912385e3.png
asciidoctor: WARNING: image to embed not found or not readable: /home/andrew/asciidoc-test/chapters/intro/images/generated_images/stem-06cc0e32aefea03545983a9c9db6f8bc.png

and I get

Introduction
[$$a^2 + b^2 = c^2$$] | generated_images/stem-eec5713a36c954c2630d087e912385e3.png
Equation 1
[$$d^3 + e^3 = f^3$$] | generated_images/stem-06cc0e32aefea03545983a9c9db6f8bc.png
Equation 2

displayed in book.pdf 😭

Looking in /home/andrew/asciidoc-test/generated_images the stem-06cc0e32aefea03545983a9c9db6f8bc.png and stem-eec5713a36c954c2630d087e912385e3.png files have been created directly, they just haven't been included into the PDF properly.

Until this is fixed, or unless there's a workaround because I've been doing something wrong, this is a bit of a show-stopper for me.

liblasem.so error: cannot open shared object file

I tried compiling the sample.adoc in the repo with the command asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf sample.adoc --trace, and I get the following error:

/usr/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require': liblasem.so: cannot open shared object file: No such file or directory - /usr/lib/ruby/gems/2.4.0/gems/mathematical-1.6.8/lib/mathematical/mathematical.so (LoadError)
	from /usr/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/lib/ruby/gems/2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /usr/lib/ruby/gems/2.4.0/gems/mathematical-1.6.8/lib/mathematical.rb:1:in `<top (required)>'
	from /usr/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/lib/ruby/gems/2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-mathematical-0.2.2/lib/asciidoctor-mathematical/extension.rb:23:in `process'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `[]'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `block in parse'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `each'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `parse'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1347:in `load'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1465:in `convert'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:95:in `block in invoke!'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `each'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `invoke!'
	from /usr/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.15/bin/asciidoctor-pdf:31:in `<top (required)>'
	from /usr/bin/asciidoctor-pdf:22:in `load'
	from /usr/bin/asciidoctor-pdf:22:in `<main>'

However, I do have liblasem.so, since whereis liblasem.so returns liblasem: /usr/local/lib/liblasem.so

Also, file /usr/lib/ruby/gems/2.4.0/gems/mathematical-1.6.8/lib/mathematical/mathematical.so gives:

/usr/lib/ruby/gems/2.4.0/gems/mathematical-1.6.8/lib/mathematical/mathematical.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e6486c2bae1ffc8f3c5793ae3ef32e1c8c1cc068, not stripped, with debug_info

Asciidoctor-pdf verison:

Asciidoctor PDF 1.5.0.alpha.15 using Asciidoctor 1.5.5 [http://asciidoctor.org]
Runtime Environment (ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)

Asciidoctor version:

Asciidoctor 1.5.5 [http://asciidoctor.org]
Runtime Environment (ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)

Kindly suggest some workarounds

sample.adoc can't be rendered?

asciidoctor -v reports

Asciidoctor 2.0.10 [https://asciidoctor.org]
Runtime Environment (ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux-gnu]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

When I try running asciidoctor -r asciidoctor-mathematical sample.adoc (with the sample.adoc being downloaded from this repo) it says:

asciidoctor: FAILED: /home/andrew/asciidoc-mathematical/sample.adoc: Failed to load AsciiDoc document - undefined method `lines=' for #<Asciidoctor::Table::Cell:0x00000000013f0f60>
  Use --trace for backtrace

I'm assuming that asciidoctor-mathematical used to be able to render sample.adoc, so presumably this is a regression somewhere? I wonder if it'd be worth trying to render sample.adoc during the CI process ( #51 ), just to check that no errors get reported? (even if it means ignoring any output that gets created)

Invitation to join the Asciidoctor organization

On behalf of the Asciidoctor project, I'd like to invite this extension into the Asciidoctor organization on GitHub. Reply to this thread if you are interested and I'll get you set up with the permissions to transfer the repository and I will make you the owner of the repository. GitHub will automatically redirect visitors to the new URL.

I also encourage you to add Asciidoctor Mathematical to the list of official extensions on asciidoctor.org. See http://asciidoctor.org/docs/extensions/#official-extensions.

libintl load error with macOS Sierra (10.12.3)

$ asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf sample.adoc --trace
/Users/amodig/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mathematical-1.6.7/lib/mathematical/mathematical.bundle, 9): Library not loaded: @rpath/libintl.9.dylib (LoadError)
  Referenced from: /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mathematical-1.6.7/ext/mathematical/lasem/build/liblasem.dylib
  Reason: image not found - /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mathematical-1.6.7/lib/mathematical/mathematical.bundle
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mathematical-1.6.7/lib/mathematical.rb:1:in `<top (required)>'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-mathematical-0.2.2/lib/asciidoctor-mathematical/extension.rb:23:in `process'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `[]'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:479:in `block in parse'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `each'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/document.rb:478:in `parse'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1347:in `load'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor.rb:1465:in `convert'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:95:in `block in invoke!'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `each'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.5/lib/asciidoctor/cli/invoker.rb:87:in `invoke!'
	from /Users/amodig/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.14/bin/asciidoctor-pdf:31:in `<top (required)>'
	from /Users/amodig/.rbenv/versions/2.4.0/bin/asciidoctor-pdf:22:in `load'
	from /Users/amodig/.rbenv/versions/2.4.0/bin/asciidoctor-pdf:22:in `<main>'

I noticed that libintl.9.dylib isn't installed on my system (see find below). With Homebrew, libintl comes with gettext, which I linked, but it has only libint.8.dylib.

$ sudo find /usr/ -name *libintl*
/usr/local/Cellar/gettext/0.19.8.1/include/libintl.h
/usr/local/Cellar/gettext/0.19.8.1/lib/libintl.8.dylib
/usr/local/Cellar/gettext/0.19.8.1/lib/libintl.a
/usr/local/Cellar/gettext/0.19.8.1/lib/libintl.dylib
/usr/local/Cellar/gettext/0.19.8.1/share/gettext/intl/libintl.rc
/usr/local/Cellar/texi2html/5.0/share/texi2html/lib/libintl-perl
/usr/local/include/libintl.h
/usr/local/lib/libintl.8.dylib
/usr/local/lib/libintl.a
/usr/local/lib/libintl.dylib
/usr/local/lib/libintl.la
/usr/local/share/doc/libintl

I tested mathematical separately, and it works. I have brew+rbenv installation of ruby 2.4.0 (https://github.com/rbenv/rbenv#homebrew-on-mac-os-x).

Maybe a similar problem here:
http://stackoverflow.com/questions/42080325/rp2-missing-libintl-9-dylib-library

\underbrace

Dear Developers,
I have a problem with underbraces in my formulae, namely, they are too small.

Here is a small example of asciidoctor source:

= Underbrace example
Me <[email protected]>
:stem: latexmath

Test of underbrace:

[stem]
++++
  \Phi = \underbrace{\sum_{i} \gamma_i \left( s_i M^{model}(s_i) - s_i M^{exp}(s_i) \right)}_{\Phi_{GED}} + \alpha \cdot \underbrace{ \sum_{j} \gamma_j \left( p_j^{model} - p_j^{QC} \right)}_{\Phi_{QC}} \rightarrow min
++++

I am using the command
asciidoctor --backend=html5 -a embedded -a nofooter -r asciidoctor-mathematical -a mathematical-format=svg -o test.html test.adoc
and getting a respective output HTML with too small underbraces

In contrast, pure latex works well. An equivalent code

\documentclass{article}
\title{Testing underbrace}
\begin{document}
\maketitle
\begin{equation}
 \label{eq:ged_qc_min}
  \Phi = \underbrace{\sum_{i} \gamma_i \left( s_i M^{model}(s_i) - s_i M^{exp}(s_i) \right)}_{\Phi_{GED}} + \alpha \cdot \underbrace{ \sum_{j} \gamma_j \left( p_j^{model} - p_j^{QC} \right)}_{\Phi_{QC}} \rightarrow min \ ,
\end{equation}
\end{document}

produces correct output PDF

How can I get underbraces with correct size in asciidoctor?

Thank you in advance!

Error in PDF?

I ran the minimal example (sample.adoc) with the following command:
asciidoctor-pdf -r asciidoctor-mathematical -a mathematical-format=svg -o testsvg.pdf sample.adoc

The output file is:
testsvg.pdf

The file opens fine in Apple's Preview, but if I try to open it in Adobe Acrobat on both OS X and Windows, the following error is reported on opening it:

An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.

The file then opens, but it only displayed as far as the first equation after which it is blank. When using the PNG output with
asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf sample.adoc
Acrobat opens and renders the file without problem.

I am running this on OS X 10.11.4. Can anyone else replicate this or is it just my set up?

Fail instalation on Windows

gem install asciidoctor-mathematical
generates a huge number of errors, for some reason dependencies are not installed automatically.
Did anybody install this on Windows

Publish version 0.1 and use semantic versioning

Since a lot of new stuff are added recently, I think it's time to publish a new version to rubygems so that broader users can benifit from it.

I would like to use semantic versioning and mark this version as 0.1.

Process inline stem macros inside AsciiDoc table cells

Process inline stem macros inside of AsciiDoc table cells. This is just a matter of getting the extension to run on the embedded Document object that holds the content for an AsciiDoc table cell.

Currently, Asciidoctor core does not propagate extensions to nested documents (see asciidoctor/asciidoctor#1300), so the top-level Treeprocessor will need to register itself as an extension on the nested Document object.

Failed to parse mtexFailed

I'm getting a Failed to parse mtexFailed and asciidoctor: WARNING: could not embed image: /documents/stem-7fc90f81ed556fcd40a8504532a4dfb9.svg; The data supplied is not a valid SVG document. when trying to render Latex block in PDF or HTML using asciidoctor-mathematical
.
The problem is easy to reproduce:

  1. create a test.adoc:
# Test
:doctype: article
:stem: latexmath
:icons: font

## Probability distribution
Probability distributions describe uncertainty by describing the behaviour of random variables. In mathematical terms, a probability distribution function stem:[Pr(x)] with domain stem:[ \Omega ] is defined as follows:

. stem:[ f(x) \ge 0 \text{ } \forall x \in \Omega  ]. 
. stem:[ \sum_{x \in X} Pr(x) = 1 ]
  1. Convert it to HTML (or PDF) using docker run --rm -v pwd:/documents/ --workdir /documents asciidoctor/docker-asciidoctor:latest asciidoctor --trace -r asciidoctor-mathematical -a mathematical-format=svg test.adoc

I'm using the latest Docker image asciidoctor/docker-asciidoctor:latest to render the document and the versions of the libraries are:

ARG asciidoctor_version=2.0.10
ARG asciidoctor_confluence_version=0.0.2
ARG asciidoctor_pdf_version=1.5.0.beta.5
ARG asciidoctor_diagram_version=1.5.18
ARG asciidoctor_epub3_version=1.5.0.alpha.9
ARG asciidoctor_mathematical_version=0.3.1
ARG asciidoctor_revealjs_version=2.0.0

The text renders without problems using MathJax or plain Latex.

Any help would be appreciated.

Dependencies "ruby.h" required

Installation exited because it couldn't find ruby.h.

ERROR:  Error installing asciidoctor-mathematical:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.5.0/gems/mathematical-1.6.11/ext/mathematical
/usr/bin/ruby2.5 -r ./siteconf20180620-5797-1shuyzq.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

After installing ruby2.5-dev it worked. Maybe you should mention that as dependencie for installation.

I'm running Debian Testing (Buster) with 4.16.12-1 (2018-05-27) kernel.

Specify additional packages

I'm using asciidoctor-mathematical behind asciidoctor-pdf and while I can now get equations to show up in passthrough blocks, I still need to have additional LaTeX packages loaded.

Is there a way to add, say, \usepackage{mathtools} to something like the preamble?

Can't add tag to equations

Hi, I'm having an issue with adding tags to equations :

So I'm adding,
:stem: latexmath

then,

[stem]
++++
\begin{align*}

\dot{x} = \dfrac{dx}{dt} \\

\dot{y} = \dfrac{dy}{dt} \tag{1.a}

\end{align*}
++++

This works in mathjax but does not when I use asciidoctor-mathematical. How can I fix it ?

Thanks

Set up continuous integration and automated releases

In order to prevent regressions and make releases more regular, I advise setting up continuous integration (CI) for this project to run the test suite and automate releases.

The tool we use for this in the Asciidoctor ecosystem is Travis CI. The first thing we'll need is a Travis CI configuration file (.travis.yml). Once that's in place, I can enable the CI build on this project. Travis can also handle releasing the gem to rugygems.org, which I can help you get set up.

There are plenty of references for how to set up CI to run the test suite and automate releases. Here are two good examples:

In order for the build to handle the release, the environment variable RUBYGEMS_API_KEY must be defined on the setting screen for the repository in Travis CI. It's best if we use the API key for the Asciidoctor account so that it can be easily updated if it ever has to be renewed.

asciidoctor-mathematical-0.2.2 will not recognize mathematical-1.6.9

This may well be my own misunderstanding so I'm happy for any help to correct it. What further information can I provide?

with Kali 2017.1 fully updated and required dependencies and gems installed:

cat /etc/debian_version
kali-rolling

Successfully installed prawn-2.1.0
1 gem installed
Successfully installed prawn-templates-0.0.3
1 gem installed
Building native extensions. This could take a while...
Successfully installed mathematical-1.6.9
1 gem installed
Successfully installed asciidoctor-pdf-1.5.0.alpha.16
1 gem installed
Successfully installed asciidoctor-mathematical-0.2.2
1 gem installed

ls -lha /var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical/

total 388K
drwxr-xr-x 2 root root 4.0K Sep 16 14:59 .
drwxr-xr-x 3 root root 4.0K Sep 16 14:58 ..
-rw-r--r-- 1 root root 404 Sep 16 14:58 configuration.rb
-rw-r--r-- 1 root root 482 Sep 16 14:58 corrections.rb
-rwxr-xr-x 1 root root 364K Sep 16 14:59 mathematical.so
-rw-r--r-- 1 root root 1.4K Sep 16 14:58 validator.rb
-rw-r--r-- 1 root root 50 Sep 16 14:58 version.rb

asciidoctor-pdf -v --require asciidoctor-mathematical --doctype book ./test.adoc

liblasem.so: cannot open shared object file: No such file or directory - /var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical/mathematical.so
Use --trace for backtrace

shell returned 1

/var/lib/gems/2.3.0/gems/mathematical-1.6.9/lib/mathematical/mathematical.so exists but asdciidoctor-mathematical does not see it?

Is there a missing environmental variable or some such? I can't see an issue with permissions given that user is Root.

Cross reference equations

I would like to define an equation and then to reference it later in my text. The following example works fine with bare asciidoctor:

= Test eqn cross-ref
:stem: latexmath
:eqnums:

== Let's try

[stem]
++++
\begin{equation}\label{myequation}
c^2 = a^2 + b^2 + 5
\end{equation}
++++

I refer back to \eqref{myequation}.

A number is assigned automatically to the equation and the same number appears in the text below.
Now, I would like to use asciidoctor-mathematical, but the referencing does not work anymore. The equation is generated with the number, this is already something, but the referencing does not work!
In HTML I get just (???) and in PDF I get the unprocessed \eqref{myequation}.

I am using asciidoctor 1.5.4 and asciidoctor-mathematical 0.2.2

Could you help me to solve the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.