extended-markdown-filter 0.3.0 → 0.3.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 +4 -4
- data/README.md +1 -1
- data/extended-markdown-filter.gemspec +1 -1
- data/lib/extended-markdown-filter.rb +5 -5
- data/lib/filters/filters.rb +3 -3
- data/test/test_extended_markdown_filter.rb +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e39736b7db330ed79b07670dfe2700318ecb02a
|
4
|
+
data.tar.gz: 0026e0d7a541c4724d93d4f115dca0a333e3056d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d092540fe47c5d2cd8b6712a516acbd8904e9ccedb18670baf427243fde25e1663a035b5bada89e05c333d2208cda883e05dd6fb15e830c6fd7eef500d050cf6
|
7
|
+
data.tar.gz: 3cad92de7d0d29637ecbf485bc0c09ccc2f075622b78af197361e7328fe9dd2666fda2060c19a600b437a78bcf561d43654fdaeb4da28ed47db6faeb35231357
|
data/README.md
CHANGED
@@ -33,4 +33,4 @@ Then just use the HTML pipeline normally.
|
|
33
33
|
|
34
34
|
Because of the Liquid template engine, if you use this filter with Jekyll, you might find that your curly brace tags--such as `{{#tip}}`--disappear.
|
35
35
|
|
36
|
-
You'll need to pass the context `
|
36
|
+
You'll need to pass the context `emf_use_blocks` through your filter. This sets up a totally safe monkey-patch to convert the `{{ }}` blocks into `[[ ]]`, so that Liquid ignores them. Then, this renderer will convert the Markdown appropriately.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "extended-markdown-filter"
|
3
|
-
spec.version = "0.3.
|
3
|
+
spec.version = "0.3.1"
|
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}
|
@@ -13,14 +13,14 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
13
13
|
include Filters::PreFilter
|
14
14
|
include Filters::PostFilter
|
15
15
|
|
16
|
-
|
16
|
+
EMF_CURLY_TAGS = %w(intro mac windows linux all tip warning error).join('|')
|
17
17
|
|
18
18
|
def initialize(text, context = nil, result = nil)
|
19
|
-
if defined?(Jekyll) && context[:
|
19
|
+
if defined?(Jekyll) && context[:emf_use_blocks]
|
20
20
|
require 'jekyll-override'
|
21
21
|
end
|
22
22
|
|
23
|
-
if context[:
|
23
|
+
if context[:emf_use_blocks]
|
24
24
|
text = self.class.convert_curly_to_bracket(text)
|
25
25
|
end
|
26
26
|
|
@@ -34,8 +34,8 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.convert_curly_to_bracket(text)
|
37
|
-
text = text.gsub(/\{\{\s*#(#{
|
38
|
-
text = text.gsub(/\{\{\s*\/(#{
|
37
|
+
text = text.gsub(/\{\{\s*#(#{EMF_CURLY_TAGS})\s*\}\}/, '[[#\1]]')
|
38
|
+
text = text.gsub(/\{\{\s*\/(#{EMF_CURLY_TAGS})\s*\}\}/, '[[/\1]]')
|
39
39
|
text = text.gsub(/\{\{\s*(octicon-\S+\s*[^\}]+)\s*\}\}/, '[[\1]]')
|
40
40
|
|
41
41
|
text
|
data/lib/filters/filters.rb
CHANGED
@@ -11,17 +11,17 @@ module Filters
|
|
11
11
|
module_function :context=
|
12
12
|
|
13
13
|
def front_wrap
|
14
|
-
(context[:
|
14
|
+
(context[:emf_use_blocks] == true) ? "\\[\\[" : "\{\{"
|
15
15
|
end
|
16
16
|
module_function :front_wrap
|
17
17
|
|
18
18
|
def end_wrap
|
19
|
-
(context[:
|
19
|
+
(context[:emf_use_blocks] == true) ? "\\]\\]" : "\}\}"
|
20
20
|
end
|
21
21
|
module_function :end_wrap
|
22
22
|
|
23
23
|
def wrap_symbol
|
24
|
-
(context[:
|
24
|
+
(context[:emf_use_blocks] == true) ? "\\]" : "}"
|
25
25
|
end
|
26
26
|
module_function :wrap_symbol
|
27
27
|
end
|
@@ -35,7 +35,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_block_intro
|
38
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("block_intro.md"), {:
|
38
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_intro.md"), {:emf_use_blocks => true})
|
39
39
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
40
40
|
|
41
41
|
assert_equal 1, doc.css('div.intro').size
|
@@ -43,7 +43,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_intro_conversion
|
46
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("intro.md"), {:
|
46
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("intro.md"), {:emf_use_blocks => true})
|
47
47
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
48
48
|
|
49
49
|
assert_equal 1, doc.css('div.intro').size
|
@@ -65,7 +65,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_block_os_blocks
|
68
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("block_os_blocks.md"), {:
|
68
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_os_blocks.md"), {:emf_use_blocks => true})
|
69
69
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
70
70
|
|
71
71
|
assert_equal 1, doc.css('div.platform-mac').size
|
@@ -79,7 +79,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_block_conversion
|
82
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("os_blocks.md"), {:
|
82
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("os_blocks.md"), {:emf_use_blocks => true})
|
83
83
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
84
84
|
|
85
85
|
assert_equal 1, doc.css('div.platform-mac').size
|
@@ -105,7 +105,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_block_admonition
|
108
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("block_admonition.md"), {:
|
108
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_admonition.md"), {:emf_use_blocks => true})
|
109
109
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
110
110
|
|
111
111
|
assert_equal 1, doc.css('div.tip').size
|
@@ -117,7 +117,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_admonition_conversion
|
120
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("admonition.md"), {:
|
120
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("admonition.md"), {:emf_use_blocks => true})
|
121
121
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
122
122
|
|
123
123
|
assert_equal 1, doc.css('div.tip').size
|
@@ -138,7 +138,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_block_octicon
|
141
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("block_octicon.md"), {:
|
141
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_octicon.md"), {:emf_use_blocks => true})
|
142
142
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
143
143
|
|
144
144
|
assert_equal 1, doc.css('span.cat').size
|
@@ -147,7 +147,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def test_oction_conversion
|
150
|
-
doc = ExtendedMarkdownFilter.to_document(fixture("octicon.md"), {:
|
150
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("octicon.md"), {:emf_use_blocks => true})
|
151
151
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
152
152
|
|
153
153
|
assert_equal 1, doc.css('span.cat').size
|