Skip to content

Block attribute after math block not consistently handled #533

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

Closed
luc-j-bourhis opened this issue Aug 3, 2018 · 5 comments
Closed

Block attribute after math block not consistently handled #533

luc-j-bourhis opened this issue Aug 3, 2018 · 5 comments
Assignees

Comments

@luc-j-bourhis
Copy link

luc-j-bourhis commented Aug 3, 2018

The following code

require 'kramdown'

text = <<END
This is an example of math

$$\\nabla\\cdot E = \\rho$$
{: .autotag}

and the rest follows.
END

math_eng = 'mathjax'
#math_eng = 'katex'
puts Kramdown::Document.new(text, :math_engine => math_eng).to_html

produces the following output when math_eng == 'mathjax'

<p>This is an example of math</p>

<script type="math/tex; mode=display">\nabla\cdot E = \rho</script>

<p>and the rest follows.</p>

and the following output when math_eng = 'katex'

<p>This is an example of math</p>

<div class="autotag kdmath">$$
\nabla\cdot E = \rho
$$</div>

<p>and the rest follows.</p>

I do realise that a class can't be set for a <script> tag in the Mathjax case but still I find it a problem that the class just disappears like that. Anything would be better than the current situation really!

This is with Kramdown version 1.17.0

@gettalong gettalong self-assigned this Aug 3, 2018
@gettalong
Copy link
Owner

Any suggestions?

@luc-j-bourhis
Copy link
Author

luc-j-bourhis commented Aug 4, 2018

Actually, to my surprise, the HTML Living Standard specify that «The WHATWG DOM standard defines the user agent requirements for the class, id, and slot attributes for any element in any namespace.». HTML5 too, again through global attributes. So <script> could get passed the class and the id set by kramdown attributes. Then both with KaTeX and Mathjax, one could select particular equations at will.

@gettalong
Copy link
Owner

Cool, thanks for the update. So just adding the class and id attributes, if specified, to the <script> tag of the mathjax math engine would be sufficient for you?

@luc-j-bourhis
Copy link
Author

Yes, id and class would suit me. Note that I opened issue #2041 on Mathjax repo, suggesting that class and id on the script tag are passed to the tags created by Mathjax to actually display the equation. That would nicely fit with this present issue. Thanks!

@gettalong
Copy link
Owner

@luc-j-bourhis Took a while but with the next release the MathJax engine adds <div> and <span> tags around the math (which incidentally also changed to use the standard syntax instead of <script> tags).

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