Skip to content

Equation ID #872

Description

@rgieseke

When going e.g. from JATS with MathML to JSON i noted that an id like

<inline-formula id="eq1"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" alttext="1\times 1" display="inline"><mml:mrow><mml:mn>1</mml:mn><mml:mo>&#xD7;</mml:mo><mml:mn>1</mml:mn></mml:mrow></mml:math></inline-formula> 

doesn't get an id in the resulting output.

I've changed the following

diff --git a/src/codecs/jats/index.ts b/src/codecs/jats/index.ts
index ef6a6e8c..40503729 100644
--- a/src/codecs/jats/index.ts
+++ b/src/codecs/jats/index.ts
@@ -2125,11 +2125,13 @@ function decodeMath(
     const image = decodeGraphic(graphic, inline)
     return inline ? image : [stencila.paragraph({ content: image })]
   }
-
+  const equationId = attr(formula, 'id') ?? ''
+  
   // Wrapper is needed to dump the entire math element
   const text = xml.dump(elem('wrapper', mathml))
   return [
     (inline ? stencila.mathFragment : stencila.mathBlock)({
+      id: equationId,
       mathLanguage: 'mathml',
       text,
     }),

Should i make a PR for this?

Another question, could the alttext attribute with the original TeX or screen reader information be a separate attribute?
If yes, would that have to be added in the Math schema (https://schema.stenci.la/math) or meta field?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions