asciidoctor 1.5.8 → 2.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.adoc +628 -45
- data/LICENSE +2 -1
- data/README-de.adoc +28 -38
- data/README-fr.adoc +30 -43
- data/README-jp.adoc +255 -201
- data/README-zh_CN.adoc +40 -44
- data/README.adoc +170 -143
- data/asciidoctor.gemspec +22 -34
- data/bin/asciidoctor +5 -4
- data/data/locale/attributes-ar.adoc +4 -3
- data/data/locale/attributes-be.adoc +23 -0
- data/data/locale/attributes-bg.adoc +4 -3
- data/data/locale/attributes-ca.adoc +6 -5
- data/data/locale/attributes-cs.adoc +4 -3
- data/data/locale/attributes-da.adoc +6 -5
- data/data/locale/attributes-de.adoc +6 -5
- data/data/locale/attributes-en.adoc +4 -4
- data/data/locale/attributes-es.adoc +6 -5
- data/data/locale/attributes-fa.adoc +4 -3
- data/data/locale/attributes-fi.adoc +4 -3
- data/data/locale/attributes-fr.adoc +8 -7
- data/data/locale/attributes-hu.adoc +4 -3
- data/data/locale/attributes-id.adoc +4 -3
- data/data/locale/attributes-it.adoc +6 -5
- data/data/locale/attributes-ja.adoc +4 -3
- data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
- data/data/locale/attributes-nb.adoc +4 -3
- data/data/locale/attributes-nl.adoc +6 -5
- data/data/locale/attributes-nn.adoc +4 -3
- data/data/locale/attributes-pl.adoc +8 -7
- data/data/locale/attributes-pt.adoc +6 -5
- data/data/locale/attributes-pt_BR.adoc +6 -5
- data/data/locale/attributes-ro.adoc +4 -3
- data/data/locale/attributes-ru.adoc +6 -5
- data/data/locale/attributes-sr.adoc +4 -4
- data/data/locale/attributes-sr_Latn.adoc +4 -4
- data/data/locale/attributes-sv.adoc +4 -4
- data/data/locale/attributes-th.adoc +23 -0
- data/data/locale/attributes-tr.adoc +4 -3
- data/data/locale/attributes-uk.adoc +6 -5
- data/data/locale/attributes-vi.adoc +23 -0
- data/data/locale/attributes-zh_CN.adoc +4 -3
- data/data/locale/attributes-zh_TW.adoc +4 -3
- data/data/reference/syntax.adoc +296 -0
- data/data/stylesheets/asciidoctor-default.css +120 -114
- data/data/stylesheets/coderay-asciidoctor.css +15 -17
- data/lib/asciidoctor/abstract_block.rb +146 -140
- data/lib/asciidoctor/abstract_node.rb +152 -170
- data/lib/asciidoctor/attribute_list.rb +77 -89
- data/lib/asciidoctor/block.rb +29 -28
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli/invoker.rb +20 -24
- data/lib/asciidoctor/cli/options.rb +107 -96
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/convert.rb +199 -0
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +627 -644
- data/lib/asciidoctor/converter/html5.rb +1053 -951
- data/lib/asciidoctor/converter/manpage.rb +581 -532
- data/lib/asciidoctor/converter/template.rb +232 -271
- data/lib/asciidoctor/converter.rb +370 -185
- data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
- data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
- data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
- data/lib/asciidoctor/core_ext.rb +8 -17
- data/lib/asciidoctor/document.rb +503 -461
- data/lib/asciidoctor/extensions.rb +127 -174
- data/lib/asciidoctor/helpers.rb +184 -107
- data/lib/asciidoctor/inline.rb +9 -12
- data/lib/asciidoctor/list.rb +11 -29
- data/lib/asciidoctor/load.rb +119 -0
- data/lib/asciidoctor/logging.rb +22 -17
- data/lib/asciidoctor/parser.rb +673 -719
- data/lib/asciidoctor/path_resolver.rb +48 -33
- data/lib/asciidoctor/reader.rb +383 -338
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/rx.rb +723 -0
- data/lib/asciidoctor/section.rb +17 -16
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +926 -1022
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
- data/lib/asciidoctor/syntax_highlighter.rb +253 -0
- data/lib/asciidoctor/table.rb +152 -114
- data/lib/asciidoctor/timings.rb +7 -5
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/lib/asciidoctor.rb +266 -1340
- data/man/asciidoctor.1 +49 -47
- data/man/asciidoctor.adoc +54 -45
- metadata +50 -245
- data/CONTRIBUTING.adoc +0 -185
- data/Gemfile +0 -60
- data/Rakefile +0 -129
- data/bin/asciidoctor-safe +0 -15
- data/features/open_block.feature +0 -92
- data/features/pass_block.feature +0 -66
- data/features/step_definitions.rb +0 -49
- data/features/text_formatting.feature +0 -57
- data/features/xref.feature +0 -1039
- data/lib/asciidoctor/converter/base.rb +0 -59
- data/lib/asciidoctor/converter/docbook45.rb +0 -93
- data/lib/asciidoctor/converter/factory.rb +0 -226
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
- data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
- data/test/api_test.rb +0 -1240
- data/test/attribute_list_test.rb +0 -242
- data/test/attributes_test.rb +0 -1623
- data/test/blocks_test.rb +0 -3870
- data/test/converter_test.rb +0 -470
- data/test/document_test.rb +0 -1853
- data/test/extensions_test.rb +0 -1560
- data/test/fixtures/asciidoc_index.txt +0 -521
- data/test/fixtures/basic-docinfo-footer.html +0 -6
- data/test/fixtures/basic-docinfo-footer.xml +0 -8
- data/test/fixtures/basic-docinfo.html +0 -1
- data/test/fixtures/basic-docinfo.xml +0 -4
- data/test/fixtures/basic.asciidoc +0 -5
- data/test/fixtures/chapter-a.adoc +0 -3
- data/test/fixtures/child-include.adoc +0 -5
- data/test/fixtures/circle.svg +0 -9
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
- data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
- data/test/fixtures/docinfo-footer.html +0 -1
- data/test/fixtures/docinfo-footer.xml +0 -9
- data/test/fixtures/docinfo.html +0 -1
- data/test/fixtures/docinfo.xml +0 -3
- data/test/fixtures/doctime-localtime.adoc +0 -2
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/file-with-missing-include.adoc +0 -1
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -69
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.jsx +0 -8
- data/test/fixtures/include-file.ml +0 -3
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/lists.adoc +0 -96
- data/test/fixtures/master.adoc +0 -5
- data/test/fixtures/mismatched-end-tag.adoc +0 -7
- data/test/fixtures/other-chapters.adoc +0 -11
- data/test/fixtures/outer-include.adoc +0 -5
- data/test/fixtures/parent-include-restricted.adoc +0 -5
- data/test/fixtures/parent-include.adoc +0 -5
- data/test/fixtures/sample.asciidoc +0 -30
- data/test/fixtures/section-a.adoc +0 -4
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subdir/index.adoc +0 -3
- data/test/fixtures/subdir/inner-include.adoc +0 -3
- data/test/fixtures/subdir/middle-include.adoc +0 -5
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -6
- data/test/fixtures/tagged-class-enclosed.rb +0 -25
- data/test/fixtures/tagged-class.rb +0 -23
- data/test/fixtures/tip.gif +0 -0
- data/test/fixtures/unclosed-tag.adoc +0 -3
- data/test/fixtures/unexpected-end-tag.adoc +0 -4
- data/test/invoker_test.rb +0 -745
- data/test/links_test.rb +0 -855
- data/test/lists_test.rb +0 -5151
- data/test/logger_test.rb +0 -211
- data/test/manpage_test.rb +0 -660
- data/test/options_test.rb +0 -262
- data/test/paragraphs_test.rb +0 -562
- data/test/parser_test.rb +0 -742
- data/test/paths_test.rb +0 -395
- data/test/preamble_test.rb +0 -173
- data/test/reader_test.rb +0 -2161
- data/test/sections_test.rb +0 -3575
- data/test/substitutions_test.rb +0 -2066
- data/test/tables_test.rb +0 -2036
- data/test/test_helper.rb +0 -447
- data/test/text_test.rb +0 -309
data/lib/asciidoctor/section.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
module Asciidoctor
|
3
3
|
# Public: Methods for managing sections of AsciiDoc content in a document.
|
4
4
|
# The section responds as an Array of content blocks by delegating
|
@@ -64,6 +64,13 @@ class Section < AbstractBlock
|
|
64
64
|
Section.generate_id title, @document
|
65
65
|
end
|
66
66
|
|
67
|
+
# Public: Check whether this Section has any child Section objects.
|
68
|
+
#
|
69
|
+
# Returns A [Boolean] to indicate whether this Section has child Section objects
|
70
|
+
def sections?
|
71
|
+
@next_section_index > 0
|
72
|
+
end
|
73
|
+
|
67
74
|
# Public: Get the section number for the current Section
|
68
75
|
#
|
69
76
|
# The section number is a dot-separated String that uniquely describes the position of this
|
@@ -111,14 +118,7 @@ class Section < AbstractBlock
|
|
111
118
|
# Returns the section number as a String
|
112
119
|
def sectnum(delimiter = '.', append = nil)
|
113
120
|
append ||= (append == false ? '' : delimiter)
|
114
|
-
|
115
|
-
%(#{@numeral}#{append})
|
116
|
-
elsif @level > 1
|
117
|
-
Section === @parent ? %(#{@parent.sectnum(delimiter, delimiter)}#{@numeral}#{append}) : %(#{@numeral}#{append})
|
118
|
-
else # @level == 0
|
119
|
-
# NOTE coerce @numeral to int just in case not set; can happen if section nesting is out of sequence
|
120
|
-
%(#{Helpers.int_to_roman @numeral.to_i}#{append})
|
121
|
-
end
|
121
|
+
@level > 1 && Section === @parent ? %(#{@parent.sectnum(delimiter, delimiter)}#{@numeral}#{append}) : %(#{@numeral}#{append})
|
122
122
|
end
|
123
123
|
|
124
124
|
# (see AbstractBlock#xreftext)
|
@@ -130,9 +130,9 @@ class Section < AbstractBlock
|
|
130
130
|
case xrefstyle
|
131
131
|
when 'full'
|
132
132
|
if (type = @sectname) == 'chapter' || type == 'appendix'
|
133
|
-
quoted_title =
|
133
|
+
quoted_title = sub_placeholder (sub_quotes '_%s_'), title
|
134
134
|
else
|
135
|
-
quoted_title =
|
135
|
+
quoted_title = sub_placeholder (sub_quotes @document.compat_mode ? %q(``%s'') : '"`%s`"'), title
|
136
136
|
end
|
137
137
|
if (signifier = @document.attributes[%(#{type}-refsig)])
|
138
138
|
%(#{signifier} #{sectnum '.', ','} #{quoted_title})
|
@@ -146,10 +146,10 @@ class Section < AbstractBlock
|
|
146
146
|
sectnum '.', ''
|
147
147
|
end
|
148
148
|
else # 'basic'
|
149
|
-
(type = @sectname) == 'chapter' || type == 'appendix' ? (
|
149
|
+
(type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
|
150
150
|
end
|
151
151
|
else # apply basic styling
|
152
|
-
(type = @sectname) == 'chapter' || type == 'appendix' ? (
|
152
|
+
(type = @sectname) == 'chapter' || type == 'appendix' ? (sub_placeholder (sub_quotes '_%s_'), title) : title
|
153
153
|
end
|
154
154
|
else
|
155
155
|
title
|
@@ -215,9 +215,10 @@ class Section < AbstractBlock
|
|
215
215
|
# ensure id doesn't begin with idseparator if idprefix is empty (assuming idseparator is not empty)
|
216
216
|
gen_id = gen_id.slice 1, gen_id.length if pre.empty? && (gen_id.start_with? sep)
|
217
217
|
end
|
218
|
-
if document.catalog[:
|
219
|
-
ids
|
220
|
-
cnt
|
218
|
+
if document.catalog[:refs].key? gen_id
|
219
|
+
ids = document.catalog[:refs]
|
220
|
+
cnt = Compliance.unique_id_start_index
|
221
|
+
cnt += 1 while ids[candidate_id = %(#{gen_id}#{sep}#{cnt})]
|
221
222
|
candidate_id
|
222
223
|
else
|
223
224
|
gen_id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
module Asciidoctor
|
3
3
|
# A utility class for working with the built-in stylesheets.
|
4
4
|
#--
|
@@ -6,9 +6,7 @@ module Asciidoctor
|
|
6
6
|
# QUESTION create method for user stylesheet?
|
7
7
|
class Stylesheets
|
8
8
|
DEFAULT_STYLESHEET_NAME = 'asciidoctor.css'
|
9
|
-
|
10
|
-
STYLESHEETS_DATA_PATH = ::File.join DATA_PATH, 'stylesheets'
|
11
|
-
PygmentsBgColorRx = /^\.pygments +\{ *background: *([^;]+);/
|
9
|
+
STYLESHEETS_DIR = ::File.join DATA_DIR, 'stylesheets'
|
12
10
|
|
13
11
|
@__instance__ = new
|
14
12
|
|
@@ -24,9 +22,12 @@ class Stylesheets
|
|
24
22
|
#
|
25
23
|
# returns the [String] Asciidoctor stylesheet data
|
26
24
|
def primary_stylesheet_data
|
27
|
-
@primary_stylesheet_data ||= ::
|
25
|
+
@primary_stylesheet_data ||= (::File.read (::File.join STYLESHEETS_DIR, 'asciidoctor-default.css'), mode: FILE_READ_MODE).rstrip
|
28
26
|
end
|
29
27
|
|
28
|
+
# Deprecated: Generate code to embed the primary stylesheet
|
29
|
+
#
|
30
|
+
# Returns the [String] primary stylesheet data wrapped in a <style> tag
|
30
31
|
def embed_primary_stylesheet
|
31
32
|
%(<style>
|
32
33
|
#{primary_stylesheet_data}
|
@@ -34,24 +35,23 @@ class Stylesheets
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def write_primary_stylesheet target_dir = '.'
|
37
|
-
::
|
38
|
+
::File.write (::File.join target_dir, primary_stylesheet_name), primary_stylesheet_data, mode: FILE_WRITE_MODE
|
38
39
|
end
|
39
40
|
|
40
41
|
def coderay_stylesheet_name
|
41
|
-
'coderay
|
42
|
+
(SyntaxHighlighter.for 'coderay').stylesheet_basename
|
42
43
|
end
|
43
44
|
|
44
45
|
# Public: Read the contents of the default CodeRay stylesheet
|
45
46
|
#
|
46
47
|
# returns the [String] CodeRay stylesheet data
|
47
48
|
def coderay_stylesheet_data
|
48
|
-
|
49
|
-
# unless load_coderay.nil?
|
50
|
-
# ::CodeRay::Encoders[:html]::CSS.new(:default).stylesheet
|
51
|
-
# end
|
52
|
-
@coderay_stylesheet_data ||= ::IO.read(::File.join(STYLESHEETS_DATA_PATH, 'coderay-asciidoctor.css')).rstrip
|
49
|
+
(SyntaxHighlighter.for 'coderay').read_stylesheet
|
53
50
|
end
|
54
51
|
|
52
|
+
# Deprecated: Generate code to embed the CodeRay stylesheet
|
53
|
+
#
|
54
|
+
# Returns the [String] CodeRay stylesheet data wrapped in a <style> tag
|
55
55
|
def embed_coderay_stylesheet
|
56
56
|
%(<style>
|
57
57
|
#{coderay_stylesheet_data}
|
@@ -59,33 +59,23 @@ class Stylesheets
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def write_coderay_stylesheet target_dir = '.'
|
62
|
-
::
|
62
|
+
::File.write (::File.join target_dir, coderay_stylesheet_name), coderay_stylesheet_data, mode: FILE_WRITE_MODE
|
63
63
|
end
|
64
64
|
|
65
65
|
def pygments_stylesheet_name style = nil
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
def pygments_background style = nil
|
70
|
-
if load_pygments && PygmentsBgColorRx =~ (::Pygments.css '.pygments', :style => style || DEFAULT_PYGMENTS_STYLE)
|
71
|
-
$1
|
72
|
-
end
|
66
|
+
(SyntaxHighlighter.for 'pygments').stylesheet_basename style
|
73
67
|
end
|
74
68
|
|
75
69
|
# Public: Generate the Pygments stylesheet with the specified style.
|
76
70
|
#
|
77
71
|
# returns the [String] Pygments stylesheet data
|
78
72
|
def pygments_stylesheet_data style = nil
|
79
|
-
|
80
|
-
style ||= DEFAULT_PYGMENTS_STYLE
|
81
|
-
(@pygments_stylesheet_data ||= {})[style] ||=
|
82
|
-
((::Pygments.css '.listingblock .pygments', :classprefix => 'tok-', :style => style) || '/* Failed to load Pygments CSS. */').
|
83
|
-
sub('.listingblock .pygments {', '.listingblock .pygments, .listingblock .pygments code {')
|
84
|
-
else
|
85
|
-
'/* Pygments CSS disabled. Pygments is not available. */'
|
86
|
-
end
|
73
|
+
(SyntaxHighlighter.for 'pygments').read_stylesheet style
|
87
74
|
end
|
88
75
|
|
76
|
+
# Deprecated: Generate code to embed the Pygments stylesheet
|
77
|
+
#
|
78
|
+
# Returns the [String] Pygments stylesheet data for the specified style wrapped in a <style> tag
|
89
79
|
def embed_pygments_stylesheet style = nil
|
90
80
|
%(<style>
|
91
81
|
#{pygments_stylesheet_data style}
|
@@ -93,15 +83,7 @@ class Stylesheets
|
|
93
83
|
end
|
94
84
|
|
95
85
|
def write_pygments_stylesheet target_dir = '.', style = nil
|
96
|
-
::
|
97
|
-
end
|
98
|
-
|
99
|
-
#def load_coderay
|
100
|
-
# (defined? ::CodeRay) ? true : !(Helpers.require_library 'coderay', true, :ignore).nil?
|
101
|
-
#end
|
102
|
-
|
103
|
-
def load_pygments
|
104
|
-
(defined? ::Pygments) ? true : !(Helpers.require_library 'pygments', 'pygments.rb', :ignore).nil?
|
86
|
+
::File.write (::File.join target_dir, (pygments_stylesheet_name style)), (pygments_stylesheet_data style), mode: FILE_WRITE_MODE
|
105
87
|
end
|
106
88
|
end
|
107
89
|
end
|