github-markdown-preview 3.1.0 → 3.1.1

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: fddee4db6c56bdf780f90d4660204917dcf583e2
4
- data.tar.gz: be0534e36ac9d885bec975a5245cbb3273763dba
3
+ metadata.gz: 6811fc2d2bbf7b805709ea7c7f483a03db65482f
4
+ data.tar.gz: 0cfd60ce46df545e790f5b3e67a11f6990ce5225
5
5
  SHA512:
6
- metadata.gz: 2ec8668c6455da1113937d57adc3d877310419cde82a881242f28b64a2e1a123b01ceff0de3cef98d703f7fa649d356b06f6cb2794f3c946049ec6cae178f356
7
- data.tar.gz: 287ecf069ad8e5ab61a61f6664a6665ba494113e54bccb53bcab238af0c28645bc244adb23fa42699916058630ca7b126f464791211058ead036e7eacc12a1b6
6
+ metadata.gz: 249bcd30e981b81b4dda35f9aaf56e81a1aa33a4b6b3316f6a451f76c8458400e5ab238e7dd6587afdced9350c45bc9cce9ba28ff7d5d6d94849607839010b54
7
+ data.tar.gz: 0fa92d6fcda6d4b8bc2bd82843a81ef2881d1a2816ebbdbf8a116c785d0cb1bb96860ff4774bbfc861fe1509a5b2f853d48af1199a364fbd32f30687a4482930
data/CHANGELOG.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v3.1.1
4
+ * Fix double-spaced task lists [#31](https://github.com/dmarcotte/github-markdown-preview/pull/31)
5
+
3
6
  ## v3.1.0
4
- * Add anchor links in default mode [#30](https://github.com/dmarcotte/github-markdown-preview/pull/30), [#30](https://github.com/dmarcotte/github-markdown-preview/pull/30)
7
+ * Add anchor links in default mode [#28](https://github.com/dmarcotte/github-markdown-preview/pull/28), [#30](https://github.com/dmarcotte/github-markdown-preview/pull/30)
5
8
 
6
9
  ## v3.0.0
7
10
  * Render task lists for readmes [#25](https://github.com/dmarcotte/github-markdown-preview/pull/25) ([Github announcement](https://github.com/blog/1825-task-lists-in-all-markdown-documents))
@@ -25,16 +25,18 @@ module GithubMarkdownPreview
25
25
  end
26
26
 
27
27
  def call
28
- doc.search('ul/li').each do |node|
28
+ process_task = Proc.new do |node|
29
29
  first_child = node.children.first
30
- next if !first_child.text?
30
+ next unless first_child.text?
31
31
  content = first_child.to_html
32
32
  html = task_list_item_filter(content)
33
33
  next if html == content
34
- node['class'] = 'task-list-item'
35
- node.parent()['class'] = 'task-list'
34
+ (first_child.ancestors('li').first || { })['class'] = 'task-list-item'
35
+ (first_child.ancestors('ul').first || { })['class'] = 'task-list'
36
36
  first_child.replace(html)
37
37
  end
38
+ doc.search('ul/li').each &process_task
39
+ doc.search('ul/li/p').each &process_task
38
40
  doc
39
41
  end
40
42
 
@@ -1,3 +1,3 @@
1
1
  module GithubMarkdownPreview
2
- VERSION = '3.1.0'
2
+ VERSION = '3.1.1'
3
3
  end
@@ -42,7 +42,7 @@ class HTML::Pipeline::MentionFilterTest < Minitest::Test
42
42
  html = "<ul><li>[ ] <em>task</em></li></ul>"
43
43
  result = filter(html)
44
44
 
45
- assert_equal "<ul class=\"task-list\"><li class=\"task-list-item\">\n<input class=\"task-list-item-checkbox\" type=\"checkbox\"><em>task</em>\n</li></ul>",
45
+ assert_equal "<ul class=\"task-list\"><li class=\"task-list-item\">\n<input class=\"task-list-item-checkbox\" type=\"checkbox\"> <em>task</em>\n</li></ul>",
46
46
  result
47
47
  end
48
48
 
@@ -94,4 +94,12 @@ class HTML::Pipeline::MentionFilterTest < Minitest::Test
94
94
  result
95
95
  end
96
96
 
97
+ def test_lists_with_p_tags
98
+ html = "<ul><li><p>[ ] One</p></li><li><p>[ ] Two</p></li></ul>"
99
+ result = filter(html)
100
+
101
+ assert_equal "<ul class=\"task-list\">\n<li class=\"task-list-item\"><p><input class=\"task-list-item-checkbox\" type=\"checkbox\"> One</p></li>\n<li class=\"task-list-item\"><p><input class=\"task-list-item-checkbox\" type=\"checkbox\"> Two</p></li>\n</ul>",
102
+ result
103
+ end
104
+
97
105
  end
@@ -101,6 +101,14 @@ class TestHtmlPreview < Minitest::Test
101
101
  'Should contain a task list item in comment mode'
102
102
  end
103
103
 
104
+ def test_double_spaced_task_lists
105
+ write(@source_file_path, "- [ ] one\n\n- [ ] two")
106
+ markdown_preview = @ghp.new( @source_file_path, { :comment_mode => true } )
107
+ assert_equal markdown_preview.wrap_preview("<ul class=\"task-list\">\n<li class=\"task-list-item\"><p><input class=\"task-list-item-checkbox\" type=\"checkbox\"> one</p></li>\n<li class=\"task-list-item\"><p><input class=\"task-list-item-checkbox\" type=\"checkbox\"> two</p></li>\n</ul>"),
108
+ read(markdown_preview.preview_file),
109
+ 'Should render tasks even if list has extra spaces (which render as <p> elements)'
110
+ end
111
+
104
112
  def test_newlines_ignored
105
113
  write(@source_file_path, "foo\nbar")
106
114
  markdown_preview = @ghp.new( @source_file_path )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markdown-preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Marcotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-11 00:00:00.000000000 Z
11
+ date: 2014-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen