Class: Qiita::Markdown::Filters::CustomBlock::Note
- Inherits:
-
Object
- Object
- Qiita::Markdown::Filters::CustomBlock::Note
- Defined in:
- lib/qiita/markdown/filters/custom_block.rb
Constant Summary collapse
- ALLOWED_TYPES =
%w[info warn alert].freeze
- DEFAULT_TYPE =
"info"
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(node, type) ⇒ Note
constructor
A new instance of Note.
Constructor Details
#initialize(node, type) ⇒ Note
Returns a new instance of Note.
40 41 42 43 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 40 def initialize(node, type) @node = node @type = ALLOWED_TYPES.include?(type) ? type : DEFAULT_TYPE end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
33 34 35 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 33 def node @node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
33 34 35 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 33 def type @type end |
Instance Method Details
#convert ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 45 def convert children = node.children children.each(&:unlink) node.add_child("<div></div>") node.children.first.children = children node["class"] = "note #{type}" node.children.first.add_previous_sibling(icon) if icon end |