motion-markdown-it 8.4.1.1 → 9.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +43 -2
  3. data/lib/motion-markdown-it/common/entities.rb +3 -0
  4. data/lib/motion-markdown-it/common/simpleidn.rb +8 -9
  5. data/lib/motion-markdown-it/common/utils.rb +48 -8
  6. data/lib/motion-markdown-it/helpers/parse_link_destination.rb +5 -5
  7. data/lib/motion-markdown-it/helpers/parse_link_label.rb +1 -1
  8. data/lib/motion-markdown-it/helpers/parse_link_title.rb +3 -3
  9. data/lib/motion-markdown-it/parser_core.rb +3 -3
  10. data/lib/motion-markdown-it/ruler.rb +3 -3
  11. data/lib/motion-markdown-it/rules_block/blockquote.rb +8 -8
  12. data/lib/motion-markdown-it/rules_block/fence.rb +5 -3
  13. data/lib/motion-markdown-it/rules_block/heading.rb +4 -4
  14. data/lib/motion-markdown-it/rules_block/hr.rb +2 -2
  15. data/lib/motion-markdown-it/rules_block/html_block.rb +2 -1
  16. data/lib/motion-markdown-it/rules_block/lheading.rb +2 -1
  17. data/lib/motion-markdown-it/rules_block/list.rb +36 -12
  18. data/lib/motion-markdown-it/rules_block/reference.rb +13 -13
  19. data/lib/motion-markdown-it/rules_block/state_block.rb +13 -11
  20. data/lib/motion-markdown-it/rules_block/table.rb +8 -8
  21. data/lib/motion-markdown-it/rules_core/linkify.rb +1 -1
  22. data/lib/motion-markdown-it/rules_core/normalize.rb +2 -2
  23. data/lib/motion-markdown-it/rules_core/replacements.rb +1 -1
  24. data/lib/motion-markdown-it/rules_core/smartquotes.rb +5 -5
  25. data/lib/motion-markdown-it/rules_inline/autolink.rb +3 -2
  26. data/lib/motion-markdown-it/rules_inline/backticks.rb +8 -5
  27. data/lib/motion-markdown-it/rules_inline/balance_pairs.rb +13 -3
  28. data/lib/motion-markdown-it/rules_inline/emphasis.rb +1 -1
  29. data/lib/motion-markdown-it/rules_inline/entity.rb +6 -6
  30. data/lib/motion-markdown-it/rules_inline/escape.rb +3 -3
  31. data/lib/motion-markdown-it/rules_inline/html_inline.rb +5 -5
  32. data/lib/motion-markdown-it/rules_inline/image.rb +8 -8
  33. data/lib/motion-markdown-it/rules_inline/link.rb +7 -7
  34. data/lib/motion-markdown-it/rules_inline/newline.rb +4 -4
  35. data/lib/motion-markdown-it/rules_inline/state_inline.rb +7 -7
  36. data/lib/motion-markdown-it/rules_inline/strikethrough.rb +1 -1
  37. data/lib/motion-markdown-it/rules_inline/text.rb +2 -1
  38. data/lib/motion-markdown-it/rules_inline/text_collapse.rb +10 -2
  39. data/lib/motion-markdown-it/version.rb +1 -3
  40. data/lib/motion-markdown-it.rb +0 -1
  41. data/spec/spec_helper.rb +2 -1
  42. metadata +11 -13
  43. data/lib/motion-markdown-it/common/string.rb +0 -14
@@ -45,9 +45,9 @@ module MarkdownIt
45
45
  pushPending unless @pending.empty?
46
46
 
47
47
  token = Token.new(type, tag, nesting);
48
- @level -= 1 if nesting < 0
48
+ @level -= 1 if nesting < 0 # closing tag
49
49
  token.level = @level
50
- @level += 1 if nesting > 0
50
+ @level += 1 if nesting > 0 # opening tag
51
51
 
52
52
  @pendingLevel = @level
53
53
  @tokens.push(token)
@@ -65,19 +65,19 @@ module MarkdownIt
65
65
  left_flanking = true
66
66
  right_flanking = true
67
67
  max = @posMax
68
- marker = @src.charCodeAt(start)
68
+ marker = charCodeAt(@src, start)
69
69
 
70
70
  # treat beginning of the line as a whitespace
71
- lastChar = start > 0 ? @src.charCodeAt(start - 1) : 0x20
71
+ lastChar = start > 0 ? charCodeAt(@src, start - 1) : 0x20
72
72
 
73
- while (pos < max && @src.charCodeAt(pos) == marker)
73
+ while (pos < max && charCodeAt(@src, pos) == marker)
74
74
  pos += 1
75
75
  end
76
76
 
77
77
  count = pos - start
78
78
 
79
79
  # treat end of the line as a whitespace
80
- nextChar = pos < max ? @src.charCodeAt(pos) : 0x20
80
+ nextChar = pos < max ? charCodeAt(@src, pos) : 0x20
81
81
 
82
82
  isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(fromCodePoint(lastChar))
83
83
  isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(fromCodePoint(nextChar))
@@ -113,4 +113,4 @@ module MarkdownIt
113
113
  end
114
114
  end
115
115
  end
116
- end
116
+ end
@@ -9,7 +9,7 @@ module MarkdownIt
9
9
  #------------------------------------------------------------------------------
10
10
  def self.tokenize(state, silent)
11
11
  start = state.pos
12
- marker = state.src.charCodeAt(start)
12
+ marker = charCodeAt(state.src, start)
13
13
 
