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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +91 -0
  3. data/Gemfile +10 -0
  4. data/README.adoc +27 -16
  5. data/jekyll-asciidoc.gemspec +31 -0
  6. data/lib/jekyll-asciidoc/compat.rb +7 -2
  7. data/lib/jekyll-asciidoc/converter.rb +61 -9
  8. data/lib/jekyll-asciidoc/filters.rb +1 -1
  9. data/lib/jekyll-asciidoc/integrator.rb +45 -20
  10. data/lib/jekyll-asciidoc/utils.rb +2 -74
  11. data/lib/jekyll-asciidoc/version.rb +1 -1
  12. data/spec/fixtures/alternate_page_attribute_prefix/_config.yml +4 -0
  13. data/spec/fixtures/alternate_page_attribute_prefix/_layouts/default.html +12 -0
  14. data/spec/fixtures/alternate_page_attribute_prefix/explicit-permalink.adoc +4 -0
  15. data/spec/fixtures/attributes_as_array/_config.yml +7 -0
  16. data/spec/fixtures/attributes_as_hash/_config.yml +7 -0
  17. data/spec/fixtures/basic_site/_config.yml +2 -0
  18. data/spec/fixtures/basic_site/_layouts/custom.html +15 -0
  19. data/spec/fixtures/basic_site/_layouts/page.html +15 -0
  20. data/spec/fixtures/basic_site/auto-layout.adoc +4 -0
  21. data/spec/fixtures/basic_site/bare-header.adoc +4 -0
  22. data/spec/fixtures/basic_site/custom-layout.adoc +4 -0
  23. data/spec/fixtures/basic_site/empty-layout.adoc +4 -0
  24. data/spec/fixtures/basic_site/empty-page-attribute.adoc +4 -0
  25. data/spec/fixtures/basic_site/liquid-enabled.adoc +6 -0
  26. data/spec/fixtures/basic_site/nil-layout.adoc +4 -0
  27. data/spec/fixtures/basic_site/no-doctitle.adoc +2 -0
  28. data/spec/fixtures/basic_site/no-liquid.adoc +3 -0
  29. data/spec/fixtures/basic_site/not-published.adoc +4 -0
  30. data/spec/fixtures/basic_site/standalone-a.adoc +4 -0
  31. data/spec/fixtures/basic_site/standalone-b.adoc +4 -0
  32. data/spec/fixtures/basic_site/subdir/page-in-subdir.adoc +7 -0
  33. data/spec/fixtures/basic_site/with-front-matter-header.adoc +6 -0
  34. data/spec/fixtures/basic_site/without-front-matter-header.adoc +3 -0
  35. data/spec/fixtures/blank_page_attribute_prefix/_config.yml +4 -0
  36. data/spec/fixtures/blank_page_attribute_prefix/_layouts/default.html +12 -0
  37. data/spec/fixtures/blank_page_attribute_prefix/explicit-permalink.adoc +4 -0
  38. data/spec/fixtures/default_config/_config.yml +2 -0
  39. data/spec/fixtures/explicit_site_time/_config.yml +4 -0
  40. data/spec/fixtures/explicit_site_time/_layouts/default.html +12 -0
  41. data/spec/fixtures/explicit_site_time/home.adoc +3 -0
  42. data/spec/fixtures/fallback_to_default_layout/_blueprints/blueprint.adoc +3 -0
  43. data/spec/fixtures/fallback_to_default_layout/_config.yml +5 -0
  44. data/spec/fixtures/fallback_to_default_layout/_layouts/default.html +15 -0
  45. data/spec/fixtures/fallback_to_default_layout/_posts/2016-01-01-post.adoc +4 -0
  46. data/spec/fixtures/fallback_to_default_layout/home.adoc +3 -0
  47. data/spec/fixtures/hybrid_config/_config.yml +8 -0
  48. data/spec/fixtures/imagesdir_relative_to_root/_config.yml +5 -0
  49. data/spec/fixtures/include_relative_to_doc/_config.yml +4 -0
  50. data/spec/fixtures/include_relative_to_doc/_layouts/default.html +12 -0
  51. data/spec/fixtures/include_relative_to_doc/about/_people.adoc +2 -0
  52. data/spec/fixtures/include_relative_to_doc/about/index.adoc +13 -0
  53. data/spec/fixtures/include_relative_to_source/_config.yml +4 -0
  54. data/spec/fixtures/include_relative_to_source/_layouts/default.html +12 -0
  55. data/spec/fixtures/include_relative_to_source/about/_people.adoc +2 -0
  56. data/spec/fixtures/include_relative_to_source/about/index.adoc +13 -0
  57. data/spec/fixtures/legacy_config/_config.yml +5 -0
  58. data/spec/fixtures/pygments_code_highlighting/_config.yml +6 -0
  59. data/spec/fixtures/pygments_code_highlighting/_layouts/page.html +13 -0
  60. data/spec/fixtures/pygments_code_highlighting/page-with-code.adoc +16 -0
  61. data/spec/fixtures/read_error/_config.yml +2 -0
  62. data/spec/fixtures/read_error/unreadable.adoc +3 -0
  63. data/spec/fixtures/require_front_matter_header/_config.yml +4 -0
  64. data/spec/fixtures/require_front_matter_header/_layouts/default.html +12 -0
  65. data/spec/fixtures/require_front_matter_header/with-front-matter-header.adoc +5 -0
  66. data/spec/fixtures/require_front_matter_header/without-front-matter-header.adoc +3 -0
  67. data/spec/fixtures/safe_mode/_config.yml +4 -0
  68. data/spec/fixtures/safe_mode/_layouts/home.html +15 -0
  69. data/spec/fixtures/safe_mode/home.adoc +5 -0
  70. data/spec/fixtures/with_custom_collection/_blueprints/blueprint-a.adoc +4 -0
  71. data/spec/fixtures/with_custom_collection/_blueprints/blueprint-b.adoc +10 -0
  72. data/spec/fixtures/with_custom_collection/_config.yml +7 -0
  73. data/spec/fixtures/with_custom_collection/_layouts/blueprint.html +15 -0
  74. data/spec/fixtures/with_custom_collection/_layouts/default.html +15 -0
  75. data/spec/fixtures/with_posts/_config.yml +2 -0
  76. data/spec/fixtures/with_posts/_drafts/a-draft-post.adoc +5 -0
  77. data/spec/fixtures/with_posts/_layouts/custom.html +15 -0
  78. data/spec/fixtures/with_posts/_layouts/post.html +15 -0
  79. data/spec/fixtures/with_posts/_posts/2016-01-01-welcome.adoc +4 -0
  80. data/spec/fixtures/with_posts/_posts/2016-01-02-empty-layout.adoc +4 -0
  81. data/spec/fixtures/with_posts/_posts/2016-01-03-auto-layout.adoc +4 -0
  82. data/spec/fixtures/with_posts/_posts/2016-01-04-custom-layout.adoc +4 -0
  83. data/spec/fixtures/with_posts/_posts/2016-01-05-nil-layout.adoc +4 -0
  84. data/spec/fixtures/with_posts/_posts/2016-02-01-post-with-categories.adoc +4 -0
  85. data/spec/fixtures/with_posts/_posts/2016-03-01-post-with-excerpt.adoc +4 -0
  86. data/spec/fixtures/with_posts/_posts/2016-04-01-show-me-the-title.adoc +4 -0
  87. data/spec/fixtures/with_posts/_posts/2016-05-31-automatic-title.adoc +1 -0
  88. data/spec/fixtures/with_posts/index.html +22 -0
  89. data/spec/fixtures/xhtml_syntax/_config.yml +6 -0
  90. data/spec/fixtures/xhtml_syntax/home.adoc +5 -0
  91. data/spec/fixtures/xhtml_syntax/images/sunset.jpg +0 -0
  92. data/spec/jekyll-asciidoc_spec.rb +880 -0
  93. data/spec/spec_helper.rb +60 -0
  94. 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
