class BookLab::SML::Rules::SpanWithMark
Constants
- MARKS
Public Class Methods
match?(node)
click to toggle source
# File lib/booklab/sml/rules/span_with_mark.rb, line 17 def self.match?(node) return false unless tag_name(node) == "span" attrs = attributes(node) attrs[:t] == 0 end
to_html(node, opts = {})
click to toggle source
# File lib/booklab/sml/rules/span_with_mark.rb, line 23 def self.to_html(node, opts = {}) attrs = attributes(node) renderer = opts[:renderer] if attrs[:cd] == 1 children = renderer.children_to_text(node) else children = renderer.children_to_html(node) end case attrs[:va] when "superscript" then attrs[:sup] = 1 when "subscript" then attrs[:sub] = 1 end MARKS.each_key do |key| if attrs[key] == 1 mark = MARKS[key] children = "#{mark.first}#{children}#{mark.last}" end end children end