Module: Metanorma::Document::Components::Inline::SemanticContent
- Defined in:
- lib/metanorma/document/components/inline/semantic_content.rb
Overview
Iterator that yields only the semantic (canonical) children of a
mixed-content element, skipping any rendered-display (fmt-*)
siblings.
Background: in Metanorma presentation XML, every semantic
element with locale-sensitive rendering has a fmt-* sibling
(e.g. <stem> + <fmt-stem>). When both are present in the
same parent, each_mixed_content yields both — duplicating
the logical content.
Usage:
SemanticContent.each(paragraph) do |node|
# yields semantic children only; fmt_* skipped
end
SemanticContent.each(paragraph).to_a # => Enumerator
Consumers that want the rendered form access it directly via
node.fmt_* attributes — no iterator needed.
Class Method Summary collapse
Class Method Details
.each(element, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/metanorma/document/components/inline/semantic_content.rb', line 29 def each(element, &block) return enum_for(:each, element) unless block element.each_mixed_content do |node| next if rendered_display?(node) yield node end end |