kramdown-parser-gfm 1.0.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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTERS +3 -0
  3. data/COPYING +21 -0
  4. data/VERSION +1 -0
  5. data/lib/kramdown/parser/gfm.rb +246 -0
  6. data/test/test_files.rb +36 -0
  7. data/test/testcases/atx_header.html +3 -0
  8. data/test/testcases/atx_header.text +3 -0
  9. data/test/testcases/backticks_disable_highlighting.html +2 -0
  10. data/test/testcases/backticks_disable_highlighting.options +1 -0
  11. data/test/testcases/backticks_disable_highlighting.text +3 -0
  12. data/test/testcases/backticks_syntax.html +20 -0
  13. data/test/testcases/backticks_syntax.text +19 -0
  14. data/test/testcases/codeblock_fenced.html +20 -0
  15. data/test/testcases/codeblock_fenced.options +1 -0
  16. data/test/testcases/codeblock_fenced.text +21 -0
  17. data/test/testcases/hard_line_breaks.html +3 -0
  18. data/test/testcases/hard_line_breaks.text +3 -0
  19. data/test/testcases/hard_line_breaks_off.html +5 -0
  20. data/test/testcases/hard_line_breaks_off.options +1 -0
  21. data/test/testcases/hard_line_breaks_off.text +5 -0
  22. data/test/testcases/header_ids.html +27 -0
  23. data/test/testcases/header_ids.options +1 -0
  24. data/test/testcases/header_ids.text +27 -0
  25. data/test/testcases/header_ids_with_prefix.html +3 -0
  26. data/test/testcases/header_ids_with_prefix.options +2 -0
  27. data/test/testcases/header_ids_with_prefix.text +3 -0
  28. data/test/testcases/no_typographic.html +3 -0
  29. data/test/testcases/no_typographic.options +1 -0
  30. data/test/testcases/no_typographic.text +3 -0
  31. data/test/testcases/paragraph_end-disabled.html +31 -0
  32. data/test/testcases/paragraph_end-disabled.options +1 -0
  33. data/test/testcases/paragraph_end-disabled.text +27 -0
  34. data/test/testcases/paragraph_end.html +38 -0
  35. data/test/testcases/paragraph_end.text +27 -0
  36. data/test/testcases/strikethrough.html +27 -0
  37. data/test/testcases/strikethrough.text +27 -0
  38. data/test/testcases/task_list.html +40 -0
  39. data/test/testcases/task_list.text +26 -0
  40. data/test/testcases/two_para_hard_line_breaks.html +4 -0
  41. data/test/testcases/two_para_hard_line_breaks.text +4 -0
  42. metadata +97 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c41a35e102f66ff1ddde3ede6b4b7acda3bb504134dbb6a2961be03eb8d82a1f
