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

Differences between inline and stem blocks when using AsciiMath #2498

Closed
hgiesel opened this issue Nov 26, 2017 · 2 comments
Closed

Differences between inline and stem blocks when using AsciiMath #2498

hgiesel opened this issue Nov 26, 2017 · 2 comments
Assignees
Labels
bug v2.0.1 Issues resolved in the 2.0.1 release
Milestone

Comments

@hgiesel
Copy link

hgiesel commented Nov 26, 2017

Having the AsciiDoc:

stem:[AA x. xRx]

[stem,asciimath]
++++
AA x. xRx
++++

[stem,latexmath]
++++
\forall x. xRx
++++

... produces:

image

I don't this should be the behavior, the expected behavior would be to have the latter two formulas look the same. The produced HTML looks like this:

<div class="paragraph">
    <p>\$AA x. xRx\$</p>
</div>
<div class="stemblock">
<div class="content">
    \$AA x. xRx\$
</div>
</div>
<div class="stemblock">
<div class="content">
    \[\forall x. xRx\]
</div>
</div>

I think the simplest to match those two renderings to have two new classes stemblock-latexmath and stemblock-asciimath, where stemblock-asciimath adds text-align: center; padding: 20px 0px;, which makes both versions look pretty much the same.

@mojavelinux
Copy link
Member

This request also came up here: asciidoctor/asciidoctor-browser-extension#272

Fortunately, we can solve this without any change to the generated HTML. MathJax provides a way to apply a filter during typesetting that gives us the opportunity to change the display setting (i.e., display math).

MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
    if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains('stemblock')) {
      data.math.root.display = "block";
    }
    return data;
  });
});

If we drop this into our MathJax config, it will just work.

@mojavelinux mojavelinux self-assigned this Mar 23, 2019
@mojavelinux mojavelinux added this to the v2.0.x milestone Mar 23, 2019
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Mar 23, 2019
@mojavelinux
Copy link
Member

It's debatable whether this is a bug or a feature request. If we consider that fact that the block form of AsciiMath is not rendering like the block for of LaTeX math, then we could say it's a rendering bug.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Mar 24, 2019
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Mar 24, 2019
@mojavelinux mojavelinux modified the milestones: v2.0.x, v2.0.1 Mar 24, 2019
@mojavelinux mojavelinux added the v2.0.1 Issues resolved in the 2.0.1 release label Mar 25, 2019
@mojavelinux mojavelinux modified the milestones: v2.0.1, v2.0.x Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v2.0.1 Issues resolved in the 2.0.1 release
Projects
None yet
Development

No branches or pull requests

2 participants