asciidoctor 2.0.16 → 2.0.17
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 +50 -11
- data/README-de.adoc +8 -11
- data/README-fr.adoc +8 -11
- data/README-jp.adoc +9 -12
- data/README-zh_CN.adoc +8 -11
- data/README.adoc +33 -18
- data/asciidoctor.gemspec +1 -1
- data/data/locale/attributes-fr.adoc +2 -2
- data/data/stylesheets/asciidoctor-default.css +7 -8
- data/data/stylesheets/coderay-asciidoctor.css +9 -9
- data/lib/asciidoctor/abstract_block.rb +7 -5
- data/lib/asciidoctor/cli/invoker.rb +1 -1
- data/lib/asciidoctor/cli/options.rb +3 -3
- data/lib/asciidoctor/converter/html5.rb +47 -39
- data/lib/asciidoctor/converter/template.rb +1 -1
- data/lib/asciidoctor/converter.rb +1 -1
- data/lib/asciidoctor/core_ext/hash/merge.rb +1 -1
- data/lib/asciidoctor/document.rb +17 -4
- data/lib/asciidoctor/extensions.rb +10 -2
- data/lib/asciidoctor/parser.rb +54 -52
- data/lib/asciidoctor/reader.rb +5 -5
- data/lib/asciidoctor/rx.rb +1 -1
- data/lib/asciidoctor/section.rb +7 -0
- data/lib/asciidoctor/substitutors.rb +4 -4
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +12 -4
- data/lib/asciidoctor/table.rb +1 -1
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +23 -24
- data/man/asciidoctor.adoc +28 -23
- metadata +4 -4
@@ -183,7 +183,8 @@ body.toc2.toc-right{padding-left:0;padding-right:20em}}
|
|
183
183
|
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
|
184
184
|
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
|
185
185
|
details{margin-left:1.25rem}
|
186
|
-
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
|
186
|
+
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
|
187
|
+
details>summary::-webkit-details-marker{display:none}
|
187
188
|
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
|
188
189
|
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
|
189
190
|
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
|
@@ -225,9 +226,8 @@ pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
|
|
225
226
|
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
|
226
227
|
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
|
227
228
|
table.linenotable td.code{padding-left:.75em}
|
228
|
-
table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
|
229
|
-
pre.pygments .
|
230
|
-
pre.pygments .lineno::before{content:"";margin-right:-.125em}
|
229
|
+
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
230
|
+
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
|
231
231
|
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
|
232
232
|
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
|
233
233
|
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
|
@@ -264,7 +264,7 @@ table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-c
|
|
264
264
|
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
|
265
265
|
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
|
266
266
|
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
|
267
|
-
table.stripes-all
|
267
|
+
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
|
268
268
|
th.halign-left,td.halign-left{text-align:left}
|
269
269
|
th.halign-right,td.halign-right{text-align:right}
|
270
270
|
th.halign-center,td.halign-center{text-align:center}
|
@@ -280,10 +280,11 @@ ol{margin-left:1.75em}
|
|
280
280
|
ul li ol{margin-left:1.5em}
|
281
281
|
dl dd{margin-left:1.125em}
|
282
282
|
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
|
283
|
-
|
283
|
+
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
|
284
284
|
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
|
285
285
|
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
|
286
286
|
ul.unstyled,ol.unstyled{margin-left:0}
|
287
|
+
li>p:empty:only-child::before{content:"";display:inline-block}
|
287
288
|
ul.checklist>li>p:first-child{margin-left:-1em}
|
288
289
|
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
|
289
290
|
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
|
@@ -326,8 +327,6 @@ sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
|
|
326
327
|
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
|
327
328
|
#footnotes .footnote:last-of-type{margin-bottom:0}
|
328
329
|
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
|
329
|
-
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
|
330
|
-
.gist .file-data>table td.line-data{width:99%}
|
331
330
|
div.unbreakable{page-break-inside:avoid}
|
332
331
|
.big{font-size:larger}
|
333
332
|
.small{font-size:smaller}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
/*! Stylesheet for CodeRay to loosely match GitHub themes | MIT License */
|
2
2
|
pre.CodeRay{background:#f7f7f8}
|
3
|
-
.CodeRay .line-numbers{border-right:1px solid
|
3
|
+
.CodeRay .line-numbers{border-right:1px solid;opacity:.35;padding:0 .5em 0 0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
4
4
|
.CodeRay span.line-numbers{display:inline-block;margin-right:.75em}
|
5
5
|
.CodeRay .line-numbers strong{color:#000}
|
6
6
|
table.CodeRay{border-collapse:separate;border:0;margin-bottom:0;background:none}
|
7
7
|
table.CodeRay td{vertical-align:top;line-height:inherit}
|
8
8
|
table.CodeRay td.line-numbers{text-align:right}
|
9
9
|
table.CodeRay td.code{padding:0 0 0 .75em}
|
10
|
-
.CodeRay .debug{color:#fff
|
10
|
+
.CodeRay .debug{color:#fff!important;background:navy!important}
|
11
11
|
.CodeRay .annotation{color:#007}
|
12
|
-
.CodeRay .attribute-name{color
|
12
|
+
.CodeRay .attribute-name{color:navy}
|
13
13
|
.CodeRay .attribute-value{color:#700}
|
14
14
|
.CodeRay .binary{color:#509}
|
15
15
|
.CodeRay .comment{color:#998;font-style:italic}
|
@@ -18,7 +18,7 @@ table.CodeRay td.code{padding:0 0 0 .75em}
|
|
18
18
|
.CodeRay .char .delimiter{color:#039}
|
19
19
|
.CodeRay .class{color:#458;font-weight:bold}
|
20
20
|
.CodeRay .complex{color:#a08}
|
21
|
-
.CodeRay .constant,.CodeRay .predefined-constant{color
|
21
|
+
.CodeRay .constant,.CodeRay .predefined-constant{color:teal}
|
22
22
|
.CodeRay .color{color:#099}
|
23
23
|
.CodeRay .class-variable{color:#369}
|
24
24
|
.CodeRay .decorator{color:#b0b}
|
@@ -33,7 +33,7 @@ table.CodeRay td.code{padding:0 0 0 .75em}
|
|
33
33
|
.CodeRay .exception{color:inherit}
|
34
34
|
.CodeRay .filename{color:#099}
|
35
35
|
.CodeRay .function{color:#900;font-weight:bold}
|
36
|
-
.CodeRay .global-variable{color
|
36
|
+
.CodeRay .global-variable{color:teal}
|
37
37
|
.CodeRay .hex{color:#058}
|
38
38
|
.CodeRay .integer,.CodeRay .float{color:#099}
|
39
39
|
.CodeRay .include{color:#555}
|
@@ -44,7 +44,7 @@ table.CodeRay td.code{padding:0 0 0 .75em}
|
|
44
44
|
.CodeRay .inline-delimiter{color:#d14}
|
45
45
|
.CodeRay .important{color:#555;font-weight:bold}
|
46
46
|
.CodeRay .interpreted{color:#b2b}
|
47
|
-
.CodeRay .instance-variable{color
|
47
|
+
.CodeRay .instance-variable{color:teal}
|
48
48
|
.CodeRay .label{color:#970}
|
49
49
|
.CodeRay .local-variable{color:#963}
|
50
50
|
.CodeRay .octal{color:#40e}
|
@@ -54,7 +54,7 @@ table.CodeRay td.code{padding:0 0 0 .75em}
|
|
54
54
|
.CodeRay .directive{font-weight:bold}
|
55
55
|
.CodeRay .type{font-weight:bold}
|
56
56
|
.CodeRay .predefined-type{color:inherit}
|
57
|
-
.CodeRay .reserved,.CodeRay .keyword
|
57
|
+
.CodeRay .reserved,.CodeRay .keyword{color:#000;font-weight:bold}
|
58
58
|
.CodeRay .key{color:#808}
|
59
59
|
.CodeRay .key .delimiter{color:#606}
|
60
60
|
.CodeRay .key .char{color:#80f}
|
@@ -74,7 +74,7 @@ table.CodeRay td.code{padding:0 0 0 .75em}
|
|
74
74
|
.CodeRay .symbol{color:#990073}
|
75
75
|
.CodeRay .symbol .content{color:#a60}
|
76
76
|
.CodeRay .symbol .delimiter{color:#630}
|
77
|
-
.CodeRay .tag{color
|
77
|
+
.CodeRay .tag{color:teal}
|
78
78
|
.CodeRay .tag-special{color:#d70}
|
79
79
|
.CodeRay .variable{color:#036}
|
80
80
|
.CodeRay .insert{background:#afa}
|
@@ -11,7 +11,7 @@ class AbstractBlock < AbstractNode
|
|
11
11
|
# * :compound - this block contains other blocks
|
12
12
|
# * :simple - this block holds a paragraph of prose that receives normal substitutions
|
13
13
|
# * :verbatim - this block holds verbatim text (displayed "as is") that receives verbatim substitutions
|
14
|
-
# * :raw - this block holds unprocessed content passed directly to the output with no
|
14
|
+
# * :raw - this block holds unprocessed content passed directly to the output with no substitutions applied
|
15
15
|
# * :empty - this block has no content
|
16
16
|
attr_accessor :content_model
|
17
17
|
|
@@ -129,11 +129,13 @@ class AbstractBlock < AbstractNode
|
|
129
129
|
|
130
130
|
# Public: Check whether this block has any child Section objects.
|
131
131
|
#
|
132
|
-
#
|
132
|
+
# Acts an an abstract method that always returns false unless this block is an
|
133
|
+
# instance of Document or Section.
|
134
|
+
# Both Document and Section provide overrides for this method.
|
133
135
|
#
|
134
|
-
# Returns
|
136
|
+
# Returns false
|
135
137
|
def sections?
|
136
|
-
|
138
|
+
false
|
137
139
|
end
|
138
140
|
|
139
141
|
# Deprecated: Legacy property to get the String or Integer numeral of this section.
|
@@ -269,7 +271,7 @@ class AbstractBlock < AbstractNode
|
|
269
271
|
ORDERED_LIST_KEYWORDS[list_type || @style]
|
270
272
|
end
|
271
273
|
|
272
|
-
# Public: Get the String title of this Block with title
|
274
|
+
# Public: Get the String title of this Block with title substitutions applied
|
273
275
|
#
|
274
276
|
# The following substitutions are applied to block and section titles:
|
275
277
|
#
|
@@ -119,7 +119,7 @@ module Asciidoctor
|
|
119
119
|
'may be specified more than once') do |path|
|
120
120
|
(self[:requires] ||= []).concat(path.split ',')
|
121
121
|
end
|
122
|
-
opts.on('--failure-level LEVEL', %w(warning WARNING error ERROR
|
122
|
+
opts.on('--failure-level LEVEL', %w(info INFO warning WARNING error ERROR fatal FATAL), 'set minimum log level that yields a non-zero exit code: [INFO, WARN, ERROR, FATAL] (default: FATAL)') do |level|
|
123
123
|
level = 'WARN' if (level = level.upcase) == 'WARNING'
|
124
124
|
self[:failure_level] = ::Logger::Severity.const_get level
|
125
125
|
end
|
@@ -258,7 +258,7 @@ module Asciidoctor
|
|
258
258
|
raise $! if self[:trace]
|
259
259
|
$stderr.puts 'asciidoctor: FAILED: \'tilt\' could not be loaded'
|
260
260
|
$stderr.puts ' You must have the tilt gem installed (gem install tilt) to use custom backend templates'
|
261
|
-
$stderr.puts ' Use --trace
|
261
|
+
$stderr.puts ' Use --trace to show backtrace'
|
262
262
|
return 1
|
263
263
|
rescue ::SystemExit
|
264
264
|
# not permitted here
|
@@ -278,7 +278,7 @@ module Asciidoctor
|
|
278
278
|
rescue ::LoadError
|
279
279
|
raise $! if self[:trace]
|
280
280
|
$stderr.puts %(asciidoctor: FAILED: '#{path}' could not be loaded)
|
281
|
-
$stderr.puts ' Use --trace
|
281
|
+
$stderr.puts ' Use --trace to show backtrace'
|
282
282
|
return 1
|
283
283
|
rescue ::SystemExit
|
284
284
|
# not permitted here
|
@@ -626,16 +626,18 @@ Your browser does not support the audio tag.
|
|
626
626
|
target = node.attr 'target'
|
627
627
|
width_attr = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
628
628
|
height_attr = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
|
629
|
-
if ((node.attr? 'format', 'svg') || (target.include? '.svg')) && node.document.safe < SafeMode::SECURE
|
630
|
-
|
631
|
-
if svg
|
629
|
+
if ((node.attr? 'format', 'svg') || (target.include? '.svg')) && node.document.safe < SafeMode::SECURE
|
630
|
+
if node.option? 'inline'
|
632
631
|
img = (read_svg_contents node, target) || %(<span class="alt">#{node.alt}</span>)
|
633
|
-
elsif
|
634
|
-
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri
|
632
|
+
elsif node.option? 'interactive'
|
633
|
+
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri node.attr 'fallback'}" alt="#{encode_attribute_value node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>) : %(<span class="alt">#{node.alt}</span>)
|
635
634
|
img = %(<object type="image/svg+xml" data="#{node.image_uri target}"#{width_attr}#{height_attr}>#{fallback}</object>)
|
635
|
+
else
|
636
|
+
img = %(<img src="#{node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>)
|
636
637
|
end
|
638
|
+
else
|
639
|
+
img = %(<img src="#{node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>)
|
637
640
|
end
|
638
|
-
img ||= %(<img src="#{node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{width_attr}#{height_attr}#{@void_element_slash}>)
|
639
641
|
img = %(<a class="image" href="#{node.attr 'link'}"#{(append_link_constraint_attrs node).join}>#{img}</a>) if node.attr? 'link'
|
640
642
|
id_attr = node.id ? %( id="#{node.id}") : ''
|
641
643
|
classes = ['imageblock']
|
@@ -859,20 +861,19 @@ Your browser does not support the audio tag.
|
|
859
861
|
if (stripes = node.attr 'stripes', nil, 'table-stripes')
|
860
862
|
classes << %(stripes-#{stripes})
|
861
863
|
end
|
862
|
-
|
864
|
+
style_attribute = ''
|
863
865
|
if (autowidth = node.option? 'autowidth') && !(node.attr? 'width')
|
864
866
|
classes << 'fit-content'
|
865
867
|
elsif (tablewidth = node.attr 'tablepcwidth') == 100
|
866
868
|
classes << 'stretch'
|
867
869
|
else
|
868
|
-
|
870
|
+
style_attribute = %( style="width: #{tablewidth}%;")
|
869
871
|
end
|
870
872
|
classes << (node.attr 'float') if node.attr? 'float'
|
871
873
|
if (role = node.role)
|
872
874
|
classes << role
|
873
875
|
end
|
874
876
|
class_attribute = %( class="#{classes.join ' '}")
|
875
|
-
style_attribute = styles.empty? ? '' : %( style="#{styles.join ' '}")
|
876
877
|
|
877
878
|
result << %(<table#{id_attribute}#{class_attribute}#{style_attribute}>)
|
878
879
|
result << %(<caption class="title">#{node.captioned_title}</caption>) if node.title?
|
@@ -1035,12 +1036,14 @@ Your browser does not support the audio tag.
|
|
1035
1036
|
end
|
1036
1037
|
start_anchor = (node.attr? 'start') ? %(#at=#{node.attr 'start'}) : ''
|
1037
1038
|
delimiter = ['?']
|
1039
|
+
target, hash = (node.attr 'target').split '/', 2
|
1040
|
+
hash_param = (hash ||= node.attr 'hash') ? %(#{delimiter.pop || '&'}h=#{hash}) : ''
|
1038
1041
|
autoplay_param = (node.option? 'autoplay') ? %(#{delimiter.pop || '&'}autoplay=1) : ''
|
1039
1042
|
loop_param = (node.option? 'loop') ? %(#{delimiter.pop || '&'}loop=1) : ''
|
1040
1043
|
muted_param = (node.option? 'muted') ? %(#{delimiter.pop || '&'}muted=1) : ''
|
1041
1044
|
%(<div#{id_attribute}#{class_attribute}>#{title_element}
|
1042
1045
|
<div class="content">
|
1043
|
-
<iframe#{width_attribute}#{height_attribute} src="#{asset_uri_scheme}//player.vimeo.com/video/#{
|
1046
|
+
<iframe#{width_attribute}#{height_attribute} src="#{asset_uri_scheme}//player.vimeo.com/video/#{target}#{hash_param}#{autoplay_param}#{loop_param}#{muted_param}#{start_anchor}" frameborder="0"#{(node.option? 'nofullscreen') ? '' : (append_boolean_attribute 'allowfullscreen', xml)}></iframe>
|
1044
1047
|
</div>
|
1045
1048
|
</div>)
|
1046
1049
|
when 'youtube'
|
@@ -1076,7 +1079,7 @@ Your browser does not support the audio tag.
|
|
1076
1079
|
target, playlist = target.split ',', 2
|
1077
1080
|
if (playlist ||= (node.attr 'playlist'))
|
1078
1081
|
# INFO playlist bar doesn't appear in Firefox unless showinfo=1 and modestbranding=1
|
1079
|
-
list_param = %(&playlist=#{playlist})
|
1082
|
+
list_param = %(&playlist=#{target},#{playlist})
|
1080
1083
|
else
|
1081
1084
|
# NOTE for loop to work, playlist must be specified; use VIDEO_ID if there's no explicit playlist
|
1082
1085
|
list_param = has_loop_param ? %(&playlist=#{target}) : ''
|
@@ -1180,44 +1183,49 @@ Your browser does not support the video tag.
|
|
1180
1183
|
end
|
1181
1184
|
|
1182
1185
|
def convert_inline_image node
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1186
|
+
target = node.target
|
1187
|
+
if (type = node.type || 'image') == 'icon'
|
1188
|
+
if (icons = node.document.attr 'icons') == 'font'
|
1189
|
+
i_class_attr_val = %(fa fa-#{target})
|
1190
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-#{node.attr 'size'}) if node.attr? 'size'
|
1191
|
+
if node.attr? 'flip'
|
1192
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-flip-#{node.attr 'flip'})
|
1193
|
+
elsif node.attr? 'rotate'
|
1194
|
+
i_class_attr_val = %(#{i_class_attr_val} fa-rotate-#{node.attr 'rotate'})
|
1195
|
+
end
|
1196
|
+
attrs = (node.attr? 'title') ? %( title="#{node.attr 'title'}") : ''
|
1197
|
+
img = %(<i class="#{i_class_attr_val}"#{attrs}></i>)
|
1198
|
+
elsif icons
|
1199
|
+
attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
1200
|
+
attrs = %(#{attrs} height="#{node.attr 'height'}") if node.attr? 'height'
|
1201
|
+
attrs = %(#{attrs} title="#{node.attr 'title'}") if node.attr? 'title'
|
1202
|
+
img = %(<img src="#{node.icon_uri target}" alt="#{encode_attribute_value node.alt}"#{attrs}#{@void_element_slash}>)
|
1203
|
+
else
|
1204
|
+
img = %([#{node.alt}])
|
1187
1205
|
end
|
1188
|
-
title_attr = (node.attr? 'title') ? %( title="#{node.attr 'title'}") : ''
|
1189
|
-
img = %(<i class="#{class_attr_val}"#{title_attr}></i>)
|
1190
|
-
elsif type == 'icon' && !(node.document.attr? 'icons')
|
1191
|
-
img = %([#{node.alt}])
|
1192
1206
|
else
|
1193
|
-
|
1194
|
-
attrs =
|
1195
|
-
attrs
|
1196
|
-
|
1197
|
-
|
1198
|
-
attrs = attrs.empty? ? '' : attrs.join
|
1199
|
-
if type != 'icon' && ((node.attr? 'format', 'svg') || (target.include? '.svg')) &&
|
1200
|
-
node.document.safe < SafeMode::SECURE && ((svg = (node.option? 'inline')) || (obj = (node.option? 'interactive')))
|
1201
|
-
if svg
|
1207
|
+
attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
|
1208
|
+
attrs = %(#{attrs} height="#{node.attr 'height'}") if node.attr? 'height'
|
1209
|
+
attrs = %(#{attrs} title="#{node.attr 'title'}") if node.attr? 'title'
|
1210
|
+
if ((node.attr? 'format', 'svg') || (target.include? '.svg')) && node.document.safe < SafeMode::SECURE
|
1211
|
+
if node.option? 'inline'
|
1202
1212
|
img = (read_svg_contents node, target) || %(<span class="alt">#{node.alt}</span>)
|
1203
|
-
elsif
|
1204
|
-
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri
|
1213
|
+
elsif node.option? 'interactive'
|
1214
|
+
fallback = (node.attr? 'fallback') ? %(<img src="#{node.image_uri node.attr 'fallback'}" alt="#{encode_attribute_value node.alt}"#{attrs}#{@void_element_slash}>) : %(<span class="alt">#{node.alt}</span>)
|
1205
1215
|
img = %(<object type="image/svg+xml" data="#{node.image_uri target}"#{attrs}>#{fallback}</object>)
|
1216
|
+
else
|
1217
|
+
img = %(<img src="#{node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{attrs}#{@void_element_slash}>)
|
1206
1218
|
end
|
1219
|
+
else
|
1220
|
+
img = %(<img src="#{node.image_uri target}" alt="#{encode_attribute_value node.alt}"#{attrs}#{@void_element_slash}>)
|
1207
1221
|
end
|
1208
|
-
img ||= %(<img src="#{type == 'icon' ? (node.icon_uri target) : (node.image_uri target)}" alt="#{encode_attribute_value node.alt}"#{attrs}#{@void_element_slash}>)
|
1209
1222
|
end
|
1210
1223
|
img = %(<a class="image" href="#{node.attr 'link'}"#{(append_link_constraint_attrs node).join}>#{img}</a>) if node.attr? 'link'
|
1224
|
+
class_attr_val = type
|
1211
1225
|
if (role = node.role)
|
1212
|
-
|
1213
|
-
class_attr_val = %(#{type} #{node.attr 'float'} #{role})
|
1214
|
-
else
|
1215
|
-
class_attr_val = %(#{type} #{role})
|
1216
|
-
end
|
1226
|
+
class_attr_val = (node.attr? 'float') ? %(#{class_attr_val} #{node.attr 'float'} #{role}) : %(#{class_attr_val} #{role})
|
1217
1227
|
elsif node.attr? 'float'
|
1218
|
-
class_attr_val = %(#{
|
1219
|
-
else
|
1220
|
-
class_attr_val = type
|
1228
|
+
class_attr_val = %(#{class_attr_val} #{node.attr 'float'})
|
1221
1229
|
end
|
1222
1230
|
%(<span class="#{class_attr_val}">#{img}</span>)
|
1223
1231
|
end
|
@@ -196,7 +196,7 @@ class Converter::TemplateConverter < Converter::Base
|
|
196
196
|
def scan_dir template_dir, pattern, template_cache = nil
|
197
197
|
result, helpers = {}, nil
|
198
198
|
# Grab the files in the top level of the directory (do not recurse)
|
199
|
-
::Dir.glob(pattern).
|
199
|
+
::Dir.glob(pattern).keep_if {|match| ::File.file? match }.each do |file|
|
200
200
|
if (basename = ::File.basename file) == 'helpers.rb'
|
201
201
|
helpers = file
|
202
202
|
next
|
@@ -42,7 +42,7 @@ module Asciidoctor
|
|
42
42
|
# puts Asciidoctor.convert_file 'sample.adoc', safe: :safe
|
43
43
|
module Converter
|
44
44
|
autoload :CompositeConverter, %(#{__dir__}/converter/composite)
|
45
|
-
autoload :TemplateConverter, %(#{__dir__}/converter/template)
|
45
|
+
autoload :TemplateConverter, %(#{__dir__}/converter/template) unless RUBY_ENGINE == 'opal'
|
46
46
|
|
47
47
|
# Public: The String backend name that this converter is handling.
|
48
48
|
attr_reader :backend
|
@@ -3,6 +3,6 @@
|
|
3
3
|
# NOTE use `send :prepend` to be nice to Ruby 2.0
|
4
4
|
Hash.send :prepend, (Module.new do
|
5
5
|
def merge *args
|
6
|
-
(len = args.length) < 1 ?
|
6
|
+
(len = args.length) < 1 ? dup : (len > 1 ? args.inject(self) {|acc, arg| acc.merge arg } : (super args[0]))
|
7
7
|
end
|
8
8
|
end) if (Hash.instance_method :merge).arity == 1
|
data/lib/asciidoctor/document.rb
CHANGED
@@ -198,7 +198,7 @@ class Document < AbstractBlock
|
|
198
198
|
# Public: Get the document catalog Hash
|
199
199
|
attr_reader :catalog
|
200
200
|
|
201
|
-
# Public: Alias catalog property as references for backwards
|
201
|
+
# Public: Alias catalog property as references for backwards compatibility
|
202
202
|
alias references catalog
|
203
203
|
|
204
204
|
# Public: Get the Hash of document counters
|
@@ -328,7 +328,7 @@ class Document < AbstractBlock
|
|
328
328
|
@timings = options.delete :timings
|
329
329
|
@path_resolver = PathResolver.new
|
330
330
|
initialize_extensions = (defined? ::Asciidoctor::Extensions) || (options.key? :extensions) ? ::Asciidoctor::Extensions : nil
|
331
|
-
@extensions = nil # initialize
|
331
|
+
@extensions = nil # initialize further down if initialize_extensions is true
|
332
332
|
options[:standalone] = options[:header_footer] if (options.key? :header_footer) && !(options.key? :standalone)
|
333
333
|
end
|
334
334
|
|
@@ -631,6 +631,13 @@ class Document < AbstractBlock
|
|
631
631
|
end
|
632
632
|
end
|
633
633
|
|
634
|
+
# Public: Check whether this Document has any child Section objects.
|
635
|
+
#
|
636
|
+
# Returns A [Boolean] to indicate whether this Document has child Section objects
|
637
|
+
def sections?
|
638
|
+
@next_section_index > 0
|
639
|
+
end
|
640
|
+
|
634
641
|
def footnotes?
|
635
642
|
@catalog[:footnotes].empty? ? false : true
|
636
643
|
end
|
@@ -965,8 +972,14 @@ class Document < AbstractBlock
|
|
965
972
|
|
966
973
|
# Public: Write the output to the specified file
|
967
974
|
#
|
968
|
-
# If the converter responds to :write, delegate the work of writing the
|
969
|
-
# to that method. Otherwise, write the output the specified file.
|
975
|
+
# If the converter responds to :write, delegate the work of writing the output
|
976
|
+
# to that method. Otherwise, write the output to the specified file. In the
|
977
|
+
# latter case, this method ensures the output has a trailing newline if the
|
978
|
+
# target responds to write and the output is not empty.
|
979
|
+
#
|
980
|
+
# output - The output to write. Unless the converter responds to write, this
|
981
|
+
# object is expected to be a String.
|
982
|
+
# target - The file to write, either a File object or a String path.
|
970
983
|
#
|
971
984
|
# Returns nothing
|
972
985
|
def write output, target
|
@@ -511,6 +511,10 @@ module Extensions
|
|
511
511
|
# registered to handle this name and, if found, invokes its {Processor#process}
|
512
512
|
# method to build a corresponding node in the document tree.
|
513
513
|
#
|
514
|
+
# If the process method returns an instance of Block, the content model of that
|
515
|
+
# Block is :compound, and the Block contains at least one line, the parser will
|
516
|
+
# parse those lines into blocks an assigned them to the returned block.
|
517
|
+
#
|
514
518
|
# AsciiDoc example:
|
515
519
|
#
|
516
520
|
# [shout]
|
@@ -594,6 +598,10 @@ module Extensions
|
|
594
598
|
# Public: BlockMacroProcessors are used to handle block macros that have a
|
595
599
|
# custom name.
|
596
600
|
#
|
601
|
+
# If the process method returns an instance of Block, the content model of that
|
602
|
+
# Block is :compound, and the Block contains at least one line, the parser will
|
603
|
+
# parse those lines into blocks an assigned them to the returned block.
|
604
|
+
#
|
597
605
|
# BlockMacroProcessor implementations must extend BlockMacroProcessor.
|
598
606
|
class BlockMacroProcessor < MacroProcessor
|
599
607
|
def name
|
@@ -666,7 +674,7 @@ module Extensions
|
|
666
674
|
|
667
675
|
# Public: A specialization of the Extension proxy that additionally stores a
|
668
676
|
# reference to the {Processor#process} method. By storing this reference, its
|
669
|
-
# possible to
|
677
|
+
# possible to accommodate both concrete extension implementations and Procs.
|
670
678
|
class ProcessorExtension < Extension
|
671
679
|
attr_reader :process_method
|
672
680
|
|
@@ -954,7 +962,7 @@ module Extensions
|
|
954
962
|
end
|
955
963
|
|
956
964
|
# Public: Registers an {DocinfoProcessor} with the extension registry to
|
957
|
-
# add
|
965
|
+
# add additional docinfo to the document.
|
958
966
|
#
|
959
967
|
# The DocinfoProcessor may be one of four types:
|
960
968
|
#
|