Module: Metanorma::StandardDocument::BlockXmlMapping

Defined in:
lib/metanorma/standard_document/block_attributes.rb

Overview

Adds XML element mappings for block-level content to a mapping builder. Call inside an ‘xml do` block:

xml do
  element "clause"
  ordered
  BlockXmlMapping.apply_block_mappings(self)
  # ... additional mappings
end

Constant Summary collapse

BLOCK_MAPPINGS =
{
  "p" => :paragraphs,
  "ul" => :unordered_lists,
  "ol" => :ordered_lists,
  "table" => :tables,
  "figure" => :figures,
  "formula" => :formulas,
  "example" => :examples,
  "note" => :notes,
  "admonition" => :admonitions,
  "sourcecode" => :sourcecode_blocks,
  "quote" => :quote_blocks,
  "dl" => :definition_lists,
}.freeze

Class Method Summary collapse

Class Method Details

.apply_block_mappings(mapping) ⇒ Object



79
80
81
82
83
# File 'lib/metanorma/standard_document/block_attributes.rb', line 79

def self.apply_block_mappings(mapping)
  BLOCK_MAPPINGS.each do |element_name, attr_name|
    mapping.map_element(element_name, to: attr_name)
  end
end