extended-markdown-filter 0.4.4 → 0.4.5
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 +10 -6
- data/lib/filters/post/admonition.rb +11 -5
- data/lib/filters/post/intro.rb +5 -2
- data/lib/filters/post/octicon.rb +1 -1
- data/lib/filters/post/os-blocks.rb +11 -5
- data/lib/filters/pre/helper.rb +1 -1
- data/test/fixtures/block_octicon.md +1 -1
- data/test/fixtures/octicon.md +1 -1
- data/test/test_extended_markdown_filter.rb +1 -1
- metadata +2 -3
- data/lib/filters/filters.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a430e7d1f6ef40619c3348d33552b35802765be0
|
4
|
+
data.tar.gz: 97b4490cdf16a3fa08051a55ab3633609ce5a6da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6ab23c23863f187be0693f52cda4aebc25b291d0f84ded5b583e133dde0474aaf2529f4674be7bf3acc140f83b924868f85b96890132b340996d580b0856c8
|
7
|
+
data.tar.gz: 0cec0584264a872e84250db0d377912a18df5d734c8962404013d7670166f1c8d33ec29e2f97c4b60ac515bfe01919f3d8eb35a5657ad0301c136cb1afea0331
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "extended-markdown-filter"
|
3
|
-
spec.version = "0.4.
|
3
|
+
spec.version = "0.4.5"
|
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}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'html/pipeline'
|
2
|
-
require 'filters/filters'
|
3
2
|
require 'nokogiri'
|
4
3
|
require 'jekyll-override' unless defined?(Jekyll).nil?
|
5
4
|
|
@@ -20,10 +19,15 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
20
19
|
def initialize(text, context = nil, result = nil)
|
21
20
|
if context[:emf_use_blocks]
|
22
21
|
text = self.class.convert_curly_to_bracket(text)
|
22
|
+
@front_wrap = "\\[\\["
|
23
|
+
@end_wrap = "\\]\\]"
|
24
|
+
@wrap_symbol = "\\]"
|
25
|
+
else
|
26
|
+
@front_wrap = "\{\{"
|
27
|
+
@end_wrap = "\}\}"
|
28
|
+
@wrap_symbol = "}"
|
23
29
|
end
|
24
30
|
|
25
|
-
Filters.context = context
|
26
|
-
|
27
31
|
# do preprocessing, then call HTML::Pipeline::Markdown
|
28
32
|
text = format_command_line text
|
29
33
|
text = format_helper text
|
@@ -33,9 +37,9 @@ class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
|
33
37
|
|
34
38
|
def self.convert_curly_to_bracket(text)
|
35
39
|
return text if text.nil?
|
36
|
-
text = text.gsub(/\{\{
|
37
|
-
text = text.gsub(/\{\{
|
38
|
-
text = text.gsub(/\{\{
|
40
|
+
text = text.gsub(/\{\{#(#{EMF_CURLY_TAGS})\}\}/, '[[#\1]]')
|
41
|
+
text = text.gsub(/\{\{\/(#{EMF_CURLY_TAGS})\}\}/, '[[/\1]]')
|
42
|
+
text = text.gsub(/\{\{ (octicon-\S+\s*[^\}]+) \}\}/, '[[\1]]')
|
39
43
|
|
40
44
|
text
|
41
45
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Filters
|
2
2
|
module PostFilter
|
3
|
+
TIP_HTML = '<div class="alert tip">'
|
4
|
+
NOTE_HTML = '<div class="alert note">'
|
5
|
+
WARNING_HTML = '<div class="alert warning">'
|
6
|
+
DANGER_HTML = '<div class="alert danger">'
|
7
|
+
CLOSE_DIV = '</div>'
|
8
|
+
|
3
9
|
def format_admonitions!(html)
|
4
|
-
html.gsub!(/<p>#{
|
5
|
-
html.gsub!(/<p>#{
|
6
|
-
html.gsub!(/<p>#{
|
7
|
-
html.gsub!(/<p>#{
|
8
|
-
html.gsub!(/<p>#{
|
10
|
+
html.gsub!(/<p>#{@front_wrap}#tip#{@end_wrap}<\/p>/, TIP_HTML)
|
11
|
+
html.gsub!(/<p>#{@front_wrap}#note#{@end_wrap}<\/p>/, NOTE_HTML)
|
12
|
+
html.gsub!(/<p>#{@front_wrap}#warning#{@end_wrap}<\/p>/, WARNING_HTML)
|
13
|
+
html.gsub!(/<p>#{@front_wrap}#danger#{@end_wrap}<\/p>/, DANGER_HTML)
|
14
|
+
html.gsub!(/<p>#{@front_wrap}\/(tip|note|warning|danger)#{@end_wrap}<\/p>/, CLOSE_DIV)
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
data/lib/filters/post/intro.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Filters
|
2
2
|
module PostFilter
|
3
|
+
INTRO_HTML = '<div class="intro">'
|
4
|
+
CLOSE_DIV = '</div>'
|
5
|
+
|
3
6
|
def format_intro!(html)
|
4
|
-
html.gsub!(/<p>#{
|
5
|
-
html.gsub!(/<p>#{
|
7
|
+
html.gsub!(/<p>#{@front_wrap}#intro#{@end_wrap}<\/p>/, INTRO_HTML)
|
8
|
+
html.gsub!(/<p>#{@front_wrap}\/intro#{@end_wrap}<\/p>/, CLOSE_DIV)
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
data/lib/filters/post/octicon.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Filters
|
2
2
|
module PostFilter
|
3
3
|
def format_octicons!(html)
|
4
|
-
html.gsub!(/#{
|
4
|
+
html.gsub!(/#{@front_wrap}\s*octicon-(\S+)\s*([^\\#{@wrap_symbol}]+)\s*#{@end_wrap}/, %|<span class="octicon octicon-\\1" aria-label="\\2" title="\\2"></span>|)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Filters
|
2
2
|
module PostFilter
|
3
|
+
MAC_HTML = '<div class="platform-mac">'
|
4
|
+
WIN_HTML = '<div class="platform-windows">'
|
5
|
+
LINUX_HTML = '<div class="platform-linux">'
|
6
|
+
ALL_HTML = '<div class="platform-all">'
|
7
|
+
CLOSE_DIV = '</div>'
|
8
|
+
|
3
9
|
def format_os_blocks!(html)
|
4
|
-
html.gsub!(/<p>#{
|
5
|
-
html.gsub!(/<p>#{
|
6
|
-
html.gsub!(/<p>#{
|
7
|
-
html.gsub!(/<p>#{
|
8
|
-
html.gsub!(/<p>#{
|
10
|
+
html.gsub!(/<p>#{@front_wrap}#mac#{@end_wrap}<\/p>/, MAC_HTML)
|
11
|
+
html.gsub!(/<p>#{@front_wrap}#windows#{@end_wrap}<\/p>/, WIN_HTML)
|
12
|
+
html.gsub!(/<p>#{@front_wrap}#linux#{@end_wrap}<\/p>/, LINUX_HTML)
|
13
|
+
html.gsub!(/<p>#{@front_wrap}#all#{@end_wrap}<\/p>/, ALL_HTML)
|
14
|
+
html.gsub!(/<p>#{@front_wrap}\/(mac|windows|linux|all)#{@end_wrap}<\/p>/, CLOSE_DIV)
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
data/lib/filters/pre/helper.rb
CHANGED
data/test/fixtures/octicon.md
CHANGED
@@ -157,7 +157,7 @@ class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
|
157
157
|
|
158
158
|
assert_equal 1, doc.css('span.octicon-cat').size
|
159
159
|
assert_match "{{ octicon dog", doc.to_s
|
160
|
-
assert_match '<p><a href="http://alink.com">Click <span class="octicon octicon-gear" aria-label="Settings
|
160
|
+
assert_match '<p><a href="http://alink.com">Click <span class="octicon octicon-gear" aria-label="Settings" title="Settings"></span></a></p>', doc.to_s
|
161
161
|
end
|
162
162
|
|
163
163
|
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.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -109,7 +109,6 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- extended-markdown-filter.gemspec
|
111
111
|
- lib/extended-markdown-filter.rb
|
112
|
-
- lib/filters/filters.rb
|
113
112
|
- lib/filters/post/admonition.rb
|
114
113
|
- lib/filters/post/intro.rb
|
115
114
|
- lib/filters/post/octicon.rb
|
data/lib/filters/filters.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Filters
|
2
|
-
|
3
|
-
def context
|
4
|
-
@context || {}
|
5
|
-
end
|
6
|
-
module_function :context
|
7
|
-
|
8
|
-
def context=(ctx)
|
9
|
-
@context = ctx
|
10
|
-
end
|
11
|
-
module_function :context=
|
12
|
-
|
13
|
-
def front_wrap
|
14
|
-
(context[:emf_use_blocks] == true) ? "\\[\\[" : "\{\{"
|
15
|
-
end
|
16
|
-
module_function :front_wrap
|
17
|
-
|
18
|
-
def end_wrap
|
19
|
-
(context[:emf_use_blocks] == true) ? "\\]\\]" : "\}\}"
|
20
|
-
end
|
21
|
-
module_function :end_wrap
|
22
|
-
|
23
|
-
def wrap_symbol
|
24
|
-
(context[:emf_use_blocks] == true) ? "\\]" : "}"
|
25
|
-
end
|
26
|
-
module_function :wrap_symbol
|
27
|
-
end
|