asciidoctor 1.5.8 → 2.0.0.rc.1

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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +162 -17
  3. data/LICENSE +1 -1
  4. data/README-de.adoc +12 -13
  5. data/README-fr.adoc +11 -12
  6. data/README-jp.adoc +11 -12
  7. data/README-zh_CN.adoc +12 -13
  8. data/README.adoc +6 -7
  9. data/asciidoctor.gemspec +19 -24
  10. data/bin/asciidoctor +5 -4
  11. data/data/reference/syntax.adoc +283 -0
  12. data/data/stylesheets/asciidoctor-default.css +56 -52
  13. data/data/stylesheets/coderay-asciidoctor.css +7 -9
  14. data/lib/asciidoctor.rb +171 -232
  15. data/lib/asciidoctor/abstract_block.rb +96 -105
  16. data/lib/asciidoctor/abstract_node.rb +118 -139
  17. data/lib/asciidoctor/attribute_list.rb +10 -14
  18. data/lib/asciidoctor/block.rb +20 -19
  19. data/lib/asciidoctor/callouts.rb +4 -2
  20. data/lib/asciidoctor/cli.rb +3 -2
  21. data/lib/asciidoctor/cli/invoker.rb +14 -21
  22. data/lib/asciidoctor/cli/options.rb +64 -54
  23. data/lib/asciidoctor/converter.rb +357 -185
  24. data/lib/asciidoctor/converter/composite.rb +40 -48
  25. data/lib/asciidoctor/converter/docbook5.rb +604 -640
  26. data/lib/asciidoctor/converter/html5.rb +949 -963
  27. data/lib/asciidoctor/converter/manpage.rb +569 -548
  28. data/lib/asciidoctor/converter/template.rb +231 -272
  29. data/lib/asciidoctor/core_ext.rb +5 -18
  30. data/lib/asciidoctor/core_ext/float/truncate.rb +19 -0
  31. data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
  32. data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
  33. data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
  34. data/lib/asciidoctor/document.rb +399 -377
  35. data/lib/asciidoctor/extensions.rb +72 -140
  36. data/lib/asciidoctor/helpers.rb +122 -83
  37. data/lib/asciidoctor/inline.rb +5 -1
  38. data/lib/asciidoctor/list.rb +13 -11
  39. data/lib/asciidoctor/logging.rb +17 -16
  40. data/lib/asciidoctor/parser.rb +390 -423
  41. data/lib/asciidoctor/path_resolver.rb +10 -5
  42. data/lib/asciidoctor/reader.rb +286 -263
  43. data/lib/asciidoctor/rouge_ext.rb +39 -0
  44. data/lib/asciidoctor/section.rb +9 -8
  45. data/lib/asciidoctor/stylesheets.rb +19 -37
  46. data/lib/asciidoctor/substitutors.rb +364 -509
  47. data/lib/asciidoctor/syntax_highlighter.rb +238 -0
  48. data/lib/asciidoctor/syntax_highlighter/coderay.rb +87 -0
  49. data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +26 -0
  50. data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
  51. data/lib/asciidoctor/syntax_highlighter/prettify.rb +27 -0
  52. data/lib/asciidoctor/syntax_highlighter/pygments.rb +149 -0
  53. data/lib/asciidoctor/syntax_highlighter/rouge.rb +129 -0
  54. data/lib/asciidoctor/table.rb +73 -66
  55. data/lib/asciidoctor/timings.rb +4 -2
  56. data/lib/asciidoctor/version.rb +2 -1
  57. data/lib/asciidoctor/writer.rb +30 -0
  58. data/man/asciidoctor.1 +19 -15
  59. data/man/asciidoctor.adoc +14 -12
  60. metadata +69 -216
  61. data/CONTRIBUTING.adoc +0 -185
  62. data/Gemfile +0 -60
  63. data/Rakefile +0 -129
  64. data/bin/asciidoctor-safe +0 -15
  65. data/features/open_block.feature +0 -92
  66. data/features/pass_block.feature +0 -66
  67. data/features/step_definitions.rb +0 -49
  68. data/features/text_formatting.feature +0 -57
  69. data/features/xref.feature +0 -1039
  70. data/lib/asciidoctor/converter/base.rb +0 -59
  71. data/lib/asciidoctor/converter/docbook45.rb +0 -93
  72. data/lib/asciidoctor/converter/factory.rb +0 -226
  73. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
  74. data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
  75. data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
  76. data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
  77. data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
  78. data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
  79. data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
  80. data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
  81. data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
  82. data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
  83. data/test/api_test.rb +0 -1240
  84. data/test/attribute_list_test.rb +0 -242
  85. data/test/attributes_test.rb +0 -1623
  86. data/test/blocks_test.rb +0 -3870
  87. data/test/converter_test.rb +0 -470
  88. data/test/document_test.rb +0 -1853
  89. data/test/extensions_test.rb +0 -1560
  90. data/test/fixtures/asciidoc_index.txt +0 -521
  91. data/test/fixtures/basic-docinfo-footer.html +0 -6
  92. data/test/fixtures/basic-docinfo-footer.xml +0 -8
  93. data/test/fixtures/basic-docinfo.html +0 -1
  94. data/test/fixtures/basic-docinfo.xml +0 -4
  95. data/test/fixtures/basic.asciidoc +0 -5
  96. data/test/fixtures/chapter-a.adoc +0 -3
  97. data/test/fixtures/child-include.adoc +0 -5
  98. data/test/fixtures/circle.svg +0 -9
  99. data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
  100. data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
  101. data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
  102. data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
  103. data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
  104. data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
  105. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
  106. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
  107. data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
  108. data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
  109. data/test/fixtures/docinfo-footer.html +0 -1
  110. data/test/fixtures/docinfo-footer.xml +0 -9
  111. data/test/fixtures/docinfo.html +0 -1
  112. data/test/fixtures/docinfo.xml +0 -3
  113. data/test/fixtures/doctime-localtime.adoc +0 -2
  114. data/test/fixtures/dot.gif +0 -0
  115. data/test/fixtures/encoding.asciidoc +0 -13
  116. data/test/fixtures/file-with-missing-include.adoc +0 -1
  117. data/test/fixtures/grandchild-include.adoc +0 -3
  118. data/test/fixtures/hello-asciidoctor.pdf +0 -69
  119. data/test/fixtures/include-file.asciidoc +0 -24
  120. data/test/fixtures/include-file.jsx +0 -8
  121. data/test/fixtures/include-file.ml +0 -3
  122. data/test/fixtures/include-file.xml +0 -5
  123. data/test/fixtures/lists.adoc +0 -96
  124. data/test/fixtures/master.adoc +0 -5
  125. data/test/fixtures/mismatched-end-tag.adoc +0 -7
  126. data/test/fixtures/other-chapters.adoc +0 -11
  127. data/test/fixtures/outer-include.adoc +0 -5
  128. data/test/fixtures/parent-include-restricted.adoc +0 -5
  129. data/test/fixtures/parent-include.adoc +0 -5
  130. data/test/fixtures/sample.asciidoc +0 -30
  131. data/test/fixtures/section-a.adoc +0 -4
  132. data/test/fixtures/stylesheets/custom.css +0 -3
  133. data/test/fixtures/subdir/index.adoc +0 -3
  134. data/test/fixtures/subdir/inner-include.adoc +0 -3
  135. data/test/fixtures/subdir/middle-include.adoc +0 -5
  136. data/test/fixtures/subs-docinfo.html +0 -2
  137. data/test/fixtures/subs.adoc +0 -6
  138. data/test/fixtures/tagged-class-enclosed.rb +0 -25
  139. data/test/fixtures/tagged-class.rb +0 -23
  140. data/test/fixtures/tip.gif +0 -0
  141. data/test/fixtures/unclosed-tag.adoc +0 -3
  142. data/test/fixtures/unexpected-end-tag.adoc +0 -4
  143. data/test/invoker_test.rb +0 -745
  144. data/test/links_test.rb +0 -855
  145. data/test/lists_test.rb +0 -5151
  146. data/test/logger_test.rb +0 -211
  147. data/test/manpage_test.rb +0 -660
  148. data/test/options_test.rb +0 -262
  149. data/test/paragraphs_test.rb +0 -562
  150. data/test/parser_test.rb +0 -742
  151. data/test/paths_test.rb +0 -395
  152. data/test/preamble_test.rb +0 -173
  153. data/test/reader_test.rb +0 -2161
  154. data/test/sections_test.rb +0 -3575
  155. data/test/substitutions_test.rb +0 -2066
  156. data/test/tables_test.rb +0 -2036
  157. data/test/test_helper.rb +0 -447
  158. data/test/text_test.rb +0 -309
