selectively process AsciiMath

17 views
Skip to first unread message

David Farmer

unread,
Oct 1, 2021, 6:14:29 PM10/1/21
to mathja...@googlegroups.com

In my application I do not want to process AsciiMath in
most cases. The exception is certain divs containing user
input. On those divs I put the class "has_am".

In MathJax2, this worked as desired:

asciimath2jax: {
ignoreClass: ".*",
processClass: "has_am"
}

In MathJax3 I did this, but it did not seem to do anything:

asciimath: {
ignoreHtmlClass: ".*",
processHtmlClass: "has_am"
}

The specific problem I have is there are backticks outside of
the div.has_am, which are triggering AsciiMath processing.

This paragraph has a bunch of backticks for testing purposes:

https://pretextbook.org/examples/sample-article/html/text-in-paragraphs.html#p-380

Any suggestions are appreciated.

Davide Cervone

unread,
Oct 1, 2021, 7:54:10 PM10/1/21
to mathja...@googlegroups.com
Because AsciiMath hasn't been ported to a native v3 input jax (it is patched in using the legacy v2 jax along with much of the v2 infrastructure), it doesn't use the v3 configuration API. Instead, is still looks for the old v2 configuration in the MathJax variable. So if you include your original asciimath2jax block in the MathJax configuration variable, it should pick that up.

Davide
> --
> You received this message because you are subscribed to the Google Groups "MathJax Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/alpine.LRH.2.21.2110011758520.31378%40li375-150.members.linode.com.

David Farmer

unread,
Oct 1, 2021, 8:00:06 PM10/1/21
to mathja...@googlegroups.com

Perfect! Works as expected.

