Class: Mdlint::Token
- Inherits:
-
Object
- Object
- Mdlint::Token
- Defined in:
- lib/mdlint/token.rb,
sig/mdlint.rbs
Constant Summary collapse
- BLOCK_TYPES =
%i[ document heading_open heading_close paragraph_open paragraph_close bullet_list_open bullet_list_close ordered_list_open ordered_list_close list_item_open list_item_close blockquote_open blockquote_close code_block fence hr html_block front_matter table directive math_block footnote_definition inline ].freeze
- INLINE_TYPES =
%i[ text strong_open strong_close em_open em_close s_open s_close math_inline footnote_ref code_inline link_open link_close image softbreak hardbreak html_inline ].freeze
Instance Attribute Summary collapse
-
#attrs ⇒ Hash[Symbol, untyped]
Returns the value of attribute attrs.
-
#children ⇒ Array[Token]
Returns the value of attribute children.
-
#content ⇒ String
Returns the value of attribute content.
-
#info ⇒ String
Returns the value of attribute info.
-
#level ⇒ Integer
Returns the value of attribute level.
-
#map ⇒ Array[Integer]?
Returns the value of attribute map.
-
#markup ⇒ String
Returns the value of attribute markup.
-
#meta ⇒ Hash[Symbol, untyped]
Returns the value of attribute meta.
-
#nesting ⇒ Integer
Returns the value of attribute nesting.
-
#tag ⇒ String?
Returns the value of attribute tag.
-
#type ⇒ Symbol
Returns the value of attribute type.
Instance Method Summary collapse
- #block? ⇒ Boolean
- #closing? ⇒ Boolean
-
#initialize(type:, **kwargs) ⇒ Token
constructor
A new instance of Token.
- #inline? ⇒ Boolean
- #opening? ⇒ Boolean
- #self_closing? ⇒ Boolean
Constructor Details
#initialize(type:, **kwargs) ⇒ Token
Returns a new instance of Token.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mdlint/token.rb', line 7 def initialize(type:, **kwargs) @type = type @tag = kwargs[:tag] @nesting = kwargs[:nesting] || 0 @level = kwargs[:level] || 0 @content = kwargs[:content] || "" @markup = kwargs[:markup] || "" @info = kwargs[:info] || "" @meta = kwargs[:meta] || {} @map = kwargs[:map] @children = kwargs[:children] || [] @attrs = kwargs[:attrs] || {} end |
Instance Attribute Details
#attrs ⇒ Hash[Symbol, untyped]
Returns the value of attribute attrs.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def attrs @attrs end |
#children ⇒ Array[Token]
Returns the value of attribute children.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def children @children end |
#content ⇒ String
Returns the value of attribute content.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def content @content end |
#info ⇒ String
Returns the value of attribute info.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def info @info end |
#level ⇒ Integer
Returns the value of attribute level.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def level @level end |
#map ⇒ Array[Integer]?
Returns the value of attribute map.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def map @map end |
#markup ⇒ String
Returns the value of attribute markup.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def markup @markup end |
#meta ⇒ Hash[Symbol, untyped]
Returns the value of attribute meta.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def @meta end |
#nesting ⇒ Integer
Returns the value of attribute nesting.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def nesting @nesting end |
#tag ⇒ String?
Returns the value of attribute tag.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def tag @tag end |
#type ⇒ Symbol
Returns the value of attribute type.
5 6 7 |
# File 'lib/mdlint/token.rb', line 5 def type @type end |
Instance Method Details
#block? ⇒ Boolean
33 34 35 |
# File 'lib/mdlint/token.rb', line 33 def block? BLOCK_TYPES.include?(@type) end |
#closing? ⇒ Boolean
25 26 27 |
# File 'lib/mdlint/token.rb', line 25 def closing? @nesting == -1 end |
#inline? ⇒ Boolean
37 38 39 |
# File 'lib/mdlint/token.rb', line 37 def inline? INLINE_TYPES.include?(@type) end |
#opening? ⇒ Boolean
21 22 23 |
# File 'lib/mdlint/token.rb', line 21 def opening? @nesting == 1 end |
#self_closing? ⇒ Boolean
29 30 31 |
# File 'lib/mdlint/token.rb', line 29 def self_closing? @nesting.zero? end |