Class: Plurimath::XmlHelper
- Inherits:
-
Object
- Object
- Plurimath::XmlHelper
- Defined in:
- lib/plurimath/xml_helper.rb
Overview
XML element builders shared across every serializer (MathML and OMML), extracted from Plurimath::Utility (macro refactor). Sits alongside the Plurimath.xml_engine backend abstraction these methods build on.
Class Method Summary collapse
- .ox_element(node, attributes: [], namespace: "") ⇒ Object
- .pr_element(main_tag, wi_tag = false, namespace: "") ⇒ Object
- .rpr_element(wi_tag: false) ⇒ Object
- .update_nodes(element, nodes) ⇒ Object
Class Method Details
.ox_element(node, attributes: [], namespace: "") ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/plurimath/xml_helper.rb', line 9 def ox_element(node, attributes: [], namespace: "") namespace = "#{namespace}:" unless namespace.empty? element = Plurimath.xml_engine.new_element("#{namespace}#{node}") element.set_attr(attributes) element end |
.pr_element(main_tag, wi_tag = false, namespace: "") ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/plurimath/xml_helper.rb', line 38 def pr_element(main_tag, wi_tag = false, namespace: "") tag_name = "#{main_tag}Pr" ox_element( tag_name, namespace: namespace, ) << rpr_element(wi_tag: wi_tag) end |
.rpr_element(wi_tag: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/plurimath/xml_helper.rb', line 17 def rpr_element(wi_tag: false) rpr_element = ox_element("rPr", namespace: "w") attributes = { "w:ascii": "Cambria Math", "w:hAnsi": "Cambria Math" } rpr_element << ox_element( "rFonts", namespace: "w", attributes: attributes, ) rpr_element << ox_element("i", namespace: "w") if wi_tag rpr_element end |
.update_nodes(element, nodes) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/plurimath/xml_helper.rb', line 29 def update_nodes(element, nodes) nodes&.each do |node| next update_nodes(element, node) if node.is_a?(Array) element << node unless node.nil? end element end |