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

fix: Add equation id and alttext for MathML in JATS #875

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/codecs/jats/__file_snapshots__/elife-43154-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,7 @@ content:
width="thinmathspace"/><mml:mn>0.24</mml:mn><mml:mo>,</mml:mo></mml:mrow></mml:mstyle></mml:math>
- ' then by the law of total probability:'
- type: MathBlock
id: equ1
mathLanguage: mathml
text: >-
<mml:math id="m1"><mml:mstyle displaystyle="true"
Expand Down
4 changes: 4 additions & 0 deletions src/codecs/jats/__file_snapshots__/elife-52882-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5883,6 +5883,7 @@ content:
id="inf187"><mml:msub><mml:mi>p</mml:mi><mml:mrow><mml:mi>t</mml:mi><mml:mo>⁢</mml:mo><mml:mi>u</mml:mi><mml:mo>⁢</mml:mo><mml:mi>r</mml:mi><mml:mo>⁢</mml:mo><mml:mi>n</mml:mi></mml:mrow></mml:msub></mml:math>
- ' in the form:'
- type: MathBlock
id: equ1
mathLanguage: mathml
text: >-
<mml:math
Expand All @@ -5893,6 +5894,7 @@ content:
content:
- using
- type: MathBlock
id: equ2
mathLanguage: mathml
text: >-
<mml:math
Expand All @@ -5907,6 +5909,7 @@ content:
content:
- and
- type: MathBlock
id: equ3
mathLanguage: mathml
text: >-
<mml:math
Expand All @@ -5915,6 +5918,7 @@ content:
content:
- with
- type: MathBlock
id: equ4
mathLanguage: mathml
text: >-
<mml:math
Expand Down
1 change: 1 addition & 0 deletions src/codecs/jats/__file_snapshots__/plosone-0178565.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,7 @@ content:
where both the proteins are absent. The modified formula of Hamming
distance is:
- type: MathBlock
id: pone.0178565.e001
mathLanguage: mathml
text: >-
<mml:math display="block"
Expand Down
7 changes: 7 additions & 0 deletions src/codecs/jats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2126,10 +2126,17 @@ function decodeMath(
return inline ? image : [stencila.paragraph({ content: image })]
}

const id = attrOrUndefined(formula, 'id')

const altText = attrOrUndefined(mathml, 'alttext')
const meta = altText !== undefined ? { altText } : undefined

// Wrapper is needed to dump the entire math element
const text = xml.dump(elem('wrapper', mathml))
return [
(inline ? stencila.mathFragment : stencila.mathBlock)({
id,
meta,
mathLanguage: 'mathml',
text,
}),
Expand Down
6 changes: 6 additions & 0 deletions src/codecs/plos/__file_snapshots__/pcbi-1007273.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,7 @@ content:
- |2
as:
- type: MathBlock
id: pcbi.1007273.e001
mathLanguage: mathml
text: >-
<mml:math display="block" id="M1"><mml:mtable
Expand Down Expand Up @@ -2615,6 +2616,7 @@ content:
to the proximity of two contigs on the chromosome, we use the graph
topology to establish this relationship. Let
- type: MathFragment
id: pcbi.1007273.e002
mathLanguage: mathml
text: >-
<mml:math display="inline" id="M2"><mml:mover
Expand Down Expand Up @@ -2673,20 +2675,23 @@ content:
- v
- '), '
- type: MathFragment
id: pcbi.1007273.e003
mathLanguage: mathml
text: >-
<mml:math display="inline"
id="M3"><mml:mrow><mml:mi>σ</mml:mi><mml:mo>(</mml:mo><mml:mi>u</mml:mi><mml:mo>,</mml:mo><mml:mover
accent="true"><mml:mi>v</mml:mi><mml:mo>¯</mml:mo></mml:mover><mml:mo>)</mml:mo></mml:mrow></mml:math>
- ', '
- type: MathFragment
id: pcbi.1007273.e004
mathLanguage: mathml
text: >-
<mml:math display="inline"
id="M4"><mml:mrow><mml:mi>σ</mml:mi><mml:mo>(</mml:mo><mml:mover
accent="true"><mml:mi>u</mml:mi><mml:mo>¯</mml:mo></mml:mover><mml:mo>,</mml:mo><mml:mi>v</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math>
- ' and '
- type: MathFragment
id: pcbi.1007273.e005
mathLanguage: mathml
text: >-
<mml:math display="inline"
Expand All @@ -2696,6 +2701,7 @@ content:
- |
. With this, the score for a pair of contigs is defined as follows:
- type: MathBlock
id: pcbi.1007273.e006
mathLanguage: mathml
text: >-
<mml:math display="block" id="M6"><mml:mtable
Expand Down
5 changes: 5 additions & 0 deletions src/codecs/plos/__file_snapshots__/pmed-1002858.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3296,6 +3296,7 @@ content:
content:
- 'Patient data are denoted '
- type: MathFragment
id: pmed.1002858.e001
mathLanguage: mathml
text: >-
<mml:math display="inline"
Expand Down Expand Up @@ -3442,6 +3443,7 @@ content:
content:
- 'This model fit estimates the set of parameters '
- type: MathFragment
id: pmed.1002858.e002
mathLanguage: mathml
text: >-
<mml:math display="inline" id="M2"><mml:mrow><mml:msub><mml:mover
Expand All @@ -3457,6 +3459,7 @@ content:
content:
- 'In a second stage, the sets of parameters '
- type: MathFragment
id: pmed.1002858.e003
mathLanguage: mathml
text: >-
<mml:math display="inline"
Expand All @@ -3470,6 +3473,7 @@ content:
- '30'
- ']) and obtain a global estimate '
- type: MathFragment
id: pmed.1002858.e004
mathLanguage: mathml
text: >-
<mml:math display="inline" id="M4"><mml:mover accent="true"><mml:mi
Expand All @@ -3479,6 +3483,7 @@ content:
content:
- 'The global estimate '
- type: MathFragment
id: pmed.1002858.e005
mathLanguage: mathml
text: >-
<mml:math display="inline" id="M5"><mml:mover accent="true"><mml:mi
Expand Down
Loading