Repository navigation
Add the missing inline elements to NisoSts::Term (fixes metanorma-pdfa#122) - #63
Merged
Merged
Conversation
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
metanorma/metanorma-pdfa#122 reports a
NoMethodErrorcrash (undefined method 'monospace' for an instance of Sts::NisoSts::Term) when metanorma-iso runs with thests,isostsoutput options.Crash chain: metanorma-iso's
InlineTransformer#apply_inline_contentwalks a source's mixed content andpublic_sends each inline element name onto the target model. For a def-list, the<dt>content is applied ontoSts::NisoSts::Term; when the dt carries a<tt>, the transformer dispatchesmonospace— butTermnever 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— addedsub,sup,sc,monospace,underline,styled-content,break(the reported crash)Sts::NisoSts::Title— addedext-linkSts::NisoSts::Preformat— addedxref,sub,sup,sc,monospace,ext-link,inline-formula,breakSts::NisoSts::Sup— addedsub,sup,sc,std,ext-link,inline-formula,break(nested<sup>content)Sts::TbxIsoTml::Bold,Sts::TbxIsoTml::Italic— addedstd,inline-formula,breakSts::TbxIsoTml::Definition— addedsc,breakSts::TbxIsoTml::Note— addedmonospace,sc,ext-link,styled-content,breakSts::TbxIsoTml::Example— addedsub,sup,monospace,sc,ext-link,styled-content,breakSts::NisoSts::ParagraphandSts::NisoSts::StyledContentalready covered the full dispatched set; the tableth/tdmodels 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_FORhas no entry for::Sts::NisoSts::Term, so a def-list term carrying plain text still falls through to the:contentfallback and raisesundefined method 'content' for an instance of Sts::NisoSts::Term(Termmaps its content to:text, likeParagraph). The fix is the one-lineTEXT_ATTR_FORentry::Sts::NisoSts::Term => :textin 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>containingmonospace(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
InlineTransformerand a real metanorma-documentTtElementsource:<dt><tt>rms</tt></dt>now produces<term><monospace>rms</monospace></term>instead of theNoMethodError.Fixes the sts-side half of metanorma/metanorma-pdfa#122.