Class: Sourcerer::MarkDownGrade::InlineSemanticConverter
- Inherits:
-
ReverseMarkdown::Converters::Base
- Object
- ReverseMarkdown::Converters::Base
- Sourcerer::MarkDownGrade::InlineSemanticConverter
- Defined in:
- lib/sourcerer/mark_down_grade.rb
Overview
Preserve inline semantic tags when class/role attributes are present.
Instance Method Summary collapse
- #convert(node, state = {}) ⇒ Object
-
#initialize(tag_name, fallback_converter) ⇒ InlineSemanticConverter
constructor
A new instance of InlineSemanticConverter.
Constructor Details
#initialize(tag_name, fallback_converter) ⇒ InlineSemanticConverter
Returns a new instance of InlineSemanticConverter.
197 198 199 200 201 |
# File 'lib/sourcerer/mark_down_grade.rb', line 197 def initialize tag_name, fallback_converter super() @tag_name = tag_name @fallback_converter = fallback_converter end |
Instance Method Details
#convert(node, state = {}) ⇒ Object
203 204 205 206 207 208 209 210 |
# File 'lib/sourcerer/mark_down_grade.rb', line 203 def convert node, state={} return @fallback_converter.convert(node, state) unless preserve_semantic_tag?(node) attrs = [] attrs << %( class="#{node['class']}") if node['class'] attrs << %( role="#{node['role']}") if node['role'] "<#{@tag_name}#{attrs.join}>#{treat_children(node, state)}</#{@tag_name}>" end |