@@ -1,12 +1,12 @@
1
- /* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
2
- /* Uncomment @import statement below to use as custom stylesheet */
1
+ /* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
2
+ /* Uncomment @import statement when using as custom stylesheet */
3
3
  /*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
4
4
  article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
5
5
  audio,canvas,video{display:inline-block}
6
6
  audio:not([controls]){display:none;height:0}
7
7
  script{display:none!important}
8
8
  html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
9
- a{background:transparent}
9
+ a{background:none}
10
10
  a:focus{outline:thin dotted}
11
11
  a:active,a:hover{outline:0}
12
12
  h1{font-size:2em;margin:.67em 0}
@@ -59,7 +59,7 @@ select{width:100%}
59
59
  div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
60
60
  a{color:#2156a5;text-decoration:underline;line-height:inherit}
61
61
  a:hover,a:focus{color:#1d4b8f}
62
- a img{border:none}
62
+ a img{border:0}
63
63
  p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
64
64
  p aside{font-size:.875em;line-height:1.35;font-style:italic}
65
65
  h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
@@ -100,20 +100,23 @@ table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
100
100
  table thead,table tfoot{background:#f7f8f7}
101
101
  table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
102
102
  table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
103
- table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
103
+ table tr.even,table tr.alt{background:#f8f8f7}
104
104
  table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
105
105
  h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
106
106
  h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
107
107
  .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
108
108
  .clearfix::after,.float-group::after{clear:both}
109
- *:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
110
- *:not(pre)>code.nobreak{word-wrap:normal}
111
- *:not(pre)>code.nowrap{white-space:nowrap}
112
- pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
109
+ :not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
110
+ :not(pre)>code.nobreak{word-wrap:normal}
111
+ :not(pre)>code.nowrap{white-space:nowrap}
112
+ pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
113
+ pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
114
+ pre>code{display:block}
115
+ pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
113
116
  em em{font-style:normal}
114
117
  strong strong{font-weight:400}
115
118
  .keyseq{color:rgba(51,51,51,.8)}
116
- kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
119
+ kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
117
120
  .keyseq kbd:first-child{margin-left:0}
118
121
  .keyseq kbd:last-child{margin-right:0}
119
122
  .menuseq,.menuref{color:#000}
@@ -154,7 +157,7 @@ p a>code:hover{color:rgba(0,0,0,.9)}
154
157
  #toctitle{color:#7a2518;font-size:1.2em}
155
158
  @media screen and (min-width:768px){#toctitle{font-size:1.375em}
156
159
  body.toc2{padding-left:15em;padding-right:0}
157
- #toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
160
+ #toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
158
161
  #toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
159
162
  #toc.toc2>ul{font-size:.9em;margin-bottom:0}
160
163
  #toc.toc2 ul ul{margin-left:0;padding-left:1em}
@@ -170,7 +173,7 @@ body.toc2.toc-right{padding-left:0;padding-right:20em}}
170
173
  #content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
171
174
  #content #toc>:first-child{margin-top:0}
172
175
  #content #toc>:last-child{margin-bottom:0}
173
- #footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
176
+ #footer{max-width:100%;background:rgba(0,0,0,.8);padding:1.25em}
174
177
  #footer-text{color:rgba(255,255,255,.8);line-height:1.44}
175
178
  #content{margin-bottom:.625em}
176
179
  .sect1{padding-bottom:.625em}
@@ -197,32 +200,35 @@ table.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font
197
200
  .exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
198
201
  .exampleblock>.content>:first-child{margin-top:0}
199
202
  .exampleblock>.content>:last-child{margin-bottom:0}
200
- .sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
203
+ .sidebarblock{border-style:solid;border-width:1px;border-color:#dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;-webkit-border-radius:4px;border-radius:4px}
201
204
  .sidebarblock>:first-child{margin-top:0}
202
205
  .sidebarblock>:last-child{margin-bottom:0}
203
206
  .sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
204
207
  .exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
205
- .literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
206
- .sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
207
- .literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
208
- @media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
209
- @media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
210
- .literalblock pre.nowrap,.literalblock pre.nowrap pre,.listingblock pre.nowrap,.listingblock pre.nowrap pre{white-space:pre;word-wrap:normal}
211
- .literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
212
- .listingblock pre.highlightjs{padding:0}
213
- .listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
214
- .listingblock pre.prettyprint{border-width:0}
208
+ .literalblock pre,.listingblock>.content>pre{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
209
+ @media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
210
+ @media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
211
+ .literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
212
+ .listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class="highlight"],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
215
213
  .listingblock>.content{position:relative}
216
- .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
214
+ .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
217
215
  .listingblock:hover code[data-lang]::before{display:block}
218
- .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
216
+ .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
219
217
  .listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
220
- table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
221
- table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
222
- table.pyhltable td.code{padding-left:.75em;padding-right:0}
223
- pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #dddddf}
224
- pre.pygments .lineno{display:inline-block;margin-right:.25em}
225
- table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
218
+ .listingblock pre.highlightjs{padding:0}
219
+ .listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
220
+ .listingblock pre.prettyprint{border-width:0}
221
+ .prettyprint{background:#f7f7f8}
222
+ pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
223
+ pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
224
+ pre.prettyprint li code[data-lang]::before{opacity:1}
225
+ pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
226
+ table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
227
+ table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
228
+ table.linenotable td.code{padding-left:.75em}
229
+ table.linenotable td.linenos{border-right:1px solid currentColor;opacity:.35;padding-right:.5em}
230
+ pre.pygments .lineno{border-right:1px solid currentColor;opacity:.35;display:inline-block;margin-right:.75em}
231
+ pre.pygments .lineno::before{content:"";margin-right:-.125em}
226
232
  .quoteblock{margin:0 1em 1.25em 1.5em;display:table}
227
233
  .quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
228
234
  .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}
@@ -258,8 +264,7 @@ table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>t
258
264
  table.frame-all{border-width:1px}
259
265
  table.frame-sides{border-width:0 1px}
260
266
  table.frame-topbot,table.frame-ends{border-width:1px 0}
261
- table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
262
- table.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
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}
263
268
  th.halign-left,td.halign-left{text-align:left}
264
269
  th.halign-right,td.halign-right{text-align:right}
265
270
  th.halign-center,td.halign-center{text-align:center}
@@ -271,7 +276,6 @@ tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
271
276
  tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
272
277
  p.tableblock>code:only-child{background:none;padding:0}
273
278
  p.tableblock{font-size:1em}
274
- td>div.verse{white-space:pre}
275
279
  ol{margin-left:1.75em}
276
280
  ul li ol{margin-left:1.5em}
277
281
  dl dd{margin-left:1.125em}
@@ -330,37 +334,37 @@ div.unbreakable{page-break-inside:avoid}
330
334
  .overline{text-decoration:overline}
331
335
  .line-through{text-decoration:line-through}
332
336
  .aqua{color:#00bfbf}
333
- .aqua-background{background-color:#00fafa}
337
+ .aqua-background{background:#00fafa}
334
338
  .black{color:#000}
335
- .black-background{background-color:#000}
339
+ .black-background{background:#000}
336
340
  .blue{color:#0000bf}
337
- .blue-background{background-color:#0000fa}
341
+ .blue-background{background:#0000fa}
338
342
  .fuchsia{color:#bf00bf}
339
- .fuchsia-background{background-color:#fa00fa}
343
+ .fuchsia-background{background:#fa00fa}
340
344
  .gray{color:#606060}
341
- .gray-background{background-color:#7d7d7d}
345
+ .gray-background{background:#7d7d7d}
342
346
  .green{color:#006000}
343
- .green-background{background-color:#007d00}
347
+ .green-background{background:#007d00}
344
348
  .lime{color:#00bf00}
345
- .lime-background{background-color:#00fa00}
349
+ .lime-background{background:#00fa00}
346
350
  .maroon{color:#600000}
347
- .maroon-background{background-color:#7d0000}
351
+ .maroon-background{background:#7d0000}
348
352
  .navy{color:#000060}
349
- .navy-background{background-color:#00007d}
353
+ .navy-background{background:#00007d}
350
354
  .olive{color:#606000}
351
- .olive-background{background-color:#7d7d00}
355
+ .olive-background{background:#7d7d00}
352
356
  .purple{color:#600060}
353
- .purple-background{background-color:#7d007d}
357
+ .purple-background{background:#7d007d}
354
358
  .red{color:#bf0000}
355
- .red-background{background-color:#fa0000}
359
+ .red-background{background:#fa0000}
356
360
  .silver{color:#909090}
357
- .silver-background{background-color:#bcbcbc}
361
+ .silver-background{background:#bcbcbc}
358
362
  .teal{color:#006060}
359
- .teal-background{background-color:#007d7d}
363
+ .teal-background{background:#007d7d}
360
364
  .white{color:#bfbfbf}
361
- .white-background{background-color:#fafafa}
365
+ .white-background{background:#fafafa}
362
366
  .yellow{color:#bfbf00}
363
- .yellow-background{background-color:#fafa00}
367
+ .yellow-background{background:#fafa00}
364
368
  span.icon>.fa{cursor:default}
365
369
  a span.icon>.fa{cursor:inherit}
366
370
  .admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
@@ -369,7 +373,7 @@ a span.icon>.fa{cursor:inherit}
369
373
  .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
370
374
  .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
371
375
  .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
372
- .conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
376
+ .conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
373
377
  .conum[data-value] *{color:#fff!important}
374
378
  .conum[data-value]+b{display:none}
375
379
  .conum[data-value]::after{content:attr(data-value)}
@@ -382,7 +386,7 @@ p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
382
386
  p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
383
387
  p{margin-bottom:1.25rem}
384
388
  .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
385
- .exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
389
+ .exampleblock>.content{background:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
386
390
  .print-only{display:none!important}
387
391
  @page{margin:1.25cm .75cm}
388
392
  @media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
@@ -1,14 +1,12 @@
1
1
  /* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
2
- /*pre.CodeRay {background-color:#f7f7f8;}*/
3
- .CodeRay .line-numbers{border-right:1px solid #d8d8d8;padding:0 0.5em 0 .25em}
4
- .CodeRay span.line-numbers{display:inline-block;margin-right:.5em;color:rgba(0,0,0,.3)}
5
- .CodeRay .line-numbers strong{color:rgba(0,0,0,.4)}
6
- table.CodeRay{border-collapse:separate;border-spacing:0;margin-bottom:0;border:0;background:none}
7
- table.CodeRay td{vertical-align: top;line-height:1.45}
2
+ pre.CodeRay{background:#f7f7f8}
3
+ .CodeRay .line-numbers{border-right:1px solid currentColor;opacity:.35;padding:0 .5em 0 0}
4
+ .CodeRay span.line-numbers{display:inline-block;margin-right:.75em}
5
+ .CodeRay .line-numbers strong{color:#000}
6
+ table.CodeRay{border-collapse:separate;border:0;margin-bottom:0;background:none}
7
+ table.CodeRay td{vertical-align:top;line-height:inherit}
8
8
  table.CodeRay td.line-numbers{text-align:right}
9
- table.CodeRay td.line-numbers>pre{padding:0;color:rgba(0,0,0,.3)}
10
- table.CodeRay td.code{padding:0 0 0 .5em}
11
- table.CodeRay td.code>pre{padding:0}
9
+ table.CodeRay td.code{padding:0 0 0 .75em}
12
10
  .CodeRay .debug{color:#fff !important;background:#000080 !important}
13
11
  .CodeRay .annotation{color:#007}
14
12
  .CodeRay .attribute-name{color:#000080}
@@ -1,10 +1,4 @@
1
- # encoding: UTF-8
2
- RUBY_ENGINE = 'unknown' unless defined? RUBY_ENGINE
3
- RUBY_ENGINE_OPAL = (RUBY_ENGINE == 'opal')
4
- RUBY_ENGINE_JRUBY = (RUBY_ENGINE == 'jruby')
5
- RUBY_MIN_VERSION_1_9 = (RUBY_VERSION >= '1.9')
6
- RUBY_MIN_VERSION_2 = (RUBY_VERSION >= '2')
7
-
1
+ # frozen_string_literal: true
8
2
  require 'set'
9
3
 
10
4
  # NOTE RUBY_ENGINE == 'opal' conditional blocks like this are filtered by the Opal preprocessor
@@ -13,17 +7,13 @@ if RUBY_ENGINE == 'opal'
13
7
  require 'asciidoctor/js'
14
8
  else
15
9
  autoload :Base64, 'base64'
16
- autoload :URI, 'uri'
10
+ require 'cgi/util'
17
11
  autoload :OpenURI, 'open-uri'
18
12
  autoload :Pathname, 'pathname'
19
13
  autoload :StringScanner, 'strscan'
14
+ autoload :URI, 'uri'
20
15
  end
21
16
 
22
- # ideally we should use require_relative instead of modifying the LOAD_PATH
23
- $:.unshift File.dirname __FILE__
24
-
25
- require 'asciidoctor/logging'
26
-
27
17
  # Public: Methods for parsing AsciiDoc input files and converting documents
28
18
  # using eRuby templates.
29
19
  #
@@ -51,15 +41,13 @@ require 'asciidoctor/logging'
51
41
  #
52
42
  # Use custom (Tilt-supported) templates:
53
43
  #
54
- # Asciidoctor.convert_file 'sample.adoc', :template_dir => 'path/to/templates'
44
+ # Asciidoctor.convert_file 'sample.adoc', template_dir: 'path/to/templates'
55
45
  #
56
46
  module Asciidoctor
57
-
58
- # alias the RUBY_ENGINE constant inside the Asciidoctor namespace
59
- RUBY_ENGINE = ::RUBY_ENGINE
47
+ # alias the RUBY_ENGINE constant inside the Asciidoctor namespace and define a precomputed alias for runtime
48
+ RUBY_ENGINE_OPAL = (RUBY_ENGINE = ::RUBY_ENGINE) == 'opal'
60
49
 
61
50
  module SafeMode
62
-
63
51
  # A safe mode level that disables any of the security features enforced
64
52
  # by Asciidoctor (Ruby is still subject to its own restrictions).
65
53
  UNSAFE = 0;
@@ -71,10 +59,10 @@ module Asciidoctor
71
59
 
72
60
  # A safe mode level that disallows the document from setting attributes
73
61
  # that would affect the conversion of the document, in addition to all the
74
- # security features of SafeMode::SAFE. For instance, this level disallows
75
- # changing the backend or the source-highlighter using an attribute defined
76
- # in the source document. This is the most fundamental level of security
77
- # for server-side deployments (hence the name).
62
+ # security features of SafeMode::SAFE. For instance, this level forbids
63
+ # changing the backend or source-highlighter using an attribute defined
64
+ # in the source document header. This is the most fundamental level of
65
+ # security for server deployments (hence the name).
78
66
  SERVER = 10;
79
67
 
80
68
  # A safe mode level that disallows the document from attempting to read
@@ -86,7 +74,7 @@ module Asciidoctor
86
74
  # be allowed to embed trusted content into the document).
87
75
  #
88
76
  # Since Asciidoctor is aiming for wide adoption, this level is the default
89
- # and is recommended for server-side deployments.
77
+ # and is recommended for server deployments.
90
78
  SECURE = 20;
91
79
 
92
80
  # A planned safe mode level that disallows the use of passthrough macros and
@@ -97,12 +85,10 @@ module Asciidoctor
97
85
  # enforced)!
98
86
  #PARANOID = 100;
99
87
 
100
- rec = {}
101
- constants.each {|sym| rec[const_get sym] = sym.to_s.downcase }
102
- @names_by_value = rec
88
+ @names_by_value = {}.tap {|accum| (constants false).each {|sym| accum[const_get sym, false] = sym.to_s.downcase } }
103
89
 
104
90
  def self.value_for_name name
105
- const_get name.upcase
91
+ const_get name.upcase, false
106
92
  end
107
93
 
108
94
  def self.name_for_value value
@@ -119,14 +105,14 @@ module Asciidoctor
119
105
  @keys = ::Set.new
120
106
  class << self
121
107
  attr_reader :keys
122
- end
123
108
 
124
- # Defines a new compliance key and assigns an initial value.
125
- def self.define key, value
126
- instance_variable_set %(@#{key}), value
127
- class << self; self; end.send :attr_accessor, key
128
- @keys << key
129
- nil
109
+ # Defines a new compliance key and assigns an initial value.
110
+ def define key, value
111
+ instance_variable_set %(@#{key}), value
112
+ singleton_class.send :attr_accessor, key
113
+ @keys << key
114
+ nil
115
+ end
130
116
  end
131
117
 
132
118
  # AsciiDoc terminates paragraphs adjacent to
@@ -184,51 +170,46 @@ module Asciidoctor
184
170
  define :markdown_syntax, true
185
171
  end
186
172
 
187
- # The absolute root path of the Asciidoctor RubyGem
188
- ROOT_PATH = ::File.dirname ::File.dirname ::File.expand_path __FILE__
173
+ # The absolute root directory of the Asciidoctor RubyGem
174
+ ROOT_DIR = ::File.dirname ::File.absolute_path __dir__ unless defined? ROOT_DIR
189
175
 
190
- # The absolute lib path of the Asciidoctor RubyGem
191
- #LIB_PATH = ::File.join ROOT_PATH, 'lib'
176
+ # The absolute lib directory of the Asciidoctor RubyGem
177
+ LIB_DIR = ::File.join ROOT_DIR, 'lib'
192
178
 
193
- # The absolute data path of the Asciidoctor RubyGem
194
- DATA_PATH = ::File.join ROOT_PATH, 'data'
179
+ # The absolute data directory of the Asciidoctor RubyGem
180
+ DATA_DIR = ::File.join ROOT_DIR, 'data'
195
181
 
196
182
  # The user's home directory, as best we can determine it
197
- # NOTE not using infix rescue for performance reasons, see: https://github.com/jruby/jruby/issues/1816
198
- begin
199
- USER_HOME = ::Dir.home
200
- rescue
201
- USER_HOME = ::ENV['HOME'] || ::Dir.pwd
202
- end
183
+ USER_HOME = ::Dir.home
203
184
 
204
- # Flag to indicate whether encoding can be coerced to UTF-8
205
- # _All_ input data must be force encoded to UTF-8 if Encoding.default_external is *not* UTF-8
206
- # Addresses failures performing string operations that are reported as "invalid byte sequence in US-ASCII"
207
- # Ruby 1.8 doesn't seem to experience this problem (perhaps because it isn't validating the encodings)
208
- COERCE_ENCODING = !::RUBY_ENGINE_OPAL && ::RUBY_MIN_VERSION_1_9
185
+ # The newline character used for output; stored in constant table as an optimization
186
+ LF = ?\n
209
187
 
210
- # Flag to indicate whether encoding of external strings needs to be forced to UTF-8
211
- FORCE_ENCODING = COERCE_ENCODING && ::Encoding.default_external != ::Encoding::UTF_8
188
+ # The null character to use for splitting attribute values
189
+ NULL = ?\0
190
+
191
+ # String for matching tab character
192
+ TAB = ?\t
193
+
194
+ # Maximum integer value for "boundless" operations; equal to MAX_SAFE_INTEGER in JavaScript
195
+ MAX_INT = 9007199254740991
196
+
197
+ # Alias UTF_8 encoding for convenience / speed
198
+ UTF_8 = ::Encoding::UTF_8
212
199
 
213
200
  # Byte arrays for UTF-* Byte Order Marks
214
201
  BOM_BYTES_UTF_8 = [0xef, 0xbb, 0xbf]
215
202
  BOM_BYTES_UTF_16LE = [0xff, 0xfe]
216
203
  BOM_BYTES_UTF_16BE = [0xfe, 0xff]
217
204
 
218
- # Flag to indicate that line length should be calculated using a unicode mode hint
219
- FORCE_UNICODE_LINE_LENGTH = !::RUBY_MIN_VERSION_1_9
220
-
221
- # The endline character used for output; stored in constant table as an optimization
222
- LF = EOL = "\n"
223
-
224
- # The null character to use for splitting attribute values
225
- NULL = "\0"
205
+ # The mode to use when opening a file for reading
206
+ FILE_READ_MODE = RUBY_ENGINE_OPAL ? 'r' : 'rb:utf-8:utf-8'
226
207
 
227
- # String for matching tab character
228
- TAB = "\t"
208
+ # The mode to use when opening a URI for reading
209
+ URI_READ_MODE = FILE_READ_MODE
229
210
 
230
- # Maximum integer value for "boundless" operations; equal to MAX_SAFE_INTEGER in JavaScript
231
- MAX_INT = 9007199254740991
211
+ # The mode to use when opening a file for writing
212
+ FILE_WRITE_MODE = RUBY_ENGINE_OPAL ? 'w' : 'w:utf-8'
232
213
 
233
214
  # The default document type
234
215
  # Can influence markup generated by the converters
@@ -295,7 +276,6 @@ module Asciidoctor
295
276
  '====' => [:example, ['admonition'].to_set],
296
277
  '****' => [:sidebar, ::Set.new],
297
278
  '____' => [:quote, ['verse'].to_set],
298
- '""' => [:quote, ['verse'].to_set],
299
279
  '++++' => [:pass, ['stem', 'latexmath', 'asciimath'].to_set],
300
280
  '|===' => [:table, ::Set.new],
301
281
  ',===' => [:table, ::Set.new],
@@ -305,7 +285,8 @@ module Asciidoctor
305
285
  '```' => [:fenced_code, ::Set.new]
306
286
  }
307
287
 
308
- DELIMITED_BLOCK_HEADS = DELIMITED_BLOCKS.keys.map {|key| key.slice 0, 2 }.to_set
288
+ DELIMITED_BLOCK_HEADS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k.slice 0, 2] = true } }
289
+ DELIMITED_BLOCK_TAILS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k] = k[k.length - 1] if k.length == 4 } }
309
290
 
310
291
  LAYOUT_BREAK_CHARS = {
311
292
  '\'' => :thematic_break,
@@ -348,16 +329,14 @@ module Asciidoctor
348
329
 
349
330
  LINE_CONTINUATION_LEGACY = ' +'
350
331
 
351
- MATHJAX_VERSION = '2.7.4'
352
-
353
332
  BLOCK_MATH_DELIMITERS = {
354
- :asciimath => ['\$', '\$'],
355
- :latexmath => ['\[', '\]'],
333
+ asciimath: ['\$', '\$'],
334
+ latexmath: ['\[', '\]'],
356
335
  }
357
336
 
358
337
  INLINE_MATH_DELIMITERS = {
359
- :asciimath => ['\$', '\$'],
360
- :latexmath => ['\(', '\)'],
338
+ asciimath: ['\$', '\$'],
339
+ latexmath: ['\(', '\)'],
361
340
  }
362
341
 
363
342
  (STEM_TYPE_ALIASES = {
@@ -368,6 +347,10 @@ module Asciidoctor
368
347
 
369
348
  FONT_AWESOME_VERSION = '4.7.0'
370
349
 
350
+ HIGHLIGHT_JS_VERSION = '9.15.6'
351
+
352
+ MATHJAX_VERSION = '2.7.5'
353
+
371
354
  # attributes which be changed within the content of the document (but not
372
355
  # header) because it has semantic meaning; ex. sectnums
373
356
  FLEXIBLE_ATTRIBUTES = ['sectnums']
@@ -387,37 +370,16 @@ module Asciidoctor
387
370
  ## Regular expression character classes (to ensure regexp compatibility between Ruby and JavaScript)
388
371
  ## CC stands for "character class", CG stands for "character class group"
389
372
 
390
- if RUBY_ENGINE == 'opal'
391
- CC_ANY = '[^\n]' unless defined? CC_ANY
392
- else
373
+ unless RUBY_ENGINE == 'opal'
393
374
  # CC_ALL is any character, including newlines (must be accompanied by multiline regexp flag)
394
375
  CC_ALL = '.'
395
376
  # CC_ANY is any character except newlines
396
377
  CC_ANY = '.'
397
378
  CC_EOL = '$'
398
- # character classes for the Regexp engine in Ruby >= 2 (Ruby 1.9 supports \p{} but has problems w/ encoding)
399
- if ::RUBY_MIN_VERSION_2
400
- CC_ALPHA = CG_ALPHA = '\p{Alpha}'
401
- CC_ALNUM = CG_ALNUM = '\p{Alnum}'
402
- CG_BLANK = '\p{Blank}'
403
- CC_WORD = CG_WORD = '\p{Word}'
404
- # character classes for the Regexp engine in Ruby < 2
405
- else
406
- CC_ALPHA = '[:alpha:]'
407
- CG_ALPHA = '[[:alpha:]]'
408
- CC_ALNUM = '[:alnum:]'
409
- CG_ALNUM = '[[:alnum:]]'
410
- if ::RUBY_MIN_VERSION_1_9
411
- CG_BLANK = '[[:blank:]]'
412
- CC_WORD = '[:word:]'
413
- CG_WORD = '[[:word:]]'
414
- else
415
- # NOTE Ruby 1.8 cannot match word characters beyond the ASCII range; if you need this feature, upgrade!
416
- CG_BLANK = '[ \t]'
417
- CC_WORD = '[:alnum:]_'
418
- CG_WORD = '[[:alnum:]_]'
419
- end
420
- end
379
+ CC_ALPHA = CG_ALPHA = '\p{Alpha}'
380
+ CC_ALNUM = CG_ALNUM = '\p{Alnum}'
381
+ CG_BLANK = '\p{Blank}'
382
+ CC_WORD = CG_WORD = '\p{Word}'
421
383
  end
422
384
 
423
385
  ## Document header
@@ -537,7 +499,7 @@ module Asciidoctor
537
499
  #
538
500
  if RUBY_ENGINE == 'opal'
539
501
  # NOTE In JavaScript, ^ and $ match the boundaries of the string when the m flag is not set
540
- AttributeEntryPassMacroRx = /^pass:([a-z]+(?:,[a-z]+)*)?\[([\S\s]*)\]$/
502
+ AttributeEntryPassMacroRx = /^pass:([a-z]+(?:,[a-z]+)*)?\[(#{CC_ALL}*)\]$/
541
503
  else
542
504
  AttributeEntryPassMacroRx = /\Apass:([a-z]+(?:,[a-z]+)*)?\[(.*)\]\Z/m
543
505
  end
@@ -646,7 +608,7 @@ module Asciidoctor
646
608
 
647
609
  # Matches the title only (first line) of an Setext (two-line) section title.
648
610
  # The title cannot begin with a dot and must have at least one alphanumeric character.
649
- SetextSectionTitleRx = /^((?!\.)#{CC_ANY}*?#{CG_WORD}#{CC_ANY}*)$/
611
+ SetextSectionTitleRx = /^((?!\.)#{CC_ANY}*?#{CG_ALNUM}#{CC_ANY}*)$/
650
612
 
651
613
  # Matches an anchor (i.e., id + optional reference text) inside a section title.
652
614
  #
@@ -662,13 +624,17 @@ module Asciidoctor
662
624
  # NOTE uppercase chars not included since expression is only run on a lowercase string
663
625
  InvalidSectionIdCharsRx = /<[^>]+>|&(?:[a-z][a-z]+\d{0,2}|#\d\d\d{0,4}|#x[\da-f][\da-f][\da-f]{0,3});|[^ #{CC_WORD}\-.]+?/
664
626
 
627
+ # Matches an explicit section level style like sect1
628
+ #
629
+ SectionLevelStyleRx = /^sect\d$/
630
+
665
631
  ## Lists
666
632
 
667
633
  # Detects the start of any list item.
668
634
  #
669
635
  # NOTE we only have to check as far as the blank character because we know it means non-whitespace follows.
670
636
  # IMPORTANT if this regexp does not agree with the regexp for each list type, the parser will hang.
671
- AnyListRx = %r(^(?:[ \t]*(?:-|\*\**|\.\.*|\u2022|\d+\.|[a-zA-Z]\.|[IVXivx]+\))[ \t]|(?!//[^/])#{CC_ANY}*?(?::::{0,2}|;;)(?:$|[ \t])|<?\d+>[ \t]))
637
+ AnyListRx = %r(^(?:[ \t]*(?:-|\*\**|\.\.*|\u2022|\d+\.|[a-zA-Z]\.|[IVXivx]+\))[ \t]|(?!//[^/])[ \t]*[^ \t]#{CC_ANY}*?(?::::{0,2}|;;)(?:$|[ \t])|<?\d+>[ \t]))
672
638
 
673
639
  # Matches an unordered list item (one level for hyphens, up to 5 levels for asterisks).
674
640
  #
@@ -698,12 +664,12 @@ module Asciidoctor
698
664
 
699
665
  # Matches the ordinals for each type of ordered list.
700
666
  OrderedListMarkerRxMap = {
701
- :arabic => /\d+\./,
702
- :loweralpha => /[a-z]\./,
703
- :lowerroman => /[ivx]+\)/,
704
- :upperalpha => /[A-Z]\./,
705
- :upperroman => /[IVX]+\)/
706
- #:lowergreek => /[a-z]\]/
667
+ arabic: /\d+\./,
668
+ loweralpha: /[a-z]\./,
669
+ lowerroman: /[ivx]+\)/,
670
+ upperalpha: /[A-Z]\./,
671
+ upperroman: /[IVX]+\)/,
672
+ #lowergreek: /[a-z]\]/,
707
673
  }
708
674
 
709
675
  # Matches a description list entry.
@@ -730,15 +696,15 @@ module Asciidoctor
730
696
  #
731
697
  # NOTE we know trailing (.*) will match at least one character because we strip trailing spaces
732
698
  # NOTE must skip line comment when looking for next list item inside list
733
- DescriptionListRx = %r(^(?!//[^/])[ \t]*(#{CC_ANY}*?)(:::{0,2}|;;)(?:$|[ \t]+(#{CC_ANY}*)$))
699
+ DescriptionListRx = %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?)(:::{0,2}|;;)(?:$|[ \t]+(#{CC_ANY}*)$))
734
700
 
735
- # Matches a sibling description list item (which does not include the type in the key).
701
+ # Matches a sibling description list item (excluding the delimiter specified by the key).
736
702
  # NOTE must skip line comment when looking for sibling list item
737
703
  DescriptionListSiblingRx = {
738
- '::' => %r(^(?!//[^/])[ \t]*(#{CC_ANY}*[^:]|)(::)(?:$|[ \t]+(#{CC_ANY}*)$)),
739
- ':::' => %r(^(?!//[^/])[ \t]*(#{CC_ANY}*[^:]|)(:::)(?:$|[ \t]+(#{CC_ANY}*)$)),
740
- '::::' => %r(^(?!//[^/])[ \t]*(#{CC_ANY}*[^:]|)(::::)(?:$|[ \t]+(#{CC_ANY}*)$)),
741
- ';;' => %r(^(?!//[^/])[ \t]*(#{CC_ANY}*?)(;;)(?:$|[ \t]+(#{CC_ANY}*)$))
704
+ '::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(::)(?:$|[ \t]+(#{CC_ANY}*)$)),
705
+ ':::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(:::)(?:$|[ \t]+(#{CC_ANY}*)$)),
706
+ '::::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(::::)(?:$|[ \t]+(#{CC_ANY}*)$)),
707
+ ';;' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?)(;;)(?:$|[ \t]+(#{CC_ANY}*)$))
742
708
  }
743
709
 
744
710
  # Matches a callout list item.
@@ -765,20 +731,20 @@ module Asciidoctor
765
731
  # NOTE extract regexps are applied line-by-line, so we can use $ as end-of-line char
766
732
  CalloutExtractRx = %r(((?://|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\3>(?=(?: ?\\?<!?\3(?:\d+|\.)\3>)*$))
767
733
  CalloutExtractRxt = '(\\\\)?<()(\\d+|\\.)>(?=(?: ?\\\\?<(?:\\d+|\\.)>)*$)'
768
- CalloutExtractRxMap = ::Hash.new {|h, k| h[k] = /(#{::Regexp.escape k} ?)?#{CalloutExtractRxt}/ }
734
+ CalloutExtractRxMap = ::Hash.new {|h, k| h[k] = /(#{k.empty? ? '' : "#{::Regexp.escape k} ?"})?#{CalloutExtractRxt}/ }
769
735
  # NOTE special characters have not been replaced when scanning
770
736
  CalloutScanRx = /\\?<!?(|--)(\d+|\.)\1>(?=(?: ?\\?<!?\1(?:\d+|\.)\1>)*#{CC_EOL})/
771
737
  # NOTE special characters have already been replaced when converting to an SGML format
772
738
  CalloutSourceRx = %r(((?://|#|--|;;) ?)?(\\)?&lt;!?(|--)(\d+|\.)\3&gt;(?=(?: ?\\?&lt;!?\3(?:\d+|\.)\3&gt;)*#{CC_EOL}))
773
739
  CalloutSourceRxt = "(\\\\)?&lt;()(\\d+|\\.)&gt;(?=(?: ?\\\\?&lt;(?:\\d+|\\.)&gt;)*#{CC_EOL})"
774
- CalloutSourceRxMap = ::Hash.new {|h, k| h[k] = /(#{::Regexp.escape k} ?)?#{CalloutSourceRxt}/ }
740
+ CalloutSourceRxMap = ::Hash.new {|h, k| h[k] = /(#{k.empty? ? '' : "#{::Regexp.escape k} ?"})?#{CalloutSourceRxt}/ }
775
741
 
776
742
  # A Hash of regexps for lists used for dynamic access.
777
743
  ListRxMap = {
778
- :ulist => UnorderedListRx,
779
- :olist => OrderedListRx,
780
- :dlist => DescriptionListRx,
781
- :colist => CalloutListRx
744
+ ulist: UnorderedListRx,
745
+ olist: OrderedListRx,
746
+ dlist: DescriptionListRx,
747
+ colist: CalloutListRx,
782
748
  }
783
749
 
784
750
  ## Tables
@@ -862,7 +828,7 @@ module Asciidoctor
862
828
  #
863
829
  # doc.writer@example.com
864
830
  #
865
- InlineEmailRx = %r(([\\>:/])?#{CG_WORD}[#{CC_WORD}.%+-]*@#{CG_ALNUM}[#{CC_ALNUM}.-]*\.#{CG_ALPHA}{2,4}\b)
831
+ InlineEmailRx = %r(([\\>:/])?#{CG_WORD}(?:&amp;|[#{CC_WORD}.%+-])*@#{CG_ALNUM}[#{CC_ALNUM}.-]*\.#{CG_ALPHA}{2,4}\b)
866
832
 
867
833
  # Matches an inline footnote macro, which is allowed to span multiple lines.
868
834
  #
@@ -884,7 +850,7 @@ module Asciidoctor
884
850
  # image:filename.png[More [Alt\] Text] (alt text becomes "More [Alt] Text")
885
851
  # icon:github[large]
886
852
  #
887
- # NOTE be as non-greedy as possible by not allowing endline or left square bracket in target
853
+ # NOTE be as non-greedy as possible by not allowing newline or left square bracket in target
888
854
  InlineImageMacroRx = /\\?i(?:mage|con):([^:\s\[](?:[^\n\[]*[^\s\[])?)\[(|#{CC_ALL}*?[^\\])\]/m
889
855
 
890
856
  # Matches an indexterm inline macro, which may span multiple lines.
@@ -1084,14 +1050,14 @@ module Asciidoctor
1084
1050
  ReplaceableTextRx = /[&']|--|\.\.\.|\([CRT]M?\)/
1085
1051
 
1086
1052
  # Matches a whitespace delimiter, a sequence of spaces, tabs, and/or newlines.
1087
- # Matches the parsing rules of %w strings in Ruby.
1053
+ # Matches the parsing rules of %w strings in Ruby.
1088
1054
  #
1089
1055
  # Examples
1090
1056
  #
1091
1057
  # one two three four
1092
1058
  # five six
1093
1059
  #
1094
- # TODO change to /(?<!\\)[ \t\n]+/ after dropping support for Ruby 1.8.7
1060
+ # TODO change to /(?<!\\)[ \t\n]+/ once lookbehind assertions are implemented in all modern browsers
1095
1061
  SpaceDelimiterRx = /([^\\])[ \t\n]+/
1096
1062
 
1097
1063
  # Matches a + or - modifier in a subs list
@@ -1102,17 +1068,11 @@ module Asciidoctor
1102
1068
  #
1103
1069
  # Examples
1104
1070
  #
1105
- # docbook45
1071
+ # docbook5
1106
1072
  # html5
1107
1073
  #
1108
1074
  TrailingDigitsRx = /\d+$/
1109
1075
 
1110
- # Matches any character with multibyte support explicitly enabled (length of multibyte char = 1)
1111
- #
1112
- unless RUBY_ENGINE == 'opal'
1113
- UnicodeCharScanRx = /./u if FORCE_UNICODE_LINE_LENGTH
1114
- end
1115
-
1116
1076
  # Detects strings that resemble URIs.
1117
1077
  #
1118
1078
  # Examples
@@ -1237,9 +1197,7 @@ module Asciidoctor
1237
1197
  quote_subs = nil
1238
1198
  compat_quote_subs = nil
1239
1199
 
1240
- # NOTE in Ruby 1.8.7, [^\\] does not match start of line,
1241
- # so we need to match it explicitly
1242
- # order is significant
1200
+ # NOTE order of replacements is significant
1243
1201
  REPLACEMENTS = [
1244
1202
  # (C)
1245
1203
  [/\\?\(C\)/, '&#169;', :none],
@@ -1247,8 +1205,8 @@ module Asciidoctor
1247
1205
  [/\\?\(R\)/, '&#174;', :none],
1248
1206
  # (TM)
1249
1207
  [/\\?\(TM\)/, '&#8482;', :none],
1250
- # foo -- bar
1251
- # FIXME this drops the endline if it appears at end of line
1208
+ # foo -- bar (where either space character can be a newline)
1209
+ # NOTE this necessarily drops the newline if it appears at end of line
1252
1210
  [/(^|\n| |\\)--( |\n|$)/, '&#8201;&#8212;&#8201;', :none],
1253
1211
  # foo--bar
1254
1212
  [/(#{CG_WORD})\\?--(?=#{CG_WORD})/, '&#8212;&#8203;', :leading],
@@ -1298,63 +1256,49 @@ module Asciidoctor
1298
1256
 
1299
1257
  if !(attrs = options[:attributes])
1300
1258
  attrs = {}
1301
- elsif ::Hash === attrs || (::RUBY_ENGINE_JRUBY && ::Java::JavaUtil::Map === attrs)
1259
+ elsif ::Hash === attrs || ((defined? ::Java::JavaUtil::Map) && ::Java::JavaUtil::Map === attrs)
1302
1260
  attrs = attrs.dup
1303
1261
  elsif ::Array === attrs
1304
- attrs, attrs_arr = {}, attrs
1305
- attrs_arr.each do |entry|
1306
- k, v = entry.split '=', 2
1307
- attrs[k] = v || ''
1262
+ attrs = {}.tap do |accum|
1263
+ attrs.each do |entry|
1264
+ k, _, v = entry.partition '='
1265
+ accum[k] = v
1266
+ end
1308
1267
  end
1309
1268
  elsif ::String === attrs
1310
1269
  # condense and convert non-escaped spaces to null, unescape escaped spaces, then split on null
1311
- attrs, attrs_arr = {}, attrs.gsub(SpaceDelimiterRx, %(\\1#{NULL})).gsub(EscapedSpaceRx, '\1').split(NULL)
1312
- attrs_arr.each do |entry|
1313
- k, v = entry.split '=', 2
1314
- attrs[k] = v || ''
1270
+ attrs = {}.tap do |accum|
1271
+ attrs.gsub(SpaceDelimiterRx, '\1' + NULL).gsub(EscapedSpaceRx, '\1').split(NULL).each do |entry|
1272
+ k, _, v = entry.partition '='
1273
+ accum[k] = v
1274
+ end
1315
1275
  end
1316
1276
  elsif (attrs.respond_to? :keys) && (attrs.respond_to? :[])
1317
- # convert it to a Hash as we know it
1318
- attrs = ::Hash[attrs.keys.map {|k| [k, attrs[k]] }]
1277
+ # coerce attrs to a real Hash
1278
+ attrs = {}.tap {|accum| attrs.keys.each {|k| accum[k] = attrs[k] } }
1319
1279
  else
1320
1280
  raise ::ArgumentError, %(illegal type for attributes option: #{attrs.class.ancestors.join ' < '})
1321
1281
  end
1322
1282
 
1323
- lines = nil
1324
1283
  if ::File === input
1325
- # TODO cli checks if input path can be read and is file, but might want to add check to API
1326
- input_path = ::File.expand_path input.path
1327
- # See https://reproducible-builds.org/specs/source-date-epoch/
1328
- # NOTE Opal can't call key? on ENV
1329
- input_mtime = ::ENV['SOURCE_DATE_EPOCH'] ? ::Time.at(Integer ::ENV['SOURCE_DATE_EPOCH']).utc : input.mtime
1330
- lines = input.readlines
1331
- # hold off on setting infile and indir until we get a better sense of their purpose
1332
- attrs['docfile'] = input_path
1284
+ options[:input_mtime] = input.mtime
1285
+ # TODO cli checks if input path can be read and is file, but might want to add check to API too
1286
+ input_path = ::File.absolute_path input.path
1287
+ # NOTE defer setting infile and indir until we get a better sense of their purpose
1288
+ attrs['docfile'] = input_path = ::File.absolute_path input.path
1333
1289
  attrs['docdir'] = ::File.dirname input_path
1334
1290
  attrs['docname'] = Helpers.basename input_path, (attrs['docfilesuffix'] = ::File.extname input_path)
1335
- if (docdate = attrs['docdate'])
1336
- attrs['docyear'] ||= ((docdate.index '-') == 4 ? (docdate.slice 0, 4) : nil)
1337
- else
1338
- docdate = attrs['docdate'] = (input_mtime.strftime '%F')
1339
- attrs['docyear'] ||= input_mtime.year.to_s
1340
- end
1341
- # %Z is OS dependent and may contain characters that aren't UTF-8 encoded (see asciidoctor#2770 and asciidoctor.js#23)
1342
- # Ruby 1.8 doesn't support %:z
1343
- doctime = (attrs['doctime'] ||= input_mtime.strftime %(%T #{input_mtime.utc_offset == 0 ? 'UTC' : '%z'}))
1344
- attrs['docdatetime'] = %(#{docdate} #{doctime})
1345
- elsif input.respond_to? :readlines
1291
+ source = input.read
1292
+ elsif input.respond_to? :read
1346
1293
  # NOTE tty, pipes & sockets can't be rewound, but can't be sniffed easily either
1347
1294
  # just fail the rewind operation silently to handle all cases
1348
- begin
1349
- input.rewind
1350
- rescue
1351
- end
1352
- lines = input.readlines
1295
+ input.rewind rescue nil
1296
+ source = input.read
1353
1297
  elsif ::String === input
1354
- lines = ::RUBY_MIN_VERSION_2 ? input.lines : input.each_line.to_a
1298
+ source = input
1355
1299
  elsif ::Array === input
1356
- lines = input.drop 0
1357
- else
1300
+ source = input.drop 0
1301
+ elsif input
1358
1302
  raise ::ArgumentError, %(unsupported input type: #{input.class})
1359
1303
  end
1360
1304
 
@@ -1364,7 +1308,7 @@ module Asciidoctor
1364
1308
  end
1365
1309
 
1366
1310
  options[:attributes] = attrs
1367
- doc = options[:parse] == false ? (Document.new lines, options) : (Document.new lines, options).parse
1311
+ doc = options[:parse] == false ? (Document.new source, options) : (Document.new source, options).parse
1368
1312
 
1369
1313
  timings.record :parse if timings
1370
1314
  doc
@@ -1372,9 +1316,9 @@ module Asciidoctor
1372
1316
  begin
1373
1317
  context = %(asciidoctor: FAILED: #{attrs['docfile'] || '<stdin>'}: Failed to load AsciiDoc document)
1374
1318
  if ex.respond_to? :exception
1375
- # The original message must be explicitely preserved when wrapping a Ruby exception
1319
+ # The original message must be explicitly preserved when wrapping a Ruby exception
1376
1320
  wrapped_ex = ex.exception %(#{context} - #{ex.message})
1377
- # JRuby automatically sets backtrace, but not MRI
1321
+ # JRuby automatically sets backtrace; MRI did not until 2.6
1378
1322
  wrapped_ex.set_backtrace ex.backtrace
1379
1323
  else
1380
1324
  # Likely a Java exception class
@@ -1396,7 +1340,7 @@ module Asciidoctor
1396
1340
  #
1397
1341
  # Returns the Asciidoctor::Document
1398
1342
  def load_file filename, options = {}
1399
- ::File.open(filename, 'rb') {|file| self.load file, options }
1343
+ ::File.open(filename, FILE_READ_MODE) {|file| self.load file, options }
1400
1344
  end
1401
1345
 
1402
1346
  # Public: Parse the AsciiDoc source input into an Asciidoctor::Document and
@@ -1460,7 +1404,7 @@ module Asciidoctor
1460
1404
 
1461
1405
  # NOTE outfile may be controlled by document attributes, so resolve outfile after loading
1462
1406
  if write_to_same_dir
1463
- input_path = ::File.expand_path input.path
1407
+ input_path = ::File.absolute_path input.path
1464
1408
  options[:to_dir] = (outdir = ::File.dirname input_path)
1465
1409
  elsif write_to_target
1466
1410
  if to_dir
@@ -1488,21 +1432,21 @@ module Asciidoctor
1488
1432
  # QUESTION should the jail be the working_dir or doc.base_dir???
1489
1433
  jail = doc.safe >= SafeMode::SAFE ? working_dir : nil
1490
1434
  if to_dir
1491
- outdir = doc.normalize_system_path(to_dir, working_dir, jail, :target_name => 'to_dir', :recover => false)
1435
+ outdir = doc.normalize_system_path(to_dir, working_dir, jail, target_name: 'to_dir', recover: false)
1492
1436
  if to_file
1493
- outfile = doc.normalize_system_path(to_file, outdir, nil, :target_name => 'to_dir', :recover => false)
1437
+ outfile = doc.normalize_system_path(to_file, outdir, nil, target_name: 'to_dir', recover: false)
1494
1438
  # reestablish outdir as the final target directory (in the case to_file had directory segments)
1495
1439
  outdir = ::File.dirname outfile
1496
1440
  else
1497
1441
  outfile = ::File.join outdir, %(#{doc.attributes['docname']}#{doc.outfilesuffix})
1498
1442
  end
1499
1443
  elsif to_file
1500
- outfile = doc.normalize_system_path(to_file, working_dir, jail, :target_name => 'to_dir', :recover => false)
1444
+ outfile = doc.normalize_system_path(to_file, working_dir, jail, target_name: 'to_dir', recover: false)
1501
1445
  # establish outdir as the final target directory (in the case to_file had directory segments)
1502
1446
  outdir = ::File.dirname outfile
1503
1447
  end
1504
1448
 
1505
- if ::File === input && outfile == (::File.expand_path input.path)
1449
+ if ::File === input && outfile == (::File.absolute_path input.path)
1506
1450
  raise ::IOError, %(input file and output file cannot be the same: #{outfile})
1507
1451
  end
1508
1452
 
@@ -1525,21 +1469,17 @@ module Asciidoctor
1525
1469
 
1526
1470
  # NOTE document cannot control this behavior if safe >= SafeMode::SERVER
1527
1471
  # NOTE skip if stylesdir is a URI
1528
- if !stream_output && doc.safe < SafeMode::SECURE && (doc.attr? 'linkcss') &&
1529
- (doc.attr? 'copycss') && (doc.attr? 'basebackend-html') &&
1530
- !((stylesdir = (doc.attr 'stylesdir')) && (Helpers.uriish? stylesdir))
1531
- copy_asciidoctor_stylesheet = false
1532
- copy_user_stylesheet = false
1533
- if (stylesheet = (doc.attr 'stylesheet'))
1472
+ if !stream_output && doc.safe < SafeMode::SECURE && (doc.attr? 'linkcss') && (doc.attr? 'copycss') &&
1473
+ (doc.basebackend? 'html') && !((stylesdir = (doc.attr 'stylesdir')) && (Helpers.uriish? stylesdir))
1474
+ if (stylesheet = doc.attr 'stylesheet')
1534
1475
  if DEFAULT_STYLESHEET_KEYS.include? stylesheet
1535
1476
  copy_asciidoctor_stylesheet = true
1536
1477
  elsif !(Helpers.uriish? stylesheet)
1537
1478
  copy_user_stylesheet = true
1538
1479
  end
1539
1480
  end
1540
- copy_coderay_stylesheet = (doc.attr? 'source-highlighter', 'coderay') && (doc.attr 'coderay-css', 'class') == 'class'
1541
- copy_pygments_stylesheet = (doc.attr? 'source-highlighter', 'pygments') && (doc.attr 'pygments-css', 'class') == 'class'
1542
- if copy_asciidoctor_stylesheet || copy_user_stylesheet || copy_coderay_stylesheet || copy_pygments_stylesheet
1481
+ copy_syntax_hl_stylesheet = (syntax_hl = doc.syntax_highlighter) && (syntax_hl.write_stylesheet? doc)
1482
+ if copy_asciidoctor_stylesheet || copy_user_stylesheet || copy_syntax_hl_stylesheet
1543
1483
  stylesoutdir = doc.normalize_system_path(stylesdir, outdir, doc.safe >= SafeMode::SAFE ? outdir : nil)
1544
1484
  if mkdirs
1545
1485
  Helpers.mkdir_p stylesoutdir
@@ -1551,7 +1491,7 @@ module Asciidoctor
1551
1491
  Stylesheets.instance.write_primary_stylesheet stylesoutdir
1552
1492
  # FIXME should Stylesheets also handle the user stylesheet?
1553
1493
  elsif copy_user_stylesheet
1554
- if (stylesheet_src = (doc.attr 'copycss')).empty?
1494
+ if (stylesheet_src = doc.attr 'copycss').empty?
1555
1495
  stylesheet_src = doc.normalize_system_path stylesheet
1556
1496
  else
1557
1497
  # NOTE in this case, copycss is a source location (but cannot be a URI)
@@ -1560,16 +1500,11 @@ module Asciidoctor
1560
1500
  stylesheet_dest = doc.normalize_system_path stylesheet, stylesoutdir, (doc.safe >= SafeMode::SAFE ? outdir : nil)
1561
1501
  # NOTE don't warn if src can't be read and dest already exists (see #2323)
1562
1502
  if stylesheet_src != stylesheet_dest && (stylesheet_data = doc.read_asset stylesheet_src,
1563
- :warn_on_failure => !(::File.file? stylesheet_dest), :label => 'stylesheet')
1564
- ::IO.write stylesheet_dest, stylesheet_data
1503
+ warn_on_failure: !(::File.file? stylesheet_dest), label: 'stylesheet')
1504
+ ::File.write stylesheet_dest, stylesheet_data, mode: FILE_WRITE_MODE
1565
1505
  end
1566
1506
  end
1567
-
1568
- if copy_coderay_stylesheet
1569
- Stylesheets.instance.write_coderay_stylesheet stylesoutdir
1570
- elsif copy_pygments_stylesheet
1571
- Stylesheets.instance.write_pygments_stylesheet stylesoutdir, (doc.attr 'pygments-style')
1572
- end
1507
+ syntax_hl.write_stylesheet doc, stylesoutdir if copy_syntax_hl_stylesheet
1573
1508
  end
1574
1509
  end
1575
1510
  doc
@@ -1592,7 +1527,7 @@ module Asciidoctor
1592
1527
  # Returns the Document object if the converted String is written to a
1593
1528
  # file, otherwise the converted String
1594
1529
  def convert_file filename, options = {}
1595
- ::File.open(filename, 'rb') {|file| self.convert file, options }
1530
+ ::File.open(filename, FILE_READ_MODE) {|file| self.convert file, options }
1596
1531
  end
1597
1532
 
1598
1533
  # Alias render_file to convert_file to maintain backwards compatibility
@@ -1610,7 +1545,7 @@ module Asciidoctor
1610
1545
  # Returns the resolved constant, if resolved, otherwise nothing.
1611
1546
  def const_missing name
1612
1547
  if name == :Extensions
1613
- require 'asciidoctor/extensions'
1548
+ require_relative 'asciidoctor/extensions'
1614
1549
  Extensions
1615
1550
  else
1616
1551
  super
@@ -1619,40 +1554,44 @@ module Asciidoctor
1619
1554
 
1620
1555
  end
1621
1556
 
1622
- if RUBY_ENGINE == 'opal'
1623
- require 'asciidoctor/timings'
1624
- require 'asciidoctor/version'
1625
- else
1626
- autoload :Timings, 'asciidoctor/timings'
1627
- autoload :VERSION, 'asciidoctor/version'
1557
+ unless RUBY_ENGINE == 'opal'
1558
+ autoload :SyntaxHighlighter, %(#{LIB_DIR}/asciidoctor/syntax_highlighter)
1559
+ autoload :Timings, %(#{LIB_DIR}/asciidoctor/timings)
1628
1560
  end
1629
1561
  end
1630
1562
 
1631
1563
  # core extensions
1632
- require 'asciidoctor/core_ext'
1564
+ require_relative 'asciidoctor/core_ext'
1633
1565
 
1634
- # modules
1635
- require 'asciidoctor/helpers'
1636
- require 'asciidoctor/substitutors'
1566
+ # modules and helpers
1567
+ require_relative 'asciidoctor/helpers'
1568
+ require_relative 'asciidoctor/logging'
1569
+ require_relative 'asciidoctor/substitutors'
1570
+ require_relative 'asciidoctor/version'
1637
1571
 
1638
1572
  # abstract classes
1639
- require 'asciidoctor/abstract_node'
1640
- require 'asciidoctor/abstract_block'
1573
+ require_relative 'asciidoctor/abstract_node'
1574
+ require_relative 'asciidoctor/abstract_block'
1641
1575
 
1642
1576
  # concrete classes
1643
- require 'asciidoctor/attribute_list'
1644
- require 'asciidoctor/block'
1645
- require 'asciidoctor/callouts'
1646
- require 'asciidoctor/converter'
1647
- require 'asciidoctor/document'
1648
- require 'asciidoctor/inline'
1649
- require 'asciidoctor/list'
1650
- require 'asciidoctor/parser'
1651
- require 'asciidoctor/path_resolver'
1652
- require 'asciidoctor/reader'
1653
- require 'asciidoctor/section'
1654
- require 'asciidoctor/stylesheets'
1655
- require 'asciidoctor/table'
1656
-
1657
- # this require is satisfied by the Asciidoctor.js build; it supplies compile and runtime overrides for Asciidoctor.js
1658
- require 'asciidoctor/js/postscript' if RUBY_ENGINE == 'opal'
1577
+ require_relative 'asciidoctor/attribute_list'
1578
+ require_relative 'asciidoctor/block'
1579
+ require_relative 'asciidoctor/callouts'
1580
+ require_relative 'asciidoctor/converter'
1581
+ require_relative 'asciidoctor/document'
1582
+ require_relative 'asciidoctor/inline'
1583
+ require_relative 'asciidoctor/list'
1584
+ require_relative 'asciidoctor/parser'
1585
+ require_relative 'asciidoctor/path_resolver'
1586
+ require_relative 'asciidoctor/reader'
1587
+ require_relative 'asciidoctor/section'
1588
+ require_relative 'asciidoctor/stylesheets'
1589
+ require_relative 'asciidoctor/table'
1590
+ require_relative 'asciidoctor/writer'
1591
+
1592
+ if RUBY_ENGINE == 'opal'
1593
+ require_relative 'asciidoctor/syntax_highlighter'
1594
+ require_relative 'asciidoctor/timings'
1595
+ # this require is satisfied by the Asciidoctor.js build; it supplies compile and runtime overrides for Asciidoctor.js
1596
+ require 'asciidoctor/js/postscript'
1597
+ end