github-markdown 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,7 +130,7 @@ static VALUE rb_ghmd_to_html(VALUE self, VALUE rb_text, VALUE rb_mode)
130
130
 
131
131
 
132
132
  /* Max recursion nesting when parsing Markdown documents */
133
- static const int GITHUB_MD_NESTING = 16;
133
+ static const int GITHUB_MD_NESTING = 32;
134
134
 
135
135
  /* Default flags for all Markdown pipelines:
136
136
  *
@@ -1624,7 +1624,7 @@ static size_t
1624
1624
  parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size, int *flags)
1625
1625
  {
1626
1626
  struct buf *work = 0, *inter = 0;
1627
- size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
1627
+ size_t beg = 0, end, pre, sublist = 0, orgpre = 0, nestpre = 0, i;
1628
1628
  int in_empty = 0, has_inside_empty = 0, in_fence = 0;
1629
1629
 
1630
1630
  /* keeping track of the first indentation prefix */
@@ -1672,6 +1672,14 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1672
1672
  while (i < 4 && beg + i < end && data[beg + i] == ' ')
1673
1673
  i++;
1674
1674
 
1675
+ /* handle nested list items */
1676
+ if (i > 0) {
1677
+ if (nestpre == 0 || nestpre > i)
1678
+ nestpre = i;
1679
+ else
1680
+ i = nestpre;
1681
+ }
1682
+
1675
1683
  pre = i;
1676
1684
 
1677
1685
  if (rndr->ext_flags & MKDEXT_FENCED_CODE) {
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'github-markdown'
4
- s.version = '0.5.0'
4
+ s.version = '0.5.1'
5
5
  s.summary = 'The Markdown parser for GitHub.com'
6
6
  s.description = 'Self-contained Markdown parser for GitHub, with all our custom extensions'
7
7
  s.date = '2012-07-08'
data/test/gfm_test.rb CHANGED
@@ -23,4 +23,37 @@ class GFMBasicTest < Test::Unit::TestCase
23
23
  def test_that_code_blocks_work
24
24
  GitHub::Markdown.to_html("~~~~~~~~~~\nhello world!\n~~~~~~~~~\n", :gfm)
25
25
  end
26
+
27
+ # With GITHUB_MD_NESTING set to 32, we can handle up to 10 levels of list
28
+ # nesting. We do not go to 11.
29
+ def test_nested_list
30
+ items = [
31
+ 'Item 1',
32
+ 'Item 1a',
33
+ 'Item 1a1',
34
+ 'Item 1a1a',
35
+ 'Item 1a1a1',
36
+ 'Item 1a1a1a',
37
+ 'Item 1a1a1a1',
38
+ 'Item 1a1a1a1a',
39
+ 'Item 1a1a1a1a1',
40
+ 'Item 1a1a1a1a1a'
41
+ ]
42
+
43
+ pre = -3
44
+ markdown = items.inject('') do |md, item|
45
+ pre += 3
46
+ md.concat(' '*pre + '+ ' + item + "\n")
47
+ end
48
+
49
+ html = GitHub::Markdown.render(markdown)
50
+ parsed = Nokogiri::HTML::DocumentFragment.parse(html)
51
+
52
+ items.inject(parsed) do |node, expected_item|
53
+ child = node.at('.//ul/li')
54
+ child_item = child.children.detect{|e| e.text?}.text.strip
55
+ assert_equal expected_item, child_item
56
+ node = child
57
+ end
58
+ end
26
59
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - GitHub, Inc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-08 00:00:00 +02:00
18
+ date: 2012-07-08 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency