Class: Stepmod::Utils::Converters::Figure
- Inherits:
-
Coradoc::Input::Html::Converters::Figure
- Object
- Coradoc::Input::Html::Converters::Figure
- Stepmod::Utils::Converters::Figure
- Defined in:
- lib/stepmod/utils/converters/figure.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.pattern(state, id) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/stepmod/utils/converters/figure.rb', line 9 def self.pattern(state, id) if state[:schema_and_entity].nil? raise StandardError.new("[figure]: no state given, #{id}") end schema = state[:schema_and_entity].split(".").first "figure-#{schema}-#{id}" end |
Instance Method Details
#extract_title(node) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/stepmod/utils/converters/figure.rb', line 37 def extract_title(node) title = node.at("./title") return "" if title.nil? treat_children(title, {}) end |
#to_coradoc(node, state = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/stepmod/utils/converters/figure.rb', line 18 def to_coradoc(node, state = {}) # If we want to skip this node return "" if state[:no_notes_examples] # Set ID to "figure-id" in case of conflicts node["id"] = if node["id"] self.class.pattern(state, node["id"]) else self.class.pattern(state, node["number"]) end result = super(node, state) id = result.id anchor = "[[#{id}]]\n" if id padding = "\n====\n" child_content = treat_children(node, state).strip "\n\n#{anchor}.#{result.title}#{padding}#{child_content}#{padding}" end |