Skip to content

Add the missing inline elements to NisoSts::Term (fixes metanorma-pdfa#122) - #63

Merged
ronaldtse merged 1 commit into
mainfrom
fix/term-inline-elements
Nov 16, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
fix/term-inline-elements

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

metanorma/metanorma-pdfa#122 reports a NoMethodError crash (undefined method 'monospace' for an instance of Sts::NisoSts::Term) when metanorma-iso runs with the sts,isosts output options.

Crash chain: metanorma-iso's InlineTransformer#apply_inline_content walks a source's mixed content and public_sends each inline element name onto the target model. For a def-list, the <dt> content is applied onto Sts::NisoSts::Term; when the dt carries a <tt>, the transformer dispatches monospace — but Term never declared it. The same crash class was latent for the rest of the dispatched inline set (sub, sup, sc, break, styled-content), and on the parse side unmapped inline elements inside <term> were silently dropped.

Changes

Declared the dispatched inline set on every mixed-content model that receives inline content, mirroring the existing attribute/map style:

  • Sts::NisoSts::Term — added sub, sup, sc, monospace, underline, styled-content, break (the reported crash)
  • Sts::NisoSts::Title — added ext-link
  • Sts::NisoSts::Preformat — added xref, sub, sup, sc, monospace, ext-link, inline-formula, break
  • Sts::NisoSts::Sup — added sub, sup, sc, std, ext-link, inline-formula, break (nested <sup> content)
  • Sts::TbxIsoTml::Bold, Sts::TbxIsoTml::Italic — added std, inline-formula, break
  • Sts::TbxIsoTml::Definition — added sc, break
  • Sts::TbxIsoTml::Note — added monospace, sc, ext-link, styled-content, break
  • Sts::TbxIsoTml::Example — added sub, sup, monospace, sc, ext-link, styled-content, break

Sts::NisoSts::Paragraph and Sts::NisoSts::StyledContent already covered the full dispatched set; the table th/td models already declare every dispatched accessor.

Companion fix needed in metanorma-iso

With this change, the element-dispatch half of the chain is fixed, but one gap remains on the metanorma-iso side: InlineTransformer::TEXT_ATTR_FOR has no entry for ::Sts::NisoSts::Term, so a def-list term carrying plain text still falls through to the :content fallback and raises undefined method 'content' for an instance of Sts::NisoSts::Term (Term maps its content to :text, like Paragraph). The fix is the one-line TEXT_ATTR_FOR entry ::Sts::NisoSts::Term => :text in metanorma-iso.

Also noted while auditing: metanorma-iso's table/figure transformers apply inline content directly onto Sts::NisoSts::Caption, but NISO STS <caption> takes no bare inline runs — those call sites should target the caption's <title> instead.

Spec

spec/sts_missing_inline_elements_spec.rb (13 examples): round-trips a <term> containing monospace (the reported crash shape), sub/sup/sc/break, nested inline content inside <sup>, underline/styled-content, plus per-model round-trips for every model touched, and an accessor-coverage test pinning the dispatched inline set on all eleven models that receive inline content.

Verified end-to-end against metanorma-iso 3.5.21's real InlineTransformer and a real metanorma-document TtElement source: <dt><tt>rms</tt></dt> now produces <term><monospace>rms</monospace></term> instead of the NoMethodError.

Fixes the sts-side half of metanorma/metanorma-pdfa#122.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant