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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7a84876c5077a91dd3c996a22c2146dda7bcc2d
4
- data.tar.gz: 6b34189241a09b08fa663af8f8e5e7c698733464
3
+ metadata.gz: 60df9d0ebe97519c31fe1f520a9c658cbd32cf93
4
+ data.tar.gz: 67ec9948aa8298368c111d4da11ecbf497a74fa0
5
5
  SHA512:
6
- metadata.gz: 66aa616925154d409791007ac40cf067d3e7b7e53f69bfea81046fabe2c1004be89747c4dde07fc129b0a76ad795da1b3578be7795cb69968e428d349db2069b
7
- data.tar.gz: b6a62afa12a8ca3d8df0ce5a079c459ce7ea5e8cf83a2e3a5ea27f15c31a849333d48e2d7aad0009e703e23efbf9f6fd3c4a2f75c3c306ea22e7c57148865f6d
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.2.1"
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
- format_admonition! html
50
+ format_admonitions! html
51
+ format_octicons! html
49
52
 
50
53
  html
51
54
  end
@@ -20,4 +20,8 @@ module Filters
20
20
  end
21
21
  module_function :end_wrap
22
22
 
23
+ def wrap_symbol
24
+ (context[:amf_use_blocks] == true) ? "\\]" : "}"
25
+ end
26
+ module_function :wrap_symbol
23
27
  end
@@ -1,6 +1,6 @@
1
1
  module Filters
2
2
  module PostFilter
3
- def format_admonition!(html)
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">')
@@ -0,0 +1,8 @@
1
+ module Filters
2
+ module PostFilter
3
+ def format_octicons!(html)
4
+ html.gsub!(/#{Filters.front_wrap}\s*octicon-(\S+)\s*([^\\#{Filters.wrap_symbol}]+)\s*#{Filters.end_wrap}/, %|<span class="octicon \\1" aria-label="\\2" title="\\2"></span>|)
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,5 @@
1
+ [[ octicon-cat This is a cat]]
2
+
3
+ [[ octicon dog This is nothing. ]]
4
+
5
+ [Click [[ octicon-gear Settings ]]](http://alink.com)
@@ -0,0 +1,5 @@
1
+ {{ octicon-cat This is a cat}}
2
+
3
+ {{ octicon dog This is nothing. }}
4
+
5
+ [Click {{ octicon-gear Settings }}](http://alink.com)
@@ -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.2.1
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-02 00:00:00.000000000 Z
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