jekyll-asciidoc 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +91 -0
- data/Gemfile +10 -0
- data/README.adoc +27 -16
- data/jekyll-asciidoc.gemspec +31 -0
- data/lib/jekyll-asciidoc/compat.rb +7 -2
- data/lib/jekyll-asciidoc/converter.rb +61 -9
- data/lib/jekyll-asciidoc/filters.rb +1 -1
- data/lib/jekyll-asciidoc/integrator.rb +45 -20
- data/lib/jekyll-asciidoc/utils.rb +2 -74
- data/lib/jekyll-asciidoc/version.rb +1 -1
- data/spec/fixtures/alternate_page_attribute_prefix/_config.yml +4 -0
- data/spec/fixtures/alternate_page_attribute_prefix/_layouts/default.html +12 -0
- data/spec/fixtures/alternate_page_attribute_prefix/explicit-permalink.adoc +4 -0
- data/spec/fixtures/attributes_as_array/_config.yml +7 -0
- data/spec/fixtures/attributes_as_hash/_config.yml +7 -0
- data/spec/fixtures/basic_site/_config.yml +2 -0
- data/spec/fixtures/basic_site/_layouts/custom.html +15 -0
- data/spec/fixtures/basic_site/_layouts/page.html +15 -0
- data/spec/fixtures/basic_site/auto-layout.adoc +4 -0
- data/spec/fixtures/basic_site/bare-header.adoc +4 -0
- data/spec/fixtures/basic_site/custom-layout.adoc +4 -0
- data/spec/fixtures/basic_site/empty-layout.adoc +4 -0
- data/spec/fixtures/basic_site/empty-page-attribute.adoc +4 -0
- data/spec/fixtures/basic_site/liquid-enabled.adoc +6 -0
- data/spec/fixtures/basic_site/nil-layout.adoc +4 -0
- data/spec/fixtures/basic_site/no-doctitle.adoc +2 -0
- data/spec/fixtures/basic_site/no-liquid.adoc +3 -0
- data/spec/fixtures/basic_site/not-published.adoc +4 -0
- data/spec/fixtures/basic_site/standalone-a.adoc +4 -0
- data/spec/fixtures/basic_site/standalone-b.adoc +4 -0
- data/spec/fixtures/basic_site/subdir/page-in-subdir.adoc +7 -0
- data/spec/fixtures/basic_site/with-front-matter-header.adoc +6 -0
- data/spec/fixtures/basic_site/without-front-matter-header.adoc +3 -0
- data/spec/fixtures/blank_page_attribute_prefix/_config.yml +4 -0
- data/spec/fixtures/blank_page_attribute_prefix/_layouts/default.html +12 -0
- data/spec/fixtures/blank_page_attribute_prefix/explicit-permalink.adoc +4 -0
- data/spec/fixtures/default_config/_config.yml +2 -0
- data/spec/fixtures/explicit_site_time/_config.yml +4 -0
- data/spec/fixtures/explicit_site_time/_layouts/default.html +12 -0
- data/spec/fixtures/explicit_site_time/home.adoc +3 -0
- data/spec/fixtures/fallback_to_default_layout/_blueprints/blueprint.adoc +3 -0
- data/spec/fixtures/fallback_to_default_layout/_config.yml +5 -0
- data/spec/fixtures/fallback_to_default_layout/_layouts/default.html +15 -0
- data/spec/fixtures/fallback_to_default_layout/_posts/2016-01-01-post.adoc +4 -0
- data/spec/fixtures/fallback_to_default_layout/home.adoc +3 -0
- data/spec/fixtures/hybrid_config/_config.yml +8 -0
- data/spec/fixtures/imagesdir_relative_to_root/_config.yml +5 -0
- data/spec/fixtures/include_relative_to_doc/_config.yml +4 -0
- data/spec/fixtures/include_relative_to_doc/_layouts/default.html +12 -0
- data/spec/fixtures/include_relative_to_doc/about/_people.adoc +2 -0
- data/spec/fixtures/include_relative_to_doc/about/index.adoc +13 -0
- data/spec/fixtures/include_relative_to_source/_config.yml +4 -0
- data/spec/fixtures/include_relative_to_source/_layouts/default.html +12 -0
- data/spec/fixtures/include_relative_to_source/about/_people.adoc +2 -0
- data/spec/fixtures/include_relative_to_source/about/index.adoc +13 -0
- data/spec/fixtures/legacy_config/_config.yml +5 -0
- data/spec/fixtures/pygments_code_highlighting/_config.yml +6 -0
- data/spec/fixtures/pygments_code_highlighting/_layouts/page.html +13 -0
- data/spec/fixtures/pygments_code_highlighting/page-with-code.adoc +16 -0
- data/spec/fixtures/read_error/_config.yml +2 -0
- data/spec/fixtures/read_error/unreadable.adoc +3 -0
- data/spec/fixtures/require_front_matter_header/_config.yml +4 -0
- data/spec/fixtures/require_front_matter_header/_layouts/default.html +12 -0
- data/spec/fixtures/require_front_matter_header/with-front-matter-header.adoc +5 -0
- data/spec/fixtures/require_front_matter_header/without-front-matter-header.adoc +3 -0
- data/spec/fixtures/safe_mode/_config.yml +4 -0
- data/spec/fixtures/safe_mode/_layouts/home.html +15 -0
- data/spec/fixtures/safe_mode/home.adoc +5 -0
- data/spec/fixtures/with_custom_collection/_blueprints/blueprint-a.adoc +4 -0
- data/spec/fixtures/with_custom_collection/_blueprints/blueprint-b.adoc +10 -0
- data/spec/fixtures/with_custom_collection/_config.yml +7 -0
- data/spec/fixtures/with_custom_collection/_layouts/blueprint.html +15 -0
- data/spec/fixtures/with_custom_collection/_layouts/default.html +15 -0
- data/spec/fixtures/with_posts/_config.yml +2 -0
- data/spec/fixtures/with_posts/_drafts/a-draft-post.adoc +5 -0
- data/spec/fixtures/with_posts/_layouts/custom.html +15 -0
- data/spec/fixtures/with_posts/_layouts/post.html +15 -0
- data/spec/fixtures/with_posts/_posts/2016-01-01-welcome.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-01-02-empty-layout.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-01-03-auto-layout.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-01-04-custom-layout.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-01-05-nil-layout.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-02-01-post-with-categories.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-03-01-post-with-excerpt.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-04-01-show-me-the-title.adoc +4 -0
- data/spec/fixtures/with_posts/_posts/2016-05-31-automatic-title.adoc +1 -0
- data/spec/fixtures/with_posts/index.html +22 -0
- data/spec/fixtures/xhtml_syntax/_config.yml +6 -0
- data/spec/fixtures/xhtml_syntax/home.adoc +5 -0
- data/spec/fixtures/xhtml_syntax/images/sunset.jpg +0 -0
- data/spec/jekyll-asciidoc_spec.rb +880 -0
- data/spec/spec_helper.rb +60 -0
- metadata +171 -3
@@ -1,86 +1,14 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module AsciiDoc
|
3
3
|
module Utils; extend self
|
4
|
+
MessageTopic = 'Jekyll AsciiDoc:'
|
4
5
|
NewLine = %(\n)
|
5
|
-
StandaloneOptionLine = %([%standalone]#{NewLine})
|
6
|
-
AttributeReferenceRx = /\\?\{(\w+(?:[\-]\w+)*)\}/
|
7
6
|
|
8
7
|
def has_front_matter? dlg_method, asciidoc_ext_re, path
|
9
8
|
(::File.extname path) =~ asciidoc_ext_re ? true : (dlg_method.call path)
|
10
9
|
end
|
11
10
|
|
12
|
-
|
13
|
-
define_method :has_yaml_header?, &(::Jekyll::Utils.method :has_yaml_header?)
|
14
|
-
rescue ::NameError; end
|
15
|
-
|
16
|
-
def hashify_attributes attrs, initial = {}
|
17
|
-
if (is_array = ::Array === attrs) || ::Hash === attrs
|
18
|
-
attrs.each_with_object(initial) {|entry, new_attrs|
|
19
|
-
key, val = is_array ? ((entry.split '=', 2) + ['', ''])[0..1] : entry
|
20
|
-
if key.start_with? '!'
|
21
|
-
new_attrs[key[1..-1]] = nil
|
22
|
-
elsif key.end_with? '!'
|
23
|
-
new_attrs[key.chop] = nil
|
24
|
-
else
|
25
|
-
new_attrs[key] = val ? (resolve_attribute_refs val, new_attrs) : nil
|
26
|
-
end
|
27
|
-
}
|
28
|
-
else
|
29
|
-
initial
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def resolve_attribute_refs text, table
|
34
|
-
if text.empty?
|
35
|
-
text
|
36
|
-
elsif text.include? '{'
|
37
|
-
text.gsub AttributeReferenceRx do
|
38
|
-
if $&.start_with? '\\'
|
39
|
-
$&[1..-1]
|
40
|
-
elsif (value = table[$1])
|
41
|
-
value
|
42
|
-
else
|
43
|
-
$&
|
44
|
-
end
|
45
|
-
end
|
46
|
-
else
|
47
|
-
text
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def symbolize_keys hash
|
52
|
-
hash.each_with_object({}) {|(key, val), accum| accum[key.to_sym] = val }
|
53
|
-
end
|
54
|
-
|
55
|
-
def get_converter site
|
56
|
-
site.find_converter_instance Converter
|
57
|
-
end
|
58
|
-
|
59
|
-
# Parse the specified value as though it is a single-line value part of a
|
60
|
-
# YAML key/value pair.
|
61
|
-
#
|
62
|
-
# Attempt to parse the specified String value as though it is a
|
63
|
-
# single-line value part of a YAML key/value pair. If the value fails to
|
64
|
-
# parse, wrap the value in single quotes (after escaping any single
|
65
|
-
# quotes in the value) and parse it as a character sequence. If the value
|
66
|
-
# is empty, return an empty String.
|
67
|
-
#
|
68
|
-
# val - The String value to parse.
|
69
|
-
#
|
70
|
-
# Returns an [Object] parsed from the string-based YAML value or empty
|
71
|
-
# [String] if the specified value is empty.
|
72
|
-
def parse_yaml_value val
|
73
|
-
if val.empty?
|
74
|
-
''
|
75
|
-
else
|
76
|
-
begin
|
77
|
-
::SafeYAML.load %(--- #{val})
|
78
|
-
rescue
|
79
|
-
val = val.gsub '\'', '\'\'' if val.include? '\''
|
80
|
-
::SafeYAML.load %(--- \'#{val}\')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
11
|
+
define_method :has_yaml_header?, &(::Jekyll::Utils.method :has_yaml_header?)
|
84
12
|
end
|
85
13
|
end
|
86
14
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>{% if page.title %}{{ page.title }}{% else %}Site Title{% endif %}</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div class="page-content">
|
9
|
+
{{ content }}
|
10
|
+
</div>
|
11
|
+
<footer>
|
12
|
+
<p>Footer for page layout.</p>
|
13
|
+
</footer>
|
14
|
+
</body>
|
15
|
+
</html>
|