asciidoctor 1.5.8 → 2.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +11 -0
  3. data/CHANGELOG.adoc +628 -45
  4. data/LICENSE +2 -1
  5. data/README-de.adoc +28 -38
  6. data/README-fr.adoc +30 -43
  7. data/README-jp.adoc +255 -201
  8. data/README-zh_CN.adoc +40 -44
  9. data/README.adoc +170 -143
  10. data/asciidoctor.gemspec +22 -34
  11. data/bin/asciidoctor +5 -4
  12. data/data/locale/attributes-ar.adoc +4 -3
  13. data/data/locale/attributes-be.adoc +23 -0
  14. data/data/locale/attributes-bg.adoc +4 -3
  15. data/data/locale/attributes-ca.adoc +6 -5
  16. data/data/locale/attributes-cs.adoc +4 -3
  17. data/data/locale/attributes-da.adoc +6 -5
  18. data/data/locale/attributes-de.adoc +6 -5
  19. data/data/locale/attributes-en.adoc +4 -4
  20. data/data/locale/attributes-es.adoc +6 -5
  21. data/data/locale/attributes-fa.adoc +4 -3
  22. data/data/locale/attributes-fi.adoc +4 -3
  23. data/data/locale/attributes-fr.adoc +8 -7
  24. data/data/locale/attributes-hu.adoc +4 -3
  25. data/data/locale/attributes-id.adoc +4 -3
  26. data/data/locale/attributes-it.adoc +6 -5
  27. data/data/locale/attributes-ja.adoc +4 -3
  28. data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
  29. data/data/locale/attributes-nb.adoc +4 -3
  30. data/data/locale/attributes-nl.adoc +6 -5
  31. data/data/locale/attributes-nn.adoc +4 -3
  32. data/data/locale/attributes-pl.adoc +8 -7
  33. data/data/locale/attributes-pt.adoc +6 -5
  34. data/data/locale/attributes-pt_BR.adoc +6 -5
  35. data/data/locale/attributes-ro.adoc +4 -3
  36. data/data/locale/attributes-ru.adoc +6 -5
  37. data/data/locale/attributes-sr.adoc +4 -4
  38. data/data/locale/attributes-sr_Latn.adoc +4 -4
  39. data/data/locale/attributes-sv.adoc +4 -4
  40. data/data/locale/attributes-th.adoc +23 -0
  41. data/data/locale/attributes-tr.adoc +4 -3
  42. data/data/locale/attributes-uk.adoc +6 -5
  43. data/data/locale/attributes-vi.adoc +23 -0
  44. data/data/locale/attributes-zh_CN.adoc +4 -3
  45. data/data/locale/attributes-zh_TW.adoc +4 -3
  46. data/data/reference/syntax.adoc +296 -0
  47. data/data/stylesheets/asciidoctor-default.css +120 -114
  48. data/data/stylesheets/coderay-asciidoctor.css +15 -17
  49. data/lib/asciidoctor/abstract_block.rb +146 -140
  50. data/lib/asciidoctor/abstract_node.rb +152 -170
  51. data/lib/asciidoctor/attribute_list.rb +77 -89
  52. data/lib/asciidoctor/block.rb +29 -28
  53. data/lib/asciidoctor/callouts.rb +4 -2
  54. data/lib/asciidoctor/cli/invoker.rb +20 -24
  55. data/lib/asciidoctor/cli/options.rb +107 -96
  56. data/lib/asciidoctor/cli.rb +3 -2
  57. data/lib/asciidoctor/convert.rb +199 -0
  58. data/lib/asciidoctor/converter/composite.rb +40 -48
  59. data/lib/asciidoctor/converter/docbook5.rb +627 -644
  60. data/lib/asciidoctor/converter/html5.rb +1053 -951
  61. data/lib/asciidoctor/converter/manpage.rb +581 -532
  62. data/lib/asciidoctor/converter/template.rb +232 -271
  63. data/lib/asciidoctor/converter.rb +370 -185
  64. data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
  65. data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
  66. data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
  67. data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
  68. data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
  69. data/lib/asciidoctor/core_ext.rb +8 -17
  70. data/lib/asciidoctor/document.rb +503 -461
  71. data/lib/asciidoctor/extensions.rb +127 -174
  72. data/lib/asciidoctor/helpers.rb +184 -107
  73. data/lib/asciidoctor/inline.rb +9 -12
  74. data/lib/asciidoctor/list.rb +11 -29
  75. data/lib/asciidoctor/load.rb +119 -0
  76. data/lib/asciidoctor/logging.rb +22 -17
  77. data/lib/asciidoctor/parser.rb +673 -719
  78. data/lib/asciidoctor/path_resolver.rb +48 -33
  79. data/lib/asciidoctor/reader.rb +383 -338
  80. data/lib/asciidoctor/rouge_ext.rb +39 -0
  81. data/lib/asciidoctor/rx.rb +723 -0
  82. data/lib/asciidoctor/section.rb +17 -16
  83. data/lib/asciidoctor/stylesheets.rb +19 -37
  84. data/lib/asciidoctor/substitutors.rb +926 -1022
  85. data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
  86. data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
  87. data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
  88. data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
  89. data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
  90. data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
  91. data/lib/asciidoctor/syntax_highlighter.rb +253 -0
  92. data/lib/asciidoctor/table.rb +152 -114
  93. data/lib/asciidoctor/timings.rb +7 -5
  94. data/lib/asciidoctor/version.rb +2 -1
  95. data/lib/asciidoctor/writer.rb +30 -0
  96. data/lib/asciidoctor.rb +266 -1340
  97. data/man/asciidoctor.1 +49 -47
  98. data/man/asciidoctor.adoc +54 -45
  99. metadata +50 -245
  100. data/CONTRIBUTING.adoc +0 -185
  101. data/Gemfile +0 -60
  102. data/Rakefile +0 -129
  103. data/bin/asciidoctor-safe +0 -15
  104. data/features/open_block.feature +0 -92
  105. data/features/pass_block.feature +0 -66
  106. data/features/step_definitions.rb +0 -49
  107. data/features/text_formatting.feature +0 -57
  108. data/features/xref.feature +0 -1039
  109. data/lib/asciidoctor/converter/base.rb +0 -59
  110. data/lib/asciidoctor/converter/docbook45.rb +0 -93
  111. data/lib/asciidoctor/converter/factory.rb +0 -226
  112. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
  113. data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
  114. data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
  115. data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
  116. data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
  117. data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
  118. data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
  119. data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
  120. data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
  121. data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
  122. data/test/api_test.rb +0 -1240
  123. data/test/attribute_list_test.rb +0 -242
  124. data/test/attributes_test.rb +0 -1623
  125. data/test/blocks_test.rb +0 -3870
  126. data/test/converter_test.rb +0 -470
  127. data/test/document_test.rb +0 -1853
  128. data/test/extensions_test.rb +0 -1560
  129. data/test/fixtures/asciidoc_index.txt +0 -521
  130. data/test/fixtures/basic-docinfo-footer.html +0 -6
  131. data/test/fixtures/basic-docinfo-footer.xml +0 -8
  132. data/test/fixtures/basic-docinfo.html +0 -1
  133. data/test/fixtures/basic-docinfo.xml +0 -4
  134. data/test/fixtures/basic.asciidoc +0 -5
  135. data/test/fixtures/chapter-a.adoc +0 -3
  136. data/test/fixtures/child-include.adoc +0 -5
  137. data/test/fixtures/circle.svg +0 -9
  138. data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
  139. data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
  140. data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
  141. data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
  142. data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
  143. data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
  144. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
  145. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
  146. data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
  147. data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
  148. data/test/fixtures/docinfo-footer.html +0 -1
  149. data/test/fixtures/docinfo-footer.xml +0 -9
  150. data/test/fixtures/docinfo.html +0 -1
  151. data/test/fixtures/docinfo.xml +0 -3
  152. data/test/fixtures/doctime-localtime.adoc +0 -2
  153. data/test/fixtures/dot.gif +0 -0
  154. data/test/fixtures/encoding.asciidoc +0 -13
  155. data/test/fixtures/file-with-missing-include.adoc +0 -1
  156. data/test/fixtures/grandchild-include.adoc +0 -3
  157. data/test/fixtures/hello-asciidoctor.pdf +0 -69
  158. data/test/fixtures/include-file.asciidoc +0 -24
  159. data/test/fixtures/include-file.jsx +0 -8
  160. data/test/fixtures/include-file.ml +0 -3
  161. data/test/fixtures/include-file.xml +0 -5
  162. data/test/fixtures/lists.adoc +0 -96
  163. data/test/fixtures/master.adoc +0 -5
  164. data/test/fixtures/mismatched-end-tag.adoc +0 -7
  165. data/test/fixtures/other-chapters.adoc +0 -11
  166. data/test/fixtures/outer-include.adoc +0 -5
  167. data/test/fixtures/parent-include-restricted.adoc +0 -5
  168. data/test/fixtures/parent-include.adoc +0 -5
  169. data/test/fixtures/sample.asciidoc +0 -30
  170. data/test/fixtures/section-a.adoc +0 -4
  171. data/test/fixtures/stylesheets/custom.css +0 -3
  172. data/test/fixtures/subdir/index.adoc +0 -3
  173. data/test/fixtures/subdir/inner-include.adoc +0 -3
  174. data/test/fixtures/subdir/middle-include.adoc +0 -5
  175. data/test/fixtures/subs-docinfo.html +0 -2
  176. data/test/fixtures/subs.adoc +0 -6
  177. data/test/fixtures/tagged-class-enclosed.rb +0 -25
  178. data/test/fixtures/tagged-class.rb +0 -23
  179. data/test/fixtures/tip.gif +0 -0
  180. data/test/fixtures/unclosed-tag.adoc +0 -3
  181. data/test/fixtures/unexpected-end-tag.adoc +0 -4
  182. data/test/invoker_test.rb +0 -745
  183. data/test/links_test.rb +0 -855
  184. data/test/lists_test.rb +0 -5151
  185. data/test/logger_test.rb +0 -211
  186. data/test/manpage_test.rb +0 -660
  187. data/test/options_test.rb +0 -262
  188. data/test/paragraphs_test.rb +0 -562
  189. data/test/parser_test.rb +0 -742
  190. data/test/paths_test.rb +0 -395
  191. data/test/preamble_test.rb +0 -173
  192. data/test/reader_test.rb +0 -2161
  193. data/test/sections_test.rb +0 -3575
  194. data/test/substitutions_test.rb +0 -2066
  195. data/test/tables_test.rb +0 -2036
  196. data/test/test_helper.rb +0 -447
  197. data/test/text_test.rb +0 -309
@@ -0,0 +1,723 @@
1
+ # frozen_string_literal: true
2
+ module Asciidoctor
3
+ # A collection of regular expression constants used by the parser. (For speed, these are not defined in the Rx module,
4
+ # but rather directly in the Asciidoctor module).
5
+ #
6
+ # NOTE The following pattern, which appears frequently, captures the contents between square brackets, ignoring
7
+ # escaped closing brackets (closing brackets prefixed with a backslash '\' character)
8
+ #
9
+ # Pattern: \[(|#{CC_ALL}*?[^\\])\]
10
+ # Matches: [enclosed text] and [enclosed [text\]], not [enclosed text \\] or [\\] (as these require a trailing space)
11
+ module Rx; end
12
+
13
+ ## Document header
14
+
15
+ # Matches the author info line immediately following the document title.
16
+ #
17
+ # Examples
18
+ #
19
+ # Doc Writer <doc@example.com>
20
+ # Mary_Sue Brontë
21
+ #
22
+ AuthorInfoLineRx = /^(#{CG_WORD}[#{CC_WORD}\-'.]*)(?: +(#{CG_WORD}[#{CC_WORD}\-'.]*))?(?: +(#{CG_WORD}[#{CC_WORD}\-'.]*))?(?: +<([^>]+)>)?$/
23
+
24
+ # Matches the delimiter that separates multiple authors.
25
+ #
26
+ # Examples
27
+ #
28
+ # Doc Writer; Junior Writer
29
+ #
30
+ AuthorDelimiterRx = /;(?: |$)/
31
+
32
+ # Matches the revision info line, which appears immediately following
33
+ # the author info line beneath the document title.
34
+ #
35
+ # Examples
36
+ #
37
+ # v1.0
38
+ # 2013-01-01
39
+ # v1.0, 2013-01-01: Ring in the new year release
40
+ # 1.0, Jan 01, 2013
41
+ #
42
+ RevisionInfoLineRx = /^(?:[^\d{]*(#{CC_ANY}*?),)? *(?!:)(#{CC_ANY}*?)(?: *(?!^),?: *(#{CC_ANY}*))?$/
43
+
44
+ # Matches the title and volnum in the manpage doctype.
45
+ #
46
+ # Examples
47
+ #
48
+ # = asciidoctor(1)
49
+ # = asciidoctor ( 1 )
50
+ #
51
+ ManpageTitleVolnumRx = /^(#{CC_ANY}+?) *\( *(#{CC_ANY}+?) *\)$/
52
+
53
+ # Matches the name and purpose in the manpage doctype.
54
+ #
55
+ # Examples
56
+ #
57
+ # asciidoctor - converts AsciiDoc source files to HTML, DocBook and other formats
58
+ #
59
+ ManpageNamePurposeRx = /^(#{CC_ANY}+?) +- +(#{CC_ANY}+)$/
60
+
61
+ ## Preprocessor directives
62
+
63
+ # Matches a conditional preprocessor directive (e.g., ifdef, ifndef, ifeval and endif).
64
+ #
65
+ # Examples
66
+ #
67
+ # ifdef::basebackend-html[]
68
+ # ifndef::theme[]
69
+ # ifeval::["{asciidoctor-version}" >= "0.1.0"]
70
+ # ifdef::asciidoctor[Asciidoctor!]
71
+ # endif::theme[]
72
+ # endif::basebackend-html[]
73
+ # endif::[]
74
+ #
75
+ ConditionalDirectiveRx = /^(\\)?(ifdef|ifndef|ifeval|endif)::(\S*?(?:([,+])\S*?)?)\[(#{CC_ANY}+)?\]$/
76
+
77
+ # Matches a restricted (read as safe) eval expression.
78
+ #
79
+ # Examples
80
+ #
81
+ # "{asciidoctor-version}" >= "0.1.0"
82
+ #
83
+ EvalExpressionRx = /^(#{CC_ANY}+?) *([=!><]=|[><]) *(#{CC_ANY}+)$/
84
+
85
+ # Matches an include preprocessor directive.
86
+ #
87
+ # Examples
88
+ #
89
+ # include::chapter1.ad[]
90
+ # include::example.txt[lines=1;2;5..10]
91
+ #
92
+ IncludeDirectiveRx = /^(\\)?include::([^\[][^\[]*)\[(#{CC_ANY}+)?\]$/
93
+
94
+ # Matches a trailing tag directive in an include file.
95
+ #
96
+ # Examples
97
+ #
98
+ # // tag::try-catch[]
99
+ # try {
100
+ # someMethod();
101
+ # catch (Exception e) {
102
+ # log(e);
103
+ # }
104
+ # // end::try-catch[]
105
+ # NOTE m flag is required for Asciidoctor.js
106
+ TagDirectiveRx = /\b(?:tag|(e)nd)::(\S+?)\[\](?=$|[ \r])/m
107
+
108
+ ## Attribute entries and references
109
+
110
+ # Matches a document attribute entry.
111
+ #
112
+ # Examples
113
+ #
114
+ # :foo: bar
115
+ # :First Name: Dan
116
+ # :sectnums!:
117
+ # :!toc:
118
+ # :long-entry: Attribute value lines ending in ' \' \
119
+ # are joined together as a single value, \
120
+ # collapsing the line breaks and indentation to \
121
+ # a single space.
122
+ #
123
+ AttributeEntryRx = /^:(!?#{CG_WORD}[^:]*):(?:[ \t]+(#{CC_ANY}*))?$/
124
+
125
+ # Matches invalid characters in an attribute name.
126
+ InvalidAttributeNameCharsRx = /[^#{CC_WORD}-]/
127
+
128
+ # Matches a pass inline macro that surrounds the value of an attribute
129
+ # entry once it has been parsed.
130
+ #
131
+ # Examples
132
+ #
133
+ # pass:[text]
134
+ # pass:a[{a} {b} {c}]
135
+ #
136
+ if RUBY_ENGINE == 'opal'
137
+ # NOTE In JavaScript, ^ and $ match the boundaries of the string when the m flag is not set
138
+ AttributeEntryPassMacroRx = /^pass:([a-z]+(?:,[a-z-]+)*)?\[(#{CC_ALL}*)\]$/
139
+ else
140
+ AttributeEntryPassMacroRx = /\Apass:([a-z]+(?:,[a-z-]+)*)?\[(.*)\]\Z/m
141
+ end
142
+
143
+ # Matches an inline attribute reference.
144
+ #
145
+ # Examples
146
+ #
147
+ # {foobar} or {app_name} or {product-version}
148
+ # {counter:sequence-name:1}
149
+ # {set:foo:bar}
150
+ # {set:name!}
151
+ #
152
+ AttributeReferenceRx = /(\\)?\{(#{CG_WORD}[#{CC_WORD}-]*|(set|counter2?):#{CC_ANY}+?)(\\)?\}/
153
+
154
+ ## Paragraphs and delimited blocks
155
+
156
+ # Matches an anchor (i.e., id + optional reference text) on a line above a block.
157
+ #
158
+ # Examples
159
+ #
160
+ # [[idname]]
161
+ # [[idname,Reference Text]]
162
+ #
163
+ BlockAnchorRx = /^\[\[(?:|([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+))?)\]\]$/
164
+
165
+ # Matches an attribute list above a block element.
166
+ #
167
+ # Examples
168
+ #
169
+ # # strictly positional
170
+ # [quote, Adam Smith, Wealth of Nations]
171
+ #
172
+ # # name/value pairs
173
+ # [NOTE, caption="Good to know"]
174
+ #
175
+ # # as attribute reference
176
+ # [{lead}]
177
+ #
178
+ BlockAttributeListRx = /^\[(|[#{CC_WORD}.#%{,"']#{CC_ANY}*)\]$/
179
+
180
+ # A combined pattern that matches either a block anchor or a block attribute list.
181
+ #
182
+ # TODO this one gets hit a lot, should be optimized as much as possible
183
+ BlockAttributeLineRx = /^\[(?:|[#{CC_WORD}.#%{,"']#{CC_ANY}*|\[(?:|[#{CC_ALPHA}_:][#{CC_WORD}\-:.]*(?:, *#{CC_ANY}+)?)\])\]$/
184
+
185
+ # Matches a title above a block.
186
+ #
187
+ # Examples
188
+ #
189
+ # .Title goes here
190
+ #
191
+ BlockTitleRx = /^\.(\.?[^ \t.]#{CC_ANY}*)$/
192
+
193
+ # Matches an admonition label at the start of a paragraph.
194
+ #
195
+ # Examples
196
+ #
197
+ # NOTE: Just a little note.
198
+ # TIP: Don't forget!
199
+ #
200
+ AdmonitionParagraphRx = /^(#{ADMONITION_STYLES.to_a.join '|'}):[ \t]+/
201
+
202
+ # Matches a literal paragraph, which is a line of text preceded by at least one space.
203
+ #
204
+ # Examples
205
+ #
206
+ # <SPACE>Foo
207
+ # <TAB>Foo
208
+ LiteralParagraphRx = /^([ \t]+#{CC_ANY}*)$/
209
+
210
+ # Matches a comment block.
211
+ #
212
+ # Examples
213
+ #
214
+ # ////
215
+ # This is a block comment.
216
+ # It can span one or more lines.
217
+ # ////
218
+ #CommentBlockRx = %r(^/{4,}$)
219
+
220
+ # Matches a comment line.
221
+ #
222
+ # Examples
223
+ #
224
+ # // note to author
225
+ #
226
+ #CommentLineRx = %r(^//(?=[^/]|$))
227
+
228
+ ## Section titles
229
+
230
+ # Matches an Atx (single-line) section title.
231
+ #
232
+ # Examples
233
+ #
234
+ # == Foo
235
+ # // ^ a level 1 (h2) section title
236
+ #
237
+ # == Foo ==
238
+ # // ^ also a level 1 (h2) section title
239
+ #
240
+ AtxSectionTitleRx = /^(=={0,5})[ \t]+(#{CC_ANY}+?)(?:[ \t]+\1)?$/
241
+
242
+ # Matches an extended Atx section title that includes support for the Markdown variant.
243
+ ExtAtxSectionTitleRx = /^(=={0,5}|#\#{0,5})[ \t]+(#{CC_ANY}+?)(?:[ \t]+\1)?$/
244
+
245
+ # Matches the title only (first line) of an Setext (two-line) section title.
246
+ # The title cannot begin with a dot and must have at least one alphanumeric character.
247
+ SetextSectionTitleRx = /^((?!\.)#{CC_ANY}*?#{CG_ALNUM}#{CC_ANY}*)$/
248
+
249
+ # Matches an anchor (i.e., id + optional reference text) inside a section title.
250
+ #
251
+ # Examples
252
+ #
253
+ # Section Title [[idname]]
254
+ # Section Title [[idname,Reference Text]]
255
+ #
256
+ InlineSectionAnchorRx = / (\\)?\[\[([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+))?\]\]$/
257
+
258
+ # Matches invalid ID characters in a section title.
259
+ #
260
+ # NOTE uppercase chars not included since expression is only run on a lowercase string
261
+ InvalidSectionIdCharsRx = /<[^>]+>|&(?:[a-z][a-z]+\d{0,2}|#\d\d\d{0,4}|#x[\da-f][\da-f][\da-f]{0,3});|[^ #{CC_WORD}\-.]+?/
262
+
263
+ # Matches an explicit section level style like sect1
264
+ #
265
+ SectionLevelStyleRx = /^sect\d$/
266
+
267
+ ## Lists
268
+
269
+ # Detects the start of any list item.
270
+ #
271
+ # NOTE we only have to check as far as the blank character because we know it means non-whitespace follows.
272
+ # IMPORTANT if this regexp does not agree with the regexp for each list type, the parser will hang.
273
+ AnyListRx = %r(^(?:[ \t]*(?:-|\*\**|\.\.*|\u2022|\d+\.|[a-zA-Z]\.|[IVXivx]+\))[ \t]|(?!//[^/])[ \t]*[^ \t]#{CC_ANY}*?(?::::{0,2}|;;)(?:$|[ \t])|<(?:\d+|\.)>[ \t]))
274
+
275
+ # Matches an unordered list item (one level for hyphens, up to 5 levels for asterisks).
276
+ #
277
+ # Examples
278
+ #
279
+ # * Foo
280
+ # - Foo
281
+ #
282
+ # NOTE we know trailing (.*) will match at least one character because we strip trailing spaces
283
+ UnorderedListRx = /^[ \t]*(-|\*\**|\u2022)[ \t]+(#{CC_ANY}*)$/
284
+
285
+ # Matches an ordered list item (explicit numbering or up to 5 consecutive dots).
286
+ #
287
+ # Examples
288
+ #
289
+ # . Foo
290
+ # .. Foo
291
+ # 1. Foo (arabic, default)
292
+ # a. Foo (loweralpha)
293
+ # A. Foo (upperalpha)
294
+ # i. Foo (lowerroman)
295
+ # I. Foo (upperroman)
296
+ #
297
+ # NOTE leading space match is not always necessary, but is used for list reader
298
+ # NOTE we know trailing (.*) will match at least one character because we strip trailing spaces
299
+ OrderedListRx = /^[ \t]*(\.\.*|\d+\.|[a-zA-Z]\.|[IVXivx]+\))[ \t]+(#{CC_ANY}*)$/
300
+
301
+ # Matches the ordinals for each type of ordered list.
302
+ OrderedListMarkerRxMap = {
303
+ arabic: /\d+\./,
304
+ loweralpha: /[a-z]\./,
305
+ lowerroman: /[ivx]+\)/,
306
+ upperalpha: /[A-Z]\./,
307
+ upperroman: /[IVX]+\)/,
308
+ #lowergreek: /[a-z]\]/,
309
+ }
310
+
311
+ # Matches a description list entry.
312
+ #
313
+ # Examples
314
+ #
315
+ # foo::
316
+ # bar:::
317
+ # baz::::
318
+ # blah;;
319
+ #
320
+ # # the term may be followed by a description on the same line...
321
+ #
322
+ # foo:: The metasyntactic variable that commonly accompanies 'bar' (see also, <<bar>>).
323
+ #
324
+ # # ...or on a separate line, which may optionally be indented
325
+ #
326
+ # foo::
327
+ # The metasyntactic variable that commonly accompanies 'bar' (see also, <<bar>>).
328
+ #
329
+ # # attribute references may be used in both the term and the description
330
+ #
331
+ # {foo-term}:: {foo-desc}
332
+ #
333
+ # NOTE we know trailing (.*) will match at least one character because we strip trailing spaces
334
+ # NOTE must skip line comment when looking for next list item inside list
335
+ DescriptionListRx = %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?)(:::{0,2}|;;)(?:$|[ \t]+(#{CC_ANY}*)$))
336
+
337
+ # Matches a sibling description list item (excluding the delimiter specified by the key).
338
+ # NOTE must skip line comment when looking for sibling list item
339
+ DescriptionListSiblingRx = {
340
+ '::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(::)(?:$|[ \t]+(#{CC_ANY}*)$)),
341
+ ':::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(:::)(?:$|[ \t]+(#{CC_ANY}*)$)),
342
+ '::::' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?[^:]|[^ \t:])(::::)(?:$|[ \t]+(#{CC_ANY}*)$)),
343
+ ';;' => %r(^(?!//[^/])[ \t]*([^ \t]#{CC_ANY}*?)(;;)(?:$|[ \t]+(#{CC_ANY}*)$))
344
+ }
345
+
346
+ # Matches a callout list item.
347
+ #
348
+ # Examples
349
+ #
350
+ # <1> Explanation
351
+ #
352
+ # or
353
+ #
354
+ # <.> Explanation with automatic number
355
+ #
356
+ # NOTE we know trailing (.*) will match at least one character because we strip trailing spaces
357
+ CalloutListRx = /^<(\d+|\.)>[ \t]+(#{CC_ANY}*)$/
358
+
359
+ # Matches a callout reference inside literal text.
360
+ #
361
+ # Examples
362
+ # <1> (optionally prefixed by //, #, -- or ;; line comment chars)
363
+ # <1> <2> (multiple callouts on one line)
364
+ # <!--1--> (for XML-based languages)
365
+ # <.> (auto-numbered)
366
+ #
367
+ # NOTE extract regexps are applied line-by-line, so we can use $ as end-of-line char
368
+ CalloutExtractRx = %r(((?://|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\3>(?=(?: ?\\?<!?\3(?:\d+|\.)\3>)*$))
369
+ CalloutExtractRxt = '(\\\\)?<()(\\d+|\\.)>(?=(?: ?\\\\?<(?:\\d+|\\.)>)*$)'
370
+ CalloutExtractRxMap = ::Hash.new {|h, k| h[k] = /(#{k.empty? ? '' : "#{::Regexp.escape k} ?"})?#{CalloutExtractRxt}/ }
371
+ # NOTE special characters have not been replaced when scanning
372
+ CalloutScanRx = /\\?<!?(|--)(\d+|\.)\1>(?=(?: ?\\?<!?\1(?:\d+|\.)\1>)*#{CC_EOL})/
373
+ # NOTE special characters have already been replaced when converting to an SGML format
374
+ CalloutSourceRx = %r(((?://|#|--|;;) ?)?(\\)?&lt;!?(|--)(\d+|\.)\3&gt;(?=(?: ?\\?&lt;!?\3(?:\d+|\.)\3&gt;)*#{CC_EOL}))
375
+ CalloutSourceRxt = "(\\\\)?&lt;()(\\d+|\\.)&gt;(?=(?: ?\\\\?&lt;(?:\\d+|\\.)&gt;)*#{CC_EOL})"
376
+ CalloutSourceRxMap = ::Hash.new {|h, k| h[k] = /(#{k.empty? ? '' : "#{::Regexp.escape k} ?"})?#{CalloutSourceRxt}/ }
377
+
378
+ # A Hash of regexps for lists used for dynamic access.
379
+ ListRxMap = { ulist: UnorderedListRx, olist: OrderedListRx, dlist: DescriptionListRx, colist: CalloutListRx }
380
+
381
+ ## Tables
382
+
383
+ # Parses the column spec (i.e., colspec) for a table.
384
+ #
385
+ # Examples
386
+ #
387
+ # 1*h,2*,^3e
388
+ #
389
+ ColumnSpecRx = /^(?:(\d+)\*)?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?(\d+%?|~)?([a-z])?$/
390
+
391
+ # Parses the start and end of a cell spec (i.e., cellspec) for a table.
392
+ #
393
+ # Examples
394
+ #
395
+ # 2.3+<.>m
396
+ #
397
+ # FIXME use step-wise scan (or treetop) rather than this mega-regexp
398
+ CellSpecStartRx = /^[ \t]*(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/
399
+ CellSpecEndRx = /[ \t]+(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/
400
+
401
+ # Block macros
402
+
403
+ # Matches the custom block macro pattern.
404
+ #
405
+ # Examples
406
+ #
407
+ # gist::123456[]
408
+ #
409
+ #--
410
+ # NOTE we've relaxed the match for target to accommodate the short format (e.g., name::[attrlist])
411
+ CustomBlockMacroRx = /^(#{CG_WORD}[#{CC_WORD}-]*)::(|\S|\S#{CC_ANY}*?\S)\[(#{CC_ANY}+)?\]$/
412
+
413
+ # Matches an image, video or audio block macro.
414
+ #
415
+ # Examples
416
+ #
417
+ # image::filename.png[Caption]
418
+ # video::http://youtube.com/12345[Cats vs Dogs]
419
+ #
420
+ BlockMediaMacroRx = /^(image|video|audio)::(\S|\S#{CC_ANY}*?\S)\[(#{CC_ANY}+)?\]$/
421
+
422
+ # Matches the TOC block macro.
423
+ #
424
+ # Examples
425
+ #
426
+ # toc::[]
427
+ # toc::[levels=2]
428
+ #
429
+ BlockTocMacroRx = /^toc::\[(#{CC_ANY}+)?\]$/
430
+
431
+ ## Inline macros
432
+
433
+ # Matches an anchor (i.e., id + optional reference text) in the flow of text.
434
+ #
435
+ # Examples
436
+ #
437
+ # [[idname]]
438
+ # [[idname,Reference Text]]
439
+ # anchor:idname[]
440
+ # anchor:idname[Reference Text]
441
+ #
442
+ InlineAnchorRx = /(\\)?(?:\[\[([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+?))?\]\]|anchor:([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)\[(?:\]|(#{CC_ANY}*?[^\\])\]))/
443
+
444
+ # Scans for a non-escaped anchor (i.e., id + optional reference text) in the flow of text.
445
+ InlineAnchorScanRx = /(?:^|[^\\\[])\[\[([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+?))?\]\]|(?:^|[^\\])anchor:([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)\[(?:\]|(#{CC_ANY}*?[^\\])\])/
446
+
447
+ # Scans for a leading, non-escaped anchor (i.e., id + optional reference text).
448
+ LeadingInlineAnchorRx = /^\[\[([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+?))?\]\]/
449
+
450
+ # Matches a bibliography anchor at the start of the list item text (in a bibliography list).
451
+ #
452
+ # Examples
453
+ #
454
+ # [[[Fowler_1997]]] Fowler M. ...
455
+ #
456
+ InlineBiblioAnchorRx = /^\[\[\[([#{CC_ALPHA}_:][#{CC_WORD}\-:.]*)(?:, *(#{CC_ANY}+?))?\]\]\]/
457
+
458
+ # Matches an inline e-mail address.
459
+ #
460
+ # doc.writer@example.com
461
+ #
462
+ InlineEmailRx = %r(([\\>:/])?#{CG_WORD}(?:&amp;|[#{CC_WORD}\-.%+])*@#{CG_ALNUM}[#{CC_ALNUM}_\-.]*\.[a-zA-Z]{2,5}\b)
463
+
464
+ # Matches an inline footnote macro, which is allowed to span multiple lines.
465
+ #
466
+ # Examples
467
+ # footnote:[text] (not referenceable)
468
+ # footnote:id[text] (referenceable)
469
+ # footnote:id[] (reference)
470
+ # footnoteref:[id,text] (legacy)
471
+ # footnoteref:[id] (legacy)
472
+ #
473
+ InlineFootnoteMacroRx = %r(\\?footnote(?:(ref):|:([#{CC_WORD}-]+)?)\[(?:|(#{CC_ALL}*?[^\\]))\](?!</a>))m
474
+
475
+ # Matches an image or icon inline macro.
476
+ #
477
+ # Examples
478
+ #
479
+ # image:filename.png[Alt Text]
480
+ # image:http://example.com/images/filename.png[Alt Text]
481
+ # image:filename.png[More [Alt\] Text] (alt text becomes "More [Alt] Text")
482
+ # icon:github[large]
483
+ #
484
+ # NOTE be as non-greedy as possible by not allowing newline or left square bracket in target
485
+ InlineImageMacroRx = /\\?i(?:mage|con):([^:\s\[](?:[^\n\[]*[^\s\[])?)\[(|#{CC_ALL}*?[^\\])\]/m
486
+
487
+ # Matches an indexterm inline macro, which may span multiple lines.
488
+ #
489
+ # Examples
490
+ #
491
+ # indexterm:[Tigers,Big cats]
492
+ # (((Tigers,Big cats)))
493
+ # indexterm2:[Tigers]
494
+ # ((Tigers))
495
+ #
496
+ InlineIndextermMacroRx = /\\?(?:(indexterm2?):\[(#{CC_ALL}*?[^\\])\]|\(\((#{CC_ALL}+?)\)\)(?!\)))/m
497
+
498
+ # Matches either the kbd or btn inline macro.
499
+ #
500
+ # Examples
501
+ #
502
+ # kbd:[F3]
503
+ # kbd:[Ctrl+Shift+T]
504
+ # kbd:[Ctrl+\]]
505
+ # kbd:[Ctrl,T]
506
+ # btn:[Save]
507
+ #
508
+ InlineKbdBtnMacroRx = /(\\)?(kbd|btn):\[(#{CC_ALL}*?[^\\])\]/m
509
+
510
+ # Matches an implicit link and some of the link inline macro.
511
+ #
512
+ # Examples
513
+ #
514
+ # https://github.com
515
+ # https://github.com[GitHub]
516
+ # <https://github.com>
517
+ # link:https://github.com[]
518
+ # "https://github.com[]"
519
+ #
520
+ # FIXME revisit! the main issue is we need different rules for implicit vs explicit
521
+ InlineLinkRx = %r((^|link:|#{CG_BLANK}|&lt;|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://[^\s\[\]<]*([^\s.,\[\]<]))(?:\[(|#{CC_ALL}*?[^\\])\])?)m
522
+
523
+ # Match a link or e-mail inline macro.
524
+ #
525
+ # Examples
526
+ #
527
+ # link:path[label]
528
+ # mailto:doc.writer@example.com[]
529
+ #
530
+ # NOTE be as non-greedy as possible by not allowing space or left square bracket in target
531
+ InlineLinkMacroRx = /\\?(?:link|(mailto)):(|[^:\s\[][^\s\[]*)\[(|#{CC_ALL}*?[^\\])\]/m
532
+
533
+ # Matches the name of a macro.
534
+ #
535
+ MacroNameRx = /^#{CG_WORD}[#{CC_WORD}-]*$/
536
+
537
+ # Matches a stem (and alternatives, asciimath and latexmath) inline macro, which may span multiple lines.
538
+ #
539
+ # Examples
540
+ #
541
+ # stem:[x != 0]
542
+ # asciimath:[x != 0]
543
+ # latexmath:[\sqrt{4} = 2]
544
+ #
545
+ InlineStemMacroRx = /\\?(stem|(?:latex|ascii)math):([a-z]+(?:,[a-z-]+)*)?\[(#{CC_ALL}*?[^\\])\]/m
546
+
547
+ # Matches a menu inline macro.
548
+ #
549
+ # Examples
550
+ #
551
+ # menu:File[Save As...]
552
+ # menu:Edit[]
553
+ # menu:View[Page Style > No Style]
554
+ # menu:View[Page Style, No Style]
555
+ #
556
+ InlineMenuMacroRx = /\\?menu:(#{CG_WORD}|[#{CC_WORD}&][^\n\[]*[^\s\[])\[ *(?:|(#{CC_ALL}*?[^\\]))\]/m
557
+
558
+ # Matches an implicit menu inline macro.
559
+ #
560
+ # Examples
561
+ #
562
+ # "File > New..."
563
+ #
564
+ InlineMenuRx = /\\?"([#{CC_WORD}&][^"]*?[ \n]+&gt;[ \n]+[^"]*)"/
565
+
566
+ # Matches an inline passthrough, which may span multiple lines.
567
+ #
568
+ # Examples
569
+ #
570
+ # +text+
571
+ # `text` (compat)
572
+ #
573
+ # NOTE we always capture the attributes so we know when to use compatible (i.e., legacy) behavior
574
+ InlinePassRx = {
575
+ false => ['+', '`', /(^|[^#{CC_WORD};:])(?:\[([^\]]+)\])?(\\?(\+|`)(\S|\S#{CC_ALL}*?\S)\4)(?!#{CG_WORD})/m],
576
+ true => ['`', nil, /(^|[^`#{CC_WORD}])(?:\[([^\]]+)\])?(\\?(`)([^`\s]|[^`\s]#{CC_ALL}*?\S)\4)(?![`#{CC_WORD}])/m]
577
+ }
578
+
579
+ # Matches an inline plus passthrough spanning multiple lines, but only when it occurs directly
580
+ # inside constrained monospaced formatting in non-compat mode.
581
+ #
582
+ # Examples
583
+ #
584
+ # +text+
585
+ #
586
+ SinglePlusInlinePassRx = /^(\\)?\+(\S|\S#{CC_ALL}*?\S)\+$/m
587
+
588
+ # Matches several variants of the passthrough inline macro, which may span multiple lines.
589
+ #
590
+ # Examples
591
+ #
592
+ # +++text+++
593
+ # $$text$$
594
+ # pass:quotes[text]
595
+ #
596
+ # NOTE we have to support an empty pass:[] for compatibility with AsciiDoc.py
597
+ InlinePassMacroRx = /(?:(?:(\\?)\[([^\]]+)\])?(\\{0,2})(\+\+\+?|\$\$)(#{CC_ALL}*?)\4|(\\?)pass:([a-z]+(?:,[a-z-]+)*)?\[(|#{CC_ALL}*?[^\\])\])/m
598
+
599
+ # Matches an xref (i.e., cross-reference) inline macro, which may span multiple lines.
600
+ #
601
+ # Examples
602
+ #
603
+ # <<id,reftext>>
604
+ # xref:id[reftext]
605
+ #
606
+ # NOTE special characters have already been escaped, hence the entity references
607
+ # NOTE { is included in start characters to support target that begins with attribute reference in title content
608
+ InlineXrefMacroRx = %r(\\?(?:&lt;&lt;([#{CC_WORD}#/.:{]#{CC_ALL}*?)&gt;&gt;|xref:([#{CC_WORD}#/.:{]#{CC_ALL}*?)\[(?:\]|(#{CC_ALL}*?[^\\])\])))m
609
+
610
+ ## Layout
611
+
612
+ # Matches a trailing + preceded by at least one space character,
613
+ # which forces a hard line break (<br> tag in HTML output).
614
+ #
615
+ # NOTE AsciiDoc.py allows + to be preceded by TAB; Asciidoctor does not
616
+ #
617
+ # Examples
618
+ #
619
+ # Humpty Dumpty sat on a wall, +
620
+ # Humpty Dumpty had a great fall.
621
+ #
622
+ if RUBY_ENGINE == 'opal'
623
+ # NOTE In JavaScript, ^ and $ only match the start and end of line if the multiline flag is present
624
+ HardLineBreakRx = /^(#{CC_ANY}*) \+$/m
625
+ else
626
+ # NOTE In Ruby, ^ and $ always match start and end of line
627
+ HardLineBreakRx = /^(.*) \+$/
628
+ end
629
+
630
+ # Matches a Markdown horizontal rule.
631
+ #
632
+ # Examples
633
+ #
634
+ # --- or - - -
635
+ # *** or * * *
636
+ # ___ or _ _ _
637
+ #
638
+ MarkdownThematicBreakRx = /^ {0,3}([-*_])( *)\1\2\1$/
639
+
640
+ # Matches an AsciiDoc or Markdown horizontal rule or AsciiDoc page break.
641
+ #
642
+ # Examples
643
+ #
644
+ # ''' (horizontal rule)
645
+ # <<< (page break)
646
+ # --- or - - - (horizontal rule, Markdown)
647
+ # *** or * * * (horizontal rule, Markdown)
648
+ # ___ or _ _ _ (horizontal rule, Markdown)
649
+ #
650
+ ExtLayoutBreakRx = /^(?:'{3,}|<{3,}|([-*_])( *)\1\2\1)$/
651
+
652
+ ## General
653
+
654
+ # Matches consecutive blank lines.
655
+ #
656
+ # Examples
657
+ #
658
+ # one
659
+ #
660
+ # two
661
+ #
662
+ BlankLineRx = /\n{2,}/
663
+
664
+ # Matches a comma or semi-colon delimiter.
665
+ #
666
+ # Examples
667
+ #
668
+ # one,two
669
+ # three;four
670
+ #
671
+ #DataDelimiterRx = /[,;]/
672
+
673
+ # Matches whitespace (space, tab, newline) escaped by a backslash.
674
+ #
675
+ # Examples
676
+ #
677
+ # three\ blind\ mice
678
+ #
679
+ EscapedSpaceRx = /\\([ \t\n])/
680
+
681
+ # Detects if text is a possible candidate for the replacements substitution.
682
+ #
683
+ ReplaceableTextRx = /[&']|--|\.\.\.|\([CRT]M?\)/
684
+
685
+ # Matches a whitespace delimiter, a sequence of spaces, tabs, and/or newlines.
686
+ # Matches the parsing rules of %w strings in Ruby.
687
+ #
688
+ # Examples
689
+ #
690
+ # one two three four
691
+ # five six
692
+ #
693
+ # TODO change to /(?<!\\)[ \t\n]+/ once lookbehind assertions are implemented in all modern browsers
694
+ SpaceDelimiterRx = /([^\\])[ \t\n]+/
695
+
696
+ # Matches a + or - modifier in a subs list
697
+ #
698
+ SubModifierSniffRx = /[+-]/
699
+
700
+ # Matches one or more consecutive digits at the end of a line.
701
+ #
702
+ # Examples
703
+ #
704
+ # docbook5
705
+ # html5
706
+ #
707
+ TrailingDigitsRx = /\d+$/
708
+
709
+ # Detects strings that resemble URIs.
710
+ #
711
+ # Examples
712
+ # http://domain
713
+ # https://domain
714
+ # file:///path
715
+ # data:info
716
+ #
717
+ # not c:/sample.adoc or c:\sample.adoc
718
+ #
719
+ UriSniffRx = %r(^#{CG_ALPHA}[#{CC_ALNUM}.+-]+:/{0,2})
720
+
721
+ # Detects XML tags
722
+ XmlSanitizeRx = /<[^>]+>/
723
+ end