Class: Stepmod::Utils::Converters::Term
- Inherits:
-
Base
- Object
- Coradoc::Input::HTML::Converters::Base
- Base
- Stepmod::Utils::Converters::Term
- Defined in:
- lib/stepmod/utils/converters/term.rb
Instance Method Summary collapse
- #to_coradoc(node, state = {}) ⇒ Object
-
#treat_children(node, state) ⇒ Object
We strip all the children in the case for “stem:[d]-manifold” vs “stem:[d] -manifold”.
Instance Method Details
#to_coradoc(node, state = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/stepmod/utils/converters/term.rb', line 18 def to_coradoc(node, state = {}) first_child = node.children.find do |child| child.name == "text" && !child.text.to_s.strip.empty? end unless first_child && node.text.split(";").length == 2 && defined?(Stepmod::Utils::Converters::Synonym) return Stepmod::Utils::Term.from_h( "definition" => treat_children(node, state).strip, ).to_mn_adoc end term_def, alt = node.text.split(";") alt_xml = Nokogiri::XML::Text.new(alt, Nokogiri::XML::Document.new) converted_alt = Stepmod::Utils::Converters::Synonym.new.convert(alt_xml) Stepmod::Utils::Term.from_h( "definition" => term_def, "synonyms" => [converted_alt], ).to_mn_adoc end |
#treat_children(node, state) ⇒ Object
We strip all the children in the case for “stem:[d]-manifold” vs “stem:[d] -manifold”
13 14 15 16 |
# File 'lib/stepmod/utils/converters/term.rb', line 13 def treat_children(node, state) res = node.children.map { |child| treat(child, state) } res.map(&:strip).reject(&:empty?).join("") end |