Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the examples into separate files so they can be tested
- Loading branch information
Showing
43 changed files
with
1,503 additions
and
314 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
docs/modules/extensions/examples/block-collapsible-extension-out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<details> | ||
<summary class="title">Show JSON</summary> | ||
<div class="content"> | ||
<div class="listingblock"> | ||
<div class="content"> | ||
<pre class="highlight"><code class="language-json" data-lang="json">{ | ||
"foo": "bar" | ||
}</code></pre> | ||
</div> | ||
</div> | ||
</div> | ||
</details> |
13 changes: 13 additions & 0 deletions
13
docs/modules/extensions/examples/block-collapsible-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
'.Show JSON | ||
[collapsible,json] | ||
---- | ||
{ | ||
"foo": "bar" | ||
} | ||
----' \ | ||
| asciidoctor -s -r ./block-collapsible-extension.rb - | ||
#end::runner[] |
29 changes: 29 additions & 0 deletions
29
docs/modules/extensions/examples/block-collapsible-extension.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
|
||
class CollapsibleBlock < Asciidoctor::Extensions::BlockProcessor | ||
enable_dsl | ||
|
||
named :collapsible | ||
contexts :listing | ||
positional_attributes 'language' | ||
|
||
def process parent, reader, attrs | ||
lang = attrs.delete 'language' | ||
attrs['title'] ||= 'Show Listing' | ||
example = create_example_block parent, [], attrs, content_model: :compound | ||
example.set_option 'collapsible' | ||
listing = create_listing_block example, reader.readlines, nil | ||
if lang | ||
listing.style = 'source' | ||
listing.set_attr 'language', lang | ||
listing.commit_subs | ||
end | ||
example << listing | ||
example | ||
end | ||
end | ||
|
||
Asciidoctor::Extensions.register do | ||
block CollapsibleBlock | ||
end |
6 changes: 6 additions & 0 deletions
6
docs/modules/extensions/examples/block-macro-gist-extension-out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="openblock gist"> | ||
<div class="title">My Gist</div> | ||
<div class="content"> | ||
<script src="https://gist.github.com/123456.js"></script> | ||
</div> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
docs/modules/extensions/examples/block-macro-gist-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
'.My Gist | ||
gist::123456[]' \ | ||
| asciidoctor -s -r ./block-macro-gist-extension.rb - | ||
#end::runner[] |
26 changes: 26 additions & 0 deletions
26
docs/modules/extensions/examples/block-macro-gist-extension.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
|
||
class GistBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor | ||
enable_dsl | ||
|
||
named :gist | ||
|
||
def process parent, target, attrs | ||
title_html = (attrs.has_key? 'title') ? | ||
%(<div class="title">#{attrs['title']}</div>\n) : nil | ||
|
||
html = %(<div class="openblock gist"> | ||
#{title_html}<div class="content"> | ||
<script src="https://gist.github.com/#{target}.js"></script> | ||
</div> | ||
</div>) | ||
|
||
create_pass_block parent, html, attrs, subs: nil | ||
end | ||
end | ||
|
||
# Self-registering | ||
Asciidoctor::Extensions.register do | ||
block_macro GistBlockMacro if document.basebackend? 'html' | ||
end |
6 changes: 6 additions & 0 deletions
6
docs/modules/extensions/examples/block-shout-extension-out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="paragraph"> | ||
<p>THE TIME IS NOW! GET A MOVE ON!</p> | ||
</div> | ||
<div class="paragraph"> | ||
<p>I MEAN IT!!!!</p> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
docs/modules/extensions/examples/block-shout-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
'[shout] | ||
The time is now. Get a move on. | ||
[shout,4] | ||
I mean it. | ||
' \ | ||
| asciidoctor -s -r ./block-shout-extension.rb - | ||
#end::runner[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
|
||
class ShoutBlock < Asciidoctor::Extensions::BlockProcessor | ||
PeriodRx = /\.(?= |$)/ | ||
|
||
enable_dsl | ||
|
||
named :shout | ||
contexts :paragraph | ||
positional_attributes 'vol' | ||
content_model :simple | ||
|
||
def process parent, reader, attrs | ||
volume = ((attrs.delete 'vol') || 1).to_i | ||
create_paragraph parent, (reader.lines.map {|l| l.upcase.gsub PeriodRx, '!' * volume }), attrs | ||
end | ||
end | ||
|
||
# self-registering | ||
Asciidoctor::Extensions.register do | ||
block ShoutBlock | ||
end |
461 changes: 461 additions & 0 deletions
461
docs/modules/extensions/examples/docinfo-google-analytics-extension-out.html
Large diffs are not rendered by default.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
docs/modules/extensions/examples/docinfo-google-analytics-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
'= Silly Page | ||
Who would look at this content? | ||
' \ | ||
| asciidoctor -r ./docinfo-google-analytics-extension.rb -a google-analytics-account=UA-ABCXYZ123 - | ||
#end::runner[] |
23 changes: 23 additions & 0 deletions
23
docs/modules/extensions/examples/docinfo-google-analytics-extension.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
|
||
class GoogleAnalyticsDocinfoProcessor < Asciidoctor::Extensions::DocinfoProcessor | ||
enable_dsl | ||
at_location :footer | ||
def process document | ||
return unless (ga_account_id = document.attr 'google-analytics-account') | ||
%(<script> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
ga('create','#{ga_account_id}','auto'); | ||
ga('send','pageview'); | ||
</script>) | ||
end | ||
end | ||
|
||
# Self-registering | ||
Asciidoctor::Extensions.register do | ||
docinfo_processor GoogleAnalyticsDocinfoProcessor | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
docs/modules/extensions/examples/include-uri-extension-out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<div class="listingblock"> | ||
<div class="title">Gemfile</div> | ||
<div class="content"> | ||
<pre class="highlight"><code class="language-ruby" data-lang="ruby">source 'https://rubygems.org' | ||
|
||
# Look in asciidoctor.gemspec for runtime and development dependencies | ||
gemspec | ||
|
||
group :development do | ||
gem 'asciimath', ENV['ASCIIMATH_VERSION'] if ENV.key? 'ASCIIMATH_VERSION' | ||
gem 'pygments.rb', ENV['PYGMENTS_VERSION'] if ENV.key? 'PYGMENTS_VERSION' | ||
gem 'rouge', ENV['ROUGE_VERSION'] if ENV.key? 'ROUGE_VERSION' | ||
gem 'haml', '~> 4.0' if RUBY_ENGINE == 'truffleruby' | ||
end | ||
|
||
group :docs do | ||
gem 'yard' | ||
gem 'yard-tomdoc' | ||
end | ||
|
||
# enable this group to use Guard for continuous testing | ||
# after removing comments, run `bundle install` then `guard` | ||
#group :guardtest do | ||
# gem 'guard' | ||
# gem 'guard-test' | ||
# gem 'libnotify' | ||
# gem 'listen', :github => 'guard/listen' | ||
#end | ||
|
||
group :ci do | ||
gem 'simplecov', '~> 0.16.0' | ||
gem 'json', '~> 2.2.0' if RUBY_ENGINE == 'truffleruby' | ||
end</code></pre> | ||
</div> | ||
</div> |
13 changes: 13 additions & 0 deletions
13
docs/modules/extensions/examples/include-uri-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
' | ||
.Gemfile | ||
[source,ruby] | ||
---- | ||
include::https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/Gemfile[] | ||
---- | ||
' \ | ||
| asciidoctor -s -r ./include-uri-extension.rb - | ||
#end::runner[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
require 'open-uri' | ||
|
||
class UriIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor | ||
def handles? target | ||
(target.start_with? 'http://') or (target.start_with? 'https://') | ||
end | ||
|
||
def process doc, reader, target, attributes | ||
content = (open target).readlines | ||
reader.push_include content, target, target, 1, attributes | ||
reader | ||
end | ||
end | ||
|
||
# Self-registering | ||
Asciidoctor::Extensions.register do | ||
include_processor UriIncludeProcessor | ||
end |
3 changes: 3 additions & 0 deletions
3
docs/modules/extensions/examples/inline-man-extension-out.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="paragraph"> | ||
<p>See <a href="gittutorial.html(7)">gittutorial</a> to get started.</p> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
docs/modules/extensions/examples/inline-man-extension-runner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
#tag::runner[] | ||
echo \ | ||
'See man:gittutorial[7] to get started. | ||
' \ | ||
| asciidoctor -s -r ./inline-man-extension.rb - | ||
#end::runner[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
|
||
class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor | ||
enable_dsl | ||
|
||
named :man | ||
name_positional_attributes 'volnum' | ||
|
||
def process parent, target, attrs | ||
text = manname = target | ||
suffix = '' | ||
target = %(#{manname}.html) | ||
suffix = if (volnum = attrs['volnum']) | ||
"(#{volnum})" | ||
else | ||
nil | ||
end | ||
parent.document.register :links, target | ||
create_anchor parent, text, type: :link, target: %(#{target}#{suffix}) | ||
end | ||
end | ||
|
||
# Self-registering | ||
Asciidoctor::Extensions.register do | ||
inline_macro ManInlineMacro | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.