Should I have thought to try that? I think so. :(

Regards,

David
> To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/2B47EBA6-F1E0-4010-A0FA-63463BA7FBCB%40gmail.com.
>

Davide Cervone

unread,
Oct 1, 2021, 8:02:12 PM10/1/21
to mathja...@googlegroups.com
Glad that worked for you. You did the right thing to try the v3 configuration.

Davide
> To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/alpine.LRH.2.21.2110011957410.31378%40li375-150.members.linode.com.

sanchit

unread,
Oct 2, 2021, 9:12:38 AM10/2/21
to mathja...@googlegroups.com, Davide Cervone, sanchi...@gmail.com

Davide

I am still using the previous version of MathJax I presume it must be v2 configuration. and I was simply unable to found it via browsing internet, I will be really grateful if you provide documentation for the latest MathJax v3 configuration. so that I can try to update myself for the necessary changes in the syntax.

Humble Request.

Thanks

Yours Sincerely,

Sanchit.

Author: Sanchits-Linux-SPS

Created: 2021-10-02 Sat 18:41

Validate

sanchit

unread,
Oct 3, 2021, 2:24:45 PM10/3/21
to Davide Cervone, mathja...@googlegroups.com, sanchi...@gmail.com

Thanks Davide

though not really sure and convinced why even do I need latest configuration version my application works just perfect with the older MathJax configuration files which is screenreader accessible most of the times so

Looking forward to hearing from you and Any suggestions would be absolutely appreciated

Thanking you.

Yours Sincerely,

Sanchit.

AUTHOR: Sanchits-Linux-SPS

On 10/2/2021 8:17 PM, Davide Cervone wrote:
> The MathJax configuration for v3 is documented at
>
> https://docs.mathjax.org/en/latest/options/index.html
>
> (and has been since v3 was released). Note that a Google search for "MathJax v3 configuration" lists this as its second link. If you are looking for the v2 documentation, there is a green link at the lower left of the v3 documentation that allows you to request the documentation for older versions.
>
> See also the
>
> https://docs.mathjax.org/en/latest/upgrading/v2.html
>
> page that points out the differences between v3 and v2, and what is and is not available in v3. There is also a configuration conversion tool at
>
> https://mathjax.github.io/MathJax-demos-web/convert-configuration/convert-configuration.html
>
> (linked to the upgrading page) that will help you convert your v2 configuration to a v3 one.
>
> Davide

>
>
>> On Oct 2, 2021, at 9:12 AM, sanchit <sanchi...@gmail.com> wrote:
>>
>>
>>
>> Davide
>>
>> I am still using the previous version of MathJax I presume it must be v2 configuration. and I was simply unable to found it via browsing internet, I will be really grateful if you provide documentation for the latest MathJax v3 configuration. so that I can try to update myself for the necessary changes in the syntax.
>>
>> Humble Request.
>>
>> Thanks
>>
>> Yours Sincerely,
>>
>> Sanchit.
>> Author: Sanchits-Linux-SPS
>> Created: 2021-10-02 Sat 18:41
>> Validate
>>
>> On 10/2/2021 5:24 AM, Davide Cervone wrote:
>>> Because AsciiMath hasn't been ported to a native v3 input jax (it is patched in using the legacy v2 jax along with much of the v2 infrastructure), it doesn't use the v3 configuration API. Instead, is still looks for the old v2 configuration in the MathJax variable. So if you include your original asciimath2jax block in the MathJax configuration variable, it should pick that up.
>>>
>>> Davide
>>>
>>>
>>>> On Oct 1, 2021, at 6:14 PM, David Farmer <far...@aimath.org> wrote:
>>>>
>>>>
>>>> In my application I do not want to process AsciiMath in
>>>> most cases. The exception is certain divs containing user

>>>> input. On those divs I put the class "hasam".

>>>>
>>>> In MathJax2, this worked as desired:
>>>>
>>>> asciimath2jax: {
>>>> ignoreClass: ".*",

>>>> processClass: "hasam"

>>>> }
>>>>
>>>> In MathJax3 I did this, but it did not seem to do anything:
>>>>
>>>> asciimath: {
>>>> ignoreHtmlClass: ".*",

>>>> processHtmlClass: "hasam"

>>>> }
>>>>
>>>> The specific problem I have is there are backticks outside of

>>>> the div.hasam, which are triggering AsciiMath processing.

>>>>
>>>> This paragraph has a bunch of backticks for testing purposes:
>>>>
>>>> https://pretextbook.org/examples/sample-article/html/text-in-paragraphs.html#p-380
>>>>
>>>> Any suggestions are appreciated.
>>>>

>>>> –

>>>> You received this message because you are subscribed to the Google Groups "MathJax Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.

Author: Sanchits-Linux-SPS

Created: 2021-10-03 Sun 23:54

Validate

David Farmer

unread,
Oct 7, 2021, 8:24:34 AM10/7/21
to mathja...@googlegroups.com

I spoke too soon. What I actually did was break the AsciiMath
processing, which I found as soon as I did a proper test.

I made the test page below, which has separate paragraphs to test every
combination process/not process TeX and AsciiMath.

It may be that I put

asciimath2jax: {
ignoreClass: ".*",
processClass: "has_am"
},

in the wrong place, but I tried several combinations. In every case
I tried, TeX and AsciiMath are treated identically (except when I don't
load 'input/asciimath', in which case the AsciiMath is never processed).


https://aimath.org/~farmer/tmp/asciimathTest0.html


Regards,

David

Davide Cervone

unread,
Oct 8, 2021, 4:58:55 PM10/8/21
to mathja...@googlegroups.com
Sorry, David, I was wrong about how this works. It turns out that patching the legacy AsciiMath input jax into v3 did require hooking it into the current infrastructure for locating the math in the page. So the v3 implementation doesn't use the v2 parameters for that. The locating of AsciiMath expressions is controlled by the same ignoreHtmlClass property as is used by the tex input jax. That is, the identification of what parts of the page are to be processed is a document-level option, not an input-level option in v3. This is because v3 is designed to manage more than one document type (HTML documents are only one type, and it would be possible to use other document types, like Markdown for example, though only HTML documents are current implemented). So the input jax don't know the type of document they are working in, and instead, the document gives them the text to be searched for math delimiters. That means all the decisions about which elements to ignore and which to process are handled at the document level. So you will not be able to control AsciiMath separately from TeX, as you are trying to do.

Davide
> --
> You received this message because you are subscribed to the Google Groups "MathJax Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/alpine.LRH.2.21.2110070815560.12086%40li375-150.members.linode.com.

Reply all
Reply to author
Forward
0 new messages