motion-markdown-it 4.2.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c25f046cd230dec30329ee31997f8d1c4820e888
4
- data.tar.gz: 989cfb0a87fd1efbbc4f332e63aff23e4a1c3349
3
+ metadata.gz: cb7bc35a96283f575397326f35cc15789b4700fe
4
+ data.tar.gz: feacd41709859ddb7b8fd30f288af2a53c80c562
5
5
  SHA512:
6
- metadata.gz: 08c3e0baeb9071852ea680700f33222ece16cec1a8edc5e33c1b8c56cc2c8efb1442a439e8c4ca1838bdec1adb47e21072f50c1eb4496c0172d4da39c5337ff2
7
- data.tar.gz: a3a58cdd184efba1d5820d5a8b10e75efa8205f5d938e0f9b87c709320fb8f71c9a899999eecd203004b98fb6f309250746e245da1cfba49c2996af1d15eb375
6
+ metadata.gz: d64baed7b2ed7ecadc4b3a31b9d723502ab564e08871401b0d9b2d7dfeb017e12c09656692639f6d1b5dc911a0cc4605c8d832181e2c5b05c43d0e725c6edec0
7
+ data.tar.gz: 6dc2d585c57113b580d398c9370db04a22c7cb8c8470af53857c8a1b5df67601368c4aa557cf4b791201a3cef7e1a7d063190857d059f24508a546d6b77ac874
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # motion-markdown-it
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/motion-markdown-it.svg)](http://badge.fury.io/rb/motion-markdown-it)
4
+ [![Build Status](https://travis-ci.org/digitalmoksha/motion-markdown-it.svg?branch=master)](https://travis-ci.org/digitalmoksha/motion-markdown-it)
4
5
 
6
+ https://travis-ci.org/digitalmoksha/motion-markdown-it.svg?branch=master
5
7
  Ruby/RubyMotion version of Markdown-it (CommonMark compliant and extendable)
6
8
 
7
- This gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 4.2.2
9
+ This gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 4.4.0
8
10
 
9
11
  __[Javascript Live demo](https://markdown-it.github.io)__
10
12
 
@@ -22,7 +24,7 @@ The benefit of this project, for me at least, is to have a standardized CommonMa
22
24
 
23
25
  ## Performance
24
26
 
25
- Performance is still an issue. While it performs reasonably well with small to medium files, it degrades for large files. Work in progres...
27
+ Performance is still an issue. While it performs reasonably well with small to medium files, it degrades for large files. Work in progress...
26
28
 
27
29
  ## Table of content
28
30
 
@@ -10,7 +10,7 @@ if defined?(Motion::Project::Config)
10
10
  require 'linkify-it-rb'
11
11
  require 'mdurl-rb'
12
12
  require 'uc.micro-rb'
13
-
13
+
14
14
  else
15
15
 
16
16
  require 'mdurl-rb'
@@ -2,59 +2,66 @@
2
2
  # http://jgm.github.io/CommonMark/spec.html#html-blocks
3
3
  #------------------------------------------------------------------------------
4
4
  module MarkdownIt
5
- HTML_BLOCKS = {}
6
-
7
- [
5
+ HTML_BLOCKS = [
6
+ 'address',
8
7
  'article',
9
8
  'aside',
10
- 'button',
9
+ 'base',
10
+ 'basefont',
11
11
  'blockquote',
12
12
  'body',
13
- 'canvas',
14
13
  'caption',
14
+ 'center',
15
15
  'col',
16
16
  'colgroup',
17
17
  'dd',
18
+ 'details',
19
+ 'dialog',
20
+ 'dir',
18
21
  'div',
19
22
  'dl',
20
23
  'dt',
21
- 'embed',
22
24
  'fieldset',
23
25
  'figcaption',
24
26
  'figure',
25
27
  'footer',
26
28
  'form',
29
+ 'frame',
30
+ 'frameset',
27
31
  'h1',
28
- 'h2',
29
- 'h3',
30
- 'h4',
31
- 'h5',
32
- 'h6',
32
+ 'head',
33
33
  'header',
34
- 'hgroup',
35
34
  'hr',
36
- 'iframe',
35
+ 'html',
36
+ 'legend',
37
37
  'li',
38
- 'map',
39
- 'object',
38
+ 'link',
39
+ 'main',
40
+ 'menu',
41
+ 'menuitem',
42
+ 'meta',
43
+ 'nav',
44
+ 'noframes',
40
45
  'ol',
41
- 'output',
46
+ 'optgroup',
47
+ 'option',
42
48
  'p',
49
+ 'param',
43
50
  'pre',
44
- 'progress',
45
- 'script',
46
51
  'section',
47
- 'style',
52
+ 'source',
53
+ 'title',
54
+ 'summary',
48
55
  'table',
49
56
  'tbody',
50
57
  'td',
51
- 'textarea',
52
58
  'tfoot',
53
59
  'th',
54
- 'tr',
55
60
  'thead',
56
- 'ul',
57
- 'video'
58
- ].each { |name| HTML_BLOCKS[name] = true }
61
+ 'title',
62
+ 'tr',
63
+ 'track',
64
+ 'ul'
65
+ ].freeze
59
66
 
60
67
  end
@@ -23,6 +23,8 @@ module MarkdownIt
23
23
 
24
24
  HTML_TAG_RE = Regexp.new('^(?:' + OPEN_TAG + '|' + CLOSE_TAG + '|' + COMMENT +
25
25
  '|' + PROCESSING + '|' + DECLARATION + '|' + CDATA + ')')
26
+
27
+ HTML_OPEN_CLOSE_TAG_RE = Regexp.new('^(?:' + OPEN_TAG + '|' + CLOSE_TAG + ')')
26
28
  end
27
29
  end
28
30
  end
@@ -25,10 +25,11 @@ module MarkdownIt
25
25
  #------------------------------------------------------------------------------
26
26
  def self.fence(tokens, idx, options, env, renderer)
27
27
  token = tokens[idx]
28
+ info = token.info ? unescapeAll(token.info).strip : ''
28
29
  langName = ''
29
30
 
30
- if !token.info.empty?
31
- langName = unescapeAll(token.info.strip.split(/\s+/)[0])
31
+ if !info.empty?
32
+ langName = info.split(/\s+/)[0]
32
33
  token.attrPush([ 'class', options[:langPrefix] + langName ])
33
34
  end
34
35
 
@@ -4,66 +4,69 @@ module MarkdownIt
4
4
  module RulesBlock
5
5
  class HtmlBlock
6
6
 
7
- HTML_TAG_OPEN_RE = /^<([a-zA-Z][a-zA-Z0-9]{0,14})[\s\/>]/
8
- HTML_TAG_CLOSE_RE = /^<\/([a-zA-Z][a-zA-Z0-9]{0,14})[\s>]/
9
-
10
- #------------------------------------------------------------------------------
11
- def self.isLetter(ch)
12
- lc = ch | 0x20; # to lower case
13
- return (lc >= 0x61) && (lc <= 0x7a) # >= a and <= z
14
- end
7
+ HTML_OPEN_CLOSE_TAG_RE = MarkdownIt::Common::HtmlRe::HTML_OPEN_CLOSE_TAG_RE
8
+
9
+ # An array of opening and corresponding closing sequences for html tags,
10
+ # last argument defines whether it can terminate a paragraph or not
11
+ #
12
+ HTML_SEQUENCES = [
13
+ [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],
14
+ [ /^<!--/, /-->/, true ],
15
+ [ /^<\?/, /\?>/, true ],
16
+ [ /^<![A-Z]/, />/, true ],
17
+ [ /^<!\[CDATA\[/, /\]\]>/, true ],
18
+ [ Regexp.new('^</?(' + MarkdownIt::HTML_BLOCKS.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
19
+ [ Regexp.new(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
20
+ ];
15
21
 
16
22
  #------------------------------------------------------------------------------
17
23
  def self.html_block(state, startLine, endLine, silent)
18
- pos = state.bMarks[startLine]
24
+ pos = state.bMarks[startLine] + state.tShift[startLine]
19
25
  max = state.eMarks[startLine]
20
- shift = state.tShift[startLine]
21
-
22
- pos += shift
23
26
 
24
27
  return false if !state.md.options[:html]
25
- return false if shift > 3 || (pos + 2) >= max
26
28
  return false if state.src.charCodeAt(pos) != 0x3C # <
27
29
 
28
- ch = state.src.charCodeAt(pos + 1)
30
+ lineText = state.src.slice(pos...max)
29
31
 
30
- if ch == 0x21 || ch == 0x3F # ! or ?
31
- # Directive start / comment start / processing instruction start
32
- return true if silent
33
-
34
- elsif ch == 0x2F || isLetter(ch) # /
35
-
36
- # Probably start or end of tag
37
- if ch == 0x2F # \
38
- # closing tag
39
- match = state.src.slice(pos...max).match(HTML_TAG_CLOSE_RE)
40
- return false if (!match)
41
- else
42
- # opening tag
43
- match = state.src.slice(pos...max).match(HTML_TAG_OPEN_RE)
44
- return false if !match
45
- end
46
-
47
- # Make sure tag name is valid
48
- return false if HTML_BLOCKS[match[1].downcase] != true
49
- return true if silent
32
+ i = 0
33
+ while i < HTML_SEQUENCES.length
34
+ break if HTML_SEQUENCES[i][0].match(lineText)
35
+ i += 1
36
+ end
37
+
38
+ return false if i == HTML_SEQUENCES.length
50
39
 
51
- else
52
- return false
40
+ if silent
41
+ # true if this sequence can be a terminator, false otherwise
42
+ return HTML_SEQUENCES[i][2]
53
43
  end
54
44
 
55
- # If we are here - we detected HTML block.
56
- # Let's roll down till empty line (block end).
57
45
  nextLine = startLine + 1
58
- while nextLine < state.lineMax && !state.isEmpty(nextLine)
59
- nextLine += 1
46
+
47
+ # If we are here - we detected HTML block.
48
+ # Let's roll down till block end.
49
+ if !HTML_SEQUENCES[i][1].match(lineText)
50
+ while nextLine < endLine
51
+ break if state.tShift[nextLine] < state.blkIndent
52
+
53
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
54
+ max = state.eMarks[nextLine]
55
+ lineText = state.src.slice(pos...max)
56
+
57
+ if HTML_SEQUENCES[i][1].match(lineText)
58
+ nextLine += 1 if lineText.length != 0
59
+ break
60
+ end
61
+ nextLine += 1
62
+ end
60
63
  end
61
64
 
62
65
  state.line = nextLine
63
66
 
64
67
  token = state.push('html_block', '', 0)
65
- token.map = [ startLine, state.line ]
66
- token.content = state.getLines(startLine, nextLine, 0, true)
68
+ token.map = [ startLine, nextLine ]
69
+ token.content = state.getLines(startLine, nextLine, state.blkIndent, true)
67
70
 
68
71
  return true
69
72
  end
@@ -32,8 +32,9 @@ module MarkdownIt
32
32
  # or -1 on fail.
33
33
  #------------------------------------------------------------------------------
34
34
  def self.skipOrderedListMarker(state, startLine)
35
- pos = state.bMarks[startLine] + state.tShift[startLine]
36
- max = state.eMarks[startLine]
35
+ start = state.bMarks[startLine] + state.tShift[startLine]
36
+ pos = start
37
+ max = state.eMarks[startLine]
37
38
 
38
39
  # List marker should have at least 2 chars (digit + dot)
39
40
  return -1 if (pos + 1 >= max)
@@ -52,6 +53,11 @@ module MarkdownIt
52
53
  pos += 1
53
54
 
54
55
  if (ch >= 0x30 && ch <= 0x39) # >= 0 && <= 9
56
+
57
+ # List marker should have no more than 9 digits
58
+ # (prevents integer overflow in browsers)
59
+ return -1 if pos - start >= 10
60
+
55
61
  next
56
62
  end
57
63
 
@@ -114,7 +120,7 @@ module MarkdownIt
114
120
  start = state.bMarks[startLine] + state.tShift[startLine]
115
121
  markerValue = state.src[start, posAfterMarker - start - 1].to_i
116
122
  token = state.push('ordered_list_open', 'ol', 1)
117
- if (markerValue > 1)
123
+ if (markerValue != 1)
118
124
  token.attrs = [ [ 'start', markerValue ] ]
119
125
  end
120
126
 
@@ -138,6 +138,19 @@ module MarkdownIt
138
138
  pos += 1
139
139
  end
140
140
 
141
+ if (pos < max && str.charCodeAt(pos) != 0x0A)
142
+ if (title)
143
+ # garbage at the end of the line after title,
144
+ # but it could still be a valid reference if we roll back
145
+ title = ''
146
+ pos = destEndPos
147
+ lines = destEndLineNo
148
+ while (pos < max && str.charCodeAt(pos) == 0x20) # space
149
+ pos += 1
150
+ end
151
+ end
152
+ end
153
+
141
154
  if (pos < max && str.charCodeAt(pos) != 0x0A)
142
155
  # garbage at the end of the line
143
156
  return false
@@ -1,5 +1,5 @@
1
1
  module MotionMarkdownIt
2
2
 
3
- VERSION = '4.2.2.0'
3
+ VERSION = '4.4.0'
4
4
 
5
5
  end
@@ -1,44 +1,44 @@
1
- require 'kramdown'
2
-
3
- runs = 50
4
- files = ['mdsyntax.text', 'mdbasics.text']
5
- benchmark_dir = File.join(File.dirname(__FILE__), '../../benchmark')
6
-
7
- puts
8
- puts "Running tests on #{Time.now.strftime("%Y-%m-%d")} under #{RUBY_DESCRIPTION}"
9
-
10
- files.each do |file|
11
- data = File.read(File.join(benchmark_dir, file))
12
- puts
13
- puts "==> Test using file #{file} and #{runs} runs"
14
-
15
- # results = Benchmark.bmbm do |b|
16
- results = Benchmark.bm do |b|
17
- b.report("motion-markdown-it #{MotionMarkdownIt::VERSION}") do
18
- parser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })
19
- runs.times { parser.render(data) }
20
- end
21
- b.report("kramdown #{Kramdown::VERSION}") { runs.times { Kramdown::Document.new(data).to_html } }
22
- # b.report("markdown-it 4.0.1 JS") { runs.times { NSApplication.sharedApplication.delegate.markdown_it(data) } }
23
- # b.report(" hoedown 3.0.1") do
24
- # runs.times do
25
- # document = HoedownDocument.new
26
- # document.initWithHtmlRendererWithFlags(FLAGS)
27
- # html = document.renderMarkdownString(data)
28
- # end
29
- # end
30
- end
31
-
32
- # puts
33
- # puts "Real time of X divided by real time of kramdown"
34
- # kd = results.shift.real
35
- # %w[hoedown].each do |name|
36
- # puts name.ljust(19) << (results.shift.real/kd).round(4).to_s
37
- # end
38
- end
39
-
40
- describe "Benchmark Test" do
41
- it "benchmarks with mdsyntax.text and mdbasics.text" do
42
- expect(true).to eq true
43
- end
44
- end
1
+ # require 'kramdown'
2
+ #
3
+ # runs = 50
4
+ # files = ['mdsyntax.text', 'mdbasics.text']
5
+ # benchmark_dir = File.join(File.dirname(__FILE__), '../../benchmark')
6
+ #
7
+ # puts
8
+ # puts "Running tests on #{Time.now.strftime("%Y-%m-%d")} under #{RUBY_DESCRIPTION}"
9
+ #
10
+ # files.each do |file|
11
+ # data = File.read(File.join(benchmark_dir, file))
12
+ # puts
13
+ # puts "==> Test using file #{file} and #{runs} runs"
14
+ #
15
+ # # results = Benchmark.bmbm do |b|
16
+ # results = Benchmark.bm do |b|
17
+ # b.report("motion-markdown-it #{MotionMarkdownIt::VERSION}") do
18
+ # parser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })
19
+ # runs.times { parser.render(data) }
20
+ # end
21
+ # b.report("kramdown #{Kramdown::VERSION}") { runs.times { Kramdown::Document.new(data).to_html } }
22
+ # # b.report("markdown-it 4.0.1 JS") { runs.times { NSApplication.sharedApplication.delegate.markdown_it(data) } }
23
+ # # b.report(" hoedown 3.0.1") do
24
+ # # runs.times do
25
+ # # document = HoedownDocument.new
26
+ # # document.initWithHtmlRendererWithFlags(FLAGS)
27
+ # # html = document.renderMarkdownString(data)
28
+ # # end
29
+ # # end
30
+ # end
31
+ #
32
+ # # puts
33
+ # # puts "Real time of X divided by real time of kramdown"
34
+ # # kd = results.shift.real
35
+ # # %w[hoedown].each do |name|
36
+ # # puts name.ljust(19) << (results.shift.real/kd).round(4).to_s
37
+ # # end
38
+ # end
39
+ #
40
+ # describe "Benchmark Test" do
41
+ # it "benchmarks with mdsyntax.text and mdbasics.text" do
42
+ # expect(true).to eq true
43
+ # end
44
+ # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-markdown-it
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.2.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Walker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-20 00:00:00.000000000 Z
13
+ date: 2016-11-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mdurl-rb
@@ -46,9 +46,23 @@ dependencies:
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '1.0'
49
+ version: '1.2'
50
50
  type: :runtime
51
51
  prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.2'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bacon-expect
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.0'
64
+ type: :development
65
+ prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - "~>"