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.

Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +209 -25
  3. data/{LICENSE → LICENSE.adoc} +4 -3
  4. data/README.adoc +392 -395
  5. data/Rakefile +94 -137
  6. data/benchmark/benchmark.rb +127 -0
  7. data/benchmark/sample-data/mdbasics.adoc +334 -0
  8. data/bin/asciidoctor +5 -8
  9. data/bin/asciidoctor-safe +4 -8
  10. data/compat/asciidoc.conf +78 -11
  11. data/compat/font-awesome-3-compat.css +397 -0
  12. data/data/stylesheets/asciidoctor-default.css +399 -0
  13. data/data/stylesheets/coderay-asciidoctor.css +89 -0
  14. data/features/open_block.feature +92 -0
  15. data/features/pass_block.feature +66 -0
  16. data/features/step_definitions.rb +42 -0
  17. data/features/text_formatting.feature +55 -0
  18. data/features/xref.feature +116 -0
  19. data/lib/asciidoctor.rb +1155 -605
  20. data/lib/asciidoctor/abstract_block.rb +157 -71
  21. data/lib/asciidoctor/abstract_node.rb +150 -93
  22. data/lib/asciidoctor/attribute_list.rb +85 -90
  23. data/lib/asciidoctor/block.rb +51 -24
  24. data/lib/asciidoctor/callouts.rb +4 -7
  25. data/lib/asciidoctor/cli.rb +3 -0
  26. data/lib/asciidoctor/cli/invoker.rb +86 -76
  27. data/lib/asciidoctor/cli/options.rb +111 -61
  28. data/lib/asciidoctor/converter.rb +232 -0
  29. data/lib/asciidoctor/converter/base.rb +58 -0
  30. data/lib/asciidoctor/converter/composite.rb +66 -0
  31. data/lib/asciidoctor/converter/docbook45.rb +94 -0
  32. data/lib/asciidoctor/converter/docbook5.rb +684 -0
  33. data/lib/asciidoctor/converter/factory.rb +225 -0
  34. data/lib/asciidoctor/converter/html5.rb +1081 -0
  35. data/lib/asciidoctor/converter/template.rb +296 -0
  36. data/lib/asciidoctor/core_ext.rb +7 -0
  37. data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
  38. data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
  39. data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
  40. data/lib/asciidoctor/document.rb +590 -304
  41. data/lib/asciidoctor/extensions.rb +1100 -308
  42. data/lib/asciidoctor/helpers.rb +109 -46
  43. data/lib/asciidoctor/inline.rb +16 -9
  44. data/lib/asciidoctor/list.rb +23 -15
  45. data/lib/asciidoctor/opal_ext.rb +4 -0
  46. data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
  47. data/lib/asciidoctor/opal_ext/dir.rb +13 -0
  48. data/lib/asciidoctor/opal_ext/error.rb +2 -0
  49. data/lib/asciidoctor/opal_ext/file.rb +125 -0
  50. data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
  51. data/lib/asciidoctor/path_resolver.rb +141 -77
  52. data/lib/asciidoctor/reader.rb +257 -187
  53. data/lib/asciidoctor/section.rb +12 -16
  54. data/lib/asciidoctor/stylesheets.rb +91 -0
  55. data/lib/asciidoctor/substitutors.rb +1548 -0
  56. data/lib/asciidoctor/table.rb +73 -57
  57. data/lib/asciidoctor/timings.rb +39 -0
  58. data/lib/asciidoctor/version.rb +1 -1
  59. data/man/asciidoctor.1 +22 -14
  60. data/man/asciidoctor.adoc +18 -10
  61. data/test/attributes_test.rb +314 -14
  62. data/test/blocks_test.rb +763 -118
  63. data/test/converter_test.rb +352 -0
  64. data/test/document_test.rb +518 -199
  65. data/test/extensions_test.rb +273 -103
  66. data/test/fixtures/asciidoc_index.txt +27 -13
  67. data/test/fixtures/basic-docinfo.xml +1 -1
  68. data/test/fixtures/chapter-a.adoc +3 -0
  69. data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
  70. data/test/fixtures/docinfo.xml +1 -1
  71. data/test/fixtures/include-file.asciidoc +2 -0
  72. data/test/fixtures/master.adoc +5 -0
  73. data/test/invoker_test.rb +173 -61
  74. data/test/links_test.rb +97 -21
  75. data/test/lists_test.rb +181 -22
  76. data/test/options_test.rb +86 -2
  77. data/test/paragraphs_test.rb +47 -5
  78. data/test/{lexer_test.rb → parser_test.rb} +128 -57
  79. data/test/paths_test.rb +36 -1
  80. data/test/preamble_test.rb +25 -17
  81. data/test/reader_test.rb +404 -249
  82. data/test/sections_test.rb +623 -58
  83. data/test/substitutions_test.rb +609 -132
  84. data/test/tables_test.rb +198 -24
  85. data/test/test_helper.rb +101 -31
  86. data/test/text_test.rb +88 -31
  87. metadata +160 -64
  88. data/Gemfile +0 -12
  89. data/Guardfile +0 -18
  90. data/asciidoctor.gemspec +0 -143
  91. data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
  92. data/lib/asciidoctor/backends/base_template.rb +0 -114
  93. data/lib/asciidoctor/backends/docbook45.rb +0 -774
  94. data/lib/asciidoctor/backends/docbook5.rb +0 -103
  95. data/lib/asciidoctor/backends/html5.rb +0 -1214
  96. data/lib/asciidoctor/renderer.rb +0 -259
  97. data/lib/asciidoctor/substituters.rb +0 -1083
  98. data/test/fixtures/asciidoc.txt +0 -105
  99. data/test/fixtures/ascshort.txt +0 -32
  100. data/test/fixtures/list_elements.asciidoc +0 -10
  101. data/test/renderer_test.rb +0 -162
@@ -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
-
@@ -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.
@@ -1,10 +0,0 @@
1
- AsciiDoc Home Page
2
- ==================
3
-
4
- Example Articles
5
- ~~~~~~~~~~~~~~~~
6
- - Item 1
7
-
8
- - Item 2
9
-
10
- - Item 3
@@ -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