extended-markdown-filter 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.md +36 -0
- data/Rakefile +10 -0
- data/extended-markdown-filter.gemspec +22 -0
- data/lib/extended-markdown-filter.rb +53 -0
- data/lib/filters/filters.rb +23 -0
- data/lib/filters/post/admonition.rb +10 -0
- data/lib/filters/post/intro.rb +8 -0
- data/lib/filters/post/os-blocks.rb +11 -0
- data/lib/filters/pre/command-line.rb +15 -0
- data/lib/filters/pre/helper.rb +20 -0
- data/lib/jekyll-override.rb +15 -0
- data/test/fixtures/admonition.md +20 -0
- data/test/fixtures/block_admonition.md +20 -0
- data/test/fixtures/block_intro.md +5 -0
- data/test/fixtures/block_os_blocks.md +23 -0
- data/test/fixtures/command_line.md +5 -0
- data/test/fixtures/helper.md +8 -0
- data/test/fixtures/intro.md +5 -0
- data/test/fixtures/os_blocks.md +23 -0
- data/test/test_extended_markdown_filter.rb +130 -0
- data/test/test_helper.rb +5 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7a84876c5077a91dd3c996a22c2146dda7bcc2d
|
4
|
+
data.tar.gz: 6b34189241a09b08fa663af8f8e5e7c698733464
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 66aa616925154d409791007ac40cf067d3e7b7e53f69bfea81046fabe2c1004be89747c4dde07fc129b0a76ad795da1b3578be7795cb69968e428d349db2069b
|
7
|
+
data.tar.gz: b6a62afa12a8ca3d8df0ce5a079c459ce7ea5e8cf83a2e3a5ea27f15c31a849333d48e2d7aad0009e703e23efbf9f6fd3c4a2f75c3c306ea22e7c57148865f6d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Garen Torikian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
extended-markdown-filter
|
2
|
+
====================
|
3
|
+
|
4
|
+
Extended Markdown filters for the [HTML::Pipeline](https://github.com/jch/html-pipeline).
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/gjtorikian/extended-markdown-filter.svg)](https://travis-ci.org/gjtorikian/extended-markdown-filter)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'extended-markdown-filter'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install extended-markdown-filter
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
The simplest way to do this is
|
25
|
+
|
26
|
+
``` ruby
|
27
|
+
require 'extended-markdown-filter'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then just use the HTML pipeline normally.
|
31
|
+
|
32
|
+
### Within Jekyll
|
33
|
+
|
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
|
+
|
36
|
+
You'll need to pass the context `amf_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.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "extended-markdown-filter"
|
3
|
+
spec.version = "0.2.1"
|
4
|
+
spec.authors = ["Garen Torikian"]
|
5
|
+
spec.email = ["gjtorikian@gmail.com"]
|
6
|
+
spec.summary = %q{Add extended markup syntax to the HTML::Pipeline}
|
7
|
+
spec.description = %q{This is a custom Markdown processor to be used with GitHub's HTML::Pipeline. }
|
8
|
+
spec.homepage = ""
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_dependency 'html-pipeline', "~> 1.0"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.4"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency 'minitest', "~> 5.0"
|
21
|
+
spec.add_development_dependency 'github-markdown', "~> 0.6.3"
|
22
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'html/pipeline'
|
2
|
+
require 'filters/filters'
|
3
|
+
|
4
|
+
Dir[File.join("#{File.expand_path(File.dirname(__FILE__))}", "filters", "pre", "*.rb")].each do |file|
|
5
|
+
require file
|
6
|
+
end
|
7
|
+
|
8
|
+
Dir[File.join("#{File.expand_path(File.dirname(__FILE__))}", "filters", "post", "*.rb")].each do |file|
|
9
|
+
require file
|
10
|
+
end
|
11
|
+
|
12
|
+
class ExtendedMarkdownFilter < HTML::Pipeline::MarkdownFilter
|
13
|
+
include Filters::PreFilter
|
14
|
+
include Filters::PostFilter
|
15
|
+
|
16
|
+
AMF_CURLY_TAGS = %w(intro mac windows linux all tip warning error).join('|')
|
17
|
+
|
18
|
+
def initialize(text, context = nil, result = nil)
|
19
|
+
if defined?(Jekyll) && context[:amf_use_blocks]
|
20
|
+
require 'jekyll-override'
|
21
|
+
end
|
22
|
+
|
23
|
+
if context[:amf_use_blocks]
|
24
|
+
text = self.class.convert_curly_to_bracket(text)
|
25
|
+
end
|
26
|
+
|
27
|
+
Filters.context = context
|
28
|
+
|
29
|
+
# do preprocessing, then call HTML::Pipeline::Markdown
|
30
|
+
format_command_line! text
|
31
|
+
format_helper! text
|
32
|
+
|
33
|
+
super text, context, result
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.convert_curly_to_bracket(text)
|
37
|
+
text = text.gsub(/\{\{\s*#(#{AMF_CURLY_TAGS})\s*\}\}/, '[[#\1]]')
|
38
|
+
text = text.gsub(/\{\{\s*\/(#{AMF_CURLY_TAGS})\s*\}\}/, '[[/\1]]')
|
39
|
+
text
|
40
|
+
end
|
41
|
+
|
42
|
+
def call
|
43
|
+
# initialize HTML::Pipeline::Markdown, then do post-processing
|
44
|
+
html = super
|
45
|
+
|
46
|
+
format_intro! html
|
47
|
+
format_os_blocks! html
|
48
|
+
format_admonition! html
|
49
|
+
|
50
|
+
html
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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[:amf_use_blocks] == true) ? "\\[\\[" : "\{\{"
|
15
|
+
end
|
16
|
+
module_function :front_wrap
|
17
|
+
|
18
|
+
def end_wrap
|
19
|
+
(context[:amf_use_blocks] == true) ? "\\]\\]" : "\}\}"
|
20
|
+
end
|
21
|
+
module_function :end_wrap
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Filters
|
2
|
+
module PostFilter
|
3
|
+
def format_admonition!(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*#warning\s*#{Filters.end_wrap}<\/p>/, '<div class="alert warning">')
|
6
|
+
html.gsub!(/<p>#{Filters.front_wrap}\s*#error\s*#{Filters.end_wrap}<\/p>/, '<div class="alert error">')
|
7
|
+
html.gsub!(/<p>#{Filters.front_wrap}\s*\/(tip|warning|error)\s*#{Filters.end_wrap}<\/p>/, '</div>')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Filters
|
2
|
+
module PostFilter
|
3
|
+
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>')
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Filters
|
2
|
+
module PostFilter
|
3
|
+
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>')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Filters
|
2
|
+
module PreFilter
|
3
|
+
def format_command_line!(text)
|
4
|
+
text.gsub! /\n?``` command-line(.+?)```/m do |block|
|
5
|
+
block.gsub! /^``` command-line/, '<pre class="command-line">'
|
6
|
+
block.gsub! /^```$/, "</pre>\n"
|
7
|
+
block.gsub!(/^\$ (.+)$/) { %Q|<span class="command">#{$1.rstrip}</span>| }
|
8
|
+
block.gsub!(/^(\# .+)$/) { %Q|<span class="comment">#{$1.rstrip}</span>| }
|
9
|
+
block.gsub!(/^> (.+)$/) { %Q|<span class="output"><span># </span>#{$1.rstrip}</span>| }
|
10
|
+
|
11
|
+
block
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Filters
|
2
|
+
module PreFilter
|
3
|
+
def format_helper!(text)
|
4
|
+
text.gsub! /\n?``` helper(.+?)```/m do |block|
|
5
|
+
block.gsub! /^``` helper\s*/, ''
|
6
|
+
block.gsub! /^```$/, ''
|
7
|
+
|
8
|
+
header = ''
|
9
|
+
block.gsub! /^#### (.+?)$/ do
|
10
|
+
header = $1.strip
|
11
|
+
''
|
12
|
+
end
|
13
|
+
|
14
|
+
content = block.strip
|
15
|
+
content = "<p>#{content}</p>" unless content =~ /^<p/
|
16
|
+
content = "<div class='helper'><h4 class='header'><a href='#'>#{header}</a></h4><div class='content'>#{content}</div></div>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Liquid disregards tags it doesn't know,
|
2
|
+
# so rather than define a new format for additions like {{#tip}},
|
3
|
+
# we'll convert them to block form
|
4
|
+
module Jekyll
|
5
|
+
class Page
|
6
|
+
old_render = self.instance_method(:render)
|
7
|
+
|
8
|
+
define_method(:render) do |layouts, site_payload|
|
9
|
+
unless self.content.nil?
|
10
|
+
self.content = ExtendedMarkdownFilter.convert_curly_to_bracket(self.content)
|
11
|
+
end
|
12
|
+
old_render.bind(self).call(layouts, site_payload)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{{#tip}}
|
2
|
+
|
3
|
+
Here's a hot tip: **line one**
|
4
|
+
Here's a hot tip: line two
|
5
|
+
|
6
|
+
{{/tip}}
|
7
|
+
|
8
|
+
{{#warning}}
|
9
|
+
|
10
|
+
Yo, check this out: line one
|
11
|
+
Yo, check this out: line two
|
12
|
+
|
13
|
+
{{/warning}}
|
14
|
+
|
15
|
+
{{#error}}
|
16
|
+
|
17
|
+
Sheeeeit, this is a problem: ~~line one~~
|
18
|
+
Sheeeeit, this is a problem: line two
|
19
|
+
|
20
|
+
{{/error}}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
[[#tip]]
|
2
|
+
|
3
|
+
Here's a hot tip: **line one**
|
4
|
+
Here's a hot tip: line two
|
5
|
+
|
6
|
+
[[/tip]]
|
7
|
+
|
8
|
+
[[#warning]]
|
9
|
+
|
10
|
+
Yo, check this out: line one
|
11
|
+
Yo, check this out: line two
|
12
|
+
|
13
|
+
[[/warning]]
|
14
|
+
|
15
|
+
[[#error]]
|
16
|
+
|
17
|
+
Sheeeeit, this is a problem: ~~line one~~
|
18
|
+
Sheeeeit, this is a problem: line two
|
19
|
+
|
20
|
+
[[/error]]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
[[#mac]]
|
2
|
+
|
3
|
+
1. [Create a new repository](/articles/creating-a-new-repository).
|
4
|
+
|
5
|
+
[[/mac]]
|
6
|
+
|
7
|
+
[[#windows]]
|
8
|
+
|
9
|
+
1. [Try to create a new repository](/articles/creating-a-new-repository).
|
10
|
+
|
11
|
+
[[/windows]]
|
12
|
+
|
13
|
+
[[#linux]]
|
14
|
+
|
15
|
+
1. You *already* know what you're doing.
|
16
|
+
|
17
|
+
[[/linux]]
|
18
|
+
|
19
|
+
[[#all]]
|
20
|
+
|
21
|
+
What?
|
22
|
+
|
23
|
+
[[/all]]
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
``` helper
|
3
|
+
#### A note about Sync in GitHub for Mac
|
4
|
+
|
5
|
+
Those that are already familiar with Git may notice that there are no "Push" or "Pull" buttons in GitHub for Mac.
|
6
|
+
|
7
|
+
Instead of bringing in new changes from the remote copy with one command and pushing your unpublished commits with another, GitHub for Mac uses a single "Sync" button that quickly completes both operations at the same. Behind the scenes, we do the equivalent of a `git pull --rebase` (but make sure to never rewrite merges).
|
8
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{{#mac}}
|
2
|
+
|
3
|
+
1. [Create a new repository](/articles/creating-a-new-repository).
|
4
|
+
|
5
|
+
{{/mac}}
|
6
|
+
|
7
|
+
{{#windows}}
|
8
|
+
|
9
|
+
1. [Try to create a new repository](/articles/creating-a-new-repository).
|
10
|
+
|
11
|
+
{{/windows}}
|
12
|
+
|
13
|
+
{{#linux}}
|
14
|
+
|
15
|
+
1. You *already* know what you're doing.
|
16
|
+
|
17
|
+
{{/linux}}
|
18
|
+
|
19
|
+
{{#all}}
|
20
|
+
|
21
|
+
What?
|
22
|
+
|
23
|
+
{{/all}}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class HTML::Pipeline::ExtendedMarkdownFilterTest < Minitest::Test
|
4
|
+
def fixture(name)
|
5
|
+
File.open(File.join("#{File.expand_path(File.dirname(__FILE__))}", "fixtures", name)).read
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_command_line
|
9
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("command_line.md"), {})
|
10
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
11
|
+
|
12
|
+
assert_equal 1, doc.css('pre').size
|
13
|
+
assert_equal 1, doc.css('span.command').size
|
14
|
+
assert_equal 1, doc.css('span.comment').size
|
15
|
+
assert_equal 2, doc.css('em').size
|
16
|
+
assert_equal 1, doc.css('span.output').size
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_helper
|
20
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("helper.md"), {})
|
21
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
22
|
+
|
23
|
+
assert_equal 1, doc.css('div.helper').size
|
24
|
+
assert_equal 1, doc.css('h4.header').size
|
25
|
+
assert_equal 1, doc.css('a').size
|
26
|
+
assert_equal 1, doc.css('div.content').size
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_intro
|
30
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("intro.md"), {})
|
31
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
32
|
+
|
33
|
+
assert_equal 1, doc.css('div.intro').size
|
34
|
+
assert_equal 1, doc.css('a').size # the inner Markdown converted!
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_block_intro
|
38
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_intro.md"), {:amf_use_blocks => true})
|
39
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
40
|
+
|
41
|
+
assert_equal 1, doc.css('div.intro').size
|
42
|
+
assert_equal 1, doc.css('a').size # the inner Markdown converted!
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_intro_conversion
|
46
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("intro.md"), {:amf_use_blocks => true})
|
47
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
48
|
+
|
49
|
+
assert_equal 1, doc.css('div.intro').size
|
50
|
+
assert_equal 1, doc.css('a').size # the inner Markdown converted!
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_os_blocks
|
54
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("os_blocks.md"), {})
|
55
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
56
|
+
|
57
|
+
assert_equal 1, doc.css('div.platform-mac').size
|
58
|
+
assert_equal 1, doc.css('div.platform-windows').size
|
59
|
+
assert_equal 1, doc.css('div.platform-linux').size
|
60
|
+
assert_equal 1, doc.css('div.platform-all').size
|
61
|
+
# the inner Markdown converted!
|
62
|
+
assert_equal 3, doc.css('ol').size
|
63
|
+
assert_equal 2, doc.css('a').size
|
64
|
+
assert_equal 1, doc.css('em').size
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_block_os_blocks
|
68
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_os_blocks.md"), {:amf_use_blocks => true})
|
69
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
70
|
+
|
71
|
+
assert_equal 1, doc.css('div.platform-mac').size
|
72
|
+
assert_equal 1, doc.css('div.platform-windows').size
|
73
|
+
assert_equal 1, doc.css('div.platform-linux').size
|
74
|
+
assert_equal 1, doc.css('div.platform-all').size
|
75
|
+
# the inner Markdown converted!
|
76
|
+
assert_equal 3, doc.css('ol').size
|
77
|
+
assert_equal 2, doc.css('a').size
|
78
|
+
assert_equal 1, doc.css('em').size
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_block_conversion
|
82
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("os_blocks.md"), {:amf_use_blocks => true})
|
83
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
84
|
+
|
85
|
+
assert_equal 1, doc.css('div.platform-mac').size
|
86
|
+
assert_equal 1, doc.css('div.platform-windows').size
|
87
|
+
assert_equal 1, doc.css('div.platform-linux').size
|
88
|
+
assert_equal 1, doc.css('div.platform-all').size
|
89
|
+
# the inner Markdown converted!
|
90
|
+
assert_equal 3, doc.css('ol').size
|
91
|
+
assert_equal 2, doc.css('a').size
|
92
|
+
assert_equal 1, doc.css('em').size
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_admonition
|
96
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("admonition.md"), {})
|
97
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
98
|
+
|
99
|
+
assert_equal 1, doc.css('div.tip').size
|
100
|
+
assert_equal 1, doc.css('div.warning').size
|
101
|
+
assert_equal 1, doc.css('div.error').size
|
102
|
+
# the inner Markdown converted!
|
103
|
+
assert_equal 1, doc.css('strong').size
|
104
|
+
assert_equal 1, doc.css('del').size
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_block_admonition
|
108
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("block_admonition.md"), {:amf_use_blocks => true})
|
109
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
110
|
+
|
111
|
+
assert_equal 1, doc.css('div.tip').size
|
112
|
+
assert_equal 1, doc.css('div.warning').size
|
113
|
+
assert_equal 1, doc.css('div.error').size
|
114
|
+
# the inner Markdown converted!
|
115
|
+
assert_equal 1, doc.css('strong').size
|
116
|
+
assert_equal 1, doc.css('del').size
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_admonition_conversion
|
120
|
+
doc = ExtendedMarkdownFilter.to_document(fixture("admonition.md"), {:amf_use_blocks => true})
|
121
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
122
|
+
|
123
|
+
assert_equal 1, doc.css('div.tip').size
|
124
|
+
assert_equal 1, doc.css('div.warning').size
|
125
|
+
assert_equal 1, doc.css('div.error').size
|
126
|
+
# the inner Markdown converted!
|
127
|
+
assert_equal 1, doc.css('strong').size
|
128
|
+
assert_equal 1, doc.css('del').size
|
129
|
+
end
|
130
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extended-markdown-filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Garen Torikian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: html-pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: github-markdown
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.6.3
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.6.3
|
83
|
+
description: 'This is a custom Markdown processor to be used with GitHub''s HTML::Pipeline. '
|
84
|
+
email:
|
85
|
+
- gjtorikian@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- extended-markdown-filter.gemspec
|
97
|
+
- lib/extended-markdown-filter.rb
|
98
|
+
- lib/filters/filters.rb
|
99
|
+
- lib/filters/post/admonition.rb
|
100
|
+
- lib/filters/post/intro.rb
|
101
|
+
- lib/filters/post/os-blocks.rb
|
102
|
+
- lib/filters/pre/command-line.rb
|
103
|
+
- lib/filters/pre/helper.rb
|
104
|
+
- lib/jekyll-override.rb
|
105
|
+
- test/fixtures/admonition.md
|
106
|
+
- test/fixtures/block_admonition.md
|
107
|
+
- test/fixtures/block_intro.md
|
108
|
+
- test/fixtures/block_os_blocks.md
|
109
|
+
- test/fixtures/command_line.md
|
110
|
+
- test/fixtures/helper.md
|
111
|
+
- test/fixtures/intro.md
|
112
|
+
- test/fixtures/os_blocks.md
|
113
|
+
- test/test_extended_markdown_filter.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
homepage: ''
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.2.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Add extended markup syntax to the HTML::Pipeline
|
139
|
+
test_files:
|
140
|
+
- test/fixtures/admonition.md
|
141
|
+
- test/fixtures/block_admonition.md
|
142
|
+
- test/fixtures/block_intro.md
|
143
|
+
- test/fixtures/block_os_blocks.md
|
144
|
+
- test/fixtures/command_line.md
|
145
|
+
- test/fixtures/helper.md
|
146
|
+
- test/fixtures/intro.md
|
147
|
+
- test/fixtures/os_blocks.md
|
148
|
+
- test/test_extended_markdown_filter.rb
|
149
|
+
- test/test_helper.rb
|