jianzhongli / MathView

A library for displaying math formula in Android apps.
Apache License 2.0
1.01k stars 188 forks source link

Cannot Load Mathml Code. #5

Closed iAviatorJose closed 8 years ago

iAviatorJose commented 8 years ago

I wasnt able to load a Mathml. I tried the following code.

<io.github.kexanie.library.MathView
        android:id="@+id/formula_one"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        auto:text="@string/math"
        auto:engine="MathJax"
        >

math --> is a string that has mathml Code given below.

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" mathcolor="white">
  <mrow>
    <mi>f</mi>
    <mrow>
      <mo>(</mo>
      <mi>a</mi>
      <mo>)</mo>
    </mrow>
  </mrow>
  <mo>=</mo>
  <mrow>
    <mfrac>
      <mn>1</mn>
      <mrow>
        <mn>2</mn>
        <mi>&#x3C0;</mi>
        <mi>i</mi>
      </mrow>
    </mfrac>
    <msub>
      <mo>&#x222E;</mo>
      <mrow>
        <mi>&#x3B3;</mi>
      </mrow>
    </msub>
    <mfrac>
      <mrow>
        <mi>f</mi>
        <mo>(</mo>
        <mi>z</mi>
        <mo>)</mo>
      </mrow>
      <mrow>
        <mi>z</mi>
        <mo>&#x2212;</mo>
        <mi>a</mi>
      </mrow>
    </mfrac>
    <mi>d</mi>
    <mi>z</mi>
  </mrow>
</math>```
jianzhongli commented 8 years ago

Support for MathML was added just now. Please upgrade to 0.0.4 to see if it works!

Also please noted that you should explicitly escape special charaters like quotes when your formula is from Java String or XML resources.