14
14
  return false if silent
15
15
 
@@ -4,6 +4,7 @@
4
4
  module MarkdownIt
5
5
  module RulesInline
6
6
  class Text
7
+ extend Common::Utils
7
8
 
8
9
  # Rule to skip pure text
9
10
  # '{}$%@~+=:' reserved for extentions
@@ -48,7 +49,7 @@ module MarkdownIt
48
49
  def self.text(state, silent)
49
50
  pos = state.pos
50
51
 
51
- while pos < state.posMax && !self.isTerminatorChar(state.src.charCodeAt(pos))
52
+ while pos < state.posMax && !self.isTerminatorChar(charCodeAt(state.src, pos))
52
53
  pos += 1
53
54
  end
54
55
 
@@ -1,4 +1,10 @@
1
+ # Clean up tokens after emphasis and strikethrough postprocessing:
1
2
  # Merge adjacent text nodes into one, and re-calculate all token levels
3
+ #
4
+ # This is necessary because initially emphasis delimiter markers (*, _, ~)
5
+ # are treated as their own separate text tokens. Then emphasis rule either
6
+ # leaves them as text (needed to merge with adjacent text) or turns them
7
+ # into opening/closing tags (which messes up levels inside).
2
8
  #------------------------------------------------------------------------------
3
9
  module MarkdownIt
4
10
  module RulesInline
@@ -12,9 +18,11 @@ module MarkdownIt
12
18
 
13
19
  last = curr = 0
14
20
  while curr < max
15
- # re-calculate levels
16
- level += tokens[curr].nesting
21
+ # re-calculate levels after emphasis/strikethrough turns some text nodes
22
+ # into opening/closing tags
23
+ level -= 1 if tokens[curr].nesting < 0 # closing tag
17
24
  tokens[curr].level = level
25
+ level += 1 if tokens[curr].nesting > 0 # opening tag
18
26
 
19
27
  if tokens[curr].type == 'text' &&
20
28
  curr + 1 < max &&
@@ -1,5 +1,3 @@
1
1
  module MotionMarkdownIt
2
-
3
- VERSION = '8.4.1.1'
4
-
2
+ VERSION = '9.0.1'
5
3
  end
@@ -24,7 +24,6 @@ else
24
24
  require 'motion-markdown-it/common/utils'
25
25
  require 'motion-markdown-it/common/html_blocks'
26
26
  require 'motion-markdown-it/common/html_re'
27
- require 'motion-markdown-it/common/string'
28
27
  require 'motion-markdown-it/common/simpleidn'
29
28
  require 'motion-markdown-it/helpers/parse_link_destination'
30
29
  require 'motion-markdown-it/helpers/parse_link_label'
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # make sure to have `--require spec_helper` in `.rspec` to have the
2
2
  # spec_helper.rb included automatically in spec files
3
- require 'pry-byebug'
4
3
  require 'motion-markdown-it/testgen_helper'
5
4
  require 'motion-markdown-it'
5
+
6
+ require 'pry'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-markdown-it
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.1.1
4
+ version: 9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Walker
8
8
  - Vitaly Puzrin
9
9
  - Alex Kocharin
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-04-16 00:00:00.000000000 Z
13
+ date: 2023-01-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mdurl-rb
@@ -46,28 +46,28 @@ dependencies:
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '2.0'
49
+ version: '4.0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '2.0'
56
+ version: '4.0'
57
57
  - !ruby/object:Gem::Dependency
58
- name: bacon-expect
58
+ name: motion-expect
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '1.0'
63
+ version: '2.0'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '1.0'
70
+ version: '2.0'
71
71
  description: Ruby/RubyMotion version of markdown-it
72
72
  email: github@digitalmoksha.com
73
73
  executables: []
@@ -80,7 +80,6 @@ files:
80
80
  - lib/motion-markdown-it/common/html_blocks.rb
81
81
  - lib/motion-markdown-it/common/html_re.rb
82
82
  - lib/motion-markdown-it/common/simpleidn.rb
83
- - lib/motion-markdown-it/common/string.rb
84
83
  - lib/motion-markdown-it/common/utils.rb
85
84
  - lib/motion-markdown-it/helpers/helper_wrapper.rb
86
85
  - lib/motion-markdown-it/helpers/parse_link_destination.rb
@@ -142,7 +141,7 @@ homepage: https://github.com/digitalmoksha/motion-markdown-it
142
141
  licenses:
143
142
  - MIT
144
143
  metadata: {}
145
- post_install_message:
144
+ post_install_message:
146
145
  rdoc_options: []
147
146
  require_paths:
148
147
  - lib
@@ -157,9 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
156
  - !ruby/object:Gem::Version
158
157
  version: '0'
159
158
  requirements: []
160
- rubyforge_project:
161
- rubygems_version: 2.6.8
162
- signing_key:
159
+ rubygems_version: 3.3.23
160
+ signing_key:
163
161
  specification_version: 4
164
162
  summary: Ruby version markdown-it
165
163
  test_files:
@@ -1,14 +0,0 @@
1
- class String
2
-
3
- # grab the remainder of the string starting at 'start'
4
- #------------------------------------------------------------------------------
5
- def slice_to_end(start)
6
- self.slice(start...self.length)
7
- end
8
-
9
- # port of Javascript function charCodeAt
10
- #------------------------------------------------------------------------------
11
- def charCodeAt(ch)
12
- self[ch].ord unless self[ch].nil?
13
- end
14
- end