- begin # supports Jekyll >= 2.3.0
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
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module AsciiDoc
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -0,0 +1,4 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoc:
4
+ page_attribute_prefix: jekyll-
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }}</title>
6
+ </head>
7
+ <body>
8
+ <div class="page-content">
9
+ {{ content }}
10
+ </div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ = Page With Explicit Permalink
2
+ :jekyll-permalink: /permalink/
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,7 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoctor:
4
+ attributes:
5
+ - icons=font
6
+ - sectanchors
7
+ - table-caption!
@@ -0,0 +1,7 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoctor:
4
+ attributes:
5
+ icons: font
6
+ sectanchors: ''
7
+ table-caption: null
@@ -0,0 +1,2 @@
1
+ gems:
2
+ - jekyll-asciidoc
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }}</title>
6
+ </head>
7
+ <body>
8
+ <div class="page-content">
9
+ {{ content }}
10
+ </div>
11
+ <footer>
12
+ <p>Footer for custom layout.</p>
13
+ </footer>
14
+ </body>
15
+ </html>
@@ -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>
@@ -0,0 +1,4 @@
1
+ = Auto Page Layout
2
+ :page-layout: _auto
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ :page-permalink: /bare/
2
+
3
+ Just content.
4
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ = Custom Layout
2
+ :page-layout: custom
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ = Auto Page Layout
2
+ :page-layout:
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ = Page Title
2
+ :page-attribute-with-empty-value:
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,6 @@
1
+ ---
2
+ liquid: true
3
+ ---
4
+ = Liquid Enabled
5
+
6
+ {{ page.title }}
@@ -0,0 +1,4 @@
1
+ = Nil Page Layout
2
+ :page-layout: ~
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,2 @@
1
+ Just content.
2
+ Lorem ipsum.
@@ -0,0 +1,3 @@
1
+ = No Liquid
2
+
3
+ {{ page.title }}
@@ -0,0 +1,4 @@
1
+ = Not Published
2
+ :page-published: false
3
+
4
+ This page should not be published.
@@ -0,0 +1,4 @@
1
+ = Standalone Page A
2
+ :page-layout!:
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ = Standalone Page B
2
+ :page-layout: false
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,7 @@
1
+ = Page In Subdir
2
+
3
+ Lorem ipsum.
4
+
5
+ * docfile={docfile}
6
+ * docdir={docdir}
7
+ * docname={docname}
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Original Page Title
3
+ ---
4
+ = Page Title
5
+
6
+ Lorem ipsum.
@@ -0,0 +1,3 @@
1
+ = Page Title
2
+
3
+ Lorem ipsum.
@@ -0,0 +1,4 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoc:
4
+ page_attribute_prefix: ~
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }}</title>
6
+ </head>
7
+ <body>
8
+ <div class="page-content">
9
+ {{ content }}
10
+ </div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ = Page With Explicit Permalink
2
+ :permalink: /permalink/
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,2 @@
1
+ gems:
2
+ - jekyll-asciidoc
@@ -0,0 +1,4 @@
1
+ time: 2016-07-04T09:15:00
2
+ timezone: UTC
3
+ gems:
4
+ - jekyll-asciidoc
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }}</title>
6
+ </head>
7
+ <body>
8
+ <div class="page-content">
9
+ {{ content }}
10
+ </div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,3 @@
1
+ = Home Page
2
+
3
+ * localdatetime={localdatetime}
@@ -0,0 +1,5 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ collections:
4
+ blueprints:
5
+ output: true
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>{{ page.title }}</title>
6
+ </head>
7
+ <body>
8
+ <div class="page-content">
9
+ {{ content }}
10
+ </div>
11
+ <footer>
12
+ <p>Footer for default layout.</p>
13
+ </footer>
14
+ </body>
15
+ </html>
@@ -0,0 +1,4 @@
1
+ = Post
2
+ Henry Jekyll
3
+
4
+ Lorem ipsum.
@@ -0,0 +1,3 @@
1
+ = Page
2
+
3
+ Lorem ipsum.
@@ -0,0 +1,8 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoc_ext: adoc
4
+ asciidoc_page_attribute_prefix: jekyll
5
+ asciidoc:
6
+ processor: asciidoctor
7
+ ext: asciidoc,adoc
8
+ page_attribute_prefix: pg
@@ -0,0 +1,5 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoctor:
4
+ attributes:
5
+ imagesdir: /images
@@ -0,0 +1,4 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoctor:
4
+ base_dir: :docdir
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ page.title }}</title>
5
+ </head>
6
+ <body>
7
+ <div class="page-content">
8
+ {{ content }}
9
+ </div>
10
+ </body>
11
+ </html>
12
+
@@ -0,0 +1,2 @@
1
+ * Doc Writer
2
+ * Word Smith
@@ -0,0 +1,13 @@
1
+ = About Us
2
+
3
+ We provide content design services for open source tech companies.
4
+
5
+ * docfile={docfile}
6
+ * docdir={docdir}
7
+ * outfile={outfile}
8
+ * outdir={outdir}
9
+ * outpath={outpath}
10
+
11
+ == Our Team
12
+
13
+ include::_people.adoc[]
@@ -0,0 +1,4 @@
1
+ gems:
2
+ - jekyll-asciidoc
3
+ asciidoctor:
4
+ base_dir: :source
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ page.title }}</title>
5
+ </head>
6
+ <body>
7
+ <div class="page-content">
8
+ {{ content }}
9
+ </div>
10
+ </body>
11
+ </html>
12
+
@@ -0,0 +1,2 @@
1
+ * Doc Writer
2
+ * Word Smith
@@ -0,0 +1,13 @@
1
+ = About Us
2
+
3
+ We provide content design services for open source tech companies.
4
+
5
+ * docfile={docfile}
6
+ * docdir={docdir}
7
+ * outfile={outfile}
8
+ * outdir={outdir}
9
+ * outpath={outpath}
10
+
11
+ == Our Team
12
+
13
+ include::about/_people.adoc[]