extended-markdown-filter 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/extended-markdown-filter.gemspec +1 -1
- data/lib/extended-markdown-filter.rb +4 -1
- data/lib/filters/filters.rb +4 -0
- data/lib/filters/post/admonition.rb +1 -1
- data/lib/filters/post/octicon.rb +8 -0
- data/test/fixtures/block_octicon.md +5 -0
- data/test/fixtures/octicon.md +5 -0
- data/test/test_extended_markdown_filter.rb +28 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60df9d0ebe97519c31fe1f520a9c658cbd32cf93
|
4
|
+
data.tar.gz: 67ec9948aa8298368c111d4da11ecbf497a74fa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8778d83a3f69f24d3d5a403f99059408f5818ae0e140ff51e057d388c5a4377cf7649de55c2dd59c26d7da22cfa72f62d7375eac1a4682b4370151e2c6ec717e
|
7
|
+
data.tar.gz: 3959bc0a0c111971292dba01716ca020494445543d66b53527071941e006398efbee2e956e3ef32376911162b5ad436d825e4bf244afeb94567107e0d0e45344
|
@@ -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.3.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}
|
@@ -36,6 +36,8 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
36
36
|
def self.convert_curly_to_bracket(text)
|
37
37
|
text = text.gsub(/\{\{\s*#(#{AMF_CURLY_TAGS})\s*\}\}/, '[[#\1]]')
|
38
38
|
text = text.gsub(/\{\{\s*\/(#{AMF_CURLY_TAGS})\s*\}\}/, '[[/\1]]')
|
39
|
+
text = text.gsub(/\{\{\s*(octicon-\S+\s*[^\}]+)\s*\}\}/, '[[\1]]')
|
40
|
+
|
39
41
|
text
|
40
42
|
end
|
41
43
|
|
@@ -45,7 +47,8 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
45
47
|
|
46
48
|
format_intro! html
|
47
49
|
format_os_blocks! html
|
48
|
-
|
50
|
+
format_admonitions! html
|
51
|
+
format_octicons! html
|
49
52
|
|
50
53
|
html
|
51
54
|
end
|
data/lib/filters/filters.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Filters
|
2
2
|
module PostFilter
|
3
|
-
def
|
3
|
+
def format_admonitions!(html)
|
4
4
|
html.gsub!(/<p>#{Filters.front_wrap}\s*#tip\s*#{Filters.end_wrap}<\/p>/, '<div class="alert tip">')
|
5
5
|
html.gsub!(/<p>#{Filters.front_wrap}\s*#warning\s*#{Filters.end_wrap}<\/p>/, '<div class="alert warning">')
|
6
6
|
html.gsub!(/<p>#{Filters.front_wrap}\s*#error\s*#{Filters.end_wrap}<\/p>/, '<div class="alert error">')
|
@@ -127,4 +127,32 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
127
127
|
assert_equal 1, doc.css('strong').size
|
128
128
|
assert_equal 1, doc.css('del').size
|
129
129
|
end
|
130
|
+
|
131
|
+
def test_octicon
|
132
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("octicon.md"), {})
|
133
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
134
|
+
|
135
|
+
assert_equal 1, doc.css('span.cat').size
|
136
|
+
assert_match "{{ octicon dog", doc.to_s
|
137
|
+
assert_match '<p><a href="http://alink.com">Click <span class="octicon gear" aria-label="Settings " title="Settings "></span></a></p>', doc.to_s
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_block_octicon
|
141
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_octicon.md"), {:amf_use_blocks => true})
|
142
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
143
|
+
|
144
|
+
assert_equal 1, doc.css('span.cat').size
|
145
|
+
assert_match "[[ octicon dog", doc.to_s
|
146
|
+
assert_match '<p><a href="http://alink.com">Click <span class="octicon gear" aria-label="Settings " title="Settings "></span></a></p>', doc.to_s
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_oction_conversion
|
150
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("octicon.md"), {:amf_use_blocks => true})
|
151
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
152
|
+
|
153
|
+
assert_equal 1, doc.css('span.cat').size
|
154
|
+
assert_match "{{ octicon dog", doc.to_s
|
155
|
+
assert_match '<p><a href="http://alink.com">Click <span class="octicon gear" aria-label="Settings " title="Settings "></span></a></p>', doc.to_s
|
156
|
+
end
|
157
|
+
|
130
158
|
end
|
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.3.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: 2014-09-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/filters/filters.rb
|
99
99
|
- lib/filters/post/admonition.rb
|
100
100
|
- lib/filters/post/intro.rb
|
101
|
+
- lib/filters/post/octicon.rb
|
101
102
|
- lib/filters/post/os-blocks.rb
|
102
103
|
- lib/filters/pre/command-line.rb
|
103
104
|
- lib/filters/pre/helper.rb
|
@@ -105,10 +106,12 @@ files:
|
|
105
106
|
- test/fixtures/admonition.md
|
106
107
|
- test/fixtures/block_admonition.md
|
107
108
|
- test/fixtures/block_intro.md
|
109
|
+
- test/fixtures/block_octicon.md
|
108
110
|
- test/fixtures/block_os_blocks.md
|
109
111
|
- test/fixtures/command_line.md
|
110
112
|
- test/fixtures/helper.md
|
111
113
|
- test/fixtures/intro.md
|
114
|
+
- test/fixtures/octicon.md
|
112
115
|
- test/fixtures/os_blocks.md
|
113
116
|
- test/test_extended_markdown_filter.rb
|
114
117
|
- test/test_helper.rb
|
@@ -140,10 +143,12 @@ test_files:
|
|
140
143
|
- test/fixtures/admonition.md
|
141
144
|
- test/fixtures/block_admonition.md
|
142
145
|
- test/fixtures/block_intro.md
|
146
|
+
- test/fixtures/block_octicon.md
|
143
147
|
- test/fixtures/block_os_blocks.md
|
144
148
|
- test/fixtures/command_line.md
|
145
149
|
- test/fixtures/helper.md
|
146
150
|
- test/fixtures/intro.md
|
151
|
+
- test/fixtures/octicon.md
|
147
152
|
- test/fixtures/os_blocks.md
|
148
153
|
- test/test_extended_markdown_filter.rb
|
149
154
|
- test/test_helper.rb
|