jekyll-asciidoc 3.0.0.beta.1 → 3.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df9c038b47a511b9b26c4c9e8f585f5d6e89b747f47cfa09f2e257edb26e73bf
4
- data.tar.gz: 86591c6545adce1715f2f3afd5032671748e33013ccc567599bd0362101ae9aa
3
+ metadata.gz: 6b2a064cf1ceff4378a24a1d48ce6249bcd33a686b1a1392c2255adf95c00cbc
4
+ data.tar.gz: e72bda16edd69136e9a73b1c0ccfc3767a4bf07d887f1fcee9947cd875abd3dd
5
5
  SHA512:
6
- metadata.gz: 5afb33673bed24e8448ab7cb4def0a6cb3606c9bdc0d69ac6dac15c374f6aa17de50a765416447699486765c5ffefaf9b5323c0e1af282e64f08956c001fbeef
7
- data.tar.gz: 7d5dbf5562d3c260555947dc264287693f5bedcf36e51e0fa63a93875013bce949f9545ddf7d318ce6485e86bae01dd2587f917ac87b00868c4da1edc7a60cb2
6
+ metadata.gz: 35f25b4477a7e9d721551738e91914ae30a5de1860a9b64908583fe9f0700a16bc40d0fb2764b446fd56196c60b818304eb76248fc9f96aaaeccbb35caa5ba3a
7
+ data.tar.gz: f59b45c2c182f9f4029e5ed711a675f31ce7c9b491ef075c28772b50e6a972585167ee1d4159ca158dac00ce3f4c09e0d1b34af73594682ff6aa539fcb354c74
@@ -0,0 +1,11 @@
1
+ --charset UTF-8
2
+ --readme README.adoc
3
+ --no-private
4
+ --hide-api private
5
+ --title "Jekyll AsciiDoc API Docs"
6
+ --output-dir apidoc
7
+ --exclude /(?:core|jekyll)_ext/
8
+ lib/**/*.rb
9
+ -
10
+ CHANGELOG.adoc
11
+ LICENSE.adoc
@@ -1,9 +1,17 @@
1
1
  = {project-name} Changelog
2
2
  :project-name: Jekyll AsciiDoc Plugin
3
- :uri-repo: https://github.com/asciidoctor/jekyll-asciidoc
3
+ :url-repo: https://github.com/asciidoctor/jekyll-asciidoc
4
4
 
5
5
  This document provides a high-level view of the changes to the {project-name} by release.
6
- For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
6
+ For a detailed view of what has changed, refer to the {url-repo}/commits/master[commit history] on GitHub.
7
+
8
+ == 3.0.0.beta.2 (2019-06-03) - @mojavelinux
9
+
10
+ * allow site-wide AsciiDoc attributes to also be defined on `asciidoc` key in site configuration (#126)
11
+ * set date page variable from revdate for any document in a collection (posts or otherwise) (#202)
12
+ * allow non-ASCII word character to be used in name of attribute reference in config file
13
+ * use File.write instead of IO.write (as IO.write has extra magic we don't need)
14
+ * auto-generate excerpts for posts and documents written in AsciiDoc (#200)
7
15
 
8
16
  == 3.0.0.beta.1 (2018-12-29) - @mojavelinux
9
17
 
@@ -98,15 +106,15 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
98
106
  * Document how to use plugin with GitLab Pages (#47)
99
107
  * Document `asciidocify` Liquid filter
100
108
 
101
- {uri-repo}/issues?q=milestone%3Av2.0.0[issues resolved] |
102
- {uri-repo}/releases/tag/v2.0.0[git tag]
109
+ {url-repo}/issues?q=milestone%3Av2.0.0[issues resolved] |
110
+ {url-repo}/releases/tag/v2.0.0[git tag]
103
111
 
104
112
  == 1.1.2 (2016-05-10) - @mkobit
105
113
 
106
114
  * Apply fix for documents that did not contain at least one attribute beginning with `page-` (#60)
107
115
 
108
- {uri-repo}/issues?q=milestone%3Av1.1.2[issues resolved] |
109
- {uri-repo}/releases/tag/v1.1.2[git tag]
116
+ {url-repo}/issues?q=milestone%3Av1.1.2[issues resolved] |
117
+ {url-repo}/releases/tag/v1.1.2[git tag]
110
118
 
111
119
  == 1.1.1 (2016-05-07) - @mkobit
112
120
 
@@ -119,8 +127,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
119
127
  * Only configure the Asciidoctor options once (previously it was being called twice in serve mode)
120
128
  * Set `env` attribute to `site` instead of `jekyll` (#55)
121
129
 
122
- {uri-repo}/issues?q=milestone%3Av1.1.1[issues resolved] |
123
- {uri-repo}/releases/tag/v1.1.1[git tag]
130
+ {url-repo}/issues?q=milestone%3Av1.1.1[issues resolved] |
131
+ {url-repo}/releases/tag/v1.1.1[git tag]
124
132
 
125
133
  == 1.0.1 (2016-03-19) - @mkobit
126
134
 
@@ -131,12 +139,12 @@ It is still compatible with Jekyll 2.
131
139
  * Documentation and onboarding improvements (#25, #24)
132
140
  * Improvements to release process (#28)
133
141
 
134
- {uri-repo}/issues?q=milestone%3Av1.0.1[issues resolved] |
135
- {uri-repo}/releases/tag/v1.0.1[git tag]
142
+ {url-repo}/issues?q=milestone%3Av1.0.1[issues resolved] |
143
+ {url-repo}/releases/tag/v1.0.1[git tag]
136
144
 
137
145
  == 1.0.0 (2015-01-04) - @paulrayner
138
146
 
139
147
  Initial release.
140
148
 
141
- {uri-repo}/issues?q=milestone%3Av1.0.0[issues resolved] |
142
- {uri-repo}/releases/tag/v1.0.0[git tag]
149
+ {url-repo}/issues?q=milestone%3Av1.0.0[issues resolved] |
150
+ {url-repo}/releases/tag/v1.0.0[git tag]
data/Gemfile CHANGED
@@ -1,8 +1,12 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
3
4
 
5
+ gem 'asciidoctor', ENV['ASCIIDOCTOR_VERSION'], require: false if ENV.key? 'ASCIIDOCTOR_VERSION'
4
6
  gem 'jekyll', %(~> #{ENV['JEKYLL_VERSION']}), require: false if ENV.key? 'JEKYLL_VERSION'
5
- gem 'pygments.rb', '~> 1.2.1', require: false
6
- gem 'rubocop', '~> 0.61.1', require: false
7
7
  # NOTE Windows does not include zoneinfo files, so load tzinfo-data gem
8
8
  gem 'tzinfo-data', platform: [:x64_mingw, :mingw], require: false
9
+
10
+ group :docs do
11
+ gem 'yard', require: false
12
+ end
@@ -1,6 +1,6 @@
1
1
  = Jekyll AsciiDoc Plugin (powered by Asciidoctor)
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Paul Rayner <https://github.com/paulrayner[@paulrayner]>
3
- v3.0.0.beta.1, 2018-12-29
3
+ v3.0.0.beta.2, 2019-06-03
4
4
  // Settings:
5
5
  :idprefix:
6
6
  :idseparator: -
@@ -24,53 +24,53 @@ endif::[]
24
24
  :conum-guard: {sp}
25
25
  ifndef::icons[:conum-guard: {sp}#{sp}]
26
26
  // URIs:
27
- :uri-repo: https://github.com/asciidoctor/jekyll-asciidoc
28
- :uri-issues: {uri-repo}/issues
29
- :uri-search-issues: {uri-repo}/search?type=Issues
30
- :uri-chat: https://gitter.im/asciidoctor/asciidoctor
31
- :uri-ci-travis: https://travis-ci.org/asciidoctor/jekyll-asciidoc
32
- :uri-ci-appveyor: https://ci.appveyor.com/project/asciidoctor/jekyll-asciidoc
33
- :uri-gem: http://rubygems.org/gems/jekyll-asciidoc
34
- :uri-gem-asciidoctor: http://rubygems.org/gems/asciidoctor
35
- :uri-asciidoc: http://asciidoc.org
36
- :uri-asciidoctor: http://asciidoctor.org
37
- :uri-asciidoctor-backends: https://github.com/asciidoctor/asciidoctor-backends
38
- :uri-asciidoctor-docs: {uri-asciidoctor}/docs
39
- :uri-asciidoctor-diagram: {uri-asciidoctor-docs}/asciidoctor-diagram
40
- :uri-asciidoctor-discuss: http://discuss.asciidoctor.org
41
- :uri-asciidoctor-manual: {uri-asciidoctor-docs}/user-manual
42
- :uri-asciidoc-practices: {uri-asciidoctor-docs}/asciidoc-recommended-practices
43
- :uri-jaq: https://github.com/asciidoctor/jekyll-asciidoc-quickstart
44
- :uri-jekyll: https://jekyllrb.com
45
- :uri-jekyll-docs: {uri-jekyll}/docs
46
- :uri-jekyll-discuss: https://talk.jekyllrb.com
47
- :uri-front-matter: {uri-jekyll-docs}/frontmatter
48
- :uri-liquid-templates: {uri-jekyll-docs}/templates
49
- :uri-variables: {uri-jekyll-docs}/variables
50
- :uri-graphviz: http://www.graphviz.org
51
- :uri-tilt: https://github.com/rtomayko/tilt
52
- :uri-yaml: https://en.wikipedia.org/wiki/YAML
53
- :uri-guide-publish-gem: http://guides.rubygems.org/publishing/#publishing-to-rubygemsorg
27
+ :url-repo: https://github.com/asciidoctor/jekyll-asciidoc
28
+ :url-issues: {url-repo}/issues
29
+ :url-search-issues: {url-repo}/search?type=Issues
30
+ :url-chat: https://gitter.im/asciidoctor/asciidoctor
31
+ :url-ci-travis: https://travis-ci.org/asciidoctor/jekyll-asciidoc
32
+ :url-ci-appveyor: https://ci.appveyor.com/project/asciidoctor/jekyll-asciidoc
33
+ :url-gem: http://rubygems.org/gems/jekyll-asciidoc
34
+ :url-gem-asciidoctor: http://rubygems.org/gems/asciidoctor
35
+ :url-asciidoc: http://asciidoc.org
36
+ :url-asciidoctor: http://asciidoctor.org
37
+ :url-asciidoctor-backends: https://github.com/asciidoctor/asciidoctor-backends
38
+ :url-asciidoctor-docs: {url-asciidoctor}/docs
39
+ :url-asciidoctor-diagram: {url-asciidoctor-docs}/asciidoctor-diagram
40
+ :url-asciidoctor-discuss: http://discuss.asciidoctor.org
41
+ :url-asciidoctor-manual: {url-asciidoctor-docs}/user-manual
42
+ :url-asciidoc-practices: {url-asciidoctor-docs}/asciidoc-recommended-practices
43
+ :url-jaq: https://github.com/asciidoctor/jekyll-asciidoc-quickstart
44
+ :url-jekyll: https://jekyllrb.com
45
+ :url-jekyll-docs: {url-jekyll}/docs
46
+ :url-jekyll-discuss: https://talk.jekyllrb.com
47
+ :url-front-matter: {url-jekyll-docs}/frontmatter
48
+ :url-liquid-templates: {url-jekyll-docs}/templates
49
+ :url-variables: {url-jekyll-docs}/variables
50
+ :url-graphviz: http://www.graphviz.org
51
+ :url-tilt: https://github.com/rtomayko/tilt
52
+ :url-yaml: https://en.wikipedia.org/wiki/YAML
53
+ :url-guide-publish-gem: http://guides.rubygems.org/publishing/#publishing-to-rubygemsorg
54
54
 
55
55
  ifdef::status[]
56
- image:https://img.shields.io/gem/v/jekyll-asciidoc.svg[Latest Release, link={uri-gem}]
56
+ image:https://img.shields.io/gem/v/jekyll-asciidoc.svg[Latest Release, link={url-gem}]
57
57
  image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License, link=#copyright-and-license]
58
- image:https://img.shields.io/travis/asciidoctor/jekyll-asciidoc/master.svg[Build Status (Travis CI), link={uri-ci-travis}]
59
- image:https://ci.appveyor.com/api/projects/status/3cf1f8p2cyoaoc25/branch/master?svg=true&passingText=green%20bar&failingText=%23fail&pendingText=checking[Build Status (AppVeyor), link={uri-ci-appveyor}]
58
+ image:https://img.shields.io/travis/asciidoctor/jekyll-asciidoc/master.svg[Build Status (Travis CI), link={url-ci-travis}]
59
+ image:https://ci.appveyor.com/api/projects/status/3cf1f8p2cyoaoc25/branch/master?svg=true&passingText=green%20bar&failingText=%23fail&pendingText=checking[Build Status (AppVeyor), link={url-ci-appveyor}]
60
60
  endif::[]
61
61
 
62
- A plugin for {uri-jekyll}[Jekyll] (>= 3.0.0) that converts {uri-asciidoc}[AsciiDoc] source files in your site to HTML pages using {uri-asciidoctor}[Asciidoctor].
62
+ A plugin for {url-jekyll}[Jekyll] (>= 3.0.0) that converts {url-asciidoc}[AsciiDoc] source files in your site to HTML pages using {url-asciidoctor}[Asciidoctor].
63
63
 
64
64
  ifeval::['{branch}' == 'master']
65
65
  NOTE: You're viewing the documentation for the upcoming release.
66
66
  If you're looking for the documentation for an older release, please refer to one of the following branches: +
67
- {uri-repo}/tree/v2.1.x#readme[2.1.x]
67
+ {url-repo}/tree/v2.1.x#readme[2.1.x]
68
68
  &hybull;
69
- {uri-repo}/tree/v2.0.x#readme[2.0.x]
69
+ {url-repo}/tree/v2.0.x#readme[2.0.x]
70
70
  &hybull;
71
- {uri-repo}/tree/v1.1.x#readme[1.1.x]
71
+ {url-repo}/tree/v1.1.x#readme[1.1.x]
72
72
  &hybull;
73
- {uri-repo}/tree/v1.0.x#readme[1.0.x]
73
+ {url-repo}/tree/v1.0.x#readme[1.0.x]
74
74
  endif::[]
75
75
 
76
76
  toc::[]
@@ -95,9 +95,9 @@ These extensions are registered automatically when the [.app]*jekyll-asciidoc* g
95
95
 
96
96
  == Prerequisites
97
97
 
98
- To use this plugin, you must be using Jekyll >= 3.0.0 and Ruby >= 2.2.0 (with development headers installed).
98
+ To use this plugin, you must be using Jekyll >= 3.0.0 and Ruby >= 2.3.0 (with development headers installed).
99
99
  You should also be familiar with creating sites with Jekyll.
100
- If you're not, you should first read the {uri-jekyll-docs}[Jekyll documentation] to familiarize yourself with how it works.
100
+ If you're not, you should first read the {url-jekyll-docs}[Jekyll documentation] to familiarize yourself with how it works.
101
101
  Experience with AsciiDoc and Asciidoctor is also helpful, but not a requirement.
102
102
 
103
103
  Like Jekyll, this plugin was designed for developers, so some assembly is required.
@@ -105,8 +105,8 @@ That means you'll be expected to edit configuration, modify HTML templates, and
105
105
 
106
106
  == Installation
107
107
 
108
- This plugin is packaged as a gem named [.app]*{uri-gem}[jekyll-asciidoc]* and published to RubyGems.org.
109
- The plugin depends on the [.app]*{uri-gem-asciidoctor}[asciidoctor]* gem, which gets installed automatically.
108
+ This plugin is packaged as a gem named [.app]*{url-gem}[jekyll-asciidoc]* and published to RubyGems.org.
109
+ The plugin depends on the [.app]*{url-gem-asciidoctor}[asciidoctor]* gem, which gets installed automatically.
110
110
 
111
111
  Your method of installation will depend on whether you use Bundler to manage the dependencies for your Jekyll project.
112
112
 
@@ -173,8 +173,8 @@ This plugin converts eligible AsciiDoc files located inside the source directory
173
173
  There are a few conditions that must be met in order for an AsciiDoc file to be eligible:
174
174
 
175
175
  . The file must have an AsciiDoc file extension (see <<configuration>>).
176
- . The name of the file must not begin with a dot (`.`) or an underscore (`_`).footnoteref:[excluded_files,Hidden files and folders are automatically excluded by Jekyll.]
177
- . The file must not be located in a folder whose name begins with a dot (`.`) or an underscore (`_`) (unless the folder is a designated collection, such as _posts).footnoteref:[excluded_files]
176
+ . The name of the file must not begin with a dot (`.`) or an underscore (`_`).footnote:excluded_files[Hidden files and folders are automatically excluded by Jekyll.]
177
+ . The file must not be located in a folder whose name begins with a dot (`.`) or an underscore (`_`) (unless the folder is a designated collection, such as _posts).footnote:excluded_files[]
178
178
  . While you can use a Jekyll front matter header, it is not required.
179
179
 
180
180
  Here's a sample AsciiDoc file that meets these criteria:
@@ -187,10 +187,10 @@ layout: info
187
187
  permalink: /sample/
188
188
  ---
189
189
  = Sample Page
190
- :uri-asciidoctor: http://asciidoctor.org
190
+ :url-asciidoctor: http://asciidoctor.org
191
191
 
192
192
  This is a sample page composed in AsciiDoc.
193
- Jekyll converts it to HTML using {uri-asciidoctor}[Asciidoctor].
193
+ Jekyll converts it to HTML using {url-asciidoctor}[Asciidoctor].
194
194
 
195
195
  [source,ruby]
196
196
  puts "Hello, World!"
@@ -204,10 +204,10 @@ Alternatively, you can define the page variables directly in the AsciiDoc header
204
204
  = Sample Page
205
205
  :page-layout: info
206
206
  :page-permalink: /sample/
207
- :uri-asciidoctor: http://asciidoctor.org
207
+ :url-asciidoctor: http://asciidoctor.org
208
208
 
209
209
  This is a sample page composed in AsciiDoc.
210
- Jekyll converts it to HTML using {uri-asciidoctor}[Asciidoctor].
210
+ Jekyll converts it to HTML using {url-asciidoctor}[Asciidoctor].
211
211
 
212
212
  [source,ruby]
213
213
  puts "Hello, World!"
@@ -215,9 +215,9 @@ puts "Hello, World!"
215
215
 
216
216
  === Page Attributes
217
217
 
218
- Any AsciiDoc attribute defined in the AsciiDoc document header whose name begins with ``page-``footnote:[The prefix used to label page attributes can be customized.] gets promoted to a {uri-variables}[page variables].
218
+ Any AsciiDoc attribute defined in the AsciiDoc document header whose name begins with ``page-``footnote:[The prefix used to label page attributes can be customized.] gets promoted to a {url-variables}[page variables].
219
219
  The part of the name after the `page-` prefix is _lowercased_ and used as the variable name (e.g., page-layout becomes layout).
220
- The value is processed as {uri-yaml}[YAML] data (single-line form).
220
+ The value is processed as {url-yaml}[YAML] data (single-line form).
221
221
 
222
222
  Since the attribute value is processed as YAML data, you can build nested data structure using the inline YAML syntax.
223
223
  For example, here's how you can assign a value to the `page.header.image` page variable:
@@ -279,7 +279,7 @@ In addition to page attributes defined explicitly (e.g., layout, permalink, etc)
279
279
  * doctitle (aka the document title) (becomes `title`)
280
280
  * id (becomes `docid`)
281
281
  * author
282
- * revdate (becomes `date`; value is converted to a DateTime object; posts only)
282
+ * revdate (becomes `date`; value is converted to a DateTime object; not applied to pages)
283
283
 
284
284
  Although not an implicit page variable, another very common page variable to set is `page-description`, which becomes `description` in the model.
285
285
 
@@ -394,7 +394,7 @@ When you're ready to publish the post, move the file from the [.path]_{empty}_dr
394
394
 
395
395
  === Enabling Liquid Preprocessing
396
396
 
397
- Unlike other content files, the {uri-liquid-templates}[Liquid template preprocessor] is not applied to AsciiDoc files by default (since version 2.0.0 of this plugin).
397
+ Unlike other content files, the {url-liquid-templates}[Liquid template preprocessor] is not applied to AsciiDoc files by default (since version 2.0.0 of this plugin).
398
398
  If you want the Liquid template preprocessor to be applied to an AsciiDoc file (prior to the content being passed to the AsciiDoc processor), you must enable it by setting the `liquid` page variable (shown here defined using a page attribute).
399
399
 
400
400
  [source,asciidoc]
@@ -402,7 +402,7 @@ If you want the Liquid template preprocessor to be applied to an AsciiDoc file (
402
402
  :page-liquid:
403
403
  ----
404
404
 
405
- IMPORTANT: AsciiDoc files may include a {uri-front-matter}[front matter header] for defining page variables.
405
+ IMPORTANT: AsciiDoc files may include a {url-front-matter}[front matter header] for defining page variables.
406
406
  If present, the front matter header must be the very first character of the file.
407
407
  The front matter header won't be seen--and could distort conversion--if the front matter is preceded by whitespace or a Byte Order Mark (BOM).
408
408
 
@@ -412,6 +412,8 @@ In these cases, you define all the page variables (e.g., layout) using AsciiDoc
412
412
  You can also use a combination of both.
413
413
  When intermixed, the page attributes defined in the AsciiDoc header take precedence.
414
414
 
415
+ Liquid processing does not extend to files included using the AsciiDoc include directive (see {url-issues}/166[#166]).
416
+
415
417
  If you're using the Liquid include tag to include HTML into the AsciiDoc document, you need to enclose it in a passthrough block.
416
418
 
417
419
  ----
@@ -421,7 +423,50 @@ If you're using the Liquid include tag to include HTML into the AsciiDoc documen
421
423
  ----
422
424
 
423
425
  This is necessary since AsciiDoc will escape HTML by default.
424
- To pass it through as is requires enclosing in a passthrough block.
426
+ To pass it through raw requires enclosing it in a passthrough block.
427
+
428
+ === Extracting Excerpts
429
+
430
+ This plugin will extract an excerpt for any post or document in a collection if the `excerpt` page variable isn't set using the same logic as for Markdown files.
431
+ By default, it will use the content between the header and the first blank line.
432
+ If the `excerpt` page variable is set, that value will be used instead.
433
+ The excerpt will automatically be converted from AsciiDoc to embedded HTML whereever the `excerpt` property is referenced in a Liquid template.
434
+
435
+ ----
436
+ {% post.excerpt %}
437
+ ----
438
+
439
+ IMPORTANT: Since version 3.0.0 of this plugin, you no longer have to run the excerpt through the `asciidocify` filter since the conversion is already done for you.
440
+ In fact, if you do, the HTML in the converted excerpt will be escaped, which is not what you want.
441
+
442
+ If you want to use a different excerpt separator for AsciiDoc files, set the `excerpt_separator` under the `asciidoc` key in the site configuration.
443
+ For example, you can configure the plugin to use the line comment `//more` as the excerpt separator as follows:
444
+
445
+ [source,yaml]
446
+ ----
447
+ asciidoc:
448
+ excerpt_separator: "\n//more\n"
449
+ ----
450
+
451
+ If you're only working with AsciiDoc files in your site, you can go ahead and set this for all files by using the top-level property:
452
+
453
+ [source,yaml]
454
+ ----
455
+ excerpt_separator: "\n//more\n"
456
+ ----
457
+
458
+ If the excerpt separator isn't found, the content of the whole document is used instead.
459
+
460
+ By default, the excerpt is converted to HTML using the article doctype.
461
+ If you want to use a different doctype, such as inline, you can set it in the site configuration as follows:
462
+
463
+ [source,yaml]
464
+ ----
465
+ asciidoc:
466
+ excerpt_doctype: inline
467
+ ----
468
+
469
+ You can also set the excerpt doctype per page using the page attribute named `page-excerpt_doctype`.
425
470
 
426
471
  == Building and Previewing Your Site
427
472
 
@@ -627,7 +672,7 @@ asciidoctor:
627
672
  -idprefix:
628
673
  ----
629
674
 
630
- In addition to `attributes`, you may define any other option key (e.g., `safe`) recognized by the {uri-asciidoctor-manual}#ruby-api-options[Asciidoctor API].
675
+ In addition to `attributes`, you may define any other option key (e.g., `safe`) recognized by the {url-asciidoctor-manual}#ruby-api-options[Asciidoctor API].
631
676
  One of those options is `base_dir`, which is covered in the next section.
632
677
 
633
678
  ==== Specifying the Base Directory
@@ -699,13 +744,13 @@ Keep in mind that the value of the attribute will be unmodified from the value d
699
744
  Many Jekyll users are used to writing in GitHub-flavored Markdown (GFM), which preserves hard line breaks in paragraph content.
700
745
  Asciidoctor supports this feature for AsciiDoc files.
701
746
  (In fact, previous versions of this plugin enabled this behavior by default).
702
- If you want to enable this behavior for AsciiDoc files, add the `hardbreaks-option` attribute to the Asciidoctor attributes configuration in your site's {path-config} file:
747
+ If you want to enable this behavior for AsciiDoc files, add the `hardbreaks` attribute to the Asciidoctor attributes configuration in your site's {path-config} file:
703
748
 
704
749
  [source,yaml]
705
750
  ----
706
751
  asciidoctor:
707
752
  attributes:
708
- - hardbreaks-option
753
+ - hardbreaks
709
754
  ----
710
755
 
711
756
  If you still want to allow individual files to be able to override the attribute, append the charcter `@` to the value in the site configuration:
@@ -714,12 +759,12 @@ If you still want to allow individual files to be able to override the attribute
714
759
  ----
715
760
  asciidoctor:
716
761
  attributes:
717
- - hardbreaks-option=@
762
+ - hardbreaks=@
718
763
  ----
719
764
 
720
765
  If you already have AsciiDoc attributes defined in the {path-config}, the new attribute should be added as a sibling entry in the YAML collection.
721
766
 
722
- WARNING: Keep in mind, if you enable hard line breaks, you won't be able to use the {uri-asciidoc-practices}#one-sentence-per-line[one sentence-per-line writing technique].
767
+ WARNING: Keep in mind, if you enable hard line breaks, you won't be able to use the {url-asciidoc-practices}#one-sentence-per-line[one sentence-per-line writing technique].
723
768
 
724
769
  == Running in Safe Mode
725
770
 
@@ -750,22 +795,22 @@ This plugin defines two additional Liquid filters, `asciidocify` and `tocify_asc
750
795
  === Converting a String from AsciiDoc
751
796
 
752
797
  You can use the `asciidocify` filter to convert an arbitrary AsciiDoc string anywhere in your template.
798
+ This filter allows you to compose site-wide data in AsciiDoc, such your site's description or synopsis, then convert it to HTML for use in the page template(s).
753
799
 
754
- Let's assume the excerpt of the post is written in AsciiDoc.
800
+ Let's assume you've defined a page variable named `synopsis` that you want treat as AsciiDoc.
755
801
  You can convert it in your template as follows:
756
802
 
757
803
  ----
758
- {{ post.excerpt | asciidocify }}
804
+ {{ page.synopsis | asciidocify }}
759
805
  ----
760
806
 
761
- By default, the AsciiDoc content is parsed as a full AsciiDoc document.
807
+ By default, the AsciiDoc content is parsed as an embedded AsciiDoc document.
762
808
  If the content represents a single paragraph, and you only want to perform inline substitutions on that content, add the `inline` doctype as the filter's first argument:
763
809
 
764
810
  ----
765
- {{ post.excerpt | asciidocify: 'inline' }}
811
+ {{ page.synopsis | asciidocify: 'inline' }}
766
812
  ----
767
813
 
768
- TIP: This filter allows you to compose site-wide data in AsciiDoc, such your site's description or synopsis, then convert it to HTML for use in the page template(s).
769
814
 
770
815
  === Generating a Table of Contents
771
816
 
@@ -805,7 +850,7 @@ content
805
850
  == Customizing the Generated HTML
806
851
 
807
852
  You can use templates to customize the HTML output that Asciidoctor generates for your site.
808
- Template files can be composed in any templating language that is supported by {uri-tilt}[Tilt].
853
+ Template files can be composed in any templating language that is supported by {url-tilt}[Tilt].
809
854
  Each template file corresponds to a node in the AsciiDoc document tree (aka AST).
810
855
 
811
856
  Below are the steps you need to take to configure Asciidoctor to use custom templates with your site.
@@ -873,7 +918,7 @@ Name the file [.path]_ulist.html.slim_.
873
918
 
874
919
  The next time you build your site, Asciidoctor will use your custom template to generate the HTML for unordered lists.
875
920
 
876
- TIP: You can find additional examples of custom templates in the {uri-asciidoctor-backends}[asciidoctor-backends] repository.
921
+ TIP: You can find additional examples of custom templates in the {url-asciidoctor-backends}[asciidoctor-backends] repository.
877
922
 
878
923
  == Enabling Asciidoctor Extensions
879
924
 
@@ -933,11 +978,11 @@ For a concrete example of using an Asciidoctor extension, refer to the next sect
933
978
 
934
979
  == Enabling Asciidoctor Diagram
935
980
 
936
- {uri-asciidoctor-diagram}[Asciidoctor Diagram] is a set of extensions for Asciidoctor that allow you to embed diagrams generated by PlantUML, Graphviz, ditaa, Shaape, and other plain-text diagram tools inside your AsciiDoc documents.
981
+ {url-asciidoctor-diagram}[Asciidoctor Diagram] is a set of extensions for Asciidoctor that allow you to embed diagrams generated by PlantUML, Graphviz, ditaa, Shaape, and other plain-text diagram tools inside your AsciiDoc documents.
937
982
  In order to use Asciidoctor Diagram in a Jekyll project successfully, *you must use a version of this plugin >= 2.0.0*.
938
983
  Other combinations are known to have issues.
939
984
 
940
- IMPORTANT: For Graphviz and PlantUML diagram generation, {uri-graphviz}[Graphviz] must be installed (i.e., the `dot` utility must be available on your `$PATH`.
985
+ IMPORTANT: For Graphviz and PlantUML diagram generation, {url-graphviz}[Graphviz] must be installed (i.e., the `dot` utility must be available on your `$PATH`.
941
986
 
942
987
  TIP: To follow a start-to-finish tutorial that covers how to integrate Asciidoctor Diagram, see https://gist.github.com/mojavelinux/968623c493190dd61c059c2d85f9bdc3[this gist].
943
988
 
@@ -1137,7 +1182,7 @@ Certain Asciidoctor features, such as icons, require additional CSS rules and ot
1137
1182
  These CSS rules and other assets do not get automatically included in the pages generated by Jekyll.
1138
1183
  This section documents how to configure these additional resources.
1139
1184
 
1140
- TIP: If you want to take a shortcut that skips all this configuration, clone the {uri-jaq}[Jekyll AsciiDoc Quickstart (JAQ)] repository and use it as a starting point for your site.
1185
+ TIP: If you want to take a shortcut that skips all this configuration, clone the {url-jaq}[Jekyll AsciiDoc Quickstart (JAQ)] repository and use it as a starting point for your site.
1141
1186
  JAQ provides a page layout out of the box configured to fully style body content generated from AsciiDoc.
1142
1187
 
1143
1188
  === Setup
@@ -1311,7 +1356,7 @@ Refer to the http://eshepelyuk.github.io/2014/10/28/automate-github-pages-travis
1311
1356
  You can also refer to the https://github.com/johncarl81/transfuse-site[Transfuse website build^] for an example in practice.
1312
1357
 
1313
1358
  In fact, if you're using Travis CI, it's even easier than that.
1314
- Travis CI provides a https://docs.travis-ci.com/user/deployment/pages/[deployer for GitLab Pages]!
1359
+ Travis CI provides a https://docs.travis-ci.com/user/deployment/pages/[deployer for GitHub Pages]!
1315
1360
  Using this deployer, Travis CI can push your generated site to GitHub Pages after a successful build on your behalf, as long as you've completed these steps:
1316
1361
 
1317
1362
  . Create a personal access token on GitHub that has write access to your GitHub repository (public_repo or repo scope)
@@ -1337,7 +1382,7 @@ TIP: When using this setup, don't forget to add the [.path]_.nojekyll_ file to t
1337
1382
 
1338
1383
  ==== Jekyll AsciiDoc Quickstart
1339
1384
 
1340
- If you want to take a shortcut that skips all the steps in the previously mentioned tutorial, clone the {uri-jaq}[Jekyll AsciiDoc Quickstart (JAQ)] repository and use it as a starting point for your site.
1385
+ If you want to take a shortcut that skips all the steps in the previously mentioned tutorial, clone the {url-jaq}[Jekyll AsciiDoc Quickstart (JAQ)] repository and use it as a starting point for your site.
1341
1386
  JAQ includes a Rake build that is preconfigured to deploy to GitHub Pages from Travis CI and also provides a theme (page layout and CSS) that properly styles body content generated from AsciiDoc.
1342
1387
 
1343
1388
  ==== Feeling Responsive
@@ -1408,17 +1453,17 @@ But we can't achieve that goal without your input.
1408
1453
  Your questions and feedback help steer the project, so speak up!
1409
1454
  Activity drives progress.
1410
1455
 
1411
- When seeking answers, always start with the official documentation for Jekyll, which can be found on the {uri-jekyll}[Jekyll website].
1412
- If you have general questions about Jekyll, we recommend you visit the {uri-jekyll-discuss}[Jekyll Talk] forum to get assistance.
1413
- For questions related to this extension specifically, or general questions about AsciiDoc, please post to the {uri-asciidoctor-discuss}[Asciidoctor discussion list].
1414
- You can also join us in the {uri-chat}[asciidoctor/asciidoctor channel] on Gitter.
1415
- For general information about AsciiDoc, look no further than the {uri-asciidoctor-manual}[Asciidoctor User Manual].
1456
+ When seeking answers, always start with the official documentation for Jekyll, which can be found on the {url-jekyll}[Jekyll website].
1457
+ If you have general questions about Jekyll, we recommend you visit the {url-jekyll-discuss}[Jekyll Talk] forum to get assistance.
1458
+ For questions related to this extension specifically, or general questions about AsciiDoc, please post to the {url-asciidoctor-discuss}[Asciidoctor discussion list].
1459
+ You can also join us in the {url-chat}[asciidoctor/asciidoctor channel] on Gitter.
1460
+ For general information about AsciiDoc, look no further than the {url-asciidoctor-manual}[Asciidoctor User Manual].
1416
1461
 
1417
1462
  === Filing Bug Reports and Feature Requests
1418
1463
 
1419
- This project uses the {uri-issues}[GitHub issue tracker] to manage bug reports and feature requests.
1420
- If you encounter a problem, please {uri-search-issues}[browse or search] the issues to find out if your problem has already been reported.
1421
- If it has not, you may {uri-issues}/new[submit a new issue].
1464
+ This project uses the {url-issues}[GitHub issue tracker] to manage bug reports and feature requests.
1465
+ If you encounter a problem, please {url-search-issues}[browse or search] the issues to find out if your problem has already been reported.
1466
+ If it has not, you may {url-issues}/new[submit a new issue].
1422
1467
 
1423
1468
  The best way to get a timely response and quick fix for your issue is to write a detailed report and respond to replies in a timely manner.
1424
1469
 
@@ -1437,11 +1482,11 @@ Follow the instructions below to learn how to clone the source, run the tests an
1437
1482
  === Retrieve the Source Code
1438
1483
 
1439
1484
  You can retrieve the source code from GitHub using git.
1440
- Simply copy the URL of the {uri-repo}[GitHub repository] and pass it to the `git clone` command:
1485
+ Simply copy the URL of the {url-repo}[GitHub repository] and pass it to the `git clone` command:
1441
1486
 
1442
1487
  [subs=attributes+]
1443
1488
  ....
1444
- git clone {uri-repo}
1489
+ git clone {url-repo}
1445
1490
  ....
1446
1491
 
1447
1492
  Next, switch to the project directory.
@@ -1570,13 +1615,13 @@ Next, package, tag and release the gem to RubyGems.org, run the following rake t
1570
1615
 
1571
1616
  $ bundle exec rake release
1572
1617
 
1573
- IMPORTANT: Ensure you have the proper credentials setup as described in the guide {uri-guide-publish-gem}[Publishing to RubyGems.org].
1618
+ IMPORTANT: Ensure you have the proper credentials setup as described in the guide {url-guide-publish-gem}[Publishing to RubyGems.org].
1574
1619
 
1575
1620
  Once you finish the release, you should update the version to the next micro version in the sequence using the `.dev` suffix (e.g., 3.0.1.dev).
1576
1621
 
1577
1622
  == About the Project
1578
1623
 
1579
- The Jekyll AsciiDoc plugin, a plugin for the static site generator {uri-jekyll}[Jekyll], is a member project of the Asciidoctor organization.
1624
+ The Jekyll AsciiDoc plugin, a plugin for the static site generator {url-jekyll}[Jekyll], is a member project of the Asciidoctor organization.
1580
1625
  This plugin is developed and supported by volunteers in the Asciidoctor community.
1581
1626
 
1582
1627
  === Authors
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  rescue ::SystemCallError
28
28
  Dir['**/*']
29
29
  end
30
- s.files = files.grep %r/^(?:lib\/.+|Gemfile|(?:CHANGELOG|LICENSE|README)\.adoc|jekyll-asciidoc\.gemspec)$/
30
+ s.files = files.grep %r/^(?:lib\/.+|Gemfile|(?:CHANGELOG|LICENSE|README)\.adoc|\.yardopts|jekyll-asciidoc\.gemspec)$/
31
31
  #s.test_files = files.grep %r/^spec\/./
32
32
 
33
33
  s.require_paths = ['lib']
@@ -36,7 +36,9 @@ Gem::Specification.new do |s|
36
36
  s.add_runtime_dependency 'jekyll', '>= 3.0.0'
37
37
 
38
38
  s.add_development_dependency 'deep-cover-core', '~> 0.7.0'
39
+ s.add_development_dependency 'pygments.rb', '~> 1.2.1'
39
40
  s.add_development_dependency 'rake', '~> 12.3.2'
40
41
  s.add_development_dependency 'rspec', '~> 3.8.0'
42
+ s.add_development_dependency 'rubocop', '~> 0.61.1'
41
43
  s.add_development_dependency 'simplecov', '~> 0.16.1'
42
44
  end
@@ -1,6 +1,15 @@
1
- require_relative 'jekyll-asciidoc/compat'
1
+ module Jekyll
2
+ module AsciiDoc
3
+ jekyll_gem_version = ::Gem::Version.new ::Jekyll::VERSION
4
+ Jekyll3_0 = (::Gem::Requirement.new '~> 3.0.0').satisfied_by? jekyll_gem_version
5
+ Jekyll3_1 = !Jekyll3_0 && ((::Gem::Requirement.new '~> 3.1.0').satisfied_by? jekyll_gem_version)
6
+ end
7
+ end
8
+ require_relative 'jekyll-asciidoc/core_ext'
9
+ require_relative 'jekyll-asciidoc/jekyll_ext'
2
10
  require_relative 'jekyll-asciidoc/utils'
3
11
  require_relative 'jekyll-asciidoc/mixins'
12
+ require_relative 'jekyll-asciidoc/excerpt'
4
13
  require_relative 'jekyll-asciidoc/converter'
5
14
  require_relative 'jekyll-asciidoc/integrator'
6
15
  require_relative 'jekyll-asciidoc/filters'
@@ -20,8 +20,9 @@ module Jekyll
20
20
  MessageTopic = Utils::MessageTopic
21
21
  NewLine = Utils::NewLine
22
22
 
23
- AttributeReferenceRx = /\\?\{(\w+(?:[\-]\w+)*)\}/
23
+ AttributeReferenceRx = /\\?\{(\p{Word}[-\p{Word}]*)\}/
24
24
  HeaderBoundaryRx = /(?<=\p{Graph}#{NewLine * 2})/
25
+ HeaderLineRx = /^=[ \t]+.|^:!?\w[-\w]*!?:(?:[ \t]+.)?/
25
26
 
26
27
  # Enable plugin when running in safe mode; jekyll-asciidoc gem must also be declared in whitelist
27
28
  safe true
@@ -97,7 +98,8 @@ module Jekyll
97
98
  'site-url' => config['url'],
98
99
  }
99
100
  attrs = asciidoctor_config[:attributes] = compile_attributes asciidoctor_config[:attributes],
100
- ((site_attributes.merge ImplicitAttributes).merge DefaultAttributes)
101
+ (compile_attributes asciidoc_config['attributes'],
102
+ ((site_attributes.merge ImplicitAttributes).merge DefaultAttributes))
101
103
  if (imagesdir = attrs['imagesdir']) && !(attrs.key? 'imagesoutdir') && (imagesdir.start_with? '/')
102
104
  attrs['imagesoutdir'] = ::File.join dest, (imagesdir.chomp '@')
103
105
  end
@@ -139,15 +141,15 @@ module Jekyll
139
141
  end
140
142
 
141
143
  def self.before_render document, payload
142
- (get_instance document.site).before_render document, payload if Document === document
144
+ (get_instance document.site).before_render document, payload if Document === document || Excerpt === document
143
145
  end
144
146
 
145
147
  def self.after_render document
146
- (get_instance document.site).after_render document if Document === document
148
+ (get_instance document.site).after_render document if Document === document || Excerpt === document
147
149
  end
148
150
 
149
151
  def before_render document, payload
150
- # NOTE Jekyll 3.1 incorrectly mapped the page payload to document.data instead of payload['page']
152
+ # NOTE Jekyll 3.1 incorrectly maps the page payload to document.data instead of payload['page']
151
153
  @page_context[:data] = ::Jekyll::AsciiDoc::Jekyll3_1 ? document.data : payload['page']
152
154
  record_paths document
153
155
  end
@@ -175,11 +177,10 @@ module Jekyll
175
177
 
176
178
  def load_header document
177
179
  record_paths document, source_only: true
178
- # NOTE merely an optimization; if this doesn't match, the header still gets extracted by the processor
179
- header = (content = document.content) ? (HeaderBoundaryRx =~ content ? $` : content) : ''
180
180
  case @asciidoc_config['processor']
181
181
  when 'asciidoctor'
182
182
  opts = @asciidoctor_config.merge parse_header_only: true
183
+ header = extract_header document
183
184
  if (paths = @page_context[:paths])
184
185
  if opts[:base_dir] == :docdir
185
186
  opts[:base_dir] = paths['docdir'] # NOTE this assignment happens inside the processor anyway
@@ -208,7 +209,7 @@ module Jekyll
208
209
 
209
210
  case @asciidoc_config['processor']
210
211
  when 'asciidoctor'
211
- opts = @asciidoctor_config.merge header_footer: (@page_context[:data] || {})['standalone']
212
+ opts = @asciidoctor_config.merge header_footer: (data = @page_context[:data] || {})['standalone']
212
213
  if (paths = @page_context[:paths])
213
214
  if opts[:base_dir] == :docdir
214
215
  opts[:base_dir] = paths['docdir'] # NOTE this assignment happens inside the processor anyway
@@ -216,11 +217,11 @@ module Jekyll
216
217
  paths.delete 'docdir'
217
218
  end
218
219
  opts[:attributes] = opts[:attributes].merge paths
219
- # for auto-extracted excerpt, paths are't available since hooks don't get triggered
220
- elsif opts[:base_dir] == :docdir
221
- opts.delete :base_dir
222
220
  end
223
- ((@page_context[:data] || {})['document'] = ::Asciidoctor.load content, opts).extend(Liquidable).convert
221
+ if (doctype = data['doctype'])
222
+ opts[:doctype] = doctype
223
+ end
224
+ (data['document'] = ::Asciidoctor.load content, opts).extend(Liquidable).convert
224
225
  else
225
226
  @logger.warn MessageTopic,
226
227
  %(Unknown AsciiDoc processor: #{@asciidoc_config['processor']}. Passing through unparsed content.)
@@ -230,6 +231,33 @@ module Jekyll
230
231
 
231
232
  private
232
233
 
234
+ # Take up to the AsciiDoc document header (if present), then continue to the excerpt separator, if non-blank.
235
+ def extract_header document
236
+ if (content = document.content)
237
+ header = (header_boundary = HeaderBoundaryRx =~ content) ? $` : content
238
+ # NOTE at this point, excerpt is already set to an instance of Jekyll::Excerpt unless set in front matter
239
+ if ::Jekyll::Page === document || !(::Jekyll::Excerpt === document.data['excerpt'])
240
+ header = '' unless HeaderLineRx.match? header
241
+ else
242
+ document.data['excerpt'] = nil
243
+ if (excerpt_separator = document.data['excerpt_separator'] || @asciidoc_config['excerpt_separator'] ||
244
+ @config['excerpt_separator']).to_s.empty?
245
+ header = '' unless HeaderLineRx.match? header
246
+ else
247
+ header_boundary = 0 unless header_boundary && (HeaderLineRx.match? header)
248
+ if (excerpt_boundary = content.index excerpt_separator, header_boundary)
249
+ header = content.slice 0, excerpt_boundary
250
+ else
251
+ header = content
252
+ end
253
+ end
254
+ end
255
+ header
256
+ else
257
+ ''
258
+ end
259
+ end
260
+
233
261
  def symbolize_keys hash
234
262
  hash.each_with_object({}) {|(key, val), accum| accum[key.to_sym] = val }
235
263
  end
@@ -237,14 +265,14 @@ module Jekyll
237
265
  def compile_attributes attrs, initial = {}
238
266
  if (is_array = ::Array === attrs) || ::Hash === attrs
239
267
  attrs.each_with_object(initial) do |entry, new_attrs|
240
- key, val = is_array ? ((entry.split '=', 2) + ['', ''])[0..1] : entry
268
+ key, val = is_array ? (((entry.split '=', 2) + ['', '']).slice 0, 2) : entry
241
269
  if key.start_with? '!'
242
- new_attrs[key[1..-1]] = nil
270
+ new_attrs[key.slice 1, key.length] = nil
243
271
  elsif key.end_with? '!'
244
272
  new_attrs[key.chop] = nil
245
273
  # we're reserving -name to mean "unset implicit value but allow doc to override"
246
274
  elsif key.start_with? '-'
247
- new_attrs.delete key[1..-1]
275
+ new_attrs.delete key.slice 1, key.length
248
276
  else
249
277
  case val
250
278
  when ::String
@@ -271,14 +299,16 @@ module Jekyll
271
299
  if text.empty?
272
300
  text
273
301
  elsif text.include? '{'
274
- text.gsub(AttributeReferenceRx) { ($&.start_with? '\\') ? $&[1..-1] : ((attrs.fetch $1, $&).to_s.chomp '@') }
302
+ text.gsub AttributeReferenceRx do
303
+ ($&.start_with? '\\') ? ($&.slice 1, $&.length) : ((attrs.fetch $1, $&).to_s.chomp '@')
304
+ end
275
305
  else
276
306
  text
277
307
  end
278
308
  end
279
309
 
280
310
  def resolve_default_layout document, attributes
281
- layout_attr_name = %(#{document.site.config['asciidoc']['page_attribute_prefix']}layout)
311
+ layout_attr_name = %(#{@asciidoc_config['page_attribute_prefix']}layout)
282
312
  if attributes.key? layout_attr_name
283
313
  if ::String === (layout = attributes[layout_attr_name])
284
314
  if layout == '~@'
@@ -0,0 +1 @@
1
+ require_relative 'core_ext/regexp/is_match'
@@ -0,0 +1,4 @@
1
+ # NOTE remove once minimum required Ruby version is at least 2.4
2
+ class Regexp
3
+ alias match? ===
4
+ end unless Regexp.method_defined? :match?
@@ -0,0 +1,49 @@
1
+ module Jekyll
2
+ module AsciiDoc
3
+ class Excerpt < ::Jekyll::Excerpt
4
+ if Jekyll3_0
5
+ def_delegators :@doc, :destination, :url
6
+ else
7
+ def_delegators :@doc, :destination
8
+ end
9
+
10
+ def initialize primary_doc, excerpt_content
11
+ excerpt_doc = primary_doc.dup
12
+ excerpt_doc.content = excerpt_content
13
+ excerpt_doc.extend NoLiquid unless primary_doc.data['liquid']
14
+ super excerpt_doc
15
+ end
16
+
17
+ def extract_excerpt content
18
+ # NOTE excerpt_doctype has already been resolved from either the page attribute or front matter variable
19
+ if (doctype = (excerpt_data = data)['excerpt_doctype'] ||
20
+ (inherited = doc.site.config['asciidoc']['excerpt_doctype']))
21
+ excerpt_data['doctype'] = doctype
22
+ excerpt_data['excerpt_doctype'] = doc.data['excerpt_doctype'] = doctype if inherited
23
+ end
24
+ content
25
+ end
26
+
27
+ def output
28
+ unless defined? @output
29
+ renderer = ::Jekyll::Renderer.new doc.site, self, site.site_payload
30
+ @output = renderer.run
31
+ trigger_hooks :post_render
32
+ end
33
+ @output
34
+ end
35
+
36
+ def render_with_liquid?
37
+ !(NoLiquid === doc)
38
+ end
39
+
40
+ # NOTE Jekyll 3.0 incorrectly maps to_liquid to primary doc
41
+ alias to_liquid data if Jekyll3_0
42
+
43
+ def trigger_hooks hook_name, *args
44
+ #::Jekyll::Hooks.trigger collection.label.to_sym, hook_name, self, *args if collection
45
+ ::Jekyll::Hooks.trigger :documents, hook_name, self, *args
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,31 +1,31 @@
1
1
  module Jekyll
2
2
  module AsciiDoc
3
3
  module Filters
4
- # A Liquid filter for converting an AsciiDoc string to HTML.
4
+ # A Liquid filter for converting an AsciiDoc string to HTML using {Converter#convert}.
5
5
  #
6
- # input - The AsciiDoc String to convert.
7
- # doctype - The target AsciiDoc doctype (optional, default: nil).
8
- #
9
- # Examples
6
+ # @param input [String] the AsciiDoc String to convert.
7
+ # @param doctype [String] the target AsciiDoc doctype.
10
8
  #
9
+ # @example Convert the AsciiDoc page excerpt to inline HTML
11
10
  # {{ page.excerpt | asciidocify: 'inline' }}
12
11
  #
13
- # Returns the converted result as an HTML-formatted String.
12
+ # @return [String] the converted result as an HTML-formatted String.
14
13
  def asciidocify input, doctype = nil
15
14
  (@context.registers[:cached_asciidoc_converter] ||= (Converter.get_instance @context.registers[:site]))
16
15
  .convert(doctype ? %(:doctype: #{doctype}#{Utils::NewLine}#{input}) : (input || ''))
17
16
  end
18
17
 
19
- # A Liquid filter for generating a table of contents in HTML from a parsed AsciiDoc document.
20
- #
21
- # document - The parsed AsciiDoc document from which to generate a table of contents in HTML.
22
- # levels - The max section depth to include (optional, default: value of toclevels document attribute).
18
+ # A Liquid filter for generating an HTML table of contents from a parsed AsciiDoc document.
23
19
  #
24
- # Examples
20
+ # @param document [Asciidoctor::Document] the parsed AsciiDoc document for which to generate an HTML table of
21
+ # contents.
22
+ # @param levels [Integer] the maximum section depth to use; if not specified, uses the value of toclevels document
23
+ # attribute.
25
24
  #
25
+ # @example Generate a table of contents from the document for the current page
26
26
  # {{ page.document | tocify_asciidoc: 3 }}
27
27
  #
28
- # Returns the table of contents as an HTML-formatted String.
28
+ # @return [String] the table of contents as an HTML-formatted String.
29
29
  def tocify_asciidoc document, levels = nil
30
30
  ::Asciidoctor::Document === document ?
31
31
  (document.converter.convert document, 'outline', toclevels: (levels.nil_or_empty? ? nil : levels.to_i)) : nil
@@ -5,6 +5,7 @@ module Jekyll
5
5
  # source highlighter and configured to use class-based styling.
6
6
  class Integrator < ::Jekyll::Generator
7
7
  NewLine = Utils::NewLine
8
+ PygmentsRootSelector = /^(.+?)\.pygments +{/
8
9
 
9
10
  # Enable plugin when running in safe mode; jekyll-asciidoc gem must also be declared in whitelist
10
11
  safe true
@@ -15,6 +16,10 @@ module Jekyll
15
16
 
16
17
  # This method is triggered each time the site is generated, including after any file has changed when running in
17
18
  # watch mode (regardless of incremental setting).
19
+ #
20
+ # @param site [Jekyll::Site] the site being processed.
21
+ #
22
+ # @return [nil] Nothing
18
23
  def generate site
19
24
  @converter = converter = Converter.get_instance site
20
25
 
@@ -28,21 +33,25 @@ module Jekyll
28
33
  end
29
34
  end
30
35
 
31
- attrs = site.config['asciidoctor'][:attributes]
32
- attrs['localdate'], attrs['localtime'] = (site.time.strftime '%Y-%m-%d %H:%M:%S %Z').split ' ', 2
33
- if ((attrs['source-highlighter'] || '').chomp '@') == 'pygments' &&
34
- ((attrs['pygments-css'] || '').chomp '@') != 'style' && (attrs.fetch 'pygments-stylesheet', '')
35
- generate_pygments_stylesheet site, attrs
36
+ if site.config['asciidoc']['processor'] == 'asciidoctor'
37
+ attrs = site.config['asciidoctor'][:attributes]
38
+ attrs['localdate'], attrs['localtime'] = (site.time.strftime '%Y-%m-%d %H:%M:%S %Z').split ' ', 2
39
+ if ((attrs['source-highlighter'] || '').chomp '@') == 'pygments' &&
40
+ ((attrs['pygments-css'] || '').chomp '@') != 'style' && (attrs.fetch 'pygments-stylesheet', '')
41
+ generate_pygments_stylesheet site, attrs
42
+ end
36
43
  end
44
+
45
+ nil
37
46
  end
38
47
 
39
48
  # Integrate the page-related attributes from the AsciiDoc document header into the data Array of the specified
40
49
  # {::Jekyll::Page}, {::Jekyll::Post} or {::Jekyll::Document}.
41
50
  #
42
- # document - the Page, Post or Document instance to integrate.
43
- # collection_name - the String name of the collection to which this document belongs (optional, default: nil).
51
+ # @param document [::Jekyll::Page, ::Jekyll::Post, ::Jekyll::Document] the page, post, or document to integrate.
52
+ # @param collection_name [String] the name of the collection to which this document belongs.
44
53
  #
45
- # Returns a [Boolean] indicating whether the document should be published.
54
+ # @return [Boolean] whether the document should be published.
46
55
  def integrate document, collection_name = nil
47
56
  return true unless (doc = @converter.load_header document)
48
57
 
@@ -52,7 +61,7 @@ module Jekyll
52
61
  data['docid'] = doc.id if doc.id
53
62
  data['title'] = doc.doctitle if doc.header?
54
63
  data['author'] = doc.author if doc.author
55
- if collection_name == 'posts' && (doc.attr? 'revdate')
64
+ if collection_name && (doc.attr? 'revdate')
56
65
  data['date'] = ::Jekyll::Utils.parse_date doc.revdate,
57
66
  %(Document '#{document.relative_path}' does not have a valid revdate in the AsciiDoc header.)
58
67
  end
@@ -75,6 +84,12 @@ module Jekyll
75
84
  end
76
85
  end
77
86
 
87
+ # NOTE excerpt must be set before layout is assigned since excerpt cannot have a layout (or be standalone)
88
+ unless ::Jekyll::Page === document
89
+ data['excerpt'] = Excerpt.new document, ((excerpt = data['excerpt']) || doc.source)
90
+ data['excerpt_origin'] = excerpt ? ((adoc_data.key? 'excerpt') ? 'asciidoc-header' : 'front-matter') : 'body'
91
+ end
92
+
78
93
  case data['layout']
79
94
  when nil
80
95
  data['standalone'] = true unless data.key? 'layout'
@@ -101,12 +116,12 @@ module Jekyll
101
116
  css_style = (attrs['pygments-style'] || 'vs').chomp '@'
102
117
  css = ::Asciidoctor::Stylesheets.instance.pygments_stylesheet_data css_style
103
118
  # NOTE apply stronger CSS rule for general text color
104
- css = css.sub '.listingblock .pygments {', '.listingblock .pygments, .listingblock .pygments code {'
119
+ css = css.sub PygmentsRootSelector, '\1.pygments, \1.pygments code {'
105
120
  if site.static_files.any? {|f| f.path == css_file }
106
- ::IO.write css_file, css unless css == (::IO.read css_file)
121
+ ::File.write css_file, css unless css == (::File.read css_file)
107
122
  else
108
- ::Asciidoctor::Helpers.mkdir_p ::File.dirname css_file
109
- ::IO.write css_file, css
123
+ ::FileUtils.mkdir_p ::File.dirname css_file
124
+ ::File.write css_file, css
110
125
  site.static_files << (::Jekyll::StaticFile.new site, css_base, css_dir, css_name)
111
126
  end
112
127
  end
@@ -119,9 +134,10 @@ module Jekyll
119
134
  # If the value fails to parse, wrap the value in single quotes (after escaping any single quotes in the value) and
120
135
  # parse it as a character sequence. If the value is empty, return an empty String.
121
136
  #
122
- # val - The String value to parse.
137
+ # @param val [String] the value to parse.
123
138
  #
124
- # Returns an [Object] parsed from the string-based YAML value or empty [String] if the specified value is empty.
139
+ # @return [Object, String] the value parsed from the string-based YAML value or an empty String if the specified
140
+ # value is empty.
125
141
  def parse_yaml_value val
126
142
  if val.empty?
127
143
  ''
@@ -0,0 +1,3 @@
1
+ require_relative 'jekyll_ext/drops/drop'
2
+ require_relative 'jekyll_ext/renderer/layouts'
3
+ require_relative 'jekyll_ext/site/find_generator_instance'
@@ -0,0 +1,14 @@
1
+ module Jekyll
2
+ module Drops
3
+ class Drop
4
+ class << self
5
+ # NOTE fixes "warning: instance variable @is_mutable not initialized"
6
+ prepend (Module.new do
7
+ def mutable?
8
+ @is_mutable ||= nil # rubocop:disable Naming/MemoizedInstanceVariableName
9
+ end
10
+ end)
11
+ end
12
+ end
13
+ end
14
+ end if defined? Jekyll::Drops::Drop
@@ -0,0 +1,11 @@
1
+ module Jekyll
2
+ class Renderer
3
+ # NOTE fixes "warning: instance variable @layouts not initialized"
4
+ prepend (Module.new do
5
+ def layouts
6
+ @layouts = nil unless defined? @layouts
7
+ super
8
+ end
9
+ end)
10
+ end
11
+ end if Jekyll::Renderer.method_defined? :layouts
@@ -0,0 +1,8 @@
1
+ module Jekyll
2
+ class Site
3
+ # Introduce complement to {::Jekyll::Site#find_converter_instance} for generators.
4
+ def find_generator_instance type
5
+ generators.find {|candidate| type === candidate } || (raise %(No Generators found for #{type}))
6
+ end
7
+ end
8
+ end unless Jekyll::Site.method_defined? :find_generator_instance
@@ -6,8 +6,16 @@ module Jekyll
6
6
 
7
7
  module_function
8
8
 
9
- def has_front_matter? dlg_method, asciidoc_ext_re, path
10
- (asciidoc_ext_re.match? ::File.extname path) || (dlg_method.call path)
9
+ # Checks whether the file at the specified path has front matter. For AsciiDoc files, this method always returns
10
+ # true. Otherwise, it delegates to {::Jekyll::Utils.has_yaml_header?}.
11
+ #
12
+ # @param dlg_method [Method] the delegate method to call if this path is not an AsciiDoc file.
13
+ # @param asciidoc_ext_rx [Regexp] the regular expression to use to check if this path is an AsciiDoc file.
14
+ # @param path [String] the path to check.
15
+ #
16
+ # @return [Boolean] whether the file at this path has front matter.
17
+ def has_front_matter? dlg_method, asciidoc_ext_rx, path
18
+ (asciidoc_ext_rx.match? ::File.extname path) || (dlg_method.call path)
11
19
  end
12
20
 
13
21
  # NOTE use define_method to match signature of original method (and avoid extra call)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module AsciiDoc
3
- VERSION = '3.0.0.beta.1'
3
+ VERSION = '3.0.0.beta.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-asciidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.1
4
+ version: 3.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-30 00:00:00.000000000 Z
12
+ date: 2019-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.7.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: pygments.rb
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 1.2.1
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.1
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rake
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +95,20 @@ dependencies:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
97
  version: 3.8.0
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.61.1
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.61.1
84
112
  - !ruby/object:Gem::Dependency
85
113
  name: simplecov
86
114
  requirement: !ruby/object:Gem::Requirement
@@ -103,16 +131,23 @@ executables: []
103
131
  extensions: []
104
132
  extra_rdoc_files: []
105
133
  files:
134
+ - ".yardopts"
106
135
  - CHANGELOG.adoc
107
136
  - Gemfile
108
137
  - LICENSE.adoc
109
138
  - README.adoc
110
139
  - jekyll-asciidoc.gemspec
111
140
  - lib/jekyll-asciidoc.rb
112
- - lib/jekyll-asciidoc/compat.rb
113
141
  - lib/jekyll-asciidoc/converter.rb
142
+ - lib/jekyll-asciidoc/core_ext.rb
143
+ - lib/jekyll-asciidoc/core_ext/regexp/is_match.rb
144
+ - lib/jekyll-asciidoc/excerpt.rb
114
145
  - lib/jekyll-asciidoc/filters.rb
115
146
  - lib/jekyll-asciidoc/integrator.rb
147
+ - lib/jekyll-asciidoc/jekyll_ext.rb
148
+ - lib/jekyll-asciidoc/jekyll_ext/drops/drop.rb
149
+ - lib/jekyll-asciidoc/jekyll_ext/renderer/layouts.rb
150
+ - lib/jekyll-asciidoc/jekyll_ext/site/find_generator_instance.rb
116
151
  - lib/jekyll-asciidoc/mixins.rb
117
152
  - lib/jekyll-asciidoc/utils.rb
118
153
  - lib/jekyll-asciidoc/version.rb
@@ -139,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
174
  - !ruby/object:Gem::Version
140
175
  version: 1.3.1
141
176
  requirements: []
142
- rubygems_version: 3.0.1
177
+ rubygems_version: 3.0.3
143
178
  signing_key:
144
179
  specification_version: 4
145
180
  summary: A Jekyll plugin that converts the AsciiDoc source files in your site to HTML
@@ -1,16 +0,0 @@
1
- module Jekyll
2
- module AsciiDoc
3
- Jekyll3_1 = (::Gem::Requirement.new '~> 3.1.0').satisfied_by? ::Gem::Version.new ::Jekyll::VERSION
4
- end
5
-
6
- class Site
7
- # Introduce complement to {::Jekyll::Site#find_converter_instance} for generators.
8
- def find_generator_instance type
9
- generators.find {|candidate| type === candidate } || (raise %(No Generators found for #{type}))
10
- end unless method_defined? :find_generator_instance
11
- end
12
- end
13
-
14
- class Regexp
15
- alias match? ===
16
- end unless Regexp.method_defined? :match?