extended-markdown-filter 0.5.1 → 0.6.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 +4 -4
- data/extended-markdown-filter.gemspec +1 -1
- data/lib/extended-markdown-filter.rb +1 -1
- data/lib/filters/post/command-line.rb +20 -0
- data/test/fixtures/command_line_nested.md +9 -0
- data/test/test_extended_markdown_filter.rb +24 -2
- metadata +5 -3
- data/lib/filters/pre/command-line.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a24153805c60c83a7451eff6e4cdf31828efdb34
|
4
|
+
data.tar.gz: 045f098ea5039f10096dc383436fff6cf97d58fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa174512d31cb75081ed55226d4962de1dc6c79938c5d7aba000f73287e9297166b951bdd0a2b640ef660149d205af23a96c4990bdc62f683207043441d1e0ad
|
7
|
+
data.tar.gz: 77aa4727d976490209aae4edaf5b731754f4803ba67d3f86577529f9abb550dc6096e045e7c1ddd0040764fe7bca809f539534b76497e495144103fdb7a7f8dc
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "extended-markdown-filter"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.6.0"
|
4
4
|
spec.authors = ["Garen Torikian"]
|
5
5
|
spec.email = ["gjtorikian@gmail.com"]
|
6
6
|
spec.summary = %q{Add extended markup syntax to the HTML::Pipeline}
|
@@ -21,7 +21,6 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# do preprocessing, then call HTML::Pipeline::Markdown
|
24
|
-
text = format_command_line text
|
25
24
|
text = format_helper text
|
26
25
|
|
27
26
|
super text, context, result
|
@@ -51,6 +50,7 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
51
50
|
format_os_blocks! html
|
52
51
|
format_admonitions! html
|
53
52
|
format_octicons! html
|
53
|
+
format_command_line! html
|
54
54
|
|
55
55
|
html
|
56
56
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Filters
|
2
|
+
module PostFilter
|
3
|
+
def format_command_line!(html)
|
4
|
+
html.gsub!(/<pre><code>``` command-line\n/, "<pre class=\"command-line\">\n")
|
5
|
+
html.gsub!(/<pre lang="command-line">/, "<pre class=\"command-line\">\n")
|
6
|
+
|
7
|
+
html.gsub! /^\n?\s*<pre class="command-line">(.+?)<\/pre>/m do |block|
|
8
|
+
block.gsub!(/<\/*code>/, "")
|
9
|
+
block.gsub!(/```/, "")
|
10
|
+
block.gsub!(/^\s*\$ (.+)$/) { %(<span class="command">#{$1.rstrip}</span>) }
|
11
|
+
block.gsub!(/^\s*(\# .+)$/) { %(<span class="comment">#{$1.rstrip}</span>) }
|
12
|
+
block.gsub!(/^\s*> (.+)$/) { %(<span class="output">#{$1.rstrip}</span>) }
|
13
|
+
block.gsub!(/</, "<")
|
14
|
+
block.gsub!(/>/, ">")
|
15
|
+
|
16
|
+
block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
2. Create a bare clone of the repository.
|
2
|
+
``` command-line
|
3
|
+
$ git clone --bare https://{{ site.data.variables.command_line.codeblock }}/<em>exampleuser</em>/<em>old-repository</em>.git
|
4
|
+
```
|
5
|
+
3. Mirror-push to the new repository.
|
6
|
+
``` command-line
|
7
|
+
$ cd <em>old-repository</em>.git
|
8
|
+
$ git push --mirror https://{{ site.data.variables.command_line.codeblock }}/<em>exampleuser</em>/<em>new-repository</em>.git
|
9
|
+
```
|
@@ -9,13 +9,15 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
9
9
|
doc = ExtendedMarkdownFilter.to_document(fixture("command_line.md"), {})
|
10
10
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
11
11
|
|
12
|
-
assert_equal 1, doc.css('pre').size
|
12
|
+
assert_equal 1, doc.css('pre.command-line').size
|
13
13
|
assert_equal 2, doc.css('span.command').size
|
14
14
|
assert_equal 1, doc.css('span.comment').size
|
15
15
|
assert_equal 2, doc.css('em').size
|
16
16
|
assert_equal 1, doc.css('span.output').size
|
17
|
+
assert_equal 0, doc.css('code').size
|
17
18
|
|
18
19
|
assert_equal 0, doc.css('.command-line a').size
|
20
|
+
assert_equal 8, doc.to_html.lines.count
|
19
21
|
refute_equal 0, doc.css('pre').inner_text.length
|
20
22
|
end
|
21
23
|
|
@@ -23,7 +25,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
23
25
|
doc = ExtendedMarkdownFilter.to_document(fixture("command_line_indented.md"), {})
|
24
26
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
25
27
|
|
26
|
-
assert_equal 1, doc.css('pre').size
|
28
|
+
assert_equal 1, doc.css('pre.command-line').size
|
27
29
|
assert_equal 2, doc.css('span.command').size
|
28
30
|
assert_equal 1, doc.css('span.comment').size
|
29
31
|
assert_equal 2, doc.css('em').size
|
@@ -33,6 +35,26 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
33
35
|
refute_equal 0, doc.css('pre').inner_text.length
|
34
36
|
end
|
35
37
|
|
38
|
+
def test_nested_command_line
|
39
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("command_line_nested.md"), {})
|
40
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
41
|
+
|
42
|
+
assert_equal 1, doc.css('ol').size
|
43
|
+
assert_equal 2, doc.css('li').size
|
44
|
+
assert_equal 2, doc.css('pre').size
|
45
|
+
|
46
|
+
list = doc.css('ol')[0]
|
47
|
+
first_list_item = doc.css('li')[0]
|
48
|
+
first_command_line_block = doc.css('pre')[0]
|
49
|
+
second_list_item = doc.css('li')[1]
|
50
|
+
second_command_line_block = doc.css('pre')[1]
|
51
|
+
|
52
|
+
assert list.children.include?(first_list_item)
|
53
|
+
assert list.children.include?(second_list_item)
|
54
|
+
assert_equal first_command_line_block.parent, first_list_item
|
55
|
+
assert_equal second_command_line_block.parent, second_list_item
|
56
|
+
end
|
57
|
+
|
36
58
|
def test_helper
|
37
59
|
doc = ExtendedMarkdownFilter.to_document(fixture("helper.md"), {})
|
38
60
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extended-markdown-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -97,10 +97,10 @@ files:
|
|
97
97
|
- lib/extended-markdown-filter.rb
|
98
98
|
- lib/filters/filters.rb
|
99
99
|
- lib/filters/post/admonition.rb
|
100
|
+
- lib/filters/post/command-line.rb
|
100
101
|
- lib/filters/post/intro.rb
|
101
102
|
- lib/filters/post/octicon.rb
|
102
103
|
- lib/filters/post/os-blocks.rb
|
103
|
-
- lib/filters/pre/command-line.rb
|
104
104
|
- lib/filters/pre/helper.rb
|
105
105
|
- lib/jekyll-override.rb
|
106
106
|
- test/fixtures/admonition.md
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- test/fixtures/block_os_blocks.md
|
111
111
|
- test/fixtures/command_line.md
|
112
112
|
- test/fixtures/command_line_indented.md
|
113
|
+
- test/fixtures/command_line_nested.md
|
113
114
|
- test/fixtures/helper.md
|
114
115
|
- test/fixtures/intro.md
|
115
116
|
- test/fixtures/octicon.md
|
@@ -148,6 +149,7 @@ test_files:
|
|
148
149
|
- test/fixtures/block_os_blocks.md
|
149
150
|
- test/fixtures/command_line.md
|
150
151
|
- test/fixtures/command_line_indented.md
|
152
|
+
- test/fixtures/command_line_nested.md
|
151
153
|
- test/fixtures/helper.md
|
152
154
|
- test/fixtures/intro.md
|
153
155
|
- test/fixtures/octicon.md
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Filters
|
2
|
-
module PreFilter
|
3
|
-
def format_command_line(text)
|
4
|
-
text.gsub /^\n?\s*``` command-line(.+?)```/m do |block|
|
5
|
-
block.gsub! /^\s*``` command-line/, '<pre class="command-line">'
|
6
|
-
block.gsub! /^\s*```$/, "</pre>\n"
|
7
|
-
block.gsub!(/^\s*\$ (.+)$/) { %(<span class="command">#{$1.rstrip}</span>) }
|
8
|
-
block.gsub!(/^\s*(\# .+)$/) { %(<span class="comment">#{$1.rstrip}</span>) }
|
9
|
-
block.gsub!(/^\s*> (.+)$/) { %(<span class="output">#{$1.rstrip}</span>) }
|
10
|
-
|
11
|
-
block
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|