4
+ data.tar.gz: 61264dfb7937d303b9a68dac5e1767db958166aa6abc97626fad33a46971d151
5
+ SHA512:
6
+ metadata.gz: b280d43c2451f604890612113fe99fe074b10ebcd6134dc2e9beac30d81412c9f72464d5ad701aec1b64f802940efc8091b7b4871b873f202a9456c337c951c3
7
+ data.tar.gz: 2fb9b53e359379221edf4d3543e417668f58d6035e08b8ffa46dd3c2b84016f66f17429f9b5da951f8eb9109cd9d68dbe18f786f27546606053c4ebb052720aa
@@ -0,0 +1,3 @@
1
+ Count Name
2
+ ======= ====
3
+ 1 Thomas Leitner <t_leitner@gmx.at>
data/COPYING ADDED
@@ -0,0 +1,21 @@
1
+ kramdown-parser-gfm
2
+ Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a
5
+ copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included
13
+ in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,246 @@
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown-parser-gfm which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'kramdown/options'
11
+ require 'kramdown/parser/kramdown'
12
+
13
+ module Kramdown
14
+ module Options
15
+
16
+ define(:hard_wrap, Boolean, true, <<EOF)
17
+ Interprets line breaks literally
18
+
19
+ Insert HTML `<br />` tags inside paragraphs where the original Markdown
20
+ document had newlines (by default, Markdown ignores these newlines).
21
+
22
+ Default: true
23
+ Used by: GFM parser
24
+ EOF
25
+
26
+ define(:gfm_quirks, Object, [:paragraph_end], <<EOF) do |val|
27
+ Enables a set of GFM specific quirks
28
+
29
+ The way how GFM is transformed on Github often differs from the way
30
+ kramdown does things. Many of these differences are negligible but
31
+ others are not.
32
+
33
+ This option allows one to enable/disable certain GFM quirks, i.e. ways
34
+ in which GFM parsing differs from kramdown parsing.
35
+
36
+ The value has to be a list of quirk names that should be enabled,
37
+ separated by commas. Possible names are:
38
+
39
+ * paragraph_end
40
+
41
+ Disables the kramdown restriction that at least one blank line has to
42
+ be used after a paragraph before a new block element can be started.
43
+
44
+ Note that if this quirk is used, lazy line wrapping does not fully
45
+ work anymore!
46
+
47
+ * no_auto_typographic
48
+
49
+ Disables automatic conversion of some characters into their
50
+ corresponding typographic symbols (like `--` to em-dash etc).
51
+ This helps to achieve results closer to what GitHub Flavored
52
+ Markdown produces.
53
+
54
+ Default: paragraph_end
55
+ Used by: GFM parser
56
+ EOF
57
+ val = simple_array_validator(val, :gfm_quirks)
58
+ val.map! {|v| str_to_sym(v.to_s)}
59
+ val
60
+ end
61
+
62
+ end
63
+
64
+ module Parser
65
+
66
+ # This class provides a parser implementation for the GFM dialect of Markdown.
67
+ class GFM < Kramdown::Parser::Kramdown
68
+
69
+ VERSION = '1.0.0'
70
+
71
+ def initialize(source, options)
72
+ super
73
+ @options[:auto_id_stripping] = true
74
+ @id_counter = Hash.new(-1)
75
+
76
+ @span_parsers.delete(:line_break) if @options[:hard_wrap]
77
+ @span_parsers.delete(:typographic_syms) if @options[:gfm_quirks].include?(:no_auto_typographic)
78
+ if @options[:gfm_quirks].include?(:paragraph_end)
79
+ atx_header_parser = :atx_header_gfm_quirk
80
+ @paragraph_end = self.class::PARAGRAPH_END_GFM
81
+ else
82
+ atx_header_parser = :atx_header_gfm
83
+ @paragraph_end = self.class::PARAGRAPH_END
84
+ end
85
+
86
+ {codeblock_fenced: :codeblock_fenced_gfm,
87
+ atx_header: atx_header_parser}.each do |current, replacement|
88
+ i = @block_parsers.index(current)
89
+ @block_parsers.delete(current)
90
+ @block_parsers.insert(i, replacement)
91
+ end
92
+
93
+ i = @span_parsers.index(:escaped_chars)
94
+ @span_parsers[i] = :escaped_chars_gfm if i
95
+ @span_parsers << :strikethrough_gfm
96
+ end
97
+
98
+ def parse
99
+ super
100
+ update_elements(@root)
101
+ end
102
+
103
+ def update_elements(element)
104
+ element.children.map! do |child|
105
+ if child.type == :text &&
106
+ child.value.include?(hard_line_break = "#{@options[:hard_wrap] ? '' : '\\'}\n")
107
+ children = []
108
+ lines = child.value.split(hard_line_break, -1)
109
+ omit_trailing_br = (Kramdown::Element.category(element) == :block &&
110
+ element.children[-1] == child && lines[-1].empty?)
111
+ lines.each_with_index do |line, index|
112
+ new_element_options = {location: child.options[:location] + index}
113
+
114
+ children << Element.new(:text, (index > 0 ? "\n#{line}" : line), nil, new_element_options)
115
+ children << Element.new(:br, nil, nil, new_element_options) if index < lines.size - 2 ||
116
+ (index == lines.size - 2 && !omit_trailing_br)
117
+ end
118
+ children
119
+ elsif child.type == :html_element
120
+ child
121
+ elsif child.type == :header && @options[:auto_ids] && !child.attr.key?('id')
122
+ child.attr['id'] = generate_gfm_header_id(child.options[:raw_text])
123
+ child
124
+ else
125
+ update_elements(child)
126
+ child
127
+ end
128
+ end.flatten!
129
+ end
130
+
131
+ # Update the raw text for automatic ID generation.
132
+ def update_raw_text(item)
133
+ raw_text = +''
134
+
135
+ append_text = lambda do |child|
136
+ if child.type == :text || child.type == :codespan || child.type == :math
137
+ raw_text << child.value
138
+ elsif child.type == :entity
139
+ raw_text << child.value.char
140
+ elsif child.type == :smart_quote
141
+ raw_text << ::Kramdown::Utils::Entities.entity(child.value.to_s).char
142
+ elsif child.type == :typographic_sym
143
+ raw_text << if child.value == :laquo_space
144
+ "« "
145
+ elsif child.value == :raquo_space
146
+ " »"
147
+ else
148
+ ::Kramdown::Utils::Entities.entity(child.value.to_s).char
149
+ end
150
+ else
151
+ child.children.each {|c| append_text.call(c) }
152
+ end
153
+ end
154
+
155
+ append_text.call(item)
156
+ item.options[:raw_text] = raw_text
157
+ end
158
+
159
+ NON_WORD_RE = /[^\p{Word}\- \t]/
160
+
161
+ def generate_gfm_header_id(text)
162
+ result = text.downcase
163
+ result.gsub!(NON_WORD_RE, '')
164
+ result.tr!(" \t", '-')
165
+ @id_counter[result] += 1
166
+ result << (@id_counter[result] > 0 ? "-#{@id_counter[result]}" : '')
167
+ @options[:auto_id_prefix] + result
168
+ end
169
+
170
+ ATX_HEADER_START = /^(?<level>\#{1,6})[\t ]+(?<contents>.*)\n/
171
+ define_parser(:atx_header_gfm, ATX_HEADER_START, nil, 'parse_atx_header')
172
+ define_parser(:atx_header_gfm_quirk, ATX_HEADER_START)
173
+
174
+ # Copied from kramdown/parser/kramdown/header.rb, removed the first line
175
+ def parse_atx_header_gfm_quirk
176
+ text, id = parse_header_contents
177
+ text.sub!(/[\t ]#+\z/, '') && text.rstrip!
178
+ return false if text.empty?
179
+ add_header(@src["level"].length, text, id)
180
+ true
181
+ end
182
+
183
+ FENCED_CODEBLOCK_START = /^[ ]{0,3}[~`]{3,}/
184
+ FENCED_CODEBLOCK_MATCH = /^[ ]{0,3}(([~`]){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^[ ]{0,3}\1\2*\s*?\n/m
185
+ define_parser(:codeblock_fenced_gfm, FENCED_CODEBLOCK_START, nil, 'parse_codeblock_fenced')
186
+
187
+ STRIKETHROUGH_DELIM = /~~/
188
+ STRIKETHROUGH_MATCH = /#{STRIKETHROUGH_DELIM}[^\s~](.*?)[^\s~]#{STRIKETHROUGH_DELIM}/m
189
+ define_parser(:strikethrough_gfm, STRIKETHROUGH_MATCH, '~~')
190
+
191
+ def parse_strikethrough_gfm
192
+ line_number = @src.current_line_number
193
+
194
+ @src.pos += @src.matched_size
195
+ el = Element.new(:html_element, 'del', {}, category: :span, line: line_number)
196
+ @tree.children << el
197
+
198
+ env = save_env
199
+ reset_env(src: Kramdown::Utils::StringScanner.new(@src.matched[2..-3], line_number),
200
+ text_type: :text)
201
+ parse_spans(el)
202
+ restore_env(env)
203
+
204
+ el
205
+ end
206
+
207
+ # To handle task-lists we override the parse method for lists, converting matching text into
208
+ # checkbox input elements where necessary (as well as applying classes to the ul/ol and li
209
+ # elements).
210
+ def parse_list
211
+ super
212
+ current_list = @tree.children.select {|element| [:ul, :ol].include?(element.type) }.last
213
+
214
+ is_tasklist = false
215
+ box_unchecked = '<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />'
216
+ box_checked = '<input type="checkbox" class="task-list-item-checkbox" ' \
217
+ 'disabled="disabled" checked="checked" />'
218
+
219
+ current_list.children.each do |li|
220
+ next unless !li.children.empty? && li.children[0].type == :p
221
+ # li -> p -> raw_text
222
+ checked = li.children[0].children[0].value.gsub!(/\A\s*\[ \]\s+/, box_unchecked)
223
+ unchecked = li.children[0].children[0].value.gsub!(/\A\s*\[x\]\s+/i, box_checked)
224
+ is_tasklist ||= (!checked.nil? || !unchecked.nil?)
225
+
226
+ li.attr['class'] = 'task-list-item' if is_tasklist
227
+ end
228
+
229
+ current_list.attr['class'] = 'task-list' if is_tasklist
230
+
231
+ true
232
+ end
233
+
234
+ ESCAPED_CHARS_GFM = /\\([\\.*_+`<>()\[\]{}#!:\|"'\$=\-~])/
235
+ define_parser(:escaped_chars_gfm, ESCAPED_CHARS_GFM, '\\\\', :parse_escaped_chars)
236
+
237
+ PARAGRAPH_END_GFM = /#{LAZY_END}|#{LIST_START}|#{ATX_HEADER_START}|
238
+ #{DEFINITION_LIST_START}|#{BLOCKQUOTE_START}|#{FENCED_CODEBLOCK_START}/x
239
+
240
+ def paragraph_end
241
+ @paragraph_end
242
+ end
243
+
244
+ end
245
+ end
246
+ end
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown-parser-gfm which is licensed under the MIT.
7
+ #++
8
+ #
9
+
10
+ require 'minitest/autorun'
11
+ require 'kramdown'
12
+ require 'kramdown/parser/gfm'
13
+ require 'yaml'
14
+ require 'tmpdir'
15
+
16
+ Encoding.default_external = 'utf-8'
17
+
18
+ class TestFiles < Minitest::Test
19
+
20
+ # Generate test methods for gfm-to-html conversion
21
+ Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
22
+ basename = text_file.sub(/\.text$/, '')
23
+
24
+ html_file = basename + '.html'
25
+ next unless File.exist?(html_file)
26
+
27
+ define_method('test_gfm_' + text_file.tr('.', '_') + "_to_html") do
28
+ opts_file = basename + '.options'
29
+ opts_file = File.join(File.dirname(html_file), 'options') if !File.exist?(opts_file)
30
+ options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {auto_ids: false, footnote_nr: 1}
31
+ doc = Kramdown::Document.new(File.read(text_file), options.merge(input: 'GFM'))
32
+ assert_equal(File.read(html_file), doc.to_html)
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,3 @@
1
+ <h1>header</h1>
2
+
3
+ <p>#no header</p>
@@ -0,0 +1,3 @@
1
+ # header
2
+
3
+ #no header
@@ -0,0 +1,2 @@
1
+ <pre><code class="language-ruby">Kramdown::Document.new(text, :input =&gt; 'GFM')
2
+ </code></pre>
@@ -0,0 +1 @@
1
+ :enable_coderay: false
@@ -0,0 +1,3 @@
1
+ ```ruby
2
+ Kramdown::Document.new(text, :input => 'GFM')
3
+ ```
@@ -0,0 +1,20 @@
1
+ <pre><code>Three backticks
2
+ </code></pre>
3
+
4
+ <pre><code>Four backticks
5
+ </code></pre>
6
+
7
+ <pre><code>Unbalanced bottom heavy
8
+ </code></pre>
9
+
10
+ <div class="language-ruby highlighter-coderay"><div class="CodeRay">
11
+ <div class="code"><pre><span class="line-numbers"><a href="#n1" name="n1">1</a></span>language no space
12
+ </pre></div>
13
+ </div>
14
+ </div>
15
+
16
+ <div class="language-ruby highlighter-coderay"><div class="CodeRay">
17
+ <div class="code"><pre><span class="line-numbers"><a href="#n1" name="n1">1</a></span>language with space
18
+ </pre></div>
19
+ </div>
20
+ </div>
@@ -0,0 +1,19 @@
1
+ ```
2
+ Three backticks
3
+ ```
4
+
5
+ ````
6
+ Four backticks
7
+ ````
8
+
9
+ ```
10
+ Unbalanced bottom heavy
11
+ ``````
12
+
13
+ ````ruby
14
+ language no space
15
+ ````
16
+
17
+ ```` ruby
18
+ language with space
19
+ ````
@@ -0,0 +1,20 @@
1
+ <p>normal</p>
2
+
3
+ <pre><code class="language-ruby">require 'kramdown'
4
+
5
+ Kramdown::Document.new(text).to_html
6
+ </code></pre>
7
+
8
+ <p>indent with tab</p>
9
+
10
+ <pre><code>```ruby
11
+ require 'kramdown'
12
+
13
+ Kramdown::Document.new(text).to_html
14
+ ```
15
+ </code></pre>
16
+
17
+ <p>indent with 2 spaces</p>
18
+
19
+ <pre><code class="language-js"> console.log("hello");
20
+ </code></pre>
@@ -0,0 +1 @@
1
+ :enable_coderay: false
@@ -0,0 +1,21 @@
1
+ normal
2
+
3
+ ```ruby
4
+ require 'kramdown'
5
+
6
+ Kramdown::Document.new(text).to_html
7
+ ```
8
+
9
+ indent with tab
10
+
11
+ ```ruby
12
+ require 'kramdown'
13
+
14
+ Kramdown::Document.new(text).to_html
15
+ ```
16
+
17
+ indent with 2 spaces
18
+
19
+ ```js
20
+ console.log("hello");
21
+ ```
@@ -0,0 +1,3 @@
1
+ <p>one<br />
2
+ <em>two</em><br />
3
+ three</p>
@@ -0,0 +1,3 @@
1
+ one
2
+ _two_
3
+ three
@@ -0,0 +1,5 @@
1
+ <p>This is just a normal paragraph.<br />
2
+ Containing a manual line break above.</p>
3
+
4
+ <p>It was the best of times,<br />
5
+ it was the worst of times.</p>
@@ -0,0 +1 @@
1
+ :hard_wrap: false
@@ -0,0 +1,5 @@
1
+ This is just a normal paragraph.
2
+ Containing a manual line break above.
3
+
4
+ It was the best of times,\
5
+ it was the worst of times.
@@ -0,0 +1,27 @@
1
+ <h3 id="myid">test</h3>
2
+
3
+ <h3 id="variable_name">variable_name</h3>
4
+
5
+ <h3 id="abc-def-öúß">abc def öúß</h3>
6
+
7
+ <h3 id="192-abc-192">192 abc 192</h3>
8
+
9
+ <h3>;.;;</h3>
10
+
11
+ <h3 id="variable_name-1">variable_name</h3>
12
+
13
+ <h3 id="variable_name-2">variable_name</h3>
14
+
15
+ <h3 id="-1">;;</h3>
16
+
17
+ <h3 id="before--after-tab">before after tab</h3>
18
+
19
+ <h3 id="with-code">with <code>code</code></h3>
20
+
21
+ <h3 id="with-äspace">with  ä space</h3>
22
+
23
+ <h3 id="with-smart-quotes">With “smart” quotes</h3>
24
+
25
+ <h3 id="with--typographic--symbols">with — « typographic » … symbols</h3>
26
+
27
+ <h3 id="with-m5">with <script type="math/tex">m=5</script></h3>
@@ -0,0 +1 @@
1
+ :auto_ids: true
@@ -0,0 +1,27 @@
1
+ ### test {#myid}
2
+
3
+ ### variable_name
4
+
5
+ ### abc def öúß
6
+
7
+ ### 192 abc 192
8
+
9
+ ### ;.;;
10
+
11
+ ### variable_name
12
+
13
+ ### variable_name
14
+
15
+ ### ;;
16
+
17
+ ### before after tab
18
+
19
+ ### with `code`
20
+
21
+ ### with &nbsp;&auml;&nbsp;space
22
+
23
+ ### With "smart" quotes
24
+
25
+ ### with --- << typographic >> ... symbols
26
+
27
+ ### with $$m=5$$
@@ -0,0 +1,3 @@
1
+ <h1 id="hallo-header-1">Header 1</h1>
2
+
3
+ <h1 id="hallo-123">123</h1>
@@ -0,0 +1,2 @@
1
+ :auto_ids: true
2
+ :auto_id_prefix: hallo-
@@ -0,0 +1,3 @@
1
+ # Header 1
2
+
3
+ # 123
@@ -0,0 +1,3 @@
1
+ <h3 id="header-with---ndash">Header with --ndash</h3>
2
+
3
+ <h3 id="with------typographic---symbols">with --- &lt;&lt; typographic &gt;&gt; ... symbols</h3>
@@ -0,0 +1 @@
1
+ :gfm_quirks: [no_auto_typographic]
@@ -0,0 +1,3 @@
1
+ ### Header with --ndash
2
+
3
+ ### with --- << typographic >> ... symbols
@@ -0,0 +1,31 @@
1
+ <p>A<br />
2
+ - b</p>
3
+
4
+ <p>This is a list<br />
5
+ - or is it</p>
6
+
7
+ <p>blockquote<br />
8
+ &gt; text</p>
9
+
10
+ <p>header<br />
11
+ # text</p>
12
+
13
+ <p>codeblock fenced<br />
14
+ <code>
15
+ puts hello world
16
+ </code></p>
17
+
18
+ <ul>
19
+ <li>
20
+ <p>level 1<br />
21
+ some text</p>
22
+
23
+ <p>begin level 2<br />
24
+ * level 2<br />
25
+ * level 2</p>
26
+ </li>
27
+ </ul>
28
+
29
+ <h1 id="h1">h1</h1>
30
+ <p>## h2<br />
31
+ ### h3</p>
@@ -0,0 +1 @@
1
+ :gfm_quirks: []
@@ -0,0 +1,27 @@
1
+ A
2
+ - b
3
+
4
+ This is a list
5
+ - or is it
6
+
7
+ blockquote
8
+ > text
9
+
10
+ header
11
+ # text
12
+
13
+ codeblock fenced
14
+ ```
15
+ puts hello world
16
+ ```
17
+
18
+ * level 1
19
+ some text
20
+
21
+ begin level 2
22
+ * level 2
23
+ * level 2
24
+
25
+ # h1
26
+ ## h2
27
+ ### h3
@@ -0,0 +1,38 @@
1
+ <p>A</p>
2
+ <ul>
3
+ <li>b</li>
4
+ </ul>
5
+
6
+ <p>This is a list</p>
7
+ <ul>
8
+ <li>or is it</li>
9
+ </ul>
10
+
11
+ <p>blockquote</p>
12
+ <blockquote>
13
+ <p>text</p>
14
+ </blockquote>
15
+
16
+ <p>header</p>
17
+ <h1>text</h1>
18
+
19
+ <p>codeblock fenced</p>
20
+ <pre><code>puts hello world
21
+ </code></pre>
22
+
23
+ <ul>
24
+ <li>
25
+ <p>level 1<br />
26
+ some text</p>
27
+
28
+ <p>begin level 2</p>
29
+ <ul>
30
+ <li>level 2</li>
31
+ <li>level 2</li>
32
+ </ul>
33
+ </li>
34
+ </ul>
35
+
36
+ <h1>h1</h1>
37
+ <h2>h2</h2>
38
+ <h3>h3</h3>
@@ -0,0 +1,27 @@
1
+ A
2
+ - b
3
+
4
+ This is a list
5
+ - or is it
6
+
7
+ blockquote
8
+ > text
9
+
10
+ header
11
+ # text
12
+
13
+ codeblock fenced
14
+ ```
15
+ puts hello world
16
+ ```
17
+
18
+ * level 1
19
+ some text
20
+
21
+ begin level 2
22
+ * level 2
23
+ * level 2
24
+
25
+ # h1
26
+ ## h2
27
+ ### h3
@@ -0,0 +1,27 @@
1
+ <p><del>This is a test</del></p>
2
+
3
+ <p>~<del>This is another test</del>~</p>
4
+
5
+ <p><del>This is yet another test</del>~</p>
6
+
7
+ <p>~~ This is a test of it NOT working ~~</p>
8
+
9
+ <p>~~<br />
10
+ This<br />
11
+ is<br />
12
+ a<br />
13
+ <strong>multiline</strong><br />
14
+ test<br />
15
+ ~~</p>
16
+
17
+ <p>This is an <del><em>inline</em> <strong>strikethrough</strong></del> test</p>
18
+
19
+ <p>This is an ~~escaped~~ strikethrough.</p>
20
+
21
+ <p>This is a <del>strikethrough with a ~ in the middle</del></p>
22
+
23
+ <p>I <del>don’t even</del>~ have an extra tilde.</p>
24
+
25
+ <p>This should ~~not be struck.</p>
26
+
27
+ <p>This <del>is a complex <em>strike</em> through *test ~~with nesting</del> involved* here~~.</p>
@@ -0,0 +1,27 @@
1
+ ~~This is a test~~
2
+
3
+ ~~~This is another test~~~
4
+
5
+ ~~This is yet another test~~~
6
+
7
+ ~~ This is a test of it NOT working ~~
8
+
9
+ ~~
10
+ This
11
+ is
12
+ a
13
+ **multiline**
14
+ test
15
+ ~~
16
+
17
+ This is an ~~_inline_ **strikethrough**~~ test
18
+
19
+ This is an \~~escaped~~ strikethrough.
20
+
21
+ This is a ~~strikethrough with a ~ in the middle~~
22
+
23
+ I ~~don't even~~~ have an extra tilde.
24
+
25
+ This should ~~not be struck.
26
+
27
+ This ~~is a complex *strike* through *test ~~with nesting~~ involved* here~~.
@@ -0,0 +1,40 @@
1
+ <p>unordered task list</p>
2
+
3
+ <ul class="task-list">
4
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />first ul task item</li>
5
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />second ul task item</li>
6
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />third ul task item</li>
7
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />fourth ul task item [ ] next</li>
8
+ </ul>
9
+
10
+ <p>unordered list</p>
11
+
12
+ <ul>
13
+ <li>
14
+ <blockquote>
15
+ <p>first ul item</p>
16
+ </blockquote>
17
+ </li>
18
+ <li></li>
19
+ <li>
20
+ <pre><code>test
21
+ </code></pre>
22
+ </li>
23
+ <li>second ul item</li>
24
+ </ul>
25
+
26
+ <p>ordered list</p>
27
+
28
+ <ol>
29
+ <li>first ol item</li>
30
+ <li>second ol item</li>
31
+ </ol>
32
+
33
+ <p>ordered task list</p>
34
+
35
+ <ol class="task-list">
36
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />first ol task item</li>
37
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />second ol task item</li>
38
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />third ol task item</li>
39
+ <li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />fourth ol task item</li>
40
+ </ol>
@@ -0,0 +1,26 @@
1
+ unordered task list
2
+
3
+ - [ ] first ul task item
4
+ - [x] second ul task item
5
+ - [X] third ul task item
6
+ - [ ] fourth ul task item [ ] next
7
+
8
+ unordered list
9
+
10
+ - > first ul item
11
+ -
12
+ -
13
+ test
14
+ - second ul item
15
+
16
+ ordered list
17
+
18
+ 1. first ol item
19
+ 2. second ol item
20
+
21
+ ordered task list
22
+
23
+ 1. [ ] first ol task item
24
+ 2. [x] second ol task item
25
+ 3. [X] third ol task item
26
+ 4. [ ] fourth ol task item
@@ -0,0 +1,4 @@
1
+ <p>This is just a normal paragraph. <br />
2
+ Containing a line break.</p>
3
+
4
+ <p>Another paragraph.</p>
@@ -0,0 +1,4 @@
1
+ This is just a normal paragraph.
2
+ Containing a line break.
3
+
4
+ Another paragraph.
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kramdown-parser-gfm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Leitner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description:
28
+ email: t_leitner@gmx.at
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - CONTRIBUTERS
34
+ - COPYING
35
+ - VERSION
36
+ - lib/kramdown/parser/gfm.rb
37
+ - test/test_files.rb
38
+ - test/testcases/atx_header.html
39
+ - test/testcases/atx_header.text
40
+ - test/testcases/backticks_disable_highlighting.html
41
+ - test/testcases/backticks_disable_highlighting.options
42
+ - test/testcases/backticks_disable_highlighting.text
43
+ - test/testcases/backticks_syntax.html
44
+ - test/testcases/backticks_syntax.text
45
+ - test/testcases/codeblock_fenced.html
46
+ - test/testcases/codeblock_fenced.options
47
+ - test/testcases/codeblock_fenced.text
48
+ - test/testcases/hard_line_breaks.html
49
+ - test/testcases/hard_line_breaks.text
50
+ - test/testcases/hard_line_breaks_off.html
51
+ - test/testcases/hard_line_breaks_off.options
52
+ - test/testcases/hard_line_breaks_off.text
53
+ - test/testcases/header_ids.html
54
+ - test/testcases/header_ids.options
55
+ - test/testcases/header_ids.text
56
+ - test/testcases/header_ids_with_prefix.html
57
+ - test/testcases/header_ids_with_prefix.options
58
+ - test/testcases/header_ids_with_prefix.text
59
+ - test/testcases/no_typographic.html
60
+ - test/testcases/no_typographic.options
61
+ - test/testcases/no_typographic.text
62
+ - test/testcases/paragraph_end-disabled.html
63
+ - test/testcases/paragraph_end-disabled.options
64
+ - test/testcases/paragraph_end-disabled.text
65
+ - test/testcases/paragraph_end.html
66
+ - test/testcases/paragraph_end.text
67
+ - test/testcases/strikethrough.html
68
+ - test/testcases/strikethrough.text
69
+ - test/testcases/task_list.html
70
+ - test/testcases/task_list.text
71
+ - test/testcases/two_para_hard_line_breaks.html
72
+ - test/testcases/two_para_hard_line_breaks.text
73
+ homepage: https://github.com/kramdown/parser-gfm
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '2.3'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.7.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: kramdown-parser-gfm provides a kramdown parser for the GFM dialect of Markdown
97
+ test_files: []