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

Add alttext at math elements #1635

Closed
rgaiacs opened this issue Sep 19, 2014 · 5 comments
Closed

Add alttext at math elements #1635

rgaiacs opened this issue Sep 19, 2014 · 5 comments

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented Sep 19, 2014

MathML math accepts an alttext attribute that "provides a textual alternative as a fall-back for user agents that do not support embedded MathML or images." This attribute isn't present at the moment:

$ pandoc --version
pandoc 1.13
$ cat math.html 
<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow></math></p>
$ cat math.md 
$a^2 + b^2 = c^2$
$ pandoc -f markdown -t html5 --mathml -o math.html math.md
$ cat math.html                                            
<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow></math></p>

Will be nice have this alttext with the LaTeX source of the equation or use MathML annotation for it.

@fred-wang Do you like to say something?

@fred-wang
Copy link

MathML annotation is best for copy & paste (MathJax, https://addons.mozilla.org/en-US/firefox/addon/mathml-copy/ etc). alttext is only a fallback in situation when the MathML rendering is not possible.

@mpickering
Copy link
Collaborator

I think you are meant to put this sort of information in the semantics element.

This wouldn't be hard to do, I just avoided doing so the first time to make the output less cluttered.

@mpickering
Copy link
Collaborator

From my dev build

> .cabal-sandbox/bin/pandoc -f markdown -t html5 --mathml -o test.html
$a^2 + b^2 = c^2$
> cat test.html 
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">a^2 + b^2 = c^2</annotation></semantics></math></p>

This works with @fred-wang's extension.

@jgm
Copy link
Owner

jgm commented Sep 25, 2014

Sounds like a good idea, but it's not entirely simple. The mathml
writer in texmath can't do it, because its input is a parse tree
(so it doesn't know about the latex source). So it would need to be
inserted in pandoc, or maybe texmath could export a function to inject
this information into a mathml xml element.

+++ mpickering [Sep 25 14 06:46 ]:

I think you are meant to put this sort of information in the semantics element.

This wouldn't be hard to do, I just avoided doing so the first time to make the output less cluttered.


Reply to this email directly or view it on GitHub:
#1635 (comment)

@jgm
Copy link
Owner

jgm commented Sep 25, 2014

Looks good.

+++ mpickering [Sep 25 14 07:28 ]:

From my dev build

> .cabal-sandbox/bin/pandoc -f markdown -t html5 --mathml -o test.html
$a^2 + b^2 = c^2$
> cat test.html
<p><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">a^2 + b^2 = c^2</annotation></semantics></math></p>

This works with @fred-wang's extension.


Reply to this email directly or view it on GitHub:
#1635 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants