jekyll-asciidoc 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f0880454bf13707df6ab46db960a614e543e1d5
|
|
4
|
+
data.tar.gz: 91f7795b3722073aca1a3ab2c49a0d04f9883033
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e865f7e9ef44ee8b8626b6948fa184d50bfd3bb8d799065e2f89dddbfc3a2a97ab5e54f6b98afe66aee5c3d771fab0a51703cbb92c6f8a10b715ada0c59256e
|
|
7
|
+
data.tar.gz: 8e210f65e121dd1d208e9b7492bf3f3f1af6284e0d433ee1e8c3fe844f3de64d7e27df163b899df347189d5fdb87c6d7dc4ac867c8cc11c483e10b212537844f
|
data/CHANGELOG.adoc
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
= {project-name} Changelog
|
|
2
|
+
:project-name: Jekyll AsciiDoc Plugin
|
|
3
|
+
:uri-repo: https://github.com/asciidoctor/jekyll-asciidoc
|
|
4
|
+
|
|
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.
|
|
7
|
+
|
|
8
|
+
== 2.0.1 (2016-07-06) - @mojavelinux
|
|
9
|
+
|
|
10
|
+
* align localtime and localdate attributes with site.time and site.timezone (#117)
|
|
11
|
+
* don't register hook callbacks again when regenerating site; use static methods for hook callbacks (#121)
|
|
12
|
+
* bundle CHANGELOG.adoc and test suite in gem
|
|
13
|
+
* minor improvements to README
|
|
14
|
+
|
|
15
|
+
== 2.0.0 (2016-07-02) - @mojavelinux
|
|
16
|
+
|
|
17
|
+
* Split source into multiple files; move all classes under the `Jekyll::AsciiDoc` module
|
|
18
|
+
* Avoid redundant initialization caused by the jekyll-watch plugin
|
|
19
|
+
* Set docdir, docfile, docname, outfile, outdir, and outpath attributes for each file if using Jekyll 3 (#59)
|
|
20
|
+
- docdir is only set if value of `base_dir` option is `:docdir`
|
|
21
|
+
- setting outdir allows proper integration with Asciidoctor Diagram
|
|
22
|
+
* Automatically set `imagesoutdir` attribute if `imagesdir` attribute is relative to root
|
|
23
|
+
* Pass site information (root, source, destination, baseurl and url) through as AsciiDoc attributes
|
|
24
|
+
* Automatically generate stylesheet for Pygments (#30)
|
|
25
|
+
* Change default layout to match collection label (#104)
|
|
26
|
+
- page for pages, post for posts, collection label for all others; use default layout as fallback
|
|
27
|
+
* Resolve attribute references in attribute values defined in config (#103)
|
|
28
|
+
* Apply AsciiDoc header integration to documents in all collections (#93)
|
|
29
|
+
* Document how to create and enable templates to customize the HTML that Asciidoctor generates (#73)
|
|
30
|
+
* Allow `base_dir` option to track document directory by setting the value to `:docdir` (#80)
|
|
31
|
+
* Add a comprehensive test suite (#77)
|
|
32
|
+
* Allow site-wide Asciidoctor attributes to be specified as a Hash; convert to Hash if Array is used (#87)
|
|
33
|
+
* Interpret page attribute values as YAML data
|
|
34
|
+
* Use Jekyll.logger to write log messages (#85)
|
|
35
|
+
* Add topic to all log messages
|
|
36
|
+
* Restructure configuration keys so all general settings are under the `asciidoc` key (#82)
|
|
37
|
+
* Don't enable `hardbreaks` attribute by default (#69)
|
|
38
|
+
* Bump minimum version of Jekyll to 2.3.0 and document requirement in README (#76)
|
|
39
|
+
* Allow layout to be disabled to create standalone document; add and document additional option values for layout (#63)
|
|
40
|
+
* Make front matter header optional (#57)
|
|
41
|
+
* Apply site-wide Asciidoctor configuration (options/attributes) when loading document header (#67)
|
|
42
|
+
* Disable liquid processor on AsciiDoc files by default; enable using liquid page variable (#65)
|
|
43
|
+
* Resolve empty page attribute value as empty string (#70)
|
|
44
|
+
* Soft assign linkattrs attribute
|
|
45
|
+
* Allow plugin to work in safe mode (#112)
|
|
46
|
+
* Major restructure and rewrite of README
|
|
47
|
+
* Document how to use plugin with GitLab Pages (#47)
|
|
48
|
+
* Document asciidocify filter
|
|
49
|
+
|
|
50
|
+
{uri-repo}/issues?q=milestone%3Av2.0.0[issues resolved] |
|
|
51
|
+
{uri-repo}/releases/tag/v2.0.0[git tag]
|
|
52
|
+
|
|
53
|
+
== 1.1.2 (2016-05-10) - @mkobit
|
|
54
|
+
|
|
55
|
+
* Apply fix for documents that did not contain at least one attribute beginning with `page-` (#60)
|
|
56
|
+
|
|
57
|
+
{uri-repo}/issues?q=milestone%3Av1.1.2[issues resolved] |
|
|
58
|
+
{uri-repo}/releases/tag/v1.1.2[git tag]
|
|
59
|
+
|
|
60
|
+
== 1.1.1 (2016-05-07) - @mkobit
|
|
61
|
+
|
|
62
|
+
* The AsciiDoc document title overrides the title set in the front matter or the auto-generated title (in the case of a post) (#48)
|
|
63
|
+
* The AsciiDoc page-related attributes override the matching entries in the page data (i.e., front matter)
|
|
64
|
+
* The value of page-related attributes are treated as YAML values (automatic type coercion)
|
|
65
|
+
* `page-` is the default prefix for page-related AsciiDoc attributes (e.g., `page-layout`) (#51)
|
|
66
|
+
* The key to configure the page attribute prefix is `asciidoc_page_attribute_prefix`; the value should not contain the trailing hyphen (#51)
|
|
67
|
+
* The date of a post can be set using the `revdate` AsciiDoc attribute (#53)
|
|
68
|
+
* Only configure the Asciidoctor options once (previously it was being called twice in serve mode)
|
|
69
|
+
* Set `env` attribute to `site` instead of `jekyll` (#55)
|
|
70
|
+
|
|
71
|
+
{uri-repo}/issues?q=milestone%3Av1.1.1[issues resolved] |
|
|
72
|
+
{uri-repo}/releases/tag/v1.1.1[git tag]
|
|
73
|
+
|
|
74
|
+
== 1.0.1 (2016-03-19) - @mkobit
|
|
75
|
+
|
|
76
|
+
Enables use with Jekyll 3.
|
|
77
|
+
It is still compatible with Jekyll 2.
|
|
78
|
+
|
|
79
|
+
* Jekyll 3 support (#36, #33)
|
|
80
|
+
* Documentation and onboarding improvements (#25, #24)
|
|
81
|
+
* Improvements to release process (#28)
|
|
82
|
+
|
|
83
|
+
{uri-repo}/issues?q=milestone%3Av1.0.1[issues resolved] |
|
|
84
|
+
{uri-repo}/releases/tag/v1.0.1[git tag]
|
|
85
|
+
|
|
86
|
+
== 1.0.0 (2015-01-04) - @paulrayner
|
|
87
|
+
|
|
88
|
+
Initial release.
|
|
89
|
+
|
|
90
|
+
{uri-repo}/issues?q=milestone%3Av1.0.0[issues resolved] |
|
|
91
|
+
{uri-repo}/releases/tag/v1.0.0[git tag]
|
data/Gemfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
gemspec
|
|
3
|
+
|
|
4
|
+
gem 'jekyll', %(~> #{ENV['JEKYLL_VERSION']}) if ENV.key? 'JEKYLL_VERSION'
|
|
5
|
+
|
|
6
|
+
if RUBY_ENGINE == 'jruby'
|
|
7
|
+
gem 'pygments.rb', github: 'mojavelinux/pygments.rb', branch: 'support-jruby'
|
|
8
|
+
else
|
|
9
|
+
gem 'pygments.rb', '~> 0.6.3'
|
|
10
|
+
end
|
data/README.adoc
CHANGED
|
@@ -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
|
-
v2.0.
|
|
3
|
+
v2.0.1, 2016-07-06
|
|
4
4
|
// Settings:
|
|
5
5
|
:idprefix:
|
|
6
6
|
:idseparator: -
|
|
@@ -206,11 +206,15 @@ You can now build your site using:
|
|
|
206
206
|
|
|
207
207
|
$ jekyll build
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
or preview it using:
|
|
210
210
|
|
|
211
211
|
$ jekyll serve
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
You can continuously build without preview using:
|
|
214
|
+
|
|
215
|
+
$ jekyll build --watch
|
|
216
|
+
|
|
217
|
+
If you're using Bundler, prefix the commands with `bundle exec`, as in:
|
|
214
218
|
|
|
215
219
|
$ bundle exec jekyll build
|
|
216
220
|
|
|
@@ -439,7 +443,7 @@ Each template file corresponds to a node in the AsciiDoc document tree (aka AST)
|
|
|
439
443
|
|
|
440
444
|
Below are the steps you need to take to configure Asciidoctor to use custom templates with your site.
|
|
441
445
|
|
|
442
|
-
=== Step
|
|
446
|
+
=== Step {counter:step}: Add Required Gems
|
|
443
447
|
|
|
444
448
|
You'll first need to add the thread_safe gem as well as the gem for the templating language you plan to use.
|
|
445
449
|
We'll assume that you are using Slim.
|
|
@@ -450,19 +454,19 @@ gem 'slim', '~> 3.0.7'
|
|
|
450
454
|
gem 'thread_safe', '~> 0.3.5'
|
|
451
455
|
----
|
|
452
456
|
|
|
453
|
-
=== Step
|
|
457
|
+
=== Step {counter:step}: Install New Gems
|
|
454
458
|
|
|
455
459
|
Now run the `bundle` command to install the new gems.
|
|
456
460
|
|
|
457
461
|
$ bundle
|
|
458
462
|
|
|
459
|
-
=== Step
|
|
463
|
+
=== Step {counter:step}: Create a Templates Folder
|
|
460
464
|
|
|
461
465
|
Next, create a new folder in your site named [path]__templates_ to store your templates.
|
|
462
466
|
|
|
463
467
|
$ mkdir _templates
|
|
464
468
|
|
|
465
|
-
=== Step
|
|
469
|
+
=== Step {counter:step}: Configure Asciidoctor to Load Templates
|
|
466
470
|
|
|
467
471
|
In your site's {path-config} file, configure Asciidoctor to load the templates by telling it the location where the templates are stored.
|
|
468
472
|
|
|
@@ -473,7 +477,7 @@ asciidoctor:
|
|
|
473
477
|
attributes: ...
|
|
474
478
|
----
|
|
475
479
|
|
|
476
|
-
=== Step
|
|
480
|
+
=== Step {counter:step}: Compose a Template
|
|
477
481
|
|
|
478
482
|
The final step is to compose a template.
|
|
479
483
|
We'll be customizing the unordered list node.
|
|
@@ -805,15 +809,20 @@ GitHub doesn't (yet) whitelist the AsciiDoc plugin, so you must run Jekyll eithe
|
|
|
805
809
|
GitHub needs to hear from enough users that need this plugin to persuade them to enable it.
|
|
806
810
|
Our recommendation is to https://github.com/contact[contact support] and keep asking for it.
|
|
807
811
|
|
|
808
|
-
Refer to the help page https://help.github.com/articles/adding-jekyll-plugins-to-a-github-pages-site
|
|
812
|
+
Refer to the help page https://help.github.com/articles/adding-jekyll-plugins-to-a-github-pages-site[Adding Jekyll Plugins to a GitHub Pages site] for a list of plugins currently supported on GitHub Pages.
|
|
809
813
|
====
|
|
810
814
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
815
|
+
_But don't despair!_
|
|
816
|
+
You can still automate publishing of the generated site to GitHub Pages using a continuous integration job.
|
|
817
|
+
Refer to the http://eshepelyuk.github.io/2014/10/28/automate-github-pages-travisci.html[Automate GitHub Pages publishing with Jekyll and Travis CI^] tutorial to find step-by-step instructions.
|
|
818
|
+
You can also refer to the https://github.com/johncarl81/transfuse-site[Transfuse website build^] for an example in practice.
|
|
814
819
|
|
|
815
|
-
TIP:
|
|
816
|
-
|
|
820
|
+
TIP: When using this setup, don't forget to add the [path]_.nojekyll_ file to the root of the source to tell GitLab Pages not to waste time running Jekyll again on the server.
|
|
821
|
+
|
|
822
|
+
=== Jekyll AsciiDoc Quickstart
|
|
823
|
+
|
|
824
|
+
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.
|
|
825
|
+
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.
|
|
817
826
|
|
|
818
827
|
== Using this Plugin on GitLab Pages
|
|
819
828
|
|
|
@@ -1006,8 +1015,10 @@ The coding style is as follows:
|
|
|
1006
1015
|
if key.start_with? '!'
|
|
1007
1016
|
...
|
|
1008
1017
|
end
|
|
1009
|
-
|
|
1010
|
-
|
|
1018
|
+
|
|
1019
|
+
* For chained method calls, wrap parentheses around nested method call.
|
|
1020
|
+
|
|
1021
|
+
asciidoctor_config.replace (Utils.symbolize_keys asciidoctor_config)
|
|
1011
1022
|
|
|
1012
1023
|
* Use parentheses outside of a method call when parentheses are required.
|
|
1013
1024
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path '../lib/jekyll-asciidoc/version', __FILE__
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = 'jekyll-asciidoc'
|
|
5
|
+
s.version = Jekyll::AsciiDoc::VERSION
|
|
6
|
+
s.summary = 'A Jekyll plugin that converts AsciiDoc source files in your site to HTML pages using Asciidoctor.'
|
|
7
|
+
s.description = 'A Jekyll plugin that converts AsciiDoc source files in your site to HTML pages using Asciidoctor.'
|
|
8
|
+
s.authors = ['Dan Allen', 'Paul Rayner']
|
|
9
|
+
s.email = ['dan.j.allen@gmail.com']
|
|
10
|
+
s.homepage = 'https://github.com/asciidoctor/jekyll-asciidoc'
|
|
11
|
+
s.license = 'MIT'
|
|
12
|
+
|
|
13
|
+
files = begin
|
|
14
|
+
output = IO.popen('git ls-files -z', err: File::NULL) {|io| io.read }.split %(\0)
|
|
15
|
+
$?.success? ? output : Dir['**/*']
|
|
16
|
+
rescue
|
|
17
|
+
Dir['**/*']
|
|
18
|
+
end
|
|
19
|
+
s.files = files.grep /^(?:lib\/.+|Gemfile|Rakefile|(CHANGELOG|LICENSE|README)\.adoc|#{s.name}\.gemspec)$/
|
|
20
|
+
s.test_files = files.grep /^spec\//
|
|
21
|
+
|
|
22
|
+
s.require_paths = ['lib']
|
|
23
|
+
|
|
24
|
+
s.add_runtime_dependency 'asciidoctor', '>= 1.5.0'
|
|
25
|
+
s.add_runtime_dependency 'jekyll', '>= 2.3.0'
|
|
26
|
+
|
|
27
|
+
s.add_development_dependency 'rake'
|
|
28
|
+
s.add_development_dependency 'rspec', '~> 3.5.0'
|
|
29
|
+
# enable pygments.rb dependency here once https://github.com/tmm1/pygments.rb/pull/162 is merged & released
|
|
30
|
+
#s.add_development_dependency 'pygments.rb', '~> 0.6.3'
|
|
31
|
+
end
|
|
@@ -7,8 +7,13 @@ end
|
|
|
7
7
|
module Jekyll
|
|
8
8
|
class Site
|
|
9
9
|
# Backport {::Jekyll::Site#find_converter_instance} to Jekyll 2.
|
|
10
|
-
def find_converter_instance
|
|
11
|
-
|
|
10
|
+
def find_converter_instance type
|
|
11
|
+
converters.find {|candidate| type === candidate } || (raise %(No Converters found for #{type}))
|
|
12
12
|
end unless respond_to? :find_converter_instance
|
|
13
|
+
|
|
14
|
+
# Introduce complement to {::Jekyll::Site#find_converter_instance} for generators.
|
|
15
|
+
def find_generator_instance type
|
|
16
|
+
generators.find {|candidate| type === candidate } || (raise %(No Generators found for #{type}))
|
|
17
|
+
end unless respond_to? :find_generator_instance
|
|
13
18
|
end
|
|
14
19
|
end
|
|
@@ -17,13 +17,14 @@ module Jekyll
|
|
|
17
17
|
'builder-jekyll' => '',
|
|
18
18
|
'jekyll-version' => ::Jekyll::VERSION
|
|
19
19
|
}
|
|
20
|
-
MessageTopic =
|
|
21
|
-
|
|
20
|
+
MessageTopic = Utils::MessageTopic
|
|
21
|
+
NewLine = Utils::NewLine
|
|
22
|
+
StandaloneOptionLine = %([%standalone]#{NewLine})
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
AttributeReferenceRx = /\\?\{(\w+(?:[\-]\w+)*)\}/
|
|
25
|
+
HeaderBoundaryRx = /(?<=\p{Graph})#{NewLine * 2}/
|
|
24
26
|
|
|
25
|
-
# Enable plugin when running in safe mode
|
|
26
|
-
# jekyll-asciidoc gem must also be declared in whitelist
|
|
27
|
+
# Enable plugin when running in safe mode; jekyll-asciidoc gem must also be declared in whitelist
|
|
27
28
|
safe true
|
|
28
29
|
|
|
29
30
|
# highlighter prefix/suffix not used by this plugin; defined only to avoid warning
|
|
@@ -75,7 +76,7 @@ module Jekyll
|
|
|
75
76
|
if (@asciidoc_config = asciidoc_config)['processor'] == 'asciidoctor'
|
|
76
77
|
unless Configured === (@asciidoctor_config = (config['asciidoctor'] ||= {}))
|
|
77
78
|
asciidoctor_config = @asciidoctor_config
|
|
78
|
-
asciidoctor_config.replace
|
|
79
|
+
asciidoctor_config.replace (symbolize_keys asciidoctor_config)
|
|
79
80
|
source = ::File.expand_path config['source']
|
|
80
81
|
dest = ::File.expand_path config['destination']
|
|
81
82
|
case (base = asciidoctor_config[:base_dir])
|
|
@@ -99,7 +100,7 @@ module Jekyll
|
|
|
99
100
|
'site-baseurl' => config['baseurl'],
|
|
100
101
|
'site-url' => config['url']
|
|
101
102
|
}
|
|
102
|
-
attrs = asciidoctor_config[:attributes] =
|
|
103
|
+
attrs = asciidoctor_config[:attributes] = hashify_attributes asciidoctor_config[:attributes],
|
|
103
104
|
((site_attributes.merge ImplicitAttributes).merge DefaultAttributes)
|
|
104
105
|
if (imagesdir = attrs['imagesdir']) && !(attrs.key? 'imagesoutdir') && (imagesdir.start_with? '/')
|
|
105
106
|
attrs['imagesoutdir'] = ::File.join dest, imagesdir
|
|
@@ -129,6 +130,10 @@ module Jekyll
|
|
|
129
130
|
self
|
|
130
131
|
end
|
|
131
132
|
|
|
133
|
+
def self.get_instance site
|
|
134
|
+
site.find_converter_instance self
|
|
135
|
+
end
|
|
136
|
+
|
|
132
137
|
def matches ext
|
|
133
138
|
ext =~ @asciidoc_config['ext_re']
|
|
134
139
|
end
|
|
@@ -137,12 +142,20 @@ module Jekyll
|
|
|
137
142
|
'.html'
|
|
138
143
|
end
|
|
139
144
|
|
|
145
|
+
def self.before_render document, payload
|
|
146
|
+
(get_instance document.site).before_render document, payload if Document === document
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.after_render document
|
|
150
|
+
(get_instance document.site).after_render document if Document === document
|
|
151
|
+
end
|
|
152
|
+
|
|
140
153
|
def before_render document, payload
|
|
141
|
-
record_path_info document
|
|
154
|
+
record_path_info document
|
|
142
155
|
end
|
|
143
156
|
|
|
144
157
|
def after_render document
|
|
145
|
-
clear_path_info
|
|
158
|
+
clear_path_info
|
|
146
159
|
end
|
|
147
160
|
|
|
148
161
|
def record_path_info document, opts = {}
|
|
@@ -213,6 +226,45 @@ module Jekyll
|
|
|
213
226
|
content
|
|
214
227
|
end
|
|
215
228
|
end
|
|
229
|
+
|
|
230
|
+
private
|
|
231
|
+
|
|
232
|
+
def symbolize_keys hash
|
|
233
|
+
hash.each_with_object({}) {|(key, val), accum| accum[key.to_sym] = val }
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def hashify_attributes attrs, initial = {}
|
|
237
|
+
if (is_array = ::Array === attrs) || ::Hash === attrs
|
|
238
|
+
attrs.each_with_object(initial) {|entry, new_attrs|
|
|
239
|
+
key, val = is_array ? ((entry.split '=', 2) + ['', ''])[0..1] : entry
|
|
240
|
+
if key.start_with? '!'
|
|
241
|
+
new_attrs[key[1..-1]] = nil
|
|
242
|
+
elsif key.end_with? '!'
|
|
243
|
+
new_attrs[key.chop] = nil
|
|
244
|
+
else
|
|
245
|
+
new_attrs[key] = val ? (resolve_attribute_refs val, new_attrs) : nil
|
|
246
|
+
end
|
|
247
|
+
}
|
|
248
|
+
else
|
|
249
|
+
initial
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def resolve_attribute_refs text, attrs
|
|
254
|
+
if text.empty?
|
|
255
|
+
text
|
|
256
|
+
elsif text.include? '{'
|
|
257
|
+
text.gsub(AttributeReferenceRx) { ((m = $&).start_with? '\\') ? m[1..-1] : (attrs.fetch $1, m) }
|
|
258
|
+
else
|
|
259
|
+
text
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Register pre and post render callbacks for saving and clearing contextual AsciiDoc attributes, respectively.
|
|
264
|
+
::Jekyll::Hooks.tap do |hooks|
|
|
265
|
+
hooks.register [:pages, :documents], :pre_render, &(method :before_render)
|
|
266
|
+
hooks.register [:pages, :documents], :post_render, &(method :after_render)
|
|
267
|
+
end if defined? ::Jekyll::Hooks
|
|
216
268
|
end
|
|
217
269
|
end
|
|
218
270
|
end
|
|
@@ -8,7 +8,7 @@ module Jekyll
|
|
|
8
8
|
#
|
|
9
9
|
# Returns the HTML formatted String.
|
|
10
10
|
def asciidocify input, doctype = nil
|
|
11
|
-
(@context.registers[:cached_asciidoc_converter] ||= (
|
|
11
|
+
(@context.registers[:cached_asciidoc_converter] ||= (Converter.get_instance @context.registers[:site]))
|
|
12
12
|
.convert(doctype ? %(:doctype: #{doctype}#{Utils::NewLine}#{input}) : (input || ''))
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
module Jekyll
|
|
2
2
|
module AsciiDoc
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# Promotes eligible AsciiDoc attributes to page variables and applies page-level settings to all documents handled
|
|
4
|
+
# by the converter included with this plugin. It also copies the custom Pygments stylesheet if Pygments is the
|
|
5
|
+
# source highlighter and configured to use class-based styling.
|
|
6
6
|
class Integrator < ::Jekyll::Generator
|
|
7
7
|
NewLine = Utils::NewLine
|
|
8
|
-
StandaloneOptionLine =
|
|
8
|
+
StandaloneOptionLine = Converter::StandaloneOptionLine
|
|
9
9
|
|
|
10
|
-
# Enable plugin when running in safe mode
|
|
11
|
-
# jekyll-asciidoc gem must also be declared in whitelist
|
|
10
|
+
# Enable plugin when running in safe mode; jekyll-asciidoc gem must also be declared in whitelist
|
|
12
11
|
safe true
|
|
13
12
|
|
|
13
|
+
def self.get_instance site
|
|
14
|
+
site.find_generator_instance self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# This method is triggered each time the site is generated, including after any file has changed when
|
|
18
|
+
# running in watch mode (regardless of incremental setting).
|
|
14
19
|
def generate site
|
|
15
|
-
@converter = converter = (
|
|
16
|
-
|
|
17
|
-
if defined? ::Jekyll::Hooks
|
|
18
|
-
before_render_callback = converter.method :before_render
|
|
19
|
-
after_render_callback = converter.method :after_render
|
|
20
|
-
[:pages, :documents].each do |collection_name|
|
|
21
|
-
::Jekyll::Hooks.register collection_name, :pre_render, &before_render_callback
|
|
22
|
-
::Jekyll::Hooks.register collection_name, :post_render, &after_render_callback
|
|
23
|
-
end
|
|
24
|
-
end
|
|
20
|
+
@converter = converter = (Converter.get_instance site).setup
|
|
25
21
|
|
|
26
22
|
unless (@page_attr_prefix = site.config['asciidoc']['page_attribute_prefix']).empty?
|
|
27
23
|
@page_attr_prefix = %(#{@page_attr_prefix}-)
|
|
@@ -43,8 +39,9 @@ module Jekyll
|
|
|
43
39
|
end
|
|
44
40
|
end
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
attrs = site.config['asciidoctor'][:attributes]
|
|
43
|
+
attrs['localdate'], attrs['localtime'] = (site.time.strftime '%Y-%m-%d %H:%M:%S %Z').split ' ', 2
|
|
44
|
+
if ((attrs['source-highlighter'] || '').chomp '@') == 'pygments' &&
|
|
48
45
|
((attrs['pygments-css'] || '').chomp '@') != 'style' && (attrs.fetch 'pygments-stylesheet', '')
|
|
49
46
|
generate_pygments_stylesheet site, attrs
|
|
50
47
|
end
|
|
@@ -72,7 +69,7 @@ module Jekyll
|
|
|
72
69
|
unless (adoc_header_data = doc.attributes
|
|
73
70
|
.each_with_object({}) {|(key, val), accum|
|
|
74
71
|
if no_prefix || ((key.start_with? @page_attr_prefix) && key = key[prefix_size..-1])
|
|
75
|
-
accum[key] = ::String === val ? (
|
|
72
|
+
accum[key] = ::String === val ? (parse_yaml_value val) : val
|
|
76
73
|
end
|
|
77
74
|
}).empty?
|
|
78
75
|
document.data.update adoc_header_data
|
|
@@ -109,11 +106,39 @@ module Jekyll
|
|
|
109
106
|
if site.static_files.any? {|f| f.path == css_file }
|
|
110
107
|
::IO.write css_file, css unless css == (::IO.read css_file)
|
|
111
108
|
else
|
|
112
|
-
::Asciidoctor::Helpers.mkdir_p ::File.dirname css_file
|
|
109
|
+
::Asciidoctor::Helpers.mkdir_p (::File.dirname css_file)
|
|
113
110
|
::IO.write css_file, css
|
|
114
111
|
site.static_files << (::Jekyll::StaticFile.new site, css_base, css_dir, css_name)
|
|
115
112
|
end
|
|
116
113
|
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
# Parse the specified value as though it is a single-line value part of a
|
|
118
|
+
# YAML key/value pair.
|
|
119
|
+
#
|
|
120
|
+
# Attempt to parse the specified String value as though it is a
|
|
121
|
+
# single-line value part of a YAML key/value pair. If the value fails to
|
|
122
|
+
# parse, wrap the value in single quotes (after escaping any single
|
|
123
|
+
# quotes in the value) and parse it as a character sequence. If the value
|
|
124
|
+
# is empty, return an empty String.
|
|
125
|
+
#
|
|
126
|
+
# val - The String value to parse.
|
|
127
|
+
#
|
|
128
|
+
# Returns an [Object] parsed from the string-based YAML value or empty
|
|
129
|
+
# [String] if the specified value is empty.
|
|
130
|
+
def parse_yaml_value val
|
|
131
|
+
if val.empty?
|
|
132
|
+
''
|
|
133
|
+
else
|
|
134
|
+
begin
|
|
135
|
+
::SafeYAML.load %(--- #{val})
|
|
136
|
+
rescue
|
|
137
|
+
val = val.gsub '\'', '\'\'' if val.include? '\''
|
|
138
|
+
::SafeYAML.load %(--- \'#{val}\')
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
117
142
|
end
|
|
118
143
|
end
|
|
119
144
|
end
|