Class: MarkdownIt::RulesInline::StateInline
- Inherits:
-
Object
- Object
- MarkdownIt::RulesInline::StateInline
- Defined in:
- lib/motion-markdown-it/rules_inline/state_inline.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#env ⇒ Object
Returns the value of attribute env.
-
#level ⇒ Object
Returns the value of attribute level.
-
#md ⇒ Object
Returns the value of attribute md.
-
#pending ⇒ Object
Returns the value of attribute pending.
-
#pendingLevel ⇒ Object
Returns the value of attribute pendingLevel.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#posMax ⇒ Object
Returns the value of attribute posMax.
-
#src ⇒ Object
Returns the value of attribute src.
-
#tokens ⇒ Object
Returns the value of attribute tokens.
Instance Method Summary collapse
-
#initialize(src, md, env, outTokens) ⇒ StateInline
constructor
——————————————————————————.
-
#push(type, tag, nesting) ⇒ Object
Push new token to “stream”.
-
#pushPending ⇒ Object
Flush pending text ——————————————————————————.
Constructor Details
#initialize(src, md, env, outTokens) ⇒ StateInline
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 11 def initialize(src, md, env, outTokens) @src = src @env = env @md = md @tokens = outTokens @pos = 0 @posMax = @src.length @level = 0 @pending = '' @pendingLevel = 0 @cache = {} # Stores { start: end } pairs. Useful for backtrack # optimization of pairs parse (emphasis, strikes). end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
8 9 10 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 8 def cache @cache end |
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def env @env end |
#level ⇒ Object
Returns the value of attribute level.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def level @level end |
#md ⇒ Object
Returns the value of attribute md.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def md @md end |
#pending ⇒ Object
Returns the value of attribute pending.
8 9 10 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 8 def pending @pending end |
#pendingLevel ⇒ Object
Returns the value of attribute pendingLevel.
8 9 10 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 8 def pendingLevel @pendingLevel end |
#pos ⇒ Object
Returns the value of attribute pos.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def pos @pos end |
#posMax ⇒ Object
Returns the value of attribute posMax.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def posMax @posMax end |
#src ⇒ Object
Returns the value of attribute src.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def src @src end |
#tokens ⇒ Object
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 7 def tokens @tokens end |
Instance Method Details
#push(type, tag, nesting) ⇒ Object
Push new token to “stream”. If pending text exists - flush it as text token
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/motion-markdown-it/rules_inline/state_inline.rb', line 42 def push(type, tag, nesting) pushPending unless @pending.empty? token = Token.new(type, tag, nesting); @level -= 1 if nesting < 0 token.level = @level @level += 1 if nesting > 0 @pendingLevel = @level @tokens.push(token) return token end |