class BookLab::SML::Renderer
Attributes
config[RW]
in_block[RW]
For table, list for temp mark in block
sml[RW]
value[RW]
Public Class Methods
new(sml, options)
click to toggle source
# File lib/booklab/sml/renderer.rb, line 14 def initialize(sml, options) @sml = sml @config = Config.new @config.plantuml_service_host = options[:plantuml_service_host] @config.mathjax_service_host = options[:mathjax_service_host] @value = YAML.load(sml) end
Public Instance Methods
children_to_html(node)
click to toggle source
# File lib/booklab/sml/renderer.rb, line 37 def children_to_html(node) return node if node.is_a?(String) children = self.class.get_children(node) children.each_with_index.map do |child, idx| prev_node = idx > 0 ? children[idx - 1] : nil next_node = idx < children.length ? children[idx + 1] : nil node_to_html(child, prev: prev_node, next: next_node) end.join("") end
children_to_text(node)
click to toggle source
# File lib/booklab/sml/renderer.rb, line 59 def children_to_text(node) return node if node.is_a?(String) children = self.class.get_children(node) children.each_with_index.map do |child, idx| text = node_to_text(child, {}) text.blank? ? nil : text end.compact.join(" ") end
node_to_html(node, opts = {})
click to toggle source
# File lib/booklab/sml/renderer.rb, line 30 def node_to_html(node, opts = {}) opts[:renderer] = self rule = BookLab::SML::Rules::find_by_node(node) rule.to_html(node, opts) end
node_to_text(node, opts = {})
click to toggle source
# File lib/booklab/sml/renderer.rb, line 53 def node_to_text(node, opts = {}) opts[:renderer] = self rule = BookLab::SML::Rules::find_by_node(node) rule.to_text(node, opts)&.strip end
to_html()
click to toggle source
# File lib/booklab/sml/renderer.rb, line 22 def to_html node_to_html(self.value) end
to_s()
click to toggle source
# File lib/booklab/sml/renderer.rb, line 26 def to_s to_html end
to_text()
click to toggle source
# File lib/booklab/sml/renderer.rb, line 49 def to_text node_to_text(self.value) end