简体   繁体   English

MathJax配置用于Web,移动和辅助

[英]MathJax config for web, mobile, and assistive

Input: 输入:

<ins class="marked-for-jax">\[
1 + 2 + 3 + \ldots + n = \frac{n(n+1)}2.
\]</ins>

MathJax Config: MathJax配置:

MathJax.Hub.Config({
  jax: ["input/TeX", "output/HTML-CSS"],
  extensions: ["tex2jax.js"],
  messageStyle: "none",
  TeX: {
    extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
  }
});

MathJax output, shortened and formatted for clarity: 为清晰起见,MathJax输出,缩短并格式化:

<p>
  <ins class="marked-for-jax">
    <span class="MathJax_Preview" style="color: inherit;"></span>
    <div class="MathJax_Display" style="text-align: center;">
      <span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="[mathML data here]" role="presentation" style="position: relative;">
        <nobr aria-hidden="true"><span class="math" id="MathJax-Span-12" role="math" style="width: 14.517em; display: inline-block;"><!--lots of nested spans here--></nobr>
        <span class="MJX_Assistive_MathML MJX_Assistive_MathML_Block" role="presentation"><!--lots of mathML here--></span>
      </span>
    </div>
    <script <!--does not impact any output. Why is it even there at all?--> type="math/tex; mode=display" id="MathJax-Element-2">1 + 2 + 3 + \ldots + n = \frac{n(n+1)}2.</script>
  </ins>
</p>

Appearance on UIWebView. UIWebView上的外观。 Notice that we are seeing the output twice. 请注意,我们看到输出两次。 The first one comes from the nested spans; 第一个来自嵌套的跨度; the second one comes from the assistive. 第二个来自辅助。 看到双倍

If I strip out the assistive one with CSS, we do indeed only see the output one time. 如果我用CSS删除辅助的那个,我们确实只看到输出一次。 But then VoiceOver users hear nothing. 但是VoiceOver用户什么都听不见。 Alternatively, I could strip out the nested spans with CSS. 或者,我可以用CSS删除嵌套的跨度。 I am suspicious of that approach because, while it would likely work on iOS, it likely would not work on all browsers. 我怀疑这种方法,因为虽然它可能适用于iOS,但它可能无法在所有浏览器上运行。 Additionally, depending on exactly how I am using the output, I may want to be able to prevent MathJax from outputting portions of what it is currently doing in the first place. 另外,根据我使用输出的确切方式,我可能希望能够阻止MathJax首先输出它当前正在做的部分。 For example, in some cases, I will be using the Html in a way that I can be sure will appear on iOS only. 例如,在某些情况下,我将以一种我确定只会出现在iOS上的方式使用Html。 In such a case, any Html that I am stripping out with css, I would prefer not to have in the first place. 在这种情况下,我用css剥离的任何Html,我宁愿不首先拥有。

How can I get the output to make sense for both sighted and assistive users? 如何让视力和辅助用户的输出有意义?

EDIT: I found a related question here: MathJax is duplicating my equations -- why and how can I fix this? 编辑:我在这里找到了一个相关的问题: MathJax正在重复我的方程式 - 为什么以及如何解决这个问题?

Further edit: I can get rid of the "seeing double" problem with the following CSS, derived from here: http://mathjax.readthedocs.org/en/latest/options/assistive-mml.html . 进一步编辑:我可以通过以下CSS解决“看到双重”问题,从这里得到: http//mathjax.readthedocs.org/en/latest/options/assistive-mml.html But then I have a new problem -- VoiceOver does not speak any math. 但后来我遇到了一个新问题 - VoiceOver不会说任何数学。

span.MJX_Assistive_MathML {
    position:absolute!important;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 1px 0 0 0!important;
    border: 0!important;
    height: 1px!important;
    width: 1px!important;
    overflow: hidden!important;
    display:block!important;
}

PARTIAL ANSWER was to put the following CSS in. Note that this is specific to my iOS/droid offline scenario. PARTIAL ANSWER是将以下CSS放入其中。请注意,这是特定于我的iOS / droid离线方案。 For those of you who have different scenarios, it may not apply. 对于那些有不同场景的人,可能不适用。 Furthermore, some things come out pretty bad. 此外,有些事情非常糟糕。 I'm not exactly happy with it. 我对此并不满意。

[aria-hidden="true"] { display: none; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM