html-pipeline-asciidoc_filter 0.1.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +12 -9
- data/examples/Gemfile +12 -0
- data/examples/example.rb +47 -0
- data/html-pipeline-asciidoc_filter.gemspec +6 -13
- data/lib/html/pipeline/asciidoc_filter.rb +2 -5
- data/lib/html/pipeline/asciidoc_filter/version.rb +1 -1
- data/test/asciidoc_filter_test.rb +16 -1
- data/test/test_helper.rb +2 -24
- metadata +12 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5901d9931bfbdf81b3bab66bd246019233e70fc0
|
4
|
+
data.tar.gz: 9aa593c80be0c7b19be53afd38be83af70f522a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 623ab2f5ada3e0ce8de5b96c87f0c11a6ebe436954163beca85029991b72b15da0a0eec5ce42945431bcecbd4644f669f83b4b4be336a68be2c917df85d4cc92
|
7
|
+
data.tar.gz: 403757cdfdc92971bff5d9839f5f51d961fcd2271c0dc1d81a252d8fc1de5052afced57bdd1d4df044c20806efeb00b3fe789a88373724fcdfc6f7016d92811d
|
data/README.adoc
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
= AsciiDoc filter for html-pipeline
|
2
2
|
Dan Allen
|
3
|
-
ifndef::safe-mode-name[]
|
4
|
-
|
5
|
-
[float]
|
6
|
-
= AsciiDoc filter for html-pipeline
|
7
|
-
endif::safe-mode-name[]
|
8
3
|
|
9
4
|
https://rubygems.org/gems/html-pipeline-asciidoc_filter[html-pipeline-asciidoc_filter] is an AsciiDoc processing filter for https://github.com/jch/html-pipeline[html-pipeline] based on https://asciidoctor.org[Asciidoctor].
|
10
5
|
|
@@ -67,12 +62,20 @@ puts pipeline.call(input)[:output]
|
|
67
62
|
|
68
63
|
== Note about dependencies
|
69
64
|
|
70
|
-
You'll need the following
|
65
|
+
You'll need the following dependencies in your Gemfile which aren't declared by +html-pipeline+ or this filter.
|
71
66
|
|
67
|
+
.Gemfile
|
72
68
|
[source,ruby]
|
73
69
|
----
|
74
|
-
gem '
|
75
|
-
|
70
|
+
gem 'html-pipeline-asciidoc_filter'
|
71
|
+
# gemoji needed for EmojiFilter
|
72
|
+
gem 'gemoji', '~> 1.0'
|
73
|
+
# rinku needed for AutolinkFilter
|
74
|
+
gem 'rinku', '~> 1.7'
|
75
|
+
# sanitize needed for Sanitization Filter
|
76
|
+
gem 'sanitize', '~> 2.0'
|
77
|
+
# github-linguist needed for SyntaxHighlightFilter
|
78
|
+
gem 'github-linguist', (RUBY_VERSION < '2.1.0' ? '~> 2.6.2', '~> 2.10')
|
76
79
|
----
|
77
80
|
|
78
81
|
== TODO
|
@@ -84,7 +87,7 @@ gem 'github-linguist', '~> 1.2.6'
|
|
84
87
|
|
85
88
|
== Copyright and License
|
86
89
|
|
87
|
-
Copyright (C)
|
90
|
+
Copyright (C) 2014 Dan Allen
|
88
91
|
Free use of this software is granted under the terms of the MIT License.
|
89
92
|
|
90
93
|
See the {license}[LICENSE] file for details.
|
data/examples/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'html-pipeline', '1.9.0'
|
4
|
+
gem 'asciidoctor', '0.1.4'
|
5
|
+
gem 'gemoji', '~> 1.0'
|
6
|
+
gem 'rinku', '~> 1.7'
|
7
|
+
gem 'sanitize', '~> 2.0'
|
8
|
+
if RUBY_VERSION < '2.1.0'
|
9
|
+
gem 'github-linguist', '~> 2.6.2'
|
10
|
+
else
|
11
|
+
gem 'github-linguist', '~> 2.10'
|
12
|
+
end
|
data/examples/example.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'html/pipeline'
|
2
|
+
require_relative '../lib/html/pipeline/asciidoc_filter'
|
3
|
+
|
4
|
+
filters = [
|
5
|
+
HTML::Pipeline::AsciiDocFilter,
|
6
|
+
HTML::Pipeline::SanitizationFilter,
|
7
|
+
HTML::Pipeline::ImageMaxWidthFilter,
|
8
|
+
HTML::Pipeline::EmojiFilter,
|
9
|
+
HTML::Pipeline::MentionFilter,
|
10
|
+
HTML::Pipeline::AutolinkFilter,
|
11
|
+
HTML::Pipeline::TableOfContentsFilter,
|
12
|
+
HTML::Pipeline::SyntaxHighlightFilter
|
13
|
+
]
|
14
|
+
|
15
|
+
context = {
|
16
|
+
:asset_root => 'https://github.global.ssl.fastly.net/images/icons/emoji'
|
17
|
+
}
|
18
|
+
|
19
|
+
pipeline = HTML::Pipeline.new filters, context
|
20
|
+
pipeline.setup_instrumentation
|
21
|
+
|
22
|
+
input = <<-EOS
|
23
|
+
= Sample Document
|
24
|
+
Author Name
|
25
|
+
|
26
|
+
Preamble paragraph.
|
27
|
+
|
28
|
+
== Sample Section
|
29
|
+
|
30
|
+
Section content.
|
31
|
+
|
32
|
+
.GitHub usernames
|
33
|
+
- @jch
|
34
|
+
- @rtomayko
|
35
|
+
- @mojavelinux
|
36
|
+
|
37
|
+
[source,ruby]
|
38
|
+
--
|
39
|
+
require 'asciidoctor'
|
40
|
+
|
41
|
+
puts Asciidoctor.render('This filter brought to you by http://asciidoctor.org[Asciidoctor].')
|
42
|
+
--
|
43
|
+
|
44
|
+
:shipit:
|
45
|
+
EOS
|
46
|
+
|
47
|
+
puts pipeline.call(input)[:output]
|
@@ -7,23 +7,16 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.version = HTML_Pipeline::AsciiDocFilter::VERSION
|
8
8
|
gem.authors = ['Dan Allen']
|
9
9
|
gem.email = ['dan.j.allen@gmail.com']
|
10
|
-
gem.summary =
|
11
|
-
gem.description =
|
10
|
+
gem.summary = 'An AsciiDoc processing filter for html-pipeline powered by Asciidoctor'
|
11
|
+
gem.description = 'An AsciiDoc processing filter for html-pipeline powered by Asciidoctor'
|
12
12
|
gem.homepage = 'https://github.com/asciidoctor/html-pipeline-asciidoc_filter'
|
13
13
|
gem.license = 'MIT'
|
14
14
|
|
15
15
|
gem.files = `git ls-files -z -- */* {README,LICENSE}* *.gemspec`.split("\0")
|
16
|
-
gem.executables = gem.files.grep(
|
17
|
-
gem.test_files = gem.files.grep(
|
16
|
+
gem.executables = gem.files.grep(/^bin\//) { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(/^test\//)
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency 'html-pipeline', '~> 0
|
21
|
-
gem.add_dependency 'asciidoctor', '
|
22
|
-
|
23
|
-
# activesupport should be a dependency of html-pipeline; cannot it load html-pipeline without it
|
24
|
-
gem.add_development_dependency 'activesupport', RUBY_VERSION < '1.9.3' ? ['>= 2', '< 4'] : '>= 2'
|
25
|
-
|
26
|
-
gem.add_development_dependency 'bundler', '~> 1.3'
|
27
|
-
gem.add_development_dependency 'rake'
|
28
|
-
gem.add_development_dependency 'github-linguist', '~> 2.6.2'
|
20
|
+
gem.add_dependency 'html-pipeline', '~> 1.9.0'
|
21
|
+
gem.add_dependency 'asciidoctor', '~> 1.5.0'
|
29
22
|
end
|
@@ -3,7 +3,6 @@ require 'html/pipeline/filter'
|
|
3
3
|
require 'html/pipeline/text_filter'
|
4
4
|
|
5
5
|
class HTML::Pipeline
|
6
|
-
|
7
6
|
# HTML Filter that converts AsciiDoc text into HTML.
|
8
7
|
#
|
9
8
|
# This filter is different from most in that it can take a non-HTML as
|
@@ -52,7 +51,7 @@ class HTML::Pipeline
|
|
52
51
|
# [source,ruby]
|
53
52
|
# --
|
54
53
|
# require 'asciidoctor'
|
55
|
-
# puts Asciidoctor.
|
54
|
+
# puts Asciidoctor.convert('This filter brought to you by http://asciidoctor.org[Asciidoctor].')
|
56
55
|
# --
|
57
56
|
#
|
58
57
|
# :shipit:
|
@@ -67,9 +66,7 @@ class HTML::Pipeline
|
|
67
66
|
|
68
67
|
# Convert AsciiDoc to HTML using Asciidoctor
|
69
68
|
def call
|
70
|
-
Asciidoctor.
|
69
|
+
Asciidoctor.convert @text, :safe => :secure, :attributes => %w(showtitle=@ idprefix= idseparator=- env=github env-github source-highlighter=html-pipeline)
|
71
70
|
end
|
72
|
-
|
73
71
|
end
|
74
|
-
|
75
72
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'html/pipeline/asciidoc_filter'
|
3
3
|
|
4
|
-
class HTML::Pipeline::AsciiDocFilterTest < Test
|
4
|
+
class HTML::Pipeline::AsciiDocFilterTest < Minitest::Test
|
5
5
|
|
6
6
|
AsciiDocFilter = HTML::Pipeline::AsciiDocFilter
|
7
7
|
|
@@ -17,6 +17,14 @@ Paragraph in preamble
|
|
17
17
|
Paragraph in section
|
18
18
|
EOS
|
19
19
|
|
20
|
+
@hidden_doctitle_example = <<-EOS
|
21
|
+
= Sample Document
|
22
|
+
Author Name
|
23
|
+
:showtitle!:
|
24
|
+
|
25
|
+
Paragraph content
|
26
|
+
EOS
|
27
|
+
|
20
28
|
@source_code_example = <<-EOS
|
21
29
|
```ruby
|
22
30
|
def hello()
|
@@ -34,6 +42,13 @@ end
|
|
34
42
|
assert_equal 1, doc.css('h2#sample-section').size
|
35
43
|
end
|
36
44
|
|
45
|
+
def test_for_hidden_document_title
|
46
|
+
doc = AsciiDocFilter.to_document(@hidden_doctitle_example)
|
47
|
+
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
48
|
+
assert_equal 0, doc.css('h1').size
|
49
|
+
assert_equal 1, doc.css('.paragraph p').size
|
50
|
+
end
|
51
|
+
|
37
52
|
def test_for_lang_attribute_on_source_code_block
|
38
53
|
doc = AsciiDocFilter.to_document(@source_code_example)
|
39
54
|
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
data/test/test_helper.rb
CHANGED
@@ -1,30 +1,8 @@
|
|
1
1
|
require 'html/pipeline'
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
require 'active_support/core_ext/object/try'
|
4
4
|
|
5
5
|
module TestHelpers
|
6
|
-
# Asserts that `needle` is not a member of `haystack`, where
|
7
|
-
# `haystack` is any object that responds to `include?`.
|
8
|
-
def assert_doesnt_include(needle, haystack, message = nil)
|
9
|
-
error = '<?> included in <?>'
|
10
|
-
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
|
11
|
-
|
12
|
-
assert_block message do
|
13
|
-
!haystack.include?(needle)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Asserts that `needle` is a member of `haystack`, where
|
18
|
-
# `haystack` is any object that responds to `include?`.
|
19
|
-
def assert_includes(needle, haystack, message = nil)
|
20
|
-
error = '<?> not included in <?>'
|
21
|
-
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
|
22
|
-
|
23
|
-
assert_block message do
|
24
|
-
haystack.include?(needle)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
6
|
# Asserts that two html fragments are equivalent. Attribute order
|
29
7
|
# will be ignored.
|
30
8
|
def assert_equal_html(expected, actual)
|
@@ -33,4 +11,4 @@ module TestHelpers
|
|
33
11
|
end
|
34
12
|
end
|
35
13
|
|
36
|
-
Test
|
14
|
+
Minitest::Test.send(:include, TestHelpers)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-asciidoc_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|
@@ -16,85 +16,29 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.9.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.9.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: asciidoctor
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.4
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.4
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.3'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.3'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: github-linguist
|
85
29
|
requirement: !ruby/object:Gem::Requirement
|
86
30
|
requirements:
|
87
31
|
- - ~>
|
88
32
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
type: :
|
33
|
+
version: 1.5.0
|
34
|
+
type: :runtime
|
91
35
|
prerelease: false
|
92
36
|
version_requirements: !ruby/object:Gem::Requirement
|
93
37
|
requirements:
|
94
38
|
- - ~>
|
95
39
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
description: An AsciiDoc filter for html-pipeline
|
40
|
+
version: 1.5.0
|
41
|
+
description: An AsciiDoc processing filter for html-pipeline powered by Asciidoctor
|
98
42
|
email:
|
99
43
|
- dan.j.allen@gmail.com
|
100
44
|
executables: []
|
@@ -103,6 +47,8 @@ extra_rdoc_files: []
|
|
103
47
|
files:
|
104
48
|
- LICENSE
|
105
49
|
- README.adoc
|
50
|
+
- examples/Gemfile
|
51
|
+
- examples/example.rb
|
106
52
|
- html-pipeline-asciidoc_filter.gemspec
|
107
53
|
- lib/html/pipeline/asciidoc_filter.rb
|
108
54
|
- lib/html/pipeline/asciidoc_filter/version.rb
|
@@ -128,10 +74,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
74
|
version: '0'
|
129
75
|
requirements: []
|
130
76
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.2.2
|
132
78
|
signing_key:
|
133
79
|
specification_version: 4
|
134
|
-
summary: An AsciiDoc filter for html-pipeline
|
80
|
+
summary: An AsciiDoc processing filter for html-pipeline powered by Asciidoctor
|
135
81
|
test_files:
|
136
82
|
- test/asciidoc_filter_test.rb
|
137
83
|
- test/test_helper.rb
|