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

Stem notation support? #163

Closed
ctargett opened this issue Aug 9, 2017 · 7 comments
Closed

Stem notation support? #163

ctargett opened this issue Aug 9, 2017 · 7 comments
Assignees
Milestone

Comments

@ctargett
Copy link
Contributor

ctargett commented Aug 9, 2017

We're using Jekyll to render our AsciiDoc files, with the jekyll-asciidoc plugin. One of our contributors needs to add content that includes stem notations, and noted that it wasn't rendered properly in his tests.

I added :page-stem: to my front-matter, but it does nothing. I also tried simply :stem: with the same result. Is Asciidoctor's stem notation support also supported with jekyll-asciidoc? Should we use something else instead as a plugin or extension to Jekyll? Or, is there something I should add to my templates to allow the support?

@mojavelinux
Copy link
Member

The correct attribute would be stem, since this is a behavior of the core parser.

But the stem support is an integration feature, which means it relies on MathJax to actually handle the equations. All the stem attribute does is process stem blocks and macros and wrap them in markup for MathJax. That means you need to add MathJax to your page template.

You can use the following as a reference:

https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L228-L249

@mojavelinux mojavelinux added this to the support milestone Aug 9, 2017
@mojavelinux mojavelinux self-assigned this Aug 9, 2017
@mojavelinux
Copy link
Member

mojavelinux commented Aug 9, 2017

To tell that the stem feature is working, you should be able to observe that stem:[x^2] is replaced with \$x^2\$. The rest is up to MathJax.

@ctargett
Copy link
Contributor Author

ctargett commented Aug 9, 2017

Ah, OK - I see content converted from asciimath:[sqrt(4) = 2]. to \$sqrt(4) = 2\$. so I can assume the stem markup part is working. I'll see what I can figure out for adding MathJax to my templates. Thanks.

@mojavelinux
Copy link
Member

This could be something nice to add to the quickstart.

@ctargett
Copy link
Contributor Author

ctargett commented Aug 9, 2017

I figured out how to add it in a relatively simple way. You may have suggestions for this that are better - I just taught myself some JS last week, so nowhere close to being an expert in it.

I added a new _include file "mathjax_support.html" that I cobbled together from Googling and from asciidoctor/asciidoctor.js#60. Then I added that to my "head.html" _include, and updated _config.yml to add the stem: attribute. Seems to look pretty good!

Here's the contents of "mathjax_support.html" in case you have feedback:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  messageStyle: "none",
  tex2jax: {
    inlineMath: [["\\(","\\)"]],
    displayMath: [["\\[","\\]"]],
    ignoreClass: "nostem|nolatexmath"
  },
  asciimath2jax: {
    delimiters: [["\\$","\\$"]],
    ignoreClass: "nostem|noasciimath"
  },
  TeX: {
      equationNumbers: {
        autoNumber: "AMS"
      }
    }
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>

@mojavelinux
Copy link
Member

Nice work!

I'll transfer this information to the README for others who are looking to set it up. Thank you for sharing!

@mojavelinux
Copy link
Member

I've transferred this information to the README.

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

2 participants