asciidoctor 0.1.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +209 -25
- data/{LICENSE → LICENSE.adoc} +4 -3
- data/README.adoc +392 -395
- data/Rakefile +94 -137
- data/benchmark/benchmark.rb +127 -0
- data/benchmark/sample-data/mdbasics.adoc +334 -0
- data/bin/asciidoctor +5 -8
- data/bin/asciidoctor-safe +4 -8
- data/compat/asciidoc.conf +78 -11
- data/compat/font-awesome-3-compat.css +397 -0
- data/data/stylesheets/asciidoctor-default.css +399 -0
- data/data/stylesheets/coderay-asciidoctor.css +89 -0
- data/features/open_block.feature +92 -0
- data/features/pass_block.feature +66 -0
- data/features/step_definitions.rb +42 -0
- data/features/text_formatting.feature +55 -0
- data/features/xref.feature +116 -0
- data/lib/asciidoctor.rb +1155 -605
- data/lib/asciidoctor/abstract_block.rb +157 -71
- data/lib/asciidoctor/abstract_node.rb +150 -93
- data/lib/asciidoctor/attribute_list.rb +85 -90
- data/lib/asciidoctor/block.rb +51 -24
- data/lib/asciidoctor/callouts.rb +4 -7
- data/lib/asciidoctor/cli.rb +3 -0
- data/lib/asciidoctor/cli/invoker.rb +86 -76
- data/lib/asciidoctor/cli/options.rb +111 -61
- data/lib/asciidoctor/converter.rb +232 -0
- data/lib/asciidoctor/converter/base.rb +58 -0
- data/lib/asciidoctor/converter/composite.rb +66 -0
- data/lib/asciidoctor/converter/docbook45.rb +94 -0
- data/lib/asciidoctor/converter/docbook5.rb +684 -0
- data/lib/asciidoctor/converter/factory.rb +225 -0
- data/lib/asciidoctor/converter/html5.rb +1081 -0
- data/lib/asciidoctor/converter/template.rb +296 -0
- data/lib/asciidoctor/core_ext.rb +7 -0
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
- data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
- data/lib/asciidoctor/document.rb +590 -304
- data/lib/asciidoctor/extensions.rb +1100 -308
- data/lib/asciidoctor/helpers.rb +109 -46
- data/lib/asciidoctor/inline.rb +16 -9
- data/lib/asciidoctor/list.rb +23 -15
- data/lib/asciidoctor/opal_ext.rb +4 -0
- data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
- data/lib/asciidoctor/opal_ext/dir.rb +13 -0
- data/lib/asciidoctor/opal_ext/error.rb +2 -0
- data/lib/asciidoctor/opal_ext/file.rb +125 -0
- data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
- data/lib/asciidoctor/path_resolver.rb +141 -77
- data/lib/asciidoctor/reader.rb +257 -187
- data/lib/asciidoctor/section.rb +12 -16
- data/lib/asciidoctor/stylesheets.rb +91 -0
- data/lib/asciidoctor/substitutors.rb +1548 -0
- data/lib/asciidoctor/table.rb +73 -57
- data/lib/asciidoctor/timings.rb +39 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -14
- data/man/asciidoctor.adoc +18 -10
- data/test/attributes_test.rb +314 -14
- data/test/blocks_test.rb +763 -118
- data/test/converter_test.rb +352 -0
- data/test/document_test.rb +518 -199
- data/test/extensions_test.rb +273 -103
- data/test/fixtures/asciidoc_index.txt +27 -13
- data/test/fixtures/basic-docinfo.xml +1 -1
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/docinfo.xml +1 -1
- data/test/fixtures/include-file.asciidoc +2 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/invoker_test.rb +173 -61
- data/test/links_test.rb +97 -21
- data/test/lists_test.rb +181 -22
- data/test/options_test.rb +86 -2
- data/test/paragraphs_test.rb +47 -5
- data/test/{lexer_test.rb → parser_test.rb} +128 -57
- data/test/paths_test.rb +36 -1
- data/test/preamble_test.rb +25 -17
- data/test/reader_test.rb +404 -249
- data/test/sections_test.rb +623 -58
- data/test/substitutions_test.rb +609 -132
- data/test/tables_test.rb +198 -24
- data/test/test_helper.rb +101 -31
- data/test/text_test.rb +88 -31
- metadata +160 -64
- data/Gemfile +0 -12
- data/Guardfile +0 -18
- data/asciidoctor.gemspec +0 -143
- data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
- data/lib/asciidoctor/backends/base_template.rb +0 -114
- data/lib/asciidoctor/backends/docbook45.rb +0 -774
- data/lib/asciidoctor/backends/docbook5.rb +0 -103
- data/lib/asciidoctor/backends/html5.rb +0 -1214
- data/lib/asciidoctor/renderer.rb +0 -259
- data/lib/asciidoctor/substituters.rb +0 -1083
- data/test/fixtures/asciidoc.txt +0 -105
- data/test/fixtures/ascshort.txt +0 -32
- data/test/fixtures/list_elements.asciidoc +0 -10
- data/test/renderer_test.rb +0 -162
data/test/fixtures/asciidoc.txt
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
AsciiDoc User Guide
|
2
|
-
===================
|
3
|
-
Stuart Rackham <srackham@gmail.com>
|
4
|
-
:Author Initials: SJR
|
5
|
-
:toc:
|
6
|
-
:icons:
|
7
|
-
:numbered:
|
8
|
-
:website: http://www.methods.co.nz/asciidoc/
|
9
|
-
|
10
|
-
AsciiDoc is a text document format for writing notes, documentation,
|
11
|
-
articles, books, ebooks, slideshows, web pages, blogs and UNIX man
|
12
|
-
pages.
|
13
|
-
|
14
|
-
.This document
|
15
|
-
**********************************************************************
|
16
|
-
This is an overly large document, it probably needs to be refactored
|
17
|
-
into a Tutorial, Quick Reference and Formal Reference.
|
18
|
-
|
19
|
-
If you're new to AsciiDoc read this section and the <<X6,Getting
|
20
|
-
Started>> section and take a look at the example AsciiDoc (`*.txt`)
|
21
|
-
source files in the distribution `doc` directory.
|
22
|
-
**********************************************************************
|
23
|
-
|
24
|
-
|
25
|
-
Introduction
|
26
|
-
------------
|
27
|
-
AsciiDoc is a plain text human readable/writable document format that
|
28
|
-
can be translated to DocBook or HTML using the asciidoc(1) command.
|
29
|
-
|
30
|
-
asciidoc(1) comes with a set of configuration files to translate
|
31
|
-
AsciiDoc articles, books and man pages to HTML or DocBook backend
|
32
|
-
formats.
|
33
|
-
|
34
|
-
.My AsciiDoc Itch
|
35
|
-
**********************************************************************
|
36
|
-
DocBook has emerged as the de facto standard Open Source documentation
|
37
|
-
format. But DocBook is a complex language, the markup is difficult to
|
38
|
-
read and even more difficult to write directly -- I found I was
|
39
|
-
and fixing syntax errors, than I was writing the documentation.
|
40
|
-
**********************************************************************
|
41
|
-
|
42
|
-
|
43
|
-
[[X6]]
|
44
|
-
Getting Started
|
45
|
-
---------------
|
46
|
-
Installing AsciiDoc
|
47
|
-
~~~~~~~~~~~~~~~~~~~
|
48
|
-
See the `README` and `INSTALL` files for install prerequisites and
|
49
|
-
procedures. Packagers take a look at <<X38,Packager Notes>>.
|
50
|
-
|
51
|
-
[[X11]]
|
52
|
-
Example AsciiDoc Documents
|
53
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
54
|
-
The best way to quickly get a feel for AsciiDoc is to view the
|
55
|
-
AsciiDoc web site and/or distributed examples:
|
56
|
-
|
57
|
-
- Take a look at the linked examples on the AsciiDoc web site home
|
58
|
-
page {website}. Press the 'Page Source' sidebar menu item to view
|
59
|
-
corresponding AsciiDoc source.
|
60
|
-
- Read the `*.txt` source files in the distribution `./doc` directory
|
61
|
-
along with the corresponding HTML and DocBook XML files.
|
62
|
-
|
63
|
-
|
64
|
-
AsciiDoc Document Types
|
65
|
-
-----------------------
|
66
|
-
There are three types of AsciiDoc documents: article, book and
|
67
|
-
manpage.
|
68
|
-
|
69
|
-
Use the asciidoc(1) `-d` (`--doctype`) option to specify the AsciiDoc
|
70
|
-
document type -- the default document type is 'article'.
|
71
|
-
|
72
|
-
article
|
73
|
-
~~~~~~~
|
74
|
-
Used for short documents, articles and general documentation. See the
|
75
|
-
AsciiDoc distribution `./doc/article.txt` example.
|
76
|
-
|
77
|
-
AsciiDoc defines standard DocBook article frontmatter and backmatter
|
78
|
-
<<X93,section markup templates>> (appendix, abstract, bibliography,
|
79
|
-
glossary, index).
|
80
|
-
|
81
|
-
book
|
82
|
-
~~~~
|
83
|
-
Books share the same format as articles, with the following
|
84
|
-
differences:
|
85
|
-
|
86
|
-
- The part titles in multi-part books are <<X17,top level titles>>
|
87
|
-
(same level as book title).
|
88
|
-
- Some sections are book specific e.g. preface and colophon.
|
89
|
-
|
90
|
-
Book documents will normally be used to produce DocBook output since
|
91
|
-
DocBook processors can automatically generate footnotes, table of
|
92
|
-
contents, list of tables, list of figures, list of examples and
|
93
|
-
indexes.
|
94
|
-
|
95
|
-
AsciiDoc defines standard DocBook book frontmatter and backmatter
|
96
|
-
<<X93,section markup templates>> (appendix, dedication, preface,
|
97
|
-
bibliography, glossary, index, colophon).
|
98
|
-
|
99
|
-
.Example book documents
|
100
|
-
Book::
|
101
|
-
The `./doc/book.txt` file in the AsciiDoc distribution.
|
102
|
-
|
103
|
-
Multi-part book::
|
104
|
-
The `./doc/book-multi.txt` file in the AsciiDoc distribution.
|
105
|
-
|
data/test/fixtures/ascshort.txt
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
AsciiDoc User Guide
|
2
|
-
===================
|
3
|
-
Stuart Rackham <srackham@gmail.com>
|
4
|
-
:Author Initials: SJR
|
5
|
-
:toc:
|
6
|
-
:icons:
|
7
|
-
:numbered:
|
8
|
-
:website: http://www.methods.co.nz/asciidoc/
|
9
|
-
|
10
|
-
AsciiDoc is a text document format for writing notes, documentation,
|
11
|
-
articles, books, ebooks, slideshows, web pages, blogs and UNIX man
|
12
|
-
pages.
|
13
|
-
|
14
|
-
.This document
|
15
|
-
**********************************************************************
|
16
|
-
This is an overly large document, it probably needs to be refactored
|
17
|
-
into a Tutorial, Quick Reference and Formal Reference.
|
18
|
-
|
19
|
-
If you're new to AsciiDoc read this section and the <<X6,Getting
|
20
|
-
Started>> section and take a look at the example AsciiDoc (`*.txt`)
|
21
|
-
source files in the distribution `doc` directory.
|
22
|
-
**********************************************************************
|
23
|
-
|
24
|
-
|
25
|
-
Introduction
|
26
|
-
------------
|
27
|
-
AsciiDoc is a plain text human readable/writable document format that
|
28
|
-
can be translated to DocBook or HTML using the asciidoc(1) command.
|
29
|
-
|
30
|
-
asciidoc(1) comes with a set of configuration files to translate
|
31
|
-
AsciiDoc articles, books and man pages to HTML or DocBook backend
|
32
|
-
formats.
|
data/test/renderer_test.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
context 'Renderer' do
|
5
|
-
|
6
|
-
context 'View mapping' do
|
7
|
-
test 'should extract view mapping from built-in template with one segment and backend' do
|
8
|
-
view_name, view_backend = Asciidoctor::Renderer.extract_view_mapping('Asciidoctor::HTML5::DocumentTemplate')
|
9
|
-
assert_equal 'document', view_name
|
10
|
-
assert_equal 'html5', view_backend
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'should extract view mapping from built-in template with two segments and backend' do
|
14
|
-
view_name, view_backend = Asciidoctor::Renderer.extract_view_mapping('Asciidoctor::DocBook45::BlockSidebarTemplate')
|
15
|
-
assert_equal 'block_sidebar', view_name
|
16
|
-
assert_equal 'docbook45', view_backend
|
17
|
-
end
|
18
|
-
|
19
|
-
test 'should extract view mapping from built-in template without backend' do
|
20
|
-
view_name, view_backend = Asciidoctor::Renderer.extract_view_mapping('Asciidoctor::DocumentTemplate')
|
21
|
-
assert_equal 'document', view_name
|
22
|
-
assert view_backend.nil?
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'View options' do
|
27
|
-
test 'should set Haml format to html5 for html5 backend' do
|
28
|
-
doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false
|
29
|
-
assert doc.renderer.views['block_paragraph'].is_a? Tilt::HamlTemplate
|
30
|
-
assert_equal :html5, doc.renderer.views['block_paragraph'].options[:format]
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'should set Haml format to xhtml for docbook backend' do
|
34
|
-
doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false
|
35
|
-
assert doc.renderer.views['block_paragraph'].is_a? Tilt::HamlTemplate
|
36
|
-
assert_equal :xhtml, doc.renderer.views['block_paragraph'].options[:format]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'Custom backends' do
|
41
|
-
test 'should load Haml templates for default backend' do
|
42
|
-
doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false
|
43
|
-
assert doc.renderer.views['block_paragraph'].is_a? Tilt::HamlTemplate
|
44
|
-
assert doc.renderer.views['block_paragraph'].file.end_with? 'block_paragraph.html.haml'
|
45
|
-
assert doc.renderer.views['block_sidebar'].is_a? Tilt::HamlTemplate
|
46
|
-
assert doc.renderer.views['block_sidebar'].file.end_with? 'block_sidebar.html.haml'
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'should load Haml templates for docbook45 backend' do
|
50
|
-
doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false
|
51
|
-
assert doc.renderer.views['block_paragraph'].is_a? Tilt::HamlTemplate
|
52
|
-
assert doc.renderer.views['block_paragraph'].file.end_with? 'block_paragraph.xml.haml'
|
53
|
-
end
|
54
|
-
|
55
|
-
test 'should use Haml templates in place of built-in templates' do
|
56
|
-
input = <<-EOS
|
57
|
-
= Document Title
|
58
|
-
Author Name
|
59
|
-
|
60
|
-
== Section One
|
61
|
-
|
62
|
-
Sample paragraph
|
63
|
-
|
64
|
-
.Related
|
65
|
-
****
|
66
|
-
Sidebar content
|
67
|
-
****
|
68
|
-
EOS
|
69
|
-
|
70
|
-
output = render_embedded_string input, :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false
|
71
|
-
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1
|
72
|
-
assert_xpath '//aside', output, 1
|
73
|
-
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1
|
74
|
-
assert_xpath '//aside/header/h1[text()="Related"]', output, 1
|
75
|
-
assert_xpath '//aside/header/following-sibling::p[text()="Sidebar content"]', output, 1
|
76
|
-
end
|
77
|
-
|
78
|
-
test 'should use built-in global cache to cache templates' do
|
79
|
-
# clear out any cache, just to be sure
|
80
|
-
Asciidoctor::Renderer.reset_global_cache
|
81
|
-
|
82
|
-
template_dir = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml')
|
83
|
-
doc = Asciidoctor::Document.new [], :template_dir => template_dir
|
84
|
-
doc.renderer
|
85
|
-
template_cache = Asciidoctor::Renderer.global_cache
|
86
|
-
assert template_cache.is_a? Asciidoctor::TemplateCache
|
87
|
-
cache = template_cache.cache
|
88
|
-
assert_not_nil cache
|
89
|
-
assert cache.size > 0
|
90
|
-
|
91
|
-
# ensure we don't scan a second time (using the view option hash to mark the cached view object)
|
92
|
-
template_path = Asciidoctor::PathResolver.new.system_path(File.join(template_dir, 'html5', 'block_paragraph.html.haml'), nil)
|
93
|
-
view = template_cache.fetch(:view, template_path)
|
94
|
-
view.options[:foo] = 'bar'
|
95
|
-
doc = Asciidoctor::Document.new [], :template_dir => template_dir
|
96
|
-
doc.renderer
|
97
|
-
template_cache = Asciidoctor::Renderer.global_cache
|
98
|
-
view = template_cache.fetch(:view, template_path)
|
99
|
-
assert_equal 'bar', view.options[:foo]
|
100
|
-
|
101
|
-
# clean up
|
102
|
-
Asciidoctor::Renderer.reset_global_cache
|
103
|
-
end
|
104
|
-
|
105
|
-
test 'should use custom cache to cache templates' do
|
106
|
-
template_dir = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml')
|
107
|
-
template_path = Asciidoctor::PathResolver.new.system_path(File.join(template_dir, 'html5', 'block_paragraph.html.haml'), nil)
|
108
|
-
doc = Asciidoctor::Document.new [], :template_dir => template_dir,
|
109
|
-
:template_cache => Asciidoctor::TemplateCache.new
|
110
|
-
template_cache = doc.renderer.cache
|
111
|
-
assert_not_nil template_cache
|
112
|
-
cache = template_cache.cache
|
113
|
-
assert_not_nil cache
|
114
|
-
assert cache.size > 0
|
115
|
-
view = template_cache.fetch(:view, template_path)
|
116
|
-
assert view.is_a? Tilt::HamlTemplate
|
117
|
-
end
|
118
|
-
|
119
|
-
test 'should be able to disable template cache' do
|
120
|
-
doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'),
|
121
|
-
:template_cache => false
|
122
|
-
assert_nil doc.renderer.cache
|
123
|
-
end
|
124
|
-
|
125
|
-
test 'should load Slim templates for default backend' do
|
126
|
-
doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false
|
127
|
-
assert doc.renderer.views['block_paragraph'].is_a? Slim::Template
|
128
|
-
assert doc.renderer.views['block_paragraph'].file.end_with? 'block_paragraph.html.slim'
|
129
|
-
assert doc.renderer.views['block_sidebar'].is_a? Slim::Template
|
130
|
-
assert doc.renderer.views['block_sidebar'].file.end_with? 'block_sidebar.html.slim'
|
131
|
-
end
|
132
|
-
|
133
|
-
test 'should load Slim templates for docbook45 backend' do
|
134
|
-
doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false
|
135
|
-
assert doc.renderer.views['block_paragraph'].is_a? Slim::Template
|
136
|
-
assert doc.renderer.views['block_paragraph'].file.end_with? 'block_paragraph.xml.slim'
|
137
|
-
end
|
138
|
-
|
139
|
-
test 'should use Slim templates in place of built-in templates' do
|
140
|
-
input = <<-EOS
|
141
|
-
= Document Title
|
142
|
-
Author Name
|
143
|
-
|
144
|
-
== Section One
|
145
|
-
|
146
|
-
Sample paragraph
|
147
|
-
|
148
|
-
.Related
|
149
|
-
****
|
150
|
-
Sidebar content
|
151
|
-
****
|
152
|
-
EOS
|
153
|
-
|
154
|
-
output = render_embedded_string input, :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false
|
155
|
-
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1
|
156
|
-
assert_xpath '//aside', output, 1
|
157
|
-
assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1
|
158
|
-
assert_xpath '//aside/header/h1[text()="Related"]', output, 1
|
159
|
-
assert_xpath '//aside/header/following-sibling::p[text()="Sidebar content"]', output, 1
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|