extended-markdown-filter 0.4.4 → 0.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1ad9e19d100797fd24c5785e1fbd1987d21f14e
4
- data.tar.gz: 7ab5e178f7c9872042439e372c65e26cce07dd58
3
+ metadata.gz: a430e7d1f6ef40619c3348d33552b35802765be0
4
+ data.tar.gz: 97b4490cdf16a3fa08051a55ab3633609ce5a6da
5
5
  SHA512:
6
- metadata.gz: 96a5c2963c29544bbce503666c0909d01c3df7ea1fad8c664b1afb13d580facd820c36e08261b11a63c5a64398a95e80b12f8a30700e15dafb3e5926408bc27a
7
- data.tar.gz: baea99ad8a1c49d4f31b4fd1753bb08d2fdf8bcc435c033de8b926acfbf14068e0789275c0704f256d6293ab4266bcf9cb30e6368c52487cc82900f41d384df6
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.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(/\{\{\s*#(#{EMF_CURLY_TAGS})\s*\}\}/, '[[#\1]]')
37
- text = text.gsub(/\{\{\s*\/(#{EMF_CURLY_TAGS})\s*\}\}/, '[[/\1]]')
38
- text = text.gsub(/\{\{\s*(octicon-\S+\s*[^\}]+)\s*\}\}/, '[[\1]]')
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>#{Filters.front_wrap}\s*#tip\s*#{Filters.end_wrap}<\/p>/, '<div class="alert tip">')
5
- html.gsub!(/<p>#{Filters.front_wrap}\s*#note\s*#{Filters.end_wrap}<\/p>/, '<div class="alert note">')
6
- html.gsub!(/<p>#{Filters.front_wrap}\s*#warning\s*#{Filters.end_wrap}<\/p>/, '<div class="alert warning">')
7
- html.gsub!(/<p>#{Filters.front_wrap}\s*#danger\s*#{Filters.end_wrap}<\/p>/, '<div class="alert danger">')
8
- html.gsub!(/<p>#{Filters.front_wrap}\s*\/(tip|note|warning|danger)\s*#{Filters.end_wrap}<\/p>/, '</div>')
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
@@ -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>#{Filters.front_wrap}\s*#intro\s*#{Filters.end_wrap}<\/p>/, '<div class="intro">')
5
- html.gsub!(/<p>#{Filters.front_wrap}\s*\/intro\s*#{Filters.end_wrap}<\/p>/, '</div>')
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
@@ -1,7 +1,7 @@
1
1
  module Filters
2
2
  module PostFilter
3
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 octicon-\\1" aria-label="\\2" title="\\2"></span>|)
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>#{Filters.front_wrap}\s*#mac\s*#{Filters.end_wrap}<\/p>/, '<div class="platform-mac">')
5
- html.gsub!(/<p>#{Filters.front_wrap}\s*#windows\s*#{Filters.end_wrap}<\/p>/, '<div class="platform-windows">')
6
- html.gsub!(/<p>#{Filters.front_wrap}\s*#linux\s*#{Filters.end_wrap}<\/p>/, '<div class="platform-linux">')
7
- html.gsub!(/<p>#{Filters.front_wrap}\s*#all\s*#{Filters.end_wrap}<\/p>/, '<div class="platform-all">')
8
- html.gsub!(/<p>#{Filters.front_wrap}\s*\/(mac|windows|linux|all)\s*#{Filters.end_wrap}<\/p>/, '</div>')
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
@@ -4,7 +4,7 @@ module Filters
4
4
  prefix = '<p'
5
5
 
6
6
  text.gsub /\n?``` helper(.+?)```/m do |block|
7
- block.gsub! /^``` helper\s*/, ''
7
+ block.gsub! /^``` helper/, ''
8
8
  block.gsub! /^```$/, ''
9
9
 
10
10
  header = ''
@@ -1,4 +1,4 @@
1
- [[ octicon-cat This is a cat]]
1
+ [[ octicon-cat This is a cat ]]
2
2
 
3
3
  [[ octicon dog This is nothing. ]]
4
4
 
@@ -1,4 +1,4 @@
1
- {{ octicon-cat This is a cat}}
1
+ {{ octicon-cat This is a cat }}
2
2
 
3
3
  {{ octicon dog This is nothing. }}
4
4
 
@@ -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 " title="Settings "></span></a></p>', doc.to_s
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
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-14 00:00:00.000000000 Z
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
@@ -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