1/* global Asciidoctor, ASCIIDOCTOR_JS_VERSION */
2import { createRequire } from 'module'
3import { fileURLToPath } from 'url'
4import path from 'path'
5import fs from 'fs'
6
7import Opal from '@asciidoctor/opal-runtime'
8import unxhr from 'unxhr'
9
10const __path__ = path
11const __XMLHttpRequest__ = unxhr.XMLHttpRequest
12const __asciidoctorDistDir__ = path.dirname(fileURLToPath(import.meta.url))
13const __require__ = createRequire(import.meta.url)
14
15export default function (moduleConfig) {
16Opal.modules["asciidoctor/js/opal_ext/electron/io"] = function(Opal) {/* Generated by Opal 1.7.3 */
17  var $gvars = Opal.gvars, $send = Opal.send, $a, nil = Opal.nil;
18  if ($gvars.stdout == null) $gvars.stdout = nil;
19  if ($gvars.stderr == null) $gvars.stderr = nil;
20
21  Opal.add_stubs('write_proc=');
22
23  $gvars.stdout['$write_proc='](function(s){console.log(s)});
24  return ($a = [function(s){console.error(s)}], $send($gvars.stderr, 'write_proc=', $a), $a[$a.length - 1]);
25};
26
27Opal.modules["asciidoctor/js/opal_ext/node"] = function(Opal) {/* Generated by Opal 1.7.3 */
28  var $const_set = Opal.const_set, $eqeq = Opal.eqeq, self = Opal.top, $nesting = [], $$ = Opal.$r($nesting), nil = Opal.nil;
29
30  Opal.add_stubs('==,require');
31
32
33  var isElectron = typeof navigator === 'object' && typeof navigator.userAgent === 'string' && typeof navigator.userAgent.indexOf('Electron') !== -1,
34      platform,
35      engine,
36      framework,
37      ioModule;
38
39  if (typeof moduleConfig === 'object' && typeof moduleConfig.runtime === 'object') {
40    var runtime = moduleConfig.runtime;
41    platform = runtime.platform;
42    engine = runtime.engine;
43    framework = runtime.framework;
44    ioModule = runtime.ioModule;
45  }
46
47  ioModule = ioModule || 'node';
48  platform = platform || 'node';
49  engine = engine || 'v8';
50  if (isElectron) {
51    framework = framework || 'electron';
52  } else {
53    framework = framework || '';
54  }
55;
56  $const_set($nesting[0], 'JAVASCRIPT_IO_MODULE', ioModule);
57  $const_set($nesting[0], 'JAVASCRIPT_PLATFORM', platform);
58  $const_set($nesting[0], 'JAVASCRIPT_ENGINE', engine);
59  $const_set($nesting[0], 'JAVASCRIPT_FRAMEWORK', framework);
60  if ($eqeq($$('JAVASCRIPT_FRAMEWORK'), "electron")) {
61    self.$require("asciidoctor/js/opal_ext/electron/io")
62  };
63
64// Load Opal modules
65Opal.load("pathname");
66Opal.load("nodejs");
67;
68};
69
70Opal.modules["asciidoctor/js/asciidoctor_ext/node/abstract_node"] = function(Opal) {/* Generated by Opal 1.7.3 */
71  var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $nesting = [], nil = Opal.nil;
72
73  return (function($base, $parent_nesting) {
74    var self = $module($base, 'Asciidoctor');
75
76    var $nesting = [self].concat($parent_nesting);
77
78    return (function($base, $super) {
79      var self = $klass($base, $super, 'AbstractNode');
80
81
82      return $def(self, '$generate_data_uri_from_uri', function $$generate_data_uri_from_uri(image_uri, cache_uri) {
83        var self = this;
84
85
86        if (cache_uri == null) cache_uri = false;
87
88      var contentType = ''
89      var b64encoded = ''
90      var status = -1
91
92      try {
93        var xhr = new __XMLHttpRequest__();
94        xhr.open('GET', image_uri, false);
95        xhr.responseType = 'arraybuffer';
96        xhr.addEventListener('load', function() {
97          status = this.status
98          if (status === 200) {
99            var arrayBuffer = this.response;
100            b64encoded = Buffer.from(arrayBuffer).toString('base64');
101            contentType = this.getResponseHeader('content-type')
102          }
103        })
104        xhr.send(null)
105      }
106      catch (e) {
107        // something bad happened!
108        status = 0
109      }
110      if (status === 404 || (status === 0 && !b64encoded)) {
111        self.$logger().$warn('could not retrieve image data from URI: ' + image_uri)
112        return image_uri
113      }
114      return 'data:' + contentType + ';base64,' + b64encoded
115    ;
116      }, -2)
117    })($nesting[0], null)
118  })($nesting[0], $nesting)
119};
120
121Opal.modules["asciidoctor/js/asciidoctor_ext/node/open_uri"] = function(Opal) {/* Generated by Opal 1.7.3 */
122  var $module = Opal.module, $slice = Opal.slice, $defs = Opal.defs, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
123
124  Opal.add_stubs('require,new,<<,rewind');
125
126  self.$require("stringio");
127  return (function($base, $parent_nesting) {
128    var self = $module($base, 'OpenURI');
129
130    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
131
132    return $defs($$('OpenURI'), '$open_uri', function $$open_uri(uri, $a) {
133      var $post_args, rest, $yield = $$open_uri.$$p || nil, io = nil, data = nil;
134
135      $$open_uri.$$p = null;
136
137      $post_args = $slice(arguments, 1);
138      rest = $post_args;
139      io = $$$('StringIO').$new();
140      data = "";
141
142      var contentType = ''
143      var status = -1
144
145      try {
146        var xhr = new __XMLHttpRequest__()
147        xhr.open('GET', uri, false)
148        xhr.responseType = 'text'
149        xhr.addEventListener('load', function() {
150          status = this.status
151          if (status === 200) {
152            data = this.responseText
153            contentType = this.getResponseHeader('content-type')
154          }
155        })
156        xhr.send(null)
157      }
158      catch (e) {
159        // something bad happened!
160        status = 0
161      }
162      if (status === 404 || (status === 0 && !data)) {
163        throw $$('IOError').$new('No such file or directory: ' + uri)
164      }
165    ;
166      io['$<<'](data);
167      io.$rewind();
168      if (($yield !== nil)) {
169        return Opal.yield1($yield, io);
170      } else {
171        return io
172      };
173    }, -2)
174  })($nesting[0], $nesting);
175};
176
177Opal.modules["asciidoctor/js/asciidoctor_ext/node/stylesheet"] = function(Opal) {/* Generated by Opal 1.7.3 */
178  var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
179
180  Opal.add_stubs('rstrip,read,join');
181  return (function($base, $parent_nesting) {
182    var self = $module($base, 'Asciidoctor');
183
184    var $nesting = [self].concat($parent_nesting);
185
186    return (function($base, $super) {
187      var self = $klass($base, $super, 'Stylesheets');
188
189      var $proto = self.$$prototype;
190
191      $proto.primary_stylesheet_data = nil;
192      return $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() {
193        var self = this, stylesheets_dir = nil, $ret_or_1 = nil;
194
195
196        if ($truthy(__path__.basename(__asciidoctorDistDir__) === 'node' && __path__.basename(__path__.dirname(__asciidoctorDistDir__)) === 'dist')) {
197          stylesheets_dir = __path__.join(__path__.dirname(__asciidoctorDistDir__), 'css')
198        } else {
199          stylesheets_dir = __path__.join(__asciidoctorDistDir__, 'css')
200        };
201        return (self.primary_stylesheet_data = ($truthy(($ret_or_1 = self.primary_stylesheet_data)) ? ($ret_or_1) : ($$$('IO').$read($$$('File').$join(stylesheets_dir, "asciidoctor.css")).$rstrip())));
202      })
203    })($nesting[0], null)
204  })($nesting[0], $nesting)
205};
206
207Opal.modules["asciidoctor/js/asciidoctor_ext/node/template"] = function(Opal) {/* Generated by Opal 1.7.3 */
208  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $return_ivar = Opal.return_ivar, $defs = Opal.defs, $truthy = Opal.truthy, $eqeqeq = Opal.eqeqeq, $def = Opal.def, $eqeq = Opal.eqeq, $send = Opal.send, $rb_lt = Opal.rb_lt, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
209
210  Opal.add_stubs('[],clear,===,caches,class,scan,node_name,raise,ctx,==,strip,rstrip,key?,merge,[]=,file,private,new,each,directory?,system_path,scan_dir,update,select,glob,file?,basename,<,size,split,start_with?,slice,length,to_sym,node_require');
211  return (function($base, $parent_nesting) {
212    var self = $module($base, 'Asciidoctor');
213
214    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
215
216    return (function($base, $super, $parent_nesting) {
217      var self = $klass($base, $super, 'TemplateConverter');
218
219      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
220
221      $proto.templates = $proto.caches = $proto.backend = $proto.engine = $proto.template_dirs = nil;
222
223      self.caches = $hash2(["scans", "templates"], {"scans": $hash2([], {}), "templates": $hash2([], {})});
224      $defs(self, '$caches', $return_ivar("caches"));
225      $defs(self, '$clear_caches', function $$clear_caches() {
226        var self = this;
227        if (self.caches == null) self.caches = nil;
228
229
230        if ($truthy(self.caches['$[]']("scans"))) {
231          self.caches['$[]']("scans").$clear()
232        };
233        if ($truthy(self.caches['$[]']("templates"))) {
234          return self.caches['$[]']("templates").$clear()
235        } else {
236          return nil
237        };
238      });
239
240      $def(self, '$initialize', function $$initialize(backend, template_dirs, opts) {
241        var self = this, $ret_or_1 = nil;
242
243
244        if (opts == null) opts = $hash2([], {});
245        self.backend = backend;
246        self.templates = $hash2([], {});
247        self.template_dirs = template_dirs;
248        self.engine = opts['$[]']("template_engine");
249        self.engine_options = ($truthy(($ret_or_1 = opts['$[]']("template_engine_options"))) ? ($ret_or_1) : ($hash2([], {})));
250        if ($eqeqeq(true, ($ret_or_1 = opts['$[]']("template_cache")))) {
251          self.caches = self.$class().$caches()
252        } else if ($eqeqeq($$$('Hash'), $ret_or_1)) {
253          self.caches = opts['$[]']("template_cache")
254        } else {
255          self.caches = $hash2([], {})
256        };
257        return self.$scan();
258      }, -3);
259
260      $def(self, '$convert', function $$convert(node, template_name, opts) {
261        var self = this, template = nil, $ret_or_1 = nil, helpers_ctx = nil;
262
263
264        if (template_name == null) template_name = nil;
265        if (opts == null) opts = nil;
266        if (!$truthy((template = self.templates['$[]']((template_name = ($truthy(($ret_or_1 = template_name)) ? ($ret_or_1) : (node.$node_name()))))))) {
267          self.$raise("Could not find a custom template to handle transform: " + (template_name))
268        };
269        helpers_ctx = ($truthy(($ret_or_1 = self.templates['$[]']("helpers.js"))) ? (self.templates['$[]']("helpers.js").$ctx()) : ($ret_or_1));
270        if ($eqeq(template_name, "document")) {
271          return (template.render({node: node, opts: fromHash(opts), helpers: helpers_ctx})).$strip()
272        } else {
273          return (template.render({node: node, opts: fromHash(opts), helpers: helpers_ctx})).$rstrip()
274        };
275      }, -2);
276
277      $def(self, '$handles?', function $TemplateConverter_handles$ques$1(name) {
278        var self = this;
279
280        return self.templates['$key?'](name)
281      });
282
283      $def(self, '$templates', function $$templates() {
284        var self = this;
285
286        return self.templates.$merge()
287      });
288
289      $def(self, '$register', function $$register(name, template) {
290        var $a, $b, self = this, template_cache = nil, $ret_or_1 = nil;
291
292        return ($a = [name, ($truthy((template_cache = ($truthy(($ret_or_1 = self.caches['$[]']("templates"))) ? (template.$file) : ($ret_or_1)))) ? (($b = [template.$file(), template], $send(template_cache, '[]=', $b), $b[$b.length - 1])) : (template))], $send(self.templates, '[]=', $a), $a[$a.length - 1])
293      });
294      self.$private();
295
296      $def(self, '$scan', function $$scan() {
297        var self = this, path_resolver = nil, backend = nil, engine = nil;
298
299
300        path_resolver = $$('PathResolver').$new();
301        backend = self.backend;
302        engine = self.engine;
303        return $send(self.template_dirs, 'each', [], function $$2(template_dir){var $a, self = $$2.$$s == null ? this : $$2.$$s, file_pattern = nil, engine_dir = nil, backend_dir = nil, pattern = nil, scan_cache = nil, template_cache = nil, templates = nil;
304          if (self.caches == null) self.caches = nil;
305          if (self.templates == null) self.templates = nil;
306
307
308          if (template_dir == null) template_dir = nil;
309          if (!$truthy($$$('File')['$directory?']((template_dir = path_resolver.$system_path(template_dir))))) {
310            return nil
311          };
312          if ($truthy(engine)) {
313
314            file_pattern = "*." + (engine);
315            if ($truthy($$$('File')['$directory?']((engine_dir = "" + (template_dir) + "/" + (engine))))) {
316              template_dir = engine_dir
317            };
318          } else {
319            file_pattern = "*"
320          };
321          if ($truthy($$$('File')['$directory?']((backend_dir = "" + (template_dir) + "/" + (backend))))) {
322            template_dir = backend_dir
323          };
324          pattern = "" + (template_dir) + "/" + (file_pattern);
325          if ($truthy((scan_cache = self.caches['$[]']("scans")))) {
326
327            template_cache = self.caches['$[]']("templates");
328            if (!$truthy((templates = scan_cache['$[]'](pattern)))) {
329              templates = ($a = [pattern, self.$scan_dir(template_dir, pattern, template_cache)], $send(scan_cache, '[]=', $a), $a[$a.length - 1])
330            };
331            $send(templates, 'each', [], function $$3(name, template){var $b, $c, self = $$3.$$s == null ? this : $$3.$$s;
332              if (self.templates == null) self.templates = nil;
333
334
335              if (name == null) name = nil;
336              if (template == null) template = nil;
337              return ($b = [name, ($c = [template.$file(), template], $send(template_cache, '[]=', $c), $c[$c.length - 1])], $send(self.templates, '[]=', $b), $b[$b.length - 1]);}, {$$s: self});
338          } else {
339            self.templates.$update(self.$scan_dir(template_dir, pattern, self.caches['$[]']("templates")))
340          };
341          return nil;}, {$$s: self});
342      });
343
344      $def(self, '$node_require', function $$node_require(module_name) {
345
346
347      try {
348        return __require__(module_name)
349      }
350      catch (e) {
351        throw $$('IOError').$new("Unable to require the module '" + (module_name) + "', please make sure that the module is installed.")
352      }
353
354      });
355      return $def(self, '$scan_dir', function $$scan_dir(template_dir, pattern, template_cache) {
356        var $a, self = this, result = nil, helpers = nil;
357
358
359        if (template_cache == null) template_cache = nil;
360        $a = [$hash2([], {}), nil], (result = $a[0]), (helpers = $a[1]), $a;
361              var enginesContext = {};
362        $send($send($$$('Dir').$glob(pattern), 'select', [], function $$4(match){
363
364          if (match == null) match = nil;
365          return $$$('File')['$file?'](match);}), 'each', [], function $$5(file){var $b, self = $$5.$$s == null ? this : $$5.$$s, basename = nil, path_segments = nil, name = nil, template = nil, extsym = nil, nunjucks = nil, handlebars = nil, ejs = nil, pug = nil;
366
367
368          if (file == null) file = nil;
369          if (($eqeq((basename = $$$('File').$basename(file)), "helpers.js") || ($eqeq((basename = $$$('File').$basename(file)), "helpers.cjs")))) {
370
371            helpers = file;
372            return nil;
373          } else if ($truthy($rb_lt((path_segments = basename.$split(".")).$size(), 2))) {
374            return nil
375          };
376          if ($eqeq((name = path_segments['$[]'](0)), "block_ruler")) {
377            name = "thematic_break"
378          } else if ($truthy(name['$start_with?']("block_"))) {
379            name = name.$slice(6, name.$length())
380          };
381          if (!($truthy(template_cache) && ($truthy((template = template_cache['$[]'](file)))))) {
382
383            extsym = path_segments['$[]'](-1).$to_sym();
384
385            switch (extsym) {
386              case "nunjucks":
387              case "njk":
388
389                nunjucks = self.$node_require("nunjucks");
390
391            var env
392            if (enginesContext.nunjucks && enginesContext.nunjucks.environment) {
393              env = enginesContext.nunjucks.environment
394            } else {
395              var opts = self.engine_options['nunjucks'] || {}
396              delete opts.web // unsupported option
397              env = nunjucks.configure(template_dir, opts)
398              enginesContext.nunjucks = { environment: env }
399            }
400            template = Object.assign(nunjucks.compile(fs.readFileSync(file, 'utf8'), env), { '$file': function() { return file } })
401          ;
402                break;
403              case "handlebars":
404              case "hbs":
405
406                handlebars = self.$node_require("handlebars");
407
408            var env
409            var opts = self.engine_options['handlebars'] || {}
410            if (enginesContext.handlebars && enginesContext.handlebars.environment) {
411              env = enginesContext.handlebars.environment
412            } else {
413              env = handlebars.create()
414              enginesContext.handlebars = { environment: env }
415            }
416            template = { render: env.compile(fs.readFileSync(file, 'utf8'), opts), '$file': function() { return file } }
417          ;
418                break;
419              case "ejs":
420
421                ejs = self.$node_require("ejs");
422
423            var opts = self.engine_options['ejs'] || {}
424            opts.filename = file
425            // unsupported options
426            delete opts.async
427            delete opts.client
428            template = { render: ejs.compile(fs.readFileSync(file, 'utf8'), opts), '$file': function() { return file } }
429          ;
430                break;
431              case "pug":
432
433                pug = self.$node_require("pug");
434
435            var opts = self.engine_options['pug'] || {}
436            opts.filename = file
437            template = { render: pug.compileFile(file, opts), '$file': function() { return file } }
438          ;
439                break;
440              case "js":
441              case "cjs":
442                template = { render: __require__(file), '$file': function() { return file } }
443                break;
444              default:
445
446            var registry = Opal.Asciidoctor.TemplateEngine.registry
447            var templateEngine = registry[extsym]
448            if (templateEngine && typeof templateEngine.compile === 'function') {
449              template = Object.assign(templateEngine.compile(file, name), { '$file': function() { return file } })
450            } else {
451              template = undefined
452            }
453
454            };
455          };
456          if ($truthy(template)) {
457            return ($b = [name, template], $send(result, '[]=', $b), $b[$b.length - 1])
458          } else {
459            return nil
460          };}, {$$s: self});
461        if ((($truthy(helpers) || ($truthy($$$('File')['$file?']((helpers = "" + (template_dir) + "/helpers.js"))))) || ($truthy($$$('File')['$file?']((helpers = "" + (template_dir) + "/helpers.cjs")))))) {
462
463
464        var ctx = __require__(helpers)
465        if (typeof ctx.configure === 'function') {
466          ctx.configure(enginesContext)
467        }
468      ;
469          result['$[]=']("helpers.js", { '$file': function() { return helpers }, $ctx: function() { return ctx } });
470        };
471        return result;
472      }, -3);
473    })($$('Converter'), $$$($$('Converter'), 'Base'), $nesting)
474  })($nesting[0], $nesting)
475};
476
477Opal.modules["asciidoctor/js/asciidoctor_ext/node"] = function(Opal) {/* Generated by Opal 1.7.3 */
478  var self = Opal.top, nil = Opal.nil;
479
480  Opal.add_stubs('require');
481
482  self.$require("asciidoctor/js/asciidoctor_ext/node/abstract_node");
483  self.$require("asciidoctor/js/asciidoctor_ext/node/open_uri");
484  self.$require("asciidoctor/js/asciidoctor_ext/node/stylesheet");
485  return self.$require("asciidoctor/js/asciidoctor_ext/node/template");
486};
487
488Opal.modules["set"] = Opal.return_val(Opal.nil); /* Generated by Opal 1.7.3 */
489
490Opal.modules["asciidoctor/js/opal_ext/kernel"] = function(Opal) {/* Generated by Opal 1.7.3 */
491  "use strict";
492  var $module = Opal.module, $slice = Opal.slice, $send = Opal.send, $to_a = Opal.to_a, $def = Opal.def, $return_val = Opal.return_val, $nesting = [], nil = Opal.nil;
493
494  Opal.add_stubs('new');
495  return (function($base, $parent_nesting) {
496    var self = $module($base, 'Kernel');
497
498    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
499
500
501
502    $def(self, '$open', function $$open(path, $a) {
503      var $post_args, rest, $yield = $$open.$$p || nil, file = nil;
504
505      $$open.$$p = null;
506
507      $post_args = $slice(arguments, 1);
508      rest = $post_args;
509      file = $send($$('File'), 'new', [path].concat($to_a(rest)));
510      if (($yield !== nil)) {
511        return Opal.yield1($yield, file);
512      } else {
513        return file
514      };
515    }, -2);
516    return $def(self, '$__dir__', $return_val(""));
517  })($nesting[0], $nesting)
518};
519
520Opal.modules["asciidoctor/js/opal_ext/file"] = function(Opal) {/* Generated by Opal 1.7.3 */
521  "use strict";
522  var $klass = Opal.klass, $def = Opal.def, $truthy = Opal.truthy, $gvars = Opal.gvars, $return_val = Opal.return_val, $defs = Opal.defs, $nesting = [], nil = Opal.nil;
523
524  Opal.add_stubs('attr_reader,delete,gsub,read,size,to_enum,chomp,each_line,readlines,split');
525
526  (function($base, $super, $parent_nesting) {
527    var self = $klass($base, $super, 'File');
528
529    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
530
531    $proto.eof = $proto.path = nil;
532
533    self.$attr_reader("eof");
534    self.$attr_reader("lineno");
535    self.$attr_reader("path");
536
537    $def(self, '$initialize', function $$initialize(path, flags) {
538      var self = this, encoding_flag_regexp = nil;
539
540
541      if (flags == null) flags = "r";
542      self.path = path;
543      self.contents = nil;
544      self.eof = false;
545      self.lineno = 0;
546      flags = flags.$delete("b");
547      encoding_flag_regexp = /:(.*)/;
548      flags = flags.$gsub(encoding_flag_regexp, "");
549      return (self.flags = flags);
550    }, -2);
551
552    $def(self, '$read', function $$read() {
553      var self = this, res = nil;
554
555      if ($truthy(self.eof)) {
556        return ""
557      } else {
558
559        res = $$('File').$read(self.path);
560        self.eof = true;
561        self.lineno = res.$size();
562        return res;
563      }
564    });
565
566    $def(self, '$each_line', function $$each_line(separator) {
567      var block = $$each_line.$$p || nil, self = this, lines = nil;
568      if ($gvars["/"] == null) $gvars["/"] = nil;
569
570      $$each_line.$$p = null;
571
572      ;
573      if (separator == null) separator = $gvars["/"];
574      if ($truthy(self.eof)) {
575        return ((block !== nil) ? (self) : ([].$to_enum()))
576      };
577      if ((block !== nil)) {
578
579        lines = $$('File').$read(self.path);
580
581        self.eof = false;
582        self.lineno = 0;
583        var chomped  = lines.$chomp(),
584            trailing = lines.length != chomped.length,
585            splitted = chomped.split(separator);
586        for (var i = 0, length = splitted.length; i < length; i++) {
587          self.lineno += 1;
588          if (i < length - 1 || trailing) {
589            Opal.yield1(block, splitted[i] + separator);
590          }
591          else {
592            Opal.yield1(block, splitted[i]);
593          }
594        }
595        self.eof = true;
596      ;
597        return self;
598      } else {
599        return self.$read().$each_line()
600      };
601    }, -1);
602
603    $def(self, '$readlines', function $$readlines() {
604      var self = this;
605
606      return $$('File').$readlines(self.path)
607    });
608    return (function(self, $parent_nesting) {
609      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
610
611
612
613      $def(self, '$readlines', function $$readlines(path, separator) {
614        var content = nil;
615        if ($gvars["/"] == null) $gvars["/"] = nil;
616
617
618        if (separator == null) separator = $gvars["/"];
619        content = $$('File').$read(path);
620        return content.$split(separator);
621      }, -2);
622
623      $def(self, '$file?', $return_val(true));
624
625      $def(self, '$readable?', $return_val(true));
626      return $def(self, '$read', $return_val(""));
627    })(Opal.get_singleton_class(self), $nesting);
628  })($nesting[0], null, $nesting);
629  return (function($base, $super, $parent_nesting) {
630    var self = $klass($base, $super, 'IO');
631
632    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
633
634    return $defs(self, '$read', function $$read(path) {
635
636      return $$('File').$read(path)
637    })
638  })($nesting[0], null, $nesting);
639};
640
641Opal.modules["asciidoctor/js/opal_ext/match_data"] = function(Opal) {/* Generated by Opal 1.7.3 */
642  "use strict";
643  var $klass = Opal.klass, $send = Opal.send, $def = Opal.def, $nesting = [], nil = Opal.nil;
644
645  Opal.add_stubs('[]=');
646  return (function($base, $super) {
647    var self = $klass($base, $super, 'MatchData');
648
649    var $proto = self.$$prototype;
650
651    $proto.matches = nil;
652    return $def(self, '$[]=', function $MatchData_$$$eq$1(idx, val) {
653      var $a, self = this;
654
655      return ($a = [idx, val], $send(self.matches, '[]=', $a), $a[$a.length - 1])
656    })
657  })($nesting[0], null)
658};
659
660Opal.modules["asciidoctor/js/opal_ext/string"] = function(Opal) {/* Generated by Opal 1.7.3 */
661  "use strict";
662  var $klass = Opal.klass, $truthy = Opal.truthy, $rb_lt = Opal.rb_lt, $def = Opal.def, $alias = Opal.alias, $rb_ge = Opal.rb_ge, $eqeq = Opal.eqeq, $rb_minus = Opal.rb_minus, $nesting = [], nil = Opal.nil;
663
664  Opal.add_stubs('method_defined?,<,length,bytes,to_s,byteslice,limit_bytesize,>=,==,-,_original_byteslice,unpack,_original_unpack');
665  return (function($base, $super) {
666    var self = $klass($base, $super, 'String');
667
668
669
670    if (!$truthy(self['$method_defined?']("limit_bytesize"))) {
671
672      $def(self, '$limit_bytesize', function $$limit_bytesize(size) {
673        var self = this, result = nil;
674
675
676        if (!$truthy($rb_lt(size, self.$bytes().$length()))) {
677          return self.$to_s()
678        };
679        result = self.$byteslice(0, size);
680        return result.$to_s();
681      })
682    };
683    if (!$truthy(self['$method_defined?']("limit"))) {
684      $alias(self, "limit", "limit_bytesize")
685    };
686    $alias(self, "_original_byteslice", "byteslice");
687
688    $def(self, '$byteslice', function $$byteslice(index, length) {
689      var self = this;
690
691
692      if (length == null) length = 1;
693      if ((($eqeq(index, 3) && ($truthy($rb_ge(length, index)))) && ($truthy(self.charCodeAt() === 65279)))) {
694        return (self.substr(1)).$byteslice(0, $rb_minus(length, 3))
695      } else {
696        return self.$_original_byteslice(index, length)
697      };
698    }, -2);
699    $alias(self, "_original_unpack", "unpack");
700    return $def(self, '$unpack', function $$unpack(format) {
701      var self = this;
702
703      if ($eqeq(format, "C3")) {
704        if ($truthy(self.charCodeAt() === 65279)) {
705          return [239, 187, 191]
706        } else {
707
708          var bytes = []
709          for (var i=0; i < 3; i++) {
710            if (i < self.length) {
711              bytes.push(self.charCodeAt(i))
712            } else {
713              bytes.push(nil)
714            }
715          }
716          return bytes
717
718        }
719      } else {
720        return self.$_original_unpack(format)
721      }
722    });
723  })($nesting[0], null)
724};
725
726Opal.modules["asciidoctor/js/opal_ext/uri"] = function(Opal) {/* Generated by Opal 1.7.3 */
727  "use strict";
728  var $module = Opal.module, $defs = Opal.defs, $return_self = Opal.return_self, $def = Opal.def, $nesting = [], nil = Opal.nil;
729
730  Opal.add_stubs('extend');
731  return (function($base, $parent_nesting) {
732    var self = $module($base, 'URI');
733
734    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
735
736
737    $defs(self, '$parse', function $$parse(str) {
738
739      return str.$extend($$('URI'))
740    });
741    return $def(self, '$path', $return_self);
742  })($nesting[0], $nesting)
743};
744
745Opal.modules["asciidoctor/js/opal_ext/base64"] = function(Opal) {/* Generated by Opal 1.7.3 */
746  "use strict";
747  var $module = Opal.module, $defs = Opal.defs, $ensure_kwargs = Opal.ensure_kwargs, $truthy = Opal.truthy, $nesting = [], nil = Opal.nil;
748
749  Opal.add_stubs('delete');
750  return (function($base) {
751    var self = $module($base, 'Base64');
752
753
754
755
756    var encode, decode;
757    encode = Opal.global.btoa || function (input) {
758      var buffer;
759      if (input instanceof Buffer) {
760        buffer = input;
761      } else {
762        buffer = Buffer.from(input.toString(), 'binary');
763      }
764      return buffer.toString('base64');
765    };
766    decode = Opal.global.atob || function (input) {
767      return Buffer.from(input, 'base64').toString('binary');
768    };
769  ;
770    $defs(self, '$decode64', function $$decode64(string) {
771
772      return decode(string.replace(/\r?\n/g, ''));
773    });
774    $defs(self, '$encode64', function $$encode64(string) {
775
776      return encode(string).replace(/(.{60})/g, "$1\n").replace(/([^\n])$/g, "$1\n");
777    });
778    $defs(self, '$strict_decode64', function $$strict_decode64(string) {
779
780      return decode(string);
781    });
782    $defs(self, '$strict_encode64', function $$strict_encode64(string) {
783
784      return encode(string);
785    });
786    $defs(self, '$urlsafe_decode64', function $$urlsafe_decode64(string) {
787
788      return decode(string.replace(/\-/g, '+').replace(/_/g, '/'));
789    });
790    return $defs(self, '$urlsafe_encode64', function $$urlsafe_encode64(string, $kwargs) {
791      var padding, str = nil;
792
793
794      $kwargs = $ensure_kwargs($kwargs);
795
796      padding = $kwargs.$$smap["padding"];if (padding == null) padding = true;
797      str = encode(string).replace(/\+/g, '-').replace(/\//g, '_');
798      if (!$truthy(padding)) {
799        str = str.$delete("=")
800      };
801      return str;
802    }, -2);
803  })($nesting[0])
804};
805
806Opal.modules["asciidoctor/js/opal_ext/number"] = function(Opal) {/* Generated by Opal 1.7.3 */
807  "use strict";
808  var $klass = Opal.klass, $truthy = Opal.truthy, $rb_gt = Opal.rb_gt, $def = Opal.def, $nesting = [], $$ = Opal.$r($nesting), nil = Opal.nil;
809
810  Opal.add_stubs('coerce_to!,>');
811  return (function($base, $super, $parent_nesting) {
812    var self = $klass($base, $super, 'Number');
813
814    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
815
816    return $def(self, '$round', function $$round(ndigits) {
817      var self = this;
818
819
820      ;
821      ndigits = $$('Opal')['$coerce_to!'](ndigits, $$('Integer'), "to_int");
822      if ($truthy($rb_gt(ndigits, 0))) {
823        return Number(self.toFixed(ndigits));
824      } else {
825        return Math.round(self);
826      };
827    }, -1)
828  })($nesting[0], $$('Numeric'), $nesting)
829};
830
831Opal.modules["asciidoctor/js/opal_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */
832  "use strict";
833  var self = Opal.top, nil = Opal.nil;
834
835  Opal.add_stubs('require');
836
837  self.$require("asciidoctor/js/opal_ext/kernel");
838  self.$require("asciidoctor/js/opal_ext/file");
839  self.$require("asciidoctor/js/opal_ext/match_data");
840  self.$require("asciidoctor/js/opal_ext/string");
841  self.$require("asciidoctor/js/opal_ext/uri");
842  self.$require("asciidoctor/js/opal_ext/base64");
843  self.$require("asciidoctor/js/opal_ext/number");
844
845// suppress "not supported" warning messages from Opal
846Opal.config.unsupported_features_severity = 'ignore'
847
848// Load specific runtime
849self.$require("asciidoctor/js/opal_ext/node");
850;
851};
852
853Opal.modules["asciidoctor/js/rx"] = function(Opal) {/* Generated by Opal 1.7.3 */
854  "use strict";
855  var $module = Opal.module, $const_set = Opal.const_set, $send = Opal.send, $gvars = Opal.gvars, $truthy = Opal.truthy, $defs = Opal.defs, $rb_plus = Opal.rb_plus, $nesting = [], nil = Opal.nil;
856
857  Opal.add_stubs('gsub,+,unpack_hex_range');
858  return (function($base, $parent_nesting) {
859    var self = $module($base, 'Asciidoctor');
860
861    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
862
863
864    $const_set($nesting[0], 'HEX_RANGE_RX', /([A-F0-9]{4})(?:-([A-F0-9]{4}))?/);
865    $defs(self, '$unpack_hex_range', function $$unpack_hex_range(str) {
866
867      return $send(str, 'gsub', [$$('HEX_RANGE_RX')], function $$1(){var $a, $ret_or_1 = nil;
868
869        return "\\u" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) + (($truthy(($ret_or_1 = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) ? ("-\\u" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) : ($ret_or_1)))})
870    });
871    $const_set($nesting[0], 'P_L', $rb_plus("A-Za-z", self.$unpack_hex_range("00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D037F03860388-038A038C038E-03A103A3-03F503F7-0481048A-052F0531-055605590561-058705D0-05EA05F0-05F20620-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280840-085808A0-08B20904-0939093D09500958-09610971-09800985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10CF10CF20D05-0D0C0D0E-0D100D12-0D3A0D3D0D4E0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC-0EDF0F000F40-0F470F49-0F6C0F88-0F8C1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510C710CD10D0-10FA10FC-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA16F1-16F81700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191E1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1BBA-1BE51C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11CF51CF61D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209C21022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2CF22CF32D00-2D252D272D2D2D30-2D672D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31BA31F0-31FF3400-4DB54E00-9FCCA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A66EA67F-A69DA6A0-A6E5A717-A71FA722-A788A78B-A78EA790-A7ADA7B0A7B1A7F7-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFA9E0-A9E4A9E6-A9EFA9FA-A9FEAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA7E-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDAAE0-AAEAAAF2-AAF4AB01-AB06AB09-AB0EAB11-AB16AB20-AB26AB28-AB2EAB30-AB5AAB5C-AB5FAB64AB65ABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC")));
872    $const_set($nesting[0], 'P_Nl', self.$unpack_hex_range("16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF"));
873    $const_set($nesting[0], 'P_Nd', $rb_plus("0-9", self.$unpack_hex_range("0660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0DE6-0DEF0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19D91A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9A9F0-A9F9AA50-AA59ABF0-ABF9FF10-FF19")));
874    $const_set($nesting[0], 'P_Pc', self.$unpack_hex_range("005F203F20402054FE33FE34FE4D-FE4FFF3F"));
875    $const_set($nesting[0], 'CC_ALPHA', "" + ($$('P_L')) + ($$('P_Nl')));
876    $const_set($nesting[0], 'CG_ALPHA', "[" + ($$('CC_ALPHA')) + "]");
877    $const_set($nesting[0], 'CC_ALNUM', "" + ($$('CC_ALPHA')) + ($$('P_Nd')));
878    $const_set($nesting[0], 'CG_ALNUM', "[" + ($$('CC_ALNUM')) + "]");
879    $const_set($nesting[0], 'CC_WORD', "" + ($$('CC_ALNUM')) + ($$('P_Pc')));
880    $const_set($nesting[0], 'CG_WORD', "[" + ($$('CC_WORD')) + "]");
881    $const_set($nesting[0], 'CG_BLANK', "[ \\t]");
882    $const_set($nesting[0], 'CC_EOL', "(?=\\n|$)");
883    $const_set($nesting[0], 'CG_GRAPH', "[^\\s\\x00-\\x1F\\x7F]");
884    $const_set($nesting[0], 'CC_ALL', "[\\s\\S]");
885    return $const_set($nesting[0], 'CC_ANY', "[^\\n]");
886  })($nesting[0], $nesting)
887};
888
889Opal.modules["strscan"] = function(Opal) {/* Generated by Opal 1.7.3 */
890  "use strict";
891  var $klass = Opal.klass, $def = Opal.def, $truthy = Opal.truthy, $eqeqeq = Opal.eqeqeq, $Opal = Opal.Opal, $return_ivar = Opal.return_ivar, $send = Opal.send, $alias = Opal.alias, $nesting = [], nil = Opal.nil;
892
893  Opal.add_stubs('attr_reader,anchor,empty?,===,to_s,coerce_to!,scan_until,length,size,rest,pos=,beginning_of_line?,get_byte,private');
894  return (function($base, $super, $parent_nesting) {
895    var self = $klass($base, $super, 'StringScanner');
896
897    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
898
899    $proto.pos = $proto.string = $proto.working = $proto.matched = $proto.prev_pos = $proto.match = nil;
900
901    self.$attr_reader("pos", "matched");
902
903    $def(self, '$initialize', function $$initialize(string) {
904      var self = this;
905
906
907      self.string = string;
908      self.pos = 0;
909      self.matched = nil;
910      self.working = string;
911      return (self.match = []);
912    });
913    self.$attr_reader("string");
914
915    $def(self, '$beginning_of_line?', function $StringScanner_beginning_of_line$ques$1() {
916      var self = this;
917
918      return self.pos === 0 || self.string.charAt(self.pos - 1) === "\n"
919    });
920
921    $def(self, '$scan', function $$scan(pattern) {
922      var self = this;
923
924
925      pattern = self.$anchor(pattern);
926
927      var result = pattern.exec(self.working);
928
929      if (result == null) {
930        return self.matched = nil;
931      }
932      self.prev_pos = self.pos;
933      self.pos     += result[0].length;
934      self.working  = self.working.substring(result[0].length);
935      self.matched  = result[0];
936      self.match    = result;
937
938      return result[0];
939    ;
940    });
941
942    $def(self, '$scan_until', function $$scan_until(pattern) {
943      var self = this;
944
945
946      pattern = self.$anchor(pattern);
947
948      var working = self.working
949
950      for(var i = 0; working.length != i; ++i) {
951        var result  = pattern.exec(working.substr(i));
952        if (result !== null) {
953          var matched_size = i + result[0].length
954          var matched = working.substr(0, matched_size)
955
956          self.matched  = result[0]
957          self.match  = result
958          self.prev_pos = self.pos + i; // Position of first character of matched
959          self.pos += matched_size // Position one after last character of matched
960          self.working = working.substr(matched_size)
961
962          return matched
963        }
964      }
965      return self.matched = nil;
966    ;
967    });
968
969    $def(self, '$[]', function $StringScanner_$$$2(idx) {
970      var self = this, $ret_or_1 = nil;
971
972
973      if ($truthy(self.match['$empty?']())) {
974        return nil
975      };
976      if ($eqeqeq($$('Symbol'), ($ret_or_1 = idx))) {
977        idx = idx.$to_s()
978      } else if (!$eqeqeq($$('String'), $ret_or_1)) {
979        idx = $Opal['$coerce_to!'](idx, $$('Integer'), "to_int")
980      };
981
982      var match = self.match;
983
984      if (idx < 0) {
985        idx += match.length;
986      }
987
988      if (idx < 0 || idx >= match.length) {
989        return nil;
990      }
991
992      if (match[idx] == null) {
993        return nil;
994      }
995
996      return match[idx];
997    ;
998    });
999
1000    $def(self, '$check', function $$check(pattern) {
1001      var self = this;
1002
1003
1004      pattern = self.$anchor(pattern);
1005
1006      var result = pattern.exec(self.working);
1007
1008      if (result == null) {
1009        return self.matched = nil;
1010      }
1011
1012      return self.matched = result[0];
1013    ;
1014    });
1015
1016    $def(self, '$check_until', function $$check_until(pattern) {
1017      var self = this;
1018
1019
1020      var old_prev_pos = self.prev_pos;
1021      var old_pos      = self.pos;
1022      var old_working  = self.working;
1023
1024      var result = self.$scan_until(pattern);
1025
1026      self.prev_pos = old_prev_pos;
1027      self.pos      = old_pos;
1028      self.working  = old_working;
1029
1030      return result;
1031
1032    });
1033
1034    $def(self, '$peek', function $$peek(length) {
1035      var self = this;
1036
1037      return self.working.substring(0, length)
1038    });
1039
1040    $def(self, '$eos?', function $StringScanner_eos$ques$3() {
1041      var self = this;
1042
1043      return self.working.length === 0
1044    });
1045
1046    $def(self, '$exist?', function $StringScanner_exist$ques$4(pattern) {
1047      var self = this;
1048
1049
1050      var result = pattern.exec(self.working);
1051
1052      if (result == null) {
1053        return nil;
1054      }
1055      else if (result.index == 0) {
1056        return 0;
1057      }
1058      else {
1059        return result.index + 1;
1060      }
1061
1062    });
1063
1064    $def(self, '$skip', function $$skip(pattern) {
1065      var self = this;
1066
1067
1068      pattern = self.$anchor(pattern);
1069
1070      var result = pattern.exec(self.working);
1071
1072      if (result == null) {
1073        self.match = [];
1074        return self.matched = nil;
1075      }
1076      else {
1077        var match_str = result[0];
1078        var match_len = match_str.length;
1079
1080        self.matched   = match_str;
1081        self.match     = result;
1082        self.prev_pos  = self.pos;
1083        self.pos      += match_len;
1084        self.working   = self.working.substring(match_len);
1085
1086        return match_len;
1087      }
1088    ;
1089    });
1090
1091    $def(self, '$skip_until', function $$skip_until(pattern) {
1092      var self = this;
1093
1094
1095      var result = self.$scan_until(pattern);
1096
1097      if (result === nil) {
1098        return nil;
1099      }
1100      else {
1101        self.matched = result.substr(-1);
1102
1103        return result.length;
1104      }
1105
1106    });
1107
1108    $def(self, '$get_byte', function $$get_byte() {
1109      var self = this;
1110
1111
1112      var result = nil;
1113
1114      if (self.pos < self.string.length) {
1115        self.prev_pos  = self.pos;
1116        self.pos      += 1;
1117        result      = self.matched = self.working.substring(0, 1);
1118        self.working   = self.working.substring(1);
1119      }
1120      else {
1121        self.matched = nil;
1122      }
1123
1124      return result;
1125
1126    });
1127
1128    $def(self, '$match?', function $StringScanner_match$ques$5(pattern) {
1129      var self = this;
1130
1131
1132      pattern = self.$anchor(pattern);
1133
1134      var result = pattern.exec(self.working);
1135
1136      if (result == null) {
1137        return nil;
1138      }
1139      else {
1140        self.prev_pos = self.pos;
1141
1142        return result[0].length;
1143      }
1144    ;
1145    });
1146
1147    $def(self, '$pos=', function $StringScanner_pos$eq$6(pos) {
1148      var self = this;
1149
1150
1151
1152      if (pos < 0) {
1153        pos += self.string.$length();
1154      }
1155    ;
1156      self.pos = pos;
1157      return (self.working = self.string.slice(pos));
1158    });
1159
1160    $def(self, '$matched_size', function $$matched_size() {
1161      var self = this;
1162
1163
1164      if (self.matched === nil) {
1165        return nil;
1166      }
1167
1168      return self.matched.length
1169
1170    });
1171
1172    $def(self, '$post_match', function $$post_match() {
1173      var self = this;
1174
1175
1176      if (self.matched === nil) {
1177        return nil;
1178      }
1179
1180      return self.string.substr(self.pos);
1181
1182    });
1183
1184    $def(self, '$pre_match', function $$pre_match() {
1185      var self = this;
1186
1187
1188      if (self.matched === nil) {
1189        return nil;
1190      }
1191
1192      return self.string.substr(0, self.prev_pos);
1193
1194    });
1195
1196    $def(self, '$reset', function $$reset() {
1197      var self = this;
1198
1199
1200      self.working = self.string;
1201      self.matched = nil;
1202      return (self.pos = 0);
1203    });
1204
1205    $def(self, '$rest', $return_ivar("working"));
1206
1207    $def(self, '$rest?', function $StringScanner_rest$ques$7() {
1208      var self = this;
1209
1210      return self.working.length !== 0
1211    });
1212
1213    $def(self, '$rest_size', function $$rest_size() {
1214      var self = this;
1215
1216      return self.$rest().$size()
1217    });
1218
1219    $def(self, '$terminate', function $$terminate() {
1220      var $a, self = this;
1221
1222
1223      self.match = nil;
1224      return ($a = [self.string.$length()], $send(self, 'pos=', $a), $a[$a.length - 1]);
1225    });
1226
1227    $def(self, '$unscan', function $$unscan() {
1228      var self = this;
1229
1230
1231      self.pos = self.prev_pos;
1232      self.prev_pos = nil;
1233      self.match = nil;
1234      return self;
1235    });
1236    $alias(self, "bol?", "beginning_of_line?");
1237    $alias(self, "getch", "get_byte");
1238    self.$private();
1239    return $def(self, '$anchor', function $$anchor(pattern) {
1240
1241
1242      var flags = pattern.toString().match(/\/([^\/]+)$/);
1243      flags = flags ? flags[1] : undefined;
1244      return new RegExp('^(?:' + pattern.source + ')', flags);
1245
1246    });
1247  })($nesting[0], null, $nesting)
1248};
1249
1250Opal.modules["asciidoctor/js"] = function(Opal) {/* Generated by Opal 1.7.3 */
1251  "use strict";
1252  var self = Opal.top, nil = Opal.nil;
1253
1254  Opal.add_stubs('require');
1255
1256  self.$require("asciidoctor/js/opal_ext");
1257  self.$require("asciidoctor/js/rx");
1258  return self.$require("strscan");
1259};
1260
1261Opal.modules["asciidoctor/core_ext/nil_or_empty"] = function(Opal) {/* Generated by Opal 1.7.3 */
1262  "use strict";
1263  var $klass = Opal.klass, $truthy = Opal.truthy, $alias = Opal.alias, $nesting = [], nil = Opal.nil;
1264
1265  Opal.add_stubs('method_defined?,nil?,empty?');
1266
1267  (function($base, $super) {
1268    var self = $klass($base, $super, 'NilClass');
1269
1270
1271    if ($truthy(self['$method_defined?']("nil_or_empty?"))) {
1272      return nil
1273    } else {
1274      return $alias(self, "nil_or_empty?", "nil?")
1275    }
1276  })($nesting[0], null);
1277  (function($base, $super) {
1278    var self = $klass($base, $super, 'String');
1279
1280
1281    if ($truthy(self['$method_defined?']("nil_or_empty?"))) {
1282      return nil
1283    } else {
1284      return $alias(self, "nil_or_empty?", "empty?")
1285    }
1286  })($nesting[0], null);
1287  (function($base, $super) {
1288    var self = $klass($base, $super, 'Array');
1289
1290
1291    if ($truthy(self['$method_defined?']("nil_or_empty?"))) {
1292      return nil
1293    } else {
1294      return $alias(self, "nil_or_empty?", "empty?")
1295    }
1296  })($nesting[0], null);
1297  (function($base, $super) {
1298    var self = $klass($base, $super, 'Hash');
1299
1300
1301    if ($truthy(self['$method_defined?']("nil_or_empty?"))) {
1302      return nil
1303    } else {
1304      return $alias(self, "nil_or_empty?", "empty?")
1305    }
1306  })($nesting[0], null);
1307  return (function($base, $super) {
1308    var self = $klass($base, $super, 'Numeric');
1309
1310
1311    if ($truthy(self['$method_defined?']("nil_or_empty?"))) {
1312      return nil
1313    } else {
1314      return $alias(self, "nil_or_empty?", "nil?")
1315    }
1316  })($nesting[0], null);
1317};
1318
1319Opal.modules["asciidoctor/core_ext/hash/merge"] = function(Opal) {/* Generated by Opal 1.7.3 */
1320  "use strict";
1321  var $eqeq = Opal.eqeq, $send = Opal.send, $slice = Opal.slice, $truthy = Opal.truthy, $rb_lt = Opal.rb_lt, $rb_gt = Opal.rb_gt, $send2 = Opal.send2, $find_super = Opal.find_super, $def = Opal.def, self = Opal.top, $nesting = [], $$ = Opal.$r($nesting), nil = Opal.nil;
1322
1323  Opal.add_stubs('==,arity,instance_method,send,new,<,length,dup,>,inject,merge,[]');
1324  if ($eqeq($$('Hash').$instance_method("merge").$arity(), 1)) {
1325    return $$('Hash').$send("prepend", $send($$('Module'), 'new', [], function $$1(){var self = $$1.$$s == null ? this : $$1.$$s;
1326
1327      return $def(self, '$merge', function $$merge($a) {
1328        var $post_args, args, $yield = $$merge.$$p || nil, self = this, len = nil;
1329
1330        $$merge.$$p = null;
1331
1332        $post_args = $slice(arguments);
1333        args = $post_args;
1334        if ($truthy($rb_lt((len = args.$length()), 1))) {
1335          return self.$dup()
1336        } else {
1337
1338          if ($truthy($rb_gt(len, 1))) {
1339            return $send(args, 'inject', [self], function $$2(acc, arg){
1340
1341              if (acc == null) acc = nil;
1342              if (arg == null) arg = nil;
1343              return acc.$merge(arg);})
1344          } else {
1345
1346            return $send2(self, $find_super(self, 'merge', $$merge, false, true), 'merge', [args['$[]'](0)], null);
1347          };
1348        };
1349      }, -1)}, {$$s: self}))
1350  } else {
1351    return nil
1352  }
1353};
1354
1355Opal.modules["asciidoctor/core_ext/match_data/names"] = function(Opal) {/* Generated by Opal 1.7.3 */
1356  "use strict";
1357  var $truthy = Opal.truthy, $klass = Opal.klass, $def = Opal.def, $nesting = [], $$ = Opal.$r($nesting), nil = Opal.nil;
1358
1359  Opal.add_stubs('method_defined?');
1360  if ($truthy($$('MatchData')['$method_defined?']("names"))) {
1361    return nil
1362  } else {
1363    return (function($base, $super) {
1364      var self = $klass($base, $super, 'MatchData');
1365
1366
1367      return $def(self, '$names', function $$names() {
1368
1369        return []
1370      })
1371    })($nesting[0], null)
1372  }
1373};
1374
1375Opal.modules["asciidoctor/core_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */
1376  "use strict";
1377  var self = Opal.top, nil = Opal.nil;
1378
1379
1380  self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/nil_or_empty");
1381  self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/hash/merge");
1382  return self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/match_data/names");
1383};
1384
1385Opal.modules["asciidoctor/helpers"] = function(Opal) {/* Generated by Opal 1.7.3 */
1386  "use strict";
1387  var $module = Opal.module, $truthy = Opal.truthy, $eqeq = Opal.eqeq, $gvars = Opal.gvars, $def = Opal.def, $send = Opal.send, $neqeq = Opal.neqeq, $const_set = Opal.const_set, $hash2 = Opal.hash2, $to_ary = Opal.to_ary, $rb_times = Opal.rb_times, $eqeqeq = Opal.eqeqeq, $rb_plus = Opal.rb_plus, $Class = Opal.Class, $Object = Opal.Object, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
1388
1389  Opal.add_stubs('module_function,require,include?,include,==,path,message,raise,warn,logger,chomp,empty?,slice,unpack,[],[]=,byteslice,bytesize,map,rstrip,encode,encoding,nil_or_empty?,!=,tap,each_line,<<,!,start_with?,match?,gsub,rindex,index,basename,extname,length,directory?,dirname,mkdir_p,mkdir,private_constant,join,divmod,*,===,+,to_s,to_i,succ,class_for_name,const_get');
1390  return (function($base, $parent_nesting) {
1391    var self = $module($base, 'Asciidoctor');
1392
1393    var $nesting = [self].concat($parent_nesting);
1394
1395    return (function($base, $parent_nesting) {
1396      var self = $module($base, 'Helpers');
1397
1398      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
1399
1400
1401      self.$module_function();
1402
1403      $def(self, '$require_library', function $$require_library(name, gem_name, on_failure) {
1404        var self = this, details = nil;
1405        if ($gvars["!"] == null) $gvars["!"] = nil;
1406
1407
1408        if (gem_name == null) gem_name = true;
1409        if (on_failure == null) on_failure = "abort";
1410        try {
1411          return self.$require(name)
1412        } catch ($err) {
1413          if (Opal.rescue($err, [$$$('LoadError')])) {
1414            try {
1415
1416              if (!$truthy(self['$include?']($$('Logging')))) {
1417                self.$include($$('Logging'))
1418              };
1419              if ($truthy(gem_name)) {
1420
1421                if ($eqeq(gem_name, true)) {
1422                  gem_name = name
1423                };
1424
1425                switch (on_failure) {
1426                  case "abort":
1427
1428                    details = ($eqeq($gvars["!"].$path(), gem_name) ? ("") : (" (reason: " + (($truthy($gvars["!"].$path()) ? ("cannot load '" + ($gvars["!"].$path()) + "'") : ($gvars["!"].$message()))) + ")"));
1429                    self.$raise($$$('LoadError'), "asciidoctor: FAILED: required gem '" + (gem_name) + "' is not available" + (details) + ". Processing aborted.");
1430                    break;
1431                  case "warn":
1432
1433                    details = ($eqeq($gvars["!"].$path(), gem_name) ? ("") : (" (reason: " + (($truthy($gvars["!"].$path()) ? ("cannot load '" + ($gvars["!"].$path()) + "'") : ($gvars["!"].$message()))) + ")"));
1434                    self.$logger().$warn("optional gem '" + (gem_name) + "' is not available" + (details) + ". Functionality disabled.");
1435                    break;
1436                  default:
1437                    nil
1438                };
1439              } else
1440              switch (on_failure) {
1441                case "abort":
1442                  self.$raise($$$('LoadError'), "asciidoctor: FAILED: " + ($gvars["!"].$message().$chomp(".")) + ". Processing aborted.")
1443                  break;
1444                case "warn":
1445                  self.$logger().$warn("" + ($gvars["!"].$message().$chomp(".")) + ". Functionality disabled.")
1446                  break;
1447                default:
1448                  nil
1449              };
1450              return nil;
1451            } finally { Opal.pop_exception(); }
1452          } else { throw $err; }
1453        };
1454      }, -2);
1455
1456      $def(self, '$prepare_source_array', function $$prepare_source_array(data, trim_end) {
1457        var leading_2_bytes = nil, leading_bytes = nil, first = nil;
1458
1459
1460        if (trim_end == null) trim_end = true;
1461        if ($truthy(data['$empty?']())) {
1462          return []
1463        };
1464        if ($eqeq((leading_2_bytes = (leading_bytes = (first = data['$[]'](0)).$unpack("C3")).$slice(0, 2)), $$('BOM_BYTES_UTF_16LE'))) {
1465
1466          data['$[]='](0, first.$byteslice(2, first.$bytesize()));
1467          return ($truthy(trim_end) ? ($send(data, 'map', [], function $$1(line){
1468
1469            if (line == null) line = nil;
1470            return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE')).$rstrip();})) : ($send(data, 'map', [], function $$2(line){
1471
1472            if (line == null) line = nil;
1473            return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE')).$chomp();})));
1474        } else if ($eqeq(leading_2_bytes, $$('BOM_BYTES_UTF_16BE'))) {
1475
1476          data['$[]='](0, first.$byteslice(2, first.$bytesize()));
1477          return ($truthy(trim_end) ? ($send(data, 'map', [], function $$3(line){
1478
1479            if (line == null) line = nil;
1480            return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE')).$rstrip();})) : ($send(data, 'map', [], function $$4(line){
1481
1482            if (line == null) line = nil;
1483            return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE')).$chomp();})));
1484        } else if ($eqeq(leading_bytes, $$('BOM_BYTES_UTF_8'))) {
1485          data['$[]='](0, first.$byteslice(3, first.$bytesize()))
1486        };
1487        if ($eqeq(first.$encoding(), $$('UTF_8'))) {
1488          if ($truthy(trim_end)) {
1489            return $send(data, 'map', [], function $$5(line){
1490
1491              if (line == null) line = nil;
1492              return line.$rstrip();})
1493          } else {
1494            return $send(data, 'map', [], function $$6(line){
1495
1496              if (line == null) line = nil;
1497              return line.$chomp();})
1498          }
1499        } else if ($truthy(trim_end)) {
1500          return $send(data, 'map', [], function $$7(line){
1501
1502            if (line == null) line = nil;
1503            return line.$encode($$('UTF_8')).$rstrip();})
1504        } else {
1505          return $send(data, 'map', [], function $$8(line){
1506
1507            if (line == null) line = nil;
1508            return line.$encode($$('UTF_8')).$chomp();})
1509        };
1510      }, -2);
1511
1512      $def(self, '$prepare_source_string', function $$prepare_source_string(data, trim_end) {
1513        var leading_2_bytes = nil, leading_bytes = nil;
1514
1515
1516        if (trim_end == null) trim_end = true;
1517        if ($truthy(data['$nil_or_empty?']())) {
1518          return []
1519        };
1520        if ($eqeq((leading_2_bytes = (leading_bytes = data.$unpack("C3")).$slice(0, 2)), $$('BOM_BYTES_UTF_16LE'))) {
1521          data = data.$byteslice(2, data.$bytesize()).$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE'))
1522        } else if ($eqeq(leading_2_bytes, $$('BOM_BYTES_UTF_16BE'))) {
1523          data = data.$byteslice(2, data.$bytesize()).$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE'))
1524        } else if ($eqeq(leading_bytes, $$('BOM_BYTES_UTF_8'))) {
1525
1526          data = data.$byteslice(3, data.$bytesize());
1527          if (!$eqeq(data.$encoding(), $$('UTF_8'))) {
1528            data = data.$encode($$('UTF_8'))
1529          };
1530        } else if ($neqeq(data.$encoding(), $$('UTF_8'))) {
1531          data = data.$encode($$('UTF_8'))
1532        };
1533        if ($truthy(trim_end)) {
1534          return $send([], 'tap', [], function $$9(lines){
1535
1536            if (lines == null) lines = nil;
1537            return $send(data, 'each_line', [], function $$10(line){
1538
1539              if (line == null) line = nil;
1540              return lines['$<<'](line.$rstrip());});})
1541        } else {
1542          return $send([], 'tap', [], function $$11(lines){
1543
1544            if (lines == null) lines = nil;
1545            return $send(data, 'each_line', [], function $$12(line){
1546
1547              if (line == null) line = nil;
1548              return lines['$<<'](line.$chomp());});})
1549        };
1550      }, -2);
1551      if ($eqeq($$$('RUBY_ENGINE'), "jruby")) {
1552
1553        $def(self, '$uriish?', function $Helpers_uriish$ques$13(str) {
1554          var $ret_or_1 = nil, $ret_or_2 = nil;
1555
1556          if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = str['$include?'](":"))) ? (str['$start_with?']("uri:classloader:")['$!']()) : ($ret_or_2))))) {
1557
1558            return $$('UriSniffRx')['$match?'](str);
1559          } else {
1560            return $ret_or_1
1561          }
1562        })
1563      } else {
1564
1565        $def(self, '$uriish?', function $Helpers_uriish$ques$14(str) {
1566          var $ret_or_1 = nil;
1567
1568          if ($truthy(($ret_or_1 = str['$include?'](":")))) {
1569
1570            return $$('UriSniffRx')['$match?'](str);
1571          } else {
1572            return $ret_or_1
1573          }
1574        })
1575      };
1576
1577      $def(self, '$encode_uri_component', function $$encode_uri_component(str) {
1578
1579
1580        return encodeURIComponent(str).replace(/%20|[!'()*]/g, function (m) {
1581          return m === '%20' ? '+' : '%' + m.charCodeAt(0).toString(16)
1582        })
1583
1584      });
1585
1586      $def(self, '$encode_spaces_in_uri', function $$encode_spaces_in_uri(str) {
1587
1588        if ($truthy(str['$include?'](" "))) {
1589
1590          return str.$gsub(" ", "%20");
1591        } else {
1592          return str
1593        }
1594      });
1595
1596      $def(self, '$rootname', function $$rootname(filename) {
1597        var last_dot_idx = nil;
1598
1599        if ($truthy((last_dot_idx = filename.$rindex(".")))) {
1600          if ($truthy(filename.$index("/", last_dot_idx))) {
1601            return filename
1602          } else {
1603
1604            return filename.$slice(0, last_dot_idx);
1605          }
1606        } else {
1607          return filename
1608        }
1609      });
1610
1611      $def(self, '$basename', function $$basename(filename, drop_ext) {
1612        var self = this;
1613
1614
1615        if (drop_ext == null) drop_ext = nil;
1616        if ($truthy(drop_ext)) {
1617          return $$$('File').$basename(filename, ($eqeq(drop_ext, true) ? (self.$extname(filename)) : (drop_ext)))
1618        } else {
1619          return $$$('File').$basename(filename)
1620        };
1621      }, -2);
1622
1623      $def(self, '$extname?', function $Helpers_extname$ques$15(path) {
1624        var $ret_or_1 = nil, last_dot_idx = nil;
1625
1626        if ($truthy(($ret_or_1 = (last_dot_idx = path.$rindex("."))))) {
1627          return path.$index("/", last_dot_idx)['$!']()
1628        } else {
1629          return $ret_or_1
1630        }
1631      });
1632      if ($truthy($$$($$$('File'), 'ALT_SEPARATOR'))) {
1633
1634        $def(self, '$extname', function $$extname(path, fallback) {
1635          var last_dot_idx = nil;
1636
1637
1638          if (fallback == null) fallback = "";
1639          if ($truthy((last_dot_idx = path.$rindex(".")))) {
1640            if (($truthy(path.$index("/", last_dot_idx)) || ($truthy(path.$index($$$($$$('File'), 'ALT_SEPARATOR'), last_dot_idx))))) {
1641              return fallback
1642            } else {
1643
1644              return path.$slice(last_dot_idx, path.$length());
1645            }
1646          } else {
1647            return fallback
1648          };
1649        }, -2)
1650      } else {
1651
1652        $def(self, '$extname', function $$extname(path, fallback) {
1653          var last_dot_idx = nil;
1654
1655
1656          if (fallback == null) fallback = "";
1657          if ($truthy((last_dot_idx = path.$rindex(".")))) {
1658            if ($truthy(path.$index("/", last_dot_idx))) {
1659              return fallback
1660            } else {
1661
1662              return path.$slice(last_dot_idx, path.$length());
1663            }
1664          } else {
1665            return fallback
1666          };
1667        }, -2)
1668      };
1669
1670      $def(self, '$mkdir_p', function $$mkdir_p(dir) {
1671        var self = this, parent_dir = nil;
1672
1673        if ($truthy($$$('File')['$directory?'](dir))) {
1674          return nil
1675        } else {
1676
1677          if (!$eqeq((parent_dir = $$$('File').$dirname(dir)), ".")) {
1678            self.$mkdir_p(parent_dir)
1679          };
1680
1681          try {
1682            return $$$('Dir').$mkdir(dir)
1683          } catch ($err) {
1684            if (Opal.rescue($err, [$$$('SystemCallError')])) {
1685              try {
1686                if ($truthy($$$('File')['$directory?'](dir))) {
1687                  return nil
1688                } else {
1689                  return self.$raise()
1690                }
1691              } finally { Opal.pop_exception(); }
1692            } else { throw $err; }
1693          };;
1694        }
1695      });
1696      $const_set($nesting[0], 'ROMAN_NUMERALS', $hash2(["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"], {"M": 1000, "CM": 900, "D": 500, "CD": 400, "C": 100, "XC": 90, "L": 50, "XL": 40, "X": 10, "IX": 9, "V": 5, "IV": 4, "I": 1}));
1697      self.$private_constant("ROMAN_NUMERALS");
1698
1699      $def(self, '$int_to_roman', function $$int_to_roman(val) {
1700
1701        return $send($$('ROMAN_NUMERALS'), 'map', [], function $$16(l, i){var $a, $b, repeat = nil;
1702
1703
1704          if (l == null) l = nil;
1705          if (i == null) i = nil;
1706          $b = val.$divmod(i), $a = $to_ary($b), (repeat = ($a[0] == null ? nil : $a[0])), (val = ($a[1] == null ? nil : $a[1])), $b;
1707          return $rb_times(l, repeat);}).$join()
1708      });
1709
1710      $def(self, '$nextval', function $$nextval(current) {
1711        var intval = nil;
1712
1713        if ($eqeqeq($$$('Integer'), current)) {
1714          return $rb_plus(current, 1)
1715        } else if ($eqeq((intval = current.$to_i()).$to_s(), current.$to_s())) {
1716          return $rb_plus(intval, 1)
1717        } else {
1718          return current.$succ()
1719        }
1720      });
1721
1722      $def(self, '$resolve_class', function $$resolve_class(object) {
1723        var self = this;
1724
1725        if ($eqeqeq($Class, object)) {
1726          return object
1727        } else {
1728
1729          if ($eqeqeq($$$('String'), object)) {
1730
1731            return self.$class_for_name(object);
1732          } else {
1733            return nil
1734          };
1735        }
1736      });
1737      return $def(self, '$class_for_name', function $$class_for_name(qualified_name) {
1738        var self = this, resolved = nil;
1739
1740        try {
1741
1742          if (!$eqeqeq($Class, (resolved = $Object.$const_get(qualified_name, false)))) {
1743            self.$raise()
1744          };
1745          return resolved;
1746        } catch ($err) {
1747          if (Opal.rescue($err, [$$('StandardError')])) {
1748            try {
1749              return self.$raise($$$('NameError'), "Could not resolve class for name: " + (qualified_name))
1750            } finally { Opal.pop_exception(); }
1751          } else { throw $err; }
1752        }
1753      });
1754    })($nesting[0], $nesting)
1755  })($nesting[0], $nesting)
1756};
1757
1758Opal.modules["logger"] = function(Opal) {/* Generated by Opal 1.7.3 */
1759  "use strict";
1760  var $klass = Opal.klass, $module = Opal.module, $const_set = Opal.const_set, $send = Opal.send, $def = Opal.def, $eqeqeq = Opal.eqeqeq, $rb_plus = Opal.rb_plus, $truthy = Opal.truthy, $rb_le = Opal.rb_le, $rb_lt = Opal.rb_lt, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
1761
1762  Opal.add_stubs('include,to_h,map,constants,const_get,to_s,format,chr,strftime,message_as_string,===,+,message,class,join,backtrace,inspect,attr_reader,attr_accessor,new,key,upcase,raise,add,to_proc,<=,<,write,call,[],now');
1763  return (function($base, $super, $parent_nesting) {
1764    var self = $klass($base, $super, 'Logger');
1765
1766    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
1767
1768    $proto.level = $proto.progname = $proto.pipe = $proto.formatter = nil;
1769
1770    (function($base, $parent_nesting) {
1771      var self = $module($base, 'Severity');
1772
1773      var $nesting = [self].concat($parent_nesting);
1774
1775
1776      $const_set($nesting[0], 'DEBUG', 0);
1777      $const_set($nesting[0], 'INFO', 1);
1778      $const_set($nesting[0], 'WARN', 2);
1779      $const_set($nesting[0], 'ERROR', 3);
1780      $const_set($nesting[0], 'FATAL', 4);
1781      return $const_set($nesting[0], 'UNKNOWN', 5);
1782    })($nesting[0], $nesting);
1783    self.$include($$('Severity'));
1784    $const_set($nesting[0], 'SEVERITY_LABELS', $send($$('Severity').$constants(), 'map', [], function $Logger$1(s){
1785
1786      if (s == null) s = nil;
1787      return [$$('Severity').$const_get(s), s.$to_s()];}).$to_h());
1788    (function($base, $super, $parent_nesting) {
1789      var self = $klass($base, $super, 'Formatter');
1790
1791      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
1792
1793
1794      $const_set($nesting[0], 'MESSAGE_FORMAT', "%s, [%s] %5s -- %s: %s\n");
1795      $const_set($nesting[0], 'DATE_TIME_FORMAT', "%Y-%m-%dT%H:%M:%S.%6N");
1796
1797      $def(self, '$call', function $$call(severity, time, progname, msg) {
1798        var self = this;
1799
1800        return self.$format($$('MESSAGE_FORMAT'), severity.$chr(), time.$strftime($$('DATE_TIME_FORMAT')), severity, progname, self.$message_as_string(msg))
1801      });
1802      return $def(self, '$message_as_string', function $$message_as_string(msg) {
1803        var $ret_or_1 = nil, $ret_or_2 = nil;
1804
1805        if ($eqeqeq($$$('String'), ($ret_or_1 = msg))) {
1806          return msg
1807        } else if ($eqeqeq($$$('Exception'), $ret_or_1)) {
1808          return $rb_plus("" + (msg.$message()) + " (" + (msg.$class()) + ")\n", ($truthy(($ret_or_2 = msg.$backtrace())) ? ($ret_or_2) : ([])).$join("\n"))
1809        } else {
1810          return msg.$inspect()
1811        }
1812      });
1813    })($nesting[0], null, $nesting);
1814    self.$attr_reader("level");
1815    self.$attr_accessor("progname");
1816    self.$attr_accessor("formatter");
1817
1818    $def(self, '$initialize', function $$initialize(pipe) {
1819      var self = this;
1820
1821
1822      self.pipe = pipe;
1823      self.level = $$('DEBUG');
1824      return (self.formatter = $$('Formatter').$new());
1825    });
1826
1827    $def(self, '$level=', function $Logger_level$eq$2(severity) {
1828      var self = this, level = nil;
1829
1830      if ($eqeqeq($$$('Integer'), severity)) {
1831        return (self.level = severity)
1832      } else if ($truthy((level = $$('SEVERITY_LABELS').$key(severity.$to_s().$upcase())))) {
1833        return (self.level = level)
1834      } else {
1835        return self.$raise($$('ArgumentError'), "invalid log level: " + (severity))
1836      }
1837    });
1838
1839    $def(self, '$info', function $$info(progname) {
1840      var block = $$info.$$p || nil, self = this;
1841
1842      $$info.$$p = null;
1843
1844      ;
1845      if (progname == null) progname = nil;
1846      return $send(self, 'add', [$$('INFO'), nil, progname], block.$to_proc());
1847    }, -1);
1848
1849    $def(self, '$debug', function $$debug(progname) {
1850      var block = $$debug.$$p || nil, self = this;
1851
1852      $$debug.$$p = null;
1853
1854      ;
1855      if (progname == null) progname = nil;
1856      return $send(self, 'add', [$$('DEBUG'), nil, progname], block.$to_proc());
1857    }, -1);
1858
1859    $def(self, '$warn', function $$warn(progname) {
1860      var block = $$warn.$$p || nil, self = this;
1861
1862      $$warn.$$p = null;
1863
1864      ;
1865      if (progname == null) progname = nil;
1866      return $send(self, 'add', [$$('WARN'), nil, progname], block.$to_proc());
1867    }, -1);
1868
1869    $def(self, '$error', function $$error(progname) {
1870      var block = $$error.$$p || nil, self = this;
1871
1872      $$error.$$p = null;
1873
1874      ;
1875      if (progname == null) progname = nil;
1876      return $send(self, 'add', [$$('ERROR'), nil, progname], block.$to_proc());
1877    }, -1);
1878
1879    $def(self, '$fatal', function $$fatal(progname) {
1880      var block = $$fatal.$$p || nil, self = this;
1881
1882      $$fatal.$$p = null;
1883
1884      ;
1885      if (progname == null) progname = nil;
1886      return $send(self, 'add', [$$('FATAL'), nil, progname], block.$to_proc());
1887    }, -1);
1888
1889    $def(self, '$unknown', function $$unknown(progname) {
1890      var block = $$unknown.$$p || nil, self = this;
1891
1892      $$unknown.$$p = null;
1893
1894      ;
1895      if (progname == null) progname = nil;
1896      return $send(self, 'add', [$$('UNKNOWN'), nil, progname], block.$to_proc());
1897    }, -1);
1898
1899    $def(self, '$info?', function $Logger_info$ques$3() {
1900      var self = this;
1901
1902      return $rb_le(self.level, $$('INFO'))
1903    });
1904
1905    $def(self, '$debug?', function $Logger_debug$ques$4() {
1906      var self = this;
1907
1908      return $rb_le(self.level, $$('DEBUG'))
1909    });
1910
1911    $def(self, '$warn?', function $Logger_warn$ques$5() {
1912      var self = this;
1913
1914      return $rb_le(self.level, $$('WARN'))
1915    });
1916
1917    $def(self, '$error?', function $Logger_error$ques$6() {
1918      var self = this;
1919
1920      return $rb_le(self.level, $$('ERROR'))
1921    });
1922
1923    $def(self, '$fatal?', function $Logger_fatal$ques$7() {
1924      var self = this;
1925
1926      return $rb_le(self.level, $$('FATAL'))
1927    });
1928    return $def(self, '$add', function $$add(severity, message, progname) {
1929      var block = $$add.$$p || nil, self = this, $ret_or_1 = nil;
1930
1931      $$add.$$p = null;
1932
1933      ;
1934      if (message == null) message = nil;
1935      if (progname == null) progname = nil;
1936      if ($truthy($rb_lt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), self.level))) {
1937        return true
1938      };
1939      progname = ($truthy(($ret_or_1 = progname)) ? ($ret_or_1) : (self.progname));
1940      if (!$truthy(message)) {
1941        if ((block !== nil)) {
1942          message = Opal.yieldX(block, [])
1943        } else {
1944
1945          message = progname;
1946          progname = self.progname;
1947        }
1948      };
1949      self.pipe.$write(self.formatter.$call(($truthy(($ret_or_1 = $$('SEVERITY_LABELS')['$[]'](severity))) ? ($ret_or_1) : ("ANY")), $$$('Time').$now(), progname, message));
1950      return true;
1951    }, -2);
1952  })($nesting[0], null, $nesting)
1953};
1954
1955Opal.modules["asciidoctor/logging"] = function(Opal) {/* Generated by Opal 1.7.3 */
1956  "use strict";
1957  var $module = Opal.module, $klass = Opal.klass, $slice = Opal.slice, $send2 = Opal.send2, $find_super = Opal.find_super, $to_a = Opal.to_a, $send = Opal.send, $def = Opal.def, $truthy = Opal.truthy, $rb_gt = Opal.rb_gt, $const_set = Opal.const_set, $hash2 = Opal.hash2, $eqeqeq = Opal.eqeqeq, $gvars = Opal.gvars, $alias = Opal.alias, $defs = Opal.defs, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
1958
1959  Opal.add_stubs('require,attr_reader,progname=,formatter=,new,level=,>,[],===,inspect,to_h,map,constants,const_get,<<,clear,empty?,max,attr_accessor,memoize_logger,private,logger,extend,private_class_method,merge');
1960
1961  self.$require("logger");
1962  return (function($base, $parent_nesting) {
1963    var self = $module($base, 'Asciidoctor');
1964
1965    var $nesting = [self].concat($parent_nesting);
1966
1967
1968    (function($base, $super, $parent_nesting) {
1969      var self = $klass($base, $super, 'Logger');
1970
1971      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
1972
1973      $proto.max_severity = nil;
1974
1975      self.$attr_reader("max_severity");
1976
1977      $def(self, '$initialize', function $$initialize($a) {
1978        var $post_args, args, $b, $yield = $$initialize.$$p || nil, self = this;
1979
1980        $$initialize.$$p = null;
1981
1982        $post_args = $slice(arguments);
1983        args = $post_args;
1984        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', $to_a(args), $yield);
1985        self['$progname=']("asciidoctor");
1986        self['$formatter=']($$('BasicFormatter').$new());
1987        return ($b = [$$('WARN')], $send(self, 'level=', $b), $b[$b.length - 1]);
1988      }, -1);
1989
1990      $def(self, '$add', function $$add(severity, message, progname) {
1991        var $yield = $$add.$$p || nil, self = this, $ret_or_1 = nil;
1992
1993        $$add.$$p = null;
1994
1995        if (message == null) message = nil;
1996        if (progname == null) progname = nil;
1997        if ($truthy($rb_gt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), (self.max_severity = ($truthy(($ret_or_1 = self.max_severity)) ? ($ret_or_1) : (severity)))))) {
1998          self.max_severity = severity
1999        };
2000        return $send2(self, $find_super(self, 'add', $$add, false, true), 'add', [severity, message, progname], $yield);
2001      }, -2);
2002      (function($base, $super, $parent_nesting) {
2003        var self = $klass($base, $super, 'BasicFormatter');
2004
2005        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
2006
2007
2008        $const_set($nesting[0], 'SEVERITY_LABEL_SUBSTITUTES', $hash2(["WARN", "FATAL"], {"WARN": "WARNING", "FATAL": "FAILED"}));
2009        return $def(self, '$call', function $$call(severity, _, progname, msg) {
2010          var $ret_or_1 = nil;
2011
2012          return "" + (progname) + ": " + (($truthy(($ret_or_1 = $$('SEVERITY_LABEL_SUBSTITUTES')['$[]'](severity))) ? ($ret_or_1) : (severity))) + ": " + (($eqeqeq($$$('String'), msg) ? (msg) : (msg.$inspect()))) + ($$('LF'))
2013        });
2014      })($nesting[0], $$('Formatter'), $nesting);
2015      return (function($base) {
2016        var self = $module($base, 'AutoFormattingMessage');
2017
2018
2019        return $def(self, '$inspect', function $$inspect() {
2020          var self = this, sloc = nil;
2021
2022          if ($truthy((sloc = self['$[]']("source_location")))) {
2023            return "" + (sloc) + ": " + (self['$[]']("text"))
2024          } else {
2025            return self['$[]']("text")
2026          }
2027        })
2028      })($nesting[0]);
2029    })($nesting[0], $$$('Logger'), $nesting);
2030    (function($base, $super, $parent_nesting) {
2031      var self = $klass($base, $super, 'MemoryLogger');
2032
2033      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
2034
2035      $proto.messages = nil;
2036
2037      $const_set($nesting[0], 'SEVERITY_SYMBOL_BY_VALUE', $send($$('Severity').$constants(false), 'map', [], function $MemoryLogger$1(c){
2038
2039        if (c == null) c = nil;
2040        return [$$('Severity').$const_get(c), c];}).$to_h());
2041      self.$attr_reader("messages");
2042
2043      $def(self, '$initialize', function $$initialize() {
2044        var self = this;
2045
2046
2047        self['$level=']($$('WARN'));
2048        return (self.messages = []);
2049      });
2050
2051      $def(self, '$add', function $$add(severity, message, progname) {
2052        var $yield = $$add.$$p || nil, self = this, $ret_or_1 = nil;
2053
2054        $$add.$$p = null;
2055
2056        if (message == null) message = nil;
2057        if (progname == null) progname = nil;
2058        message = ($truthy(($ret_or_1 = message)) ? ($ret_or_1) : (($yield !== nil) ? (Opal.yieldX($yield, [])) : (progname)));
2059        self.messages['$<<']($hash2(["severity", "message"], {"severity": $$('SEVERITY_SYMBOL_BY_VALUE')['$[]'](($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), "message": message}));
2060        return true;
2061      }, -2);
2062
2063      $def(self, '$clear', function $$clear() {
2064        var self = this;
2065
2066        return self.messages.$clear()
2067      });
2068
2069      $def(self, '$empty?', function $MemoryLogger_empty$ques$2() {
2070        var self = this;
2071
2072        return self.messages['$empty?']()
2073      });
2074      return $def(self, '$max_severity', function $$max_severity() {
2075        var self = this;
2076
2077        if ($truthy(self['$empty?']())) {
2078          return nil
2079        } else {
2080          return $send(self.messages, 'map', [], function $$3(m){
2081
2082            if (m == null) m = nil;
2083            return $$('Severity').$const_get(m['$[]']("severity"));}).$max()
2084        }
2085      });
2086    })($nesting[0], $$$('Logger'), $nesting);
2087    (function($base, $super, $parent_nesting) {
2088      var self = $klass($base, $super, 'NullLogger');
2089
2090      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
2091
2092      $proto.max_severity = nil;
2093
2094      self.$attr_reader("max_severity");
2095
2096      $def(self, '$initialize', function $$initialize() {
2097        var $a, self = this;
2098
2099        return ($a = [$$('WARN')], $send(self, 'level=', $a), $a[$a.length - 1])
2100      });
2101      return $def(self, '$add', function $$add(severity, message, progname) {
2102        var self = this, $ret_or_1 = nil;
2103
2104
2105        if (message == null) message = nil;
2106        if (progname == null) progname = nil;
2107        if ($truthy($rb_gt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), (self.max_severity = ($truthy(($ret_or_1 = self.max_severity)) ? ($ret_or_1) : (severity)))))) {
2108          self.max_severity = severity
2109        };
2110        return true;
2111      }, -2);
2112    })($nesting[0], $$$('Logger'), $nesting);
2113    (function($base, $parent_nesting) {
2114      var self = $module($base, 'LoggerManager');
2115
2116      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
2117
2118
2119      self.logger_class = $$('Logger');
2120      return (function(self, $parent_nesting) {
2121        var $nesting = [self].concat($parent_nesting);
2122
2123
2124        self.$attr_accessor("logger_class");
2125
2126        $def(self, '$logger', function $$logger(pipe) {
2127          var self = this, $ret_or_1 = nil;
2128          if (self.logger == null) self.logger = nil;
2129          if (self.logger_class == null) self.logger_class = nil;
2130          if ($gvars.stderr == null) $gvars.stderr = nil;
2131
2132
2133          if (pipe == null) pipe = $gvars.stderr;
2134          self.$memoize_logger();
2135          return (self.logger = ($truthy(($ret_or_1 = self.logger)) ? ($ret_or_1) : (self.logger_class.$new(pipe))));
2136        }, -1);
2137
2138        $def(self, '$logger=', function $logger$eq$4(new_logger) {
2139          var self = this, $ret_or_1 = nil;
2140          if (self.logger_class == null) self.logger_class = nil;
2141          if ($gvars.stderr == null) $gvars.stderr = nil;
2142
2143          return (self.logger = ($truthy(($ret_or_1 = new_logger)) ? ($ret_or_1) : (self.logger_class.$new($gvars.stderr))))
2144        });
2145        self.$private();
2146        return $def(self, '$memoize_logger', function $$memoize_logger() {
2147          var self = this;
2148
2149          return (function(self, $parent_nesting) {
2150
2151
2152            $alias(self, "logger", "logger");
2153            return self.$attr_reader("logger");
2154          })(Opal.get_singleton_class(self), $nesting)
2155        });
2156      })(Opal.get_singleton_class(self), $nesting);
2157    })($nesting[0], $nesting);
2158    return (function($base, $parent_nesting) {
2159      var self = $module($base, 'Logging');
2160
2161      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
2162
2163
2164      $defs(self, '$included', function $$included(into) {
2165
2166        return into.$extend($$('Logging'))
2167      });
2168      self.$private_class_method("included");
2169
2170      $def(self, '$logger', function $$logger() {
2171
2172        return $$('LoggerManager').$logger()
2173      });
2174      return $def(self, '$message_with_context', function $$message_with_context(text, context) {
2175
2176
2177        if (context == null) context = $hash2([], {});
2178        return $hash2(["text"], {"text": text}).$merge(context).$extend($$$($$('Logger'), 'AutoFormattingMessage'));
2179      }, -2);
2180    })($nesting[0], $nesting);
2181  })($nesting[0], $nesting);
2182};
2183
2184Opal.modules["asciidoctor/rx"] = function(Opal) {/* Generated by Opal 1.7.3 */
2185  "use strict";
2186  var $module = Opal.module, $const_set = Opal.const_set, $regexp = Opal.regexp, $hash2 = Opal.hash2, $send = Opal.send, $truthy = Opal.truthy, $hash = Opal.hash, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
2187
2188  Opal.add_stubs('join,to_a,new,[]=,empty?,escape');
2189  return (function($base, $parent_nesting) {
2190    var self = $module($base, 'Asciidoctor');
2191
2192    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
2193
2194
2195    $module($nesting[0], 'Rx');
2196    $const_set($nesting[0], 'AuthorInfoLineRx', $regexp(["^(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*)(?: +(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*))?(?: +(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*))?(?: +<([^>]+)>)?$"]));
2197    $const_set($nesting[0], 'AuthorDelimiterRx', /;(?: |$)/);
2198    $const_set($nesting[0], 'RevisionInfoLineRx', $regexp(["^(?:[^\\d{]*(", $$('CC_ANY'), "*?),)? *(?!:)(", $$('CC_ANY'), "*?)(?: *(?!^),?: *(", $$('CC_ANY'), "*))?$"]));
2199    $const_set($nesting[0], 'ManpageTitleVolnumRx', $regexp(["^(", $$('CC_ANY'), "+?) *\\( *(", $$('CC_ANY'), "+?) *\\)$"]));
2200    $const_set($nesting[0], 'ManpageNamePurposeRx', $regexp(["^(", $$('CC_ANY'), "+?) +- +(", $$('CC_ANY'), "+)$"]));
2201    $const_set($nesting[0], 'ConditionalDirectiveRx', $regexp(["^(\\\\)?(ifdef|ifndef|ifeval|endif)::(\\S*?(?:([,+])\\S*?)?)\\[(", $$('CC_ANY'), "+)?\\]$"]));
2202    $const_set($nesting[0], 'EvalExpressionRx', $regexp(["^(", $$('CC_ANY'), "+?) *([=!><]=|[><]) *(", $$('CC_ANY'), "+)$"]));
2203    $const_set($nesting[0], 'IncludeDirectiveRx', $regexp(["^(\\\\)?include::([^\\s\\[](?:[^\\[]*[^\\s\\[])?)\\[(", $$('CC_ANY'), "+)?\\]$"]));
2204    $const_set($nesting[0], 'TagDirectiveRx', /\b(?:tag|(e)nd)::(\S+?)\[\](?=$|[ \r])/m);
2205    $const_set($nesting[0], 'AttributeEntryRx', $regexp(["^:(!?", $$('CG_WORD'), "[^:]*):(?:[ \\t]+(", $$('CC_ANY'), "*))?$"]));
2206    $const_set($nesting[0], 'InvalidAttributeNameCharsRx', $regexp(["[^", $$('CC_WORD'), "-]"]));
2207    $const_set($nesting[0], 'AttributeEntryPassMacroRx', $regexp(["^pass:([a-z]+(?:,[a-z-]+)*)?\\[(", $$('CC_ALL'), "*)\\]$"]));
2208    $const_set($nesting[0], 'AttributeReferenceRx', $regexp(["(\\\\)?\\{(", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*|(set|counter2?):", $$('CC_ANY'), "+?)(\\\\)?\\}"]));
2209    $const_set($nesting[0], 'BlockAnchorRx', $regexp(["^\\[\\[(?:|([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+))?)\\]\\]$"]));
2210    $const_set($nesting[0], 'BlockAttributeListRx', $regexp(["^\\[(|[", $$('CC_WORD'), ".#%{,\"']", $$('CC_ANY'), "*)\\]$"]));
2211    $const_set($nesting[0], 'BlockAttributeLineRx', $regexp(["^\\[(?:|[", $$('CC_WORD'), ".#%{,\"']", $$('CC_ANY'), "*|\\[(?:|[", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*(?:, *", $$('CC_ANY'), "+)?)\\])\\]$"]));
2212    $const_set($nesting[0], 'BlockTitleRx', $regexp(["^\\.(\\.?[^ \\t.]", $$('CC_ANY'), "*)$"]));
2213    $const_set($nesting[0], 'AdmonitionParagraphRx', $regexp(["^(", $$('ADMONITION_STYLES').$to_a().$join("|"), "):[ \\t]+"]));
2214    $const_set($nesting[0], 'LiteralParagraphRx', $regexp(["^([ \\t]+", $$('CC_ANY'), "*)$"]));
2215    $const_set($nesting[0], 'AtxSectionTitleRx', $regexp(["^(=={0,5})[ \\t]+(", $$('CC_ANY'), "+?)(?:[ \\t]+\\1)?$"]));
2216    $const_set($nesting[0], 'ExtAtxSectionTitleRx', $regexp(["^(=={0,5}|#\\\#{0,5})[ \\t]+(", $$('CC_ANY'), "+?)(?:[ \\t]+\\1)?$"]));
2217    $const_set($nesting[0], 'SetextSectionTitleRx', $regexp(["^((?!\\.)", $$('CC_ANY'), "*?", $$('CG_ALNUM'), $$('CC_ANY'), "*)$"]));
2218    $const_set($nesting[0], 'InlineSectionAnchorRx', $regexp([" (\\\\)?\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+))?\\]\\]$"]));
2219    $const_set($nesting[0], 'InvalidSectionIdCharsRx', $regexp(["<[^>]+>|&(?:[a-z][a-z]+\\d{0,2}|#\\d\\d\\d{0,4}|#x[\\da-f][\\da-f][\\da-f]{0,3});|[^ ", $$('CC_WORD'), "\\-.]+?"]));
2220    $const_set($nesting[0], 'SectionLevelStyleRx', /^sect\d$/);
2221    $const_set($nesting[0], 'AnyListRx', $regexp(["^(?:[ \\t]*(?:-|\\*\\**|\\.\\.*|\\u2022|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))[ \\t]|(?!//[^/])[ \\t]*[^ \\t]", $$('CC_ANY'), "*?(?::::{0,2}|;;)(?:$|[ \\t])|<(?:\\d+|\\.)>[ \\t])"]));
2222    $const_set($nesting[0], 'UnorderedListRx', $regexp(["^[ \\t]*(-|\\*\\**|\\u2022)[ \\t]+(", $$('CC_ANY'), "*)$"]));
2223    $const_set($nesting[0], 'OrderedListRx', $regexp(["^[ \\t]*(\\.\\.*|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))[ \\t]+(", $$('CC_ANY'), "*)$"]));
2224    $const_set($nesting[0], 'OrderedListMarkerRxMap', $hash2(["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"], {"arabic": /\d+\./, "loweralpha": /[a-z]\./, "lowerroman": /[ivx]+\)/, "upperalpha": /[A-Z]\./, "upperroman": /[IVX]+\)/}));
2225    $const_set($nesting[0], 'DescriptionListRx', $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?)(:::{0,2}|;;)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"]));
2226    $const_set($nesting[0], 'DescriptionListSiblingRx', $hash2(["::", ":::", "::::", ";;"], {"::": $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?[^:]|[^ \\t:])(::)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"]), ":::": $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?[^:]|[^ \\t:])(:::)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"]), "::::": $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?[^:]|[^ \\t:])(::::)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"]), ";;": $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?)(;;)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"])}));
2227    $const_set($nesting[0], 'CalloutListRx', $regexp(["^<(\\d+|\\.)>[ \\t]+(", $$('CC_ANY'), "*)$"]));
2228    $const_set($nesting[0], 'CalloutExtractRx', /((?:\/\/|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\3>(?=(?: ?\\?<!?\3(?:\d+|\.)\3>)*$)/);
2229    $const_set($nesting[0], 'CalloutExtractRxt', "(\\\\)?<()(\\d+|\\.)>(?=(?: ?\\\\?<(?:\\d+|\\.)>)*$)");
2230    $const_set($nesting[0], 'CalloutExtractRxMap', $send($$$('Hash'), 'new', [], function $Asciidoctor$1(h, k){var $a;
2231
2232
2233      if (h == null) h = nil;
2234      if (k == null) k = nil;
2235      return ($a = [k, $regexp(["(", ($truthy(k['$empty?']()) ? ("") : ("" + ($$$('Regexp').$escape(k)) + " ?")), ")?", $$('CalloutExtractRxt')])], $send(h, '[]=', $a), $a[$a.length - 1]);}));
2236    $const_set($nesting[0], 'CalloutScanRx', $regexp(["\\\\?<!?(|--)(\\d+|\\.)\\1>(?=(?: ?\\\\?<!?\\1(?:\\d+|\\.)\\1>)*", $$('CC_EOL'), ")"]));
2237    $const_set($nesting[0], 'CalloutSourceRx', $regexp(["((?://|#|--|;;) ?)?(\\\\)?&lt;!?(|--)(\\d+|\\.)\\3&gt;(?=(?: ?\\\\?&lt;!?\\3(?:\\d+|\\.)\\3&gt;)*", $$('CC_EOL'), ")"]));
2238    $const_set($nesting[0], 'CalloutSourceRxt', "(\\\\)?&lt;()(\\d+|\\.)&gt;(?=(?: ?\\\\?&lt;(?:\\d+|\\.)&gt;)*" + ($$('CC_EOL')) + ")");
2239    $const_set($nesting[0], 'CalloutSourceRxMap', $send($$$('Hash'), 'new', [], function $Asciidoctor$2(h, k){var $a;
2240
2241
2242      if (h == null) h = nil;
2243      if (k == null) k = nil;
2244      return ($a = [k, $regexp(["(", ($truthy(k['$empty?']()) ? ("") : ("" + ($$$('Regexp').$escape(k)) + " ?")), ")?", $$('CalloutSourceRxt')])], $send(h, '[]=', $a), $a[$a.length - 1]);}));
2245    $const_set($nesting[0], 'ListRxMap', $hash2(["ulist", "olist", "dlist", "colist"], {"ulist": $$('UnorderedListRx'), "olist": $$('OrderedListRx'), "dlist": $$('DescriptionListRx'), "colist": $$('CalloutListRx')}));
2246    $const_set($nesting[0], 'ColumnSpecRx', /^(?:(\d+)\*)?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?(\d+%?|~)?([a-z])?$/);
2247    $const_set($nesting[0], 'CellSpecStartRx', /^[ \t]*(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/);
2248    $const_set($nesting[0], 'CellSpecEndRx', /[ \t]+(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/);
2249    $const_set($nesting[0], 'CustomBlockMacroRx', $regexp(["^(", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*)::(|\\S|\\S", $$('CC_ANY'), "*?\\S)\\[(", $$('CC_ANY'), "+)?\\]$"]));
2250    $const_set($nesting[0], 'BlockMediaMacroRx', $regexp(["^(image|video|audio)::(\\S|\\S", $$('CC_ANY'), "*?\\S)\\[(", $$('CC_ANY'), "+)?\\]$"]));
2251    $const_set($nesting[0], 'BlockTocMacroRx', $regexp(["^toc::\\[(", $$('CC_ANY'), "+)?\\]$"]));
2252    $const_set($nesting[0], 'InlineAnchorRx', $regexp(["(\\\\)?(?:\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]|anchor:([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)\\[(?:\\]|(", $$('CC_ANY'), "*?[^\\\\])\\]))"]));
2253    $const_set($nesting[0], 'InlineAnchorScanRx', $regexp(["(?:^|[^\\\\\\[])\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]|(?:^|[^\\\\])anchor:([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)\\[(?:\\]|(", $$('CC_ANY'), "*?[^\\\\])\\])"]));
2254    $const_set($nesting[0], 'LeadingInlineAnchorRx', $regexp(["^\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]"]));
2255    $const_set($nesting[0], 'InlineBiblioAnchorRx', $regexp(["^\\[\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]\\]"]));
2256    $const_set($nesting[0], 'InlineEmailRx', $regexp(["([\\\\>:/])?", $$('CG_WORD'), "(?:&amp;|[", $$('CC_WORD'), "\\-.%+])*@", $$('CG_ALNUM'), "[", $$('CC_ALNUM'), "_\\-.]*\\.[a-zA-Z]{2,5}\\b"]));
2257    $const_set($nesting[0], 'InlineFootnoteMacroRx', $regexp(["\\\\?footnote(?:(ref):|:([", $$('CC_WORD'), "-]+)?)\\[(?:|(", $$('CC_ALL'), "*?[^\\\\]))\\](?!</a>)"], 'm'));
2258    $const_set($nesting[0], 'InlineImageMacroRx', $regexp(["\\\\?i(?:mage|con):([^:\\s\\[](?:[^\\n\\[]*[^\\s\\[])?)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm'));
2259    $const_set($nesting[0], 'InlineIndextermMacroRx', $regexp(["\\\\?(?:(indexterm2?):\\[(", $$('CC_ALL'), "*?[^\\\\])\\]|\\(\\((", $$('CC_ALL'), "+?)\\)\\)(?!\\)))"], 'm'));
2260    $const_set($nesting[0], 'InlineKbdBtnMacroRx', $regexp(["(\\\\)?(kbd|btn):\\[(", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm'));
2261    $const_set($nesting[0], 'InlineLinkRx', $regexp(["(^|link:|", $$('CG_BLANK'), "|&lt;|[>\\(\\)\\[\\];\"'])(\\\\?(?:https?|file|ftp|irc)://)(?:([^\\s\\[\\]]+)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]|([^\\s\\[\\]<]*([^\\s,.?!\\[\\]<\\)])))"], 'm'));
2262    $const_set($nesting[0], 'InlineLinkMacroRx', $regexp(["\\\\?(?:link|(mailto)):(|[^:\\s\\[][^\\s\\[]*)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm'));
2263    $const_set($nesting[0], 'MacroNameRx', $regexp(["^", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*$"]));
2264    $const_set($nesting[0], 'InlineStemMacroRx', $regexp(["\\\\?(stem|(?:latex|ascii)math):([a-z]+(?:,[a-z-]+)*)?\\[(", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm'));
2265    $const_set($nesting[0], 'InlineMenuMacroRx', $regexp(["\\\\?menu:(", $$('CG_WORD'), "|[", $$('CC_WORD'), "&][^\\n\\[]*[^\\s\\[])\\[ *(?:|(", $$('CC_ALL'), "*?[^\\\\]))\\]"], 'm'));
2266    $const_set($nesting[0], 'InlineMenuRx', $regexp(["\\\\?\"([", $$('CC_WORD'), "&][^\"]*?[ \\n]+&gt;[ \\n]+[^\"]*)\""]));
2267    $const_set($nesting[0], 'InlinePassRx', $hash(false, ["+", "-]", $regexp(["((?:^|[^", $$('CC_WORD'), ";:\\\\])(?=(\\[)|\\+)|\\\\(?=\\[)|(?=\\\\\\+))(?:\\2(x-|[^\\]]+ x-)\\]|(?:\\[([^\\]]+)\\])?(?=(\\\\)?\\+))(\\5?(\\+|`)(\\S|\\S", $$('CC_ALL'), "*?\\S)\\7)(?!", $$('CG_WORD'), ")"], 'm')], true, ["`", nil, $regexp(["(^|[^`", $$('CC_WORD'), "])(?:(\\Z)()|\\[([^\\]]+)\\](?=(\\\\))?)?(\\5?(`)([^`\\s]|[^`\\s]", $$('CC_ALL'), "*?\\S)\\7)(?![`", $$('CC_WORD'), "])"], 'm')]));
2268    $const_set($nesting[0], 'InlinePassMacroRx', $regexp(["(?:(?:(\\\\?)\\[([^\\]]+)\\])?(\\\\{0,2})(\\+\\+\\+?|\\$\\$)(", $$('CC_ALL'), "*?)\\4|(\\\\?)pass:([a-z]+(?:,[a-z-]+)*)?\\[(|", $$('CC_ALL'), "*?[^\\\\])\\])"], 'm'));
2269    $const_set($nesting[0], 'InlineXrefMacroRx', $regexp(["\\\\?(?:&lt;&lt;([", $$('CC_WORD'), "#/.:{]", $$('CC_ALL'), "*?)&gt;&gt;|xref:([", $$('CC_WORD'), "#/.:{]", $$('CC_ALL'), "*?)\\[(?:\\]|(", $$('CC_ALL'), "*?[^\\\\])\\]))"], 'm'));
2270    $const_set($nesting[0], 'HardLineBreakRx', $regexp(["^(", $$('CC_ANY'), "*) \\+$"], 'm'));
2271    $const_set($nesting[0], 'MarkdownThematicBreakRx', /^ {0,3}([-*_])( *)\1\2\1$/);
2272    $const_set($nesting[0], 'ExtLayoutBreakRx', /^(?:'{3,}|<{3,}|([-*_])( *)\1\2\1)$/);
2273    $const_set($nesting[0], 'BlankLineRx', /\n{2,}/);
2274    $const_set($nesting[0], 'EscapedSpaceRx', /\\([ \t\n])/);
2275    $const_set($nesting[0], 'ReplaceableTextRx', /[&']|--|\.\.\.|\([CRT]M?\)/);
2276    $const_set($nesting[0], 'SpaceDelimiterRx', /([^\\])[ \t\n]+/);
2277    $const_set($nesting[0], 'SubModifierSniffRx', /[+-]/);
2278    $const_set($nesting[0], 'TrailingDigitsRx', /\d+$/);
2279    $const_set($nesting[0], 'UriSniffRx', $regexp(["^", $$('CG_ALPHA'), "[", $$('CC_ALNUM'), ".+-]+:/{0,2}"]));
2280    return $const_set($nesting[0], 'XmlSanitizeRx', /<[^>]+>/);
2281  })($nesting[0], $nesting)
2282};
2283
2284Opal.modules["asciidoctor/substitutors"] = function(Opal) {/* Generated by Opal 1.7.3 */
2285  "use strict";
2286  var $module = Opal.module, $const_set = Opal.const_set, $hash2 = Opal.hash2, $hash = Opal.hash, $rb_plus = Opal.rb_plus, $regexp = Opal.regexp, $not = Opal.not, $truthy = Opal.truthy, $send = Opal.send, $def = Opal.def, $alias = Opal.alias, $gvars = Opal.gvars, $eqeq = Opal.eqeq, $to_ary = Opal.to_ary, $neqeq = Opal.neqeq, $to_a = Opal.to_a, $eqeqeq = Opal.eqeqeq, $rb_gt = Opal.rb_gt, $slice = Opal.slice, $rb_minus = Opal.rb_minus, $rb_lt = Opal.rb_lt, $rb_times = Opal.rb_times, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
2287
2288  Opal.add_stubs('freeze,+,keys,!,empty?,===,[],join,include?,extract_passthroughs,each,sub_specialchars,sub_quotes,sub_attributes,sub_replacements,sub_macros,highlight_source,sub_callouts,sub_post_replacements,warn,logger,restore_passthroughs,clear,split,apply_subs,gsub,match?,compat_mode,convert_quoted_text,attributes,==,shift,store_attribute,!=,attribute_undefined,counter,key?,downcase,attribute_missing,info,squeeze,delete,reject,start_with?,do_replacement,inline_macros?,extensions,inline_macros,regexp,instance,slice,length,names,config,merge,[]=,normalize_text,parse_attributes,process_method,expand_subs,text=,text,convert,class,strip,index,min,compact,>,end_with?,map,chop,new,pop,rstrip,register,tr,basename,parse,lstrip,split_simple_csv,-,partition,extract_attributes_from_text,sub,encode_uri_component,style,extname?,rindex,catalog,info?,fetch,outfilesuffix,natural_xrefs,resolve_id,find,footnotes,id,<,size,<<,attr?,attr,to_s,read_next_id,callouts,highlight?,syntax_highlighter,sub_source,extract_callouts,name,to_i,to_sym,resolve_lines_to_highlight,highlight,nil_or_empty?,restore_callouts,count,to_a,|,sort,*,parse_quoted_text_attributes,resolve_pass_subs,basebackend?,error,chr,drop,&,resolve_subs,resolve_block_subs,parse_into,private,shorthand_property_syntax,each_char');
2289  return (function($base, $parent_nesting) {
2290    var self = $module($base, 'Asciidoctor');
2291
2292    var $nesting = [self].concat($parent_nesting);
2293
2294    return (function($base, $parent_nesting) {
2295      var self = $module($base, 'Substitutors');
2296
2297      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
2298
2299
2300      $const_set($nesting[0], 'SpecialCharsRx', /[<&>]/);
2301      $const_set($nesting[0], 'SpecialCharsTr', $hash2([">", "<", "&"], {">": "&gt;", "<": "&lt;", "&": "&amp;"}));
2302      $const_set($nesting[0], 'QuotedTextSniffRx', $hash(false, /[*_`#^~]/, true, /[*'_+#^~]/));
2303      $const_set($nesting[0], 'BASIC_SUBS', ["specialcharacters"]).$freeze();
2304      $const_set($nesting[0], 'HEADER_SUBS', ["specialcharacters", "attributes"]).$freeze();
2305      $const_set($nesting[0], 'NO_SUBS', []).$freeze();
2306      $const_set($nesting[0], 'NORMAL_SUBS', ["specialcharacters", "quotes", "attributes", "replacements", "macros", "post_replacements"]).$freeze();
2307      $const_set($nesting[0], 'REFTEXT_SUBS', ["specialcharacters", "quotes", "replacements"]).$freeze();
2308      $const_set($nesting[0], 'VERBATIM_SUBS', ["specialcharacters", "callouts"]).$freeze();
2309      $const_set($nesting[0], 'SUB_GROUPS', $hash2(["none", "normal", "verbatim", "specialchars"], {"none": $$('NO_SUBS'), "normal": $$('NORMAL_SUBS'), "verbatim": $$('VERBATIM_SUBS'), "specialchars": $$('BASIC_SUBS')}));
2310      $const_set($nesting[0], 'SUB_HINTS', $hash2(["a", "m", "n", "p", "q", "r", "c", "v"], {"a": "attributes", "m": "macros", "n": "normal", "p": "post_replacements", "q": "quotes", "r": "replacements", "c": "specialcharacters", "v": "verbatim"}));
2311      $const_set($nesting[0], 'SUB_OPTIONS', $hash2(["block", "inline"], {"block": $rb_plus($rb_plus($$('SUB_GROUPS').$keys(), $$('NORMAL_SUBS')), ["callouts"]), "inline": $rb_plus($$('SUB_GROUPS').$keys(), $$('NORMAL_SUBS'))}));
2312      $const_set($nesting[0], 'CAN', "\u0018");
2313      $const_set($nesting[0], 'DEL', "\u007F");
2314      $const_set($nesting[0], 'PASS_START', "\u0096");
2315      $const_set($nesting[0], 'PASS_END', "\u0097");
2316      $const_set($nesting[0], 'PassSlotRx', $regexp([$$('PASS_START'), "(\\d+)", $$('PASS_END')]));
2317      $const_set($nesting[0], 'HighlightedPassSlotRx', $regexp(["<span\\b[^>]*>", $$('PASS_START'), "</span>[^\\d]*(\\d+)[^\\d]*<span\\b[^>]*>", $$('PASS_END'), "</span>"]));
2318      $const_set($nesting[0], 'RS', "\\");
2319      $const_set($nesting[0], 'R_SB', "]");
2320      $const_set($nesting[0], 'ESC_R_SB', "\\]");
2321      $const_set($nesting[0], 'PLUS', "+");
2322
2323      $def(self, '$apply_subs', function $$apply_subs(text, subs) {
2324        var self = this, is_multiline = nil, passthrus = nil, $ret_or_1 = nil, clear_passthrus = nil;
2325        if (self.passthroughs == null) self.passthroughs = nil;
2326        if (self.passthroughs_locked == null) self.passthroughs_locked = nil;
2327
2328
2329        if (subs == null) subs = $$('NORMAL_SUBS');
2330        if (($truthy(text['$empty?']()) || ($not(subs)))) {
2331          return text
2332        };
2333        if ($truthy((is_multiline = $$$('Array')['$==='](text)))) {
2334          text = ($truthy(text['$[]'](1)) ? (text.$join($$('LF'))) : (text['$[]'](0)))
2335        };
2336        if ($truthy(subs['$include?']("macros"))) {
2337
2338          text = self.$extract_passthroughs(text);
2339          if (!$truthy(self.passthroughs['$empty?']())) {
2340
2341            passthrus = self.passthroughs;
2342            self.passthroughs_locked = ($truthy(($ret_or_1 = self.passthroughs_locked)) ? ($ret_or_1) : ((clear_passthrus = true)));
2343          };
2344        };
2345        $send(subs, 'each', [], function $$1(type){var self = $$1.$$s == null ? this : $$1.$$s;
2346
2347
2348          if (type == null) type = nil;
2349
2350          switch (type) {
2351            case "specialcharacters":
2352              return (text = self.$sub_specialchars(text))
2353            case "quotes":
2354              return (text = self.$sub_quotes(text))
2355            case "attributes":
2356              if ($truthy(text['$include?']($$('ATTR_REF_HEAD')))) {
2357                return (text = self.$sub_attributes(text))
2358              } else {
2359                return nil
2360              }
2361              break;
2362            case "replacements":
2363              return (text = self.$sub_replacements(text))
2364            case "macros":
2365              return (text = self.$sub_macros(text))
2366            case "highlight":
2367              return (text = self.$highlight_source(text, subs['$include?']("callouts")))
2368            case "callouts":
2369              if ($truthy(subs['$include?']("highlight"))) {
2370                return nil
2371              } else {
2372                return (text = self.$sub_callouts(text))
2373              }
2374              break;
2375            case "post_replacements":
2376              return (text = self.$sub_post_replacements(text))
2377            default:
2378              return self.$logger().$warn("unknown substitution type " + (type))
2379          };}, {$$s: self});
2380        if ($truthy(passthrus)) {
2381
2382          text = self.$restore_passthroughs(text);
2383          if ($truthy(clear_passthrus)) {
2384
2385            passthrus.$clear();
2386            self.passthroughs_locked = nil;
2387          };
2388        };
2389        if ($truthy(is_multiline)) {
2390
2391          return text.$split($$('LF'), -1);
2392        } else {
2393          return text
2394        };
2395      }, -2);
2396
2397      $def(self, '$apply_normal_subs', function $$apply_normal_subs(text) {
2398        var self = this;
2399
2400        return self.$apply_subs(text, $$('NORMAL_SUBS'))
2401      });
2402
2403      $def(self, '$apply_header_subs', function $$apply_header_subs(text) {
2404        var self = this;
2405
2406        return self.$apply_subs(text, $$('HEADER_SUBS'))
2407      });
2408      $alias(self, "apply_title_subs", "apply_subs");
2409
2410      $def(self, '$apply_reftext_subs', function $$apply_reftext_subs(text) {
2411        var self = this;
2412
2413        return self.$apply_subs(text, $$('REFTEXT_SUBS'))
2414      });
2415
2416      $def(self, '$sub_specialchars', function $$sub_specialchars(text) {
2417
2418        if ((($truthy(text['$include?'](">")) || ($truthy(text['$include?']("&")))) || ($truthy(text['$include?']("<"))))) {
2419
2420          return text.$gsub($$('SpecialCharsRx'), $$('SpecialCharsTr'));
2421        } else {
2422          return text
2423        }
2424      });
2425      $alias(self, "sub_specialcharacters", "sub_specialchars");
2426
2427      $def(self, '$sub_quotes', function $$sub_quotes(text) {
2428        var self = this, compat = nil;
2429        if (self.document == null) self.document = nil;
2430
2431
2432        if ($truthy($$('QuotedTextSniffRx')['$[]']((compat = self.document.$compat_mode()))['$match?'](text))) {
2433          $send($$('QUOTE_SUBS')['$[]'](compat), 'each', [], function $$2(type, scope, pattern){var self = $$2.$$s == null ? this : $$2.$$s;
2434
2435
2436            if (type == null) type = nil;
2437            if (scope == null) scope = nil;
2438            if (pattern == null) pattern = nil;
2439            return (text = $send(text, 'gsub', [pattern], function $$3(){var self = $$3.$$s == null ? this : $$3.$$s;
2440              if ($gvars["~"] == null) $gvars["~"] = nil;
2441
2442              return self.$convert_quoted_text($gvars["~"], type, scope)}, {$$s: self}));}, {$$s: self})
2443        };
2444        return text;
2445      });
2446
2447      $def(self, '$sub_attributes', function $$sub_attributes(text, opts) {
2448        var self = this, doc_attrs = nil, drop = nil, drop_line = nil, drop_line_severity = nil, drop_empty_line = nil, attribute_undefined = nil, attribute_missing = nil, lines = nil;
2449        if (self.document == null) self.document = nil;
2450
2451
2452        if (opts == null) opts = $hash2([], {});
2453        doc_attrs = self.document.$attributes();
2454        drop = (drop_line = (drop_line_severity = (drop_empty_line = (attribute_undefined = (attribute_missing = nil)))));
2455        text = $send(text, 'gsub', [$$('AttributeReferenceRx')], function $$4(){var $a, $b, self = $$4.$$s == null ? this : $$4.$$s, args = nil, $ret_or_2 = nil, _ = nil, value = nil, $ret_or_3 = nil, key = nil, $ret_or_4 = nil;
2456          if (self.document == null) self.document = nil;
2457
2458          if (($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $$('RS')) || ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)), $$('RS'))))) {
2459            return "{" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2))) + "}"
2460          } else if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) {
2461
2462            switch ((args = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)).$split(":", 3)).$shift()) {
2463              case "set":
2464
2465                $b = $$('Parser').$store_attribute(args['$[]'](0), ($truthy(($ret_or_2 = args['$[]'](1))) ? ($ret_or_2) : ("")), self.document), $a = $to_ary($b), (_ = ($a[0] == null ? nil : $a[0])), (value = ($a[1] == null ? nil : $a[1])), $b;
2466                if (($truthy(value) || ($neqeq((attribute_undefined = ($truthy(($ret_or_2 = attribute_undefined)) ? ($ret_or_2) : (($truthy(($ret_or_3 = doc_attrs['$[]']("attribute-undefined"))) ? ($ret_or_3) : ($$('Compliance').$attribute_undefined()))))), "drop-line")))) {
2467                  return (drop = (drop_empty_line = $$('DEL')))
2468                } else {
2469                  return (drop = (drop_line = $$('CAN')))
2470                };
2471                break;
2472              case "counter2":
2473
2474                $send(self.document, 'counter', $to_a(args));
2475                return (drop = (drop_empty_line = $$('DEL')));
2476              default:
2477                return $send(self.document, 'counter', $to_a(args))
2478            }
2479          } else if ($truthy(doc_attrs['$key?']((key = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)).$downcase())))) {
2480            return doc_attrs['$[]'](key)
2481          } else if ($truthy((value = $$('INTRINSIC_ATTRIBUTES')['$[]'](key)))) {
2482            return value
2483          } else
2484          switch ((attribute_missing = ($truthy(($ret_or_2 = attribute_missing)) ? ($ret_or_2) : (($truthy(($ret_or_3 = ($truthy(($ret_or_4 = opts['$[]']("attribute_missing"))) ? ($ret_or_4) : (doc_attrs['$[]']("attribute-missing"))))) ? ($ret_or_3) : ($$('Compliance').$attribute_missing())))))) {
2485            case "drop":
2486              return (drop = (drop_empty_line = $$('DEL')))
2487            case "drop-line":
2488
2489              if ($eqeq((drop_line_severity = ($truthy(($ret_or_2 = drop_line_severity)) ? ($ret_or_2) : (($truthy(($ret_or_3 = opts['$[]']("drop_line_severity"))) ? ($ret_or_3) : ("info"))))), "info")) {
2490                $send(self.$logger(), 'info', [], function $$5(){
2491                  return "dropping line containing reference to missing attribute: " + (key)})
2492              };
2493              return (drop = (drop_line = $$('CAN')));
2494            case "warn":
2495
2496              self.$logger().$warn("skipping reference to missing attribute: " + (key));
2497              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0));
2498            default:
2499              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
2500          }}, {$$s: self});
2501        if ($truthy(drop)) {
2502          if ($truthy(drop_empty_line)) {
2503
2504            lines = text.$squeeze($$('DEL')).$split($$('LF'), -1);
2505            if ($truthy(drop_line)) {
2506              return $send(lines, 'reject', [], function $$6(line){var $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil;
2507
2508
2509                if (line == null) line = nil;
2510                if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = line['$==']($$('DEL')))) ? ($ret_or_3) : (line['$==']($$('CAN')))))) ? ($ret_or_2) : (line['$start_with?']($$('CAN'))))))) {
2511                  return $ret_or_1
2512                } else {
2513
2514                  return line['$include?']($$('CAN'));
2515                };}).$join($$('LF')).$delete($$('DEL'))
2516            } else {
2517              return $send(lines, 'reject', [], function $$7(line){
2518
2519                if (line == null) line = nil;
2520                return line['$==']($$('DEL'));}).$join($$('LF')).$delete($$('DEL'))
2521            };
2522          } else if ($truthy(text['$include?']($$('LF')))) {
2523            return $send(text.$split($$('LF'), -1), 'reject', [], function $$8(line){var $ret_or_1 = nil, $ret_or_2 = nil;
2524
2525
2526              if (line == null) line = nil;
2527              if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = line['$==']($$('CAN')))) ? ($ret_or_2) : (line['$start_with?']($$('CAN'))))))) {
2528                return $ret_or_1
2529              } else {
2530
2531                return line['$include?']($$('CAN'));
2532              };}).$join($$('LF'))
2533          } else {
2534            return ""
2535          }
2536        } else {
2537          return text
2538        };
2539      }, -2);
2540
2541      $def(self, '$sub_replacements', function $$sub_replacements(text) {
2542        var self = this;
2543
2544
2545        if ($truthy($$('ReplaceableTextRx')['$match?'](text))) {
2546          $send($$('REPLACEMENTS'), 'each', [], function $$9(pattern, replacement, restore){var self = $$9.$$s == null ? this : $$9.$$s;
2547
2548
2549            if (pattern == null) pattern = nil;
2550            if (replacement == null) replacement = nil;
2551            if (restore == null) restore = nil;
2552            return (text = $send(text, 'gsub', [pattern], function $$10(){var self = $$10.$$s == null ? this : $$10.$$s;
2553              if ($gvars["~"] == null) $gvars["~"] = nil;
2554
2555              return self.$do_replacement($gvars["~"], replacement, restore)}, {$$s: self}));}, {$$s: self})
2556        };
2557        return text;
2558      });
2559
2560      $def(self, '$sub_macros', function $$sub_macros(text) {
2561        var self = this, found_square_bracket = nil, found_colon = nil, found_macroish = nil, $ret_or_1 = nil, found_macroish_short = nil, doc_attrs = nil, doc = nil, extensions = nil;
2562        if (self.document == null) self.document = nil;
2563        if (self.parent == null) self.parent = nil;
2564        if (self.context == null) self.context = nil;
2565
2566
2567        found_square_bracket = text['$include?']("[");
2568        found_colon = text['$include?'](":");
2569        found_macroish = ($truthy(($ret_or_1 = found_square_bracket)) ? (found_colon) : ($ret_or_1));
2570        found_macroish_short = ($truthy(($ret_or_1 = found_macroish)) ? (text['$include?'](":[")) : ($ret_or_1));
2571        doc_attrs = (doc = self.document).$attributes();
2572        if (($truthy((extensions = doc.$extensions())) && ($truthy(extensions['$inline_macros?']())))) {
2573          $send(extensions.$inline_macros(), 'each', [], function $$11(extension){var self = $$11.$$s == null ? this : $$11.$$s;
2574
2575
2576            if (extension == null) extension = nil;
2577            return (text = $send(text, 'gsub', [extension.$instance().$regexp()], function $$12(){var $a, $b, self = $$12.$$s == null ? this : $$12.$$s, match = nil, target = nil, content = nil, attributes = nil, default_attrs = nil, ext_config = nil, $ret_or_2 = nil, replacement = nil, inline_subs = nil;
2578              if ($gvars["~"] == null) $gvars["~"] = nil;
2579
2580
2581              if ($truthy((match = (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)))['$start_with?']($$('RS')))) {
2582                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2583              };
2584              if ($truthy($gvars["~"].$names()['$empty?']())) {
2585                $a = [(($b = $gvars['~']) === nil ? nil : $b['$[]'](1)), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2))], (target = $a[0]), (content = $a[1]), $a
2586              } else {
2587                $a = [(function() { try {
2588                  return $gvars["~"]['$[]']("target")
2589                } catch ($err) {
2590                  if (Opal.rescue($err, [$$('StandardError')])) {
2591                    try {
2592                      return nil
2593                    } finally { Opal.pop_exception(); }
2594                  } else { throw $err; }
2595                }})(), (function() { try {
2596                  return $gvars["~"]['$[]']("content")
2597                } catch ($err) {
2598                  if (Opal.rescue($err, [$$('StandardError')])) {
2599                    try {
2600                      return nil
2601                    } finally { Opal.pop_exception(); }
2602                  } else { throw $err; }
2603                }})()], (target = $a[0]), (content = $a[1]), $a
2604              };
2605              attributes = ($truthy((default_attrs = (ext_config = extension.$config())['$[]']("default_attrs"))) ? (default_attrs.$merge()) : ($hash2([], {})));
2606              if ($truthy(content)) {
2607
2608                if ($truthy(content['$empty?']())) {
2609                  if (!$eqeq(ext_config['$[]']("content_model"), "attributes")) {
2610                    attributes['$[]=']("text", content)
2611                  }
2612                } else {
2613
2614                  content = self.$normalize_text(content, true, true);
2615                  if ($eqeq(ext_config['$[]']("content_model"), "attributes")) {
2616                    self.$parse_attributes(content, ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = ext_config['$[]']("positional_attrs"))) ? ($ret_or_2) : (ext_config['$[]']("pos_attrs"))))) ? ($ret_or_1) : ([])), $hash2(["into"], {"into": attributes}))
2617                  } else {
2618                    attributes['$[]=']("text", content)
2619                  };
2620                };
2621                target = ($truthy(($ret_or_1 = target)) ? ($ret_or_1) : ($eqeq(ext_config['$[]']("format"), "short") ? (content) : (target)));
2622              };
2623              if ($eqeqeq($$('Inline'), (replacement = extension.$process_method()['$[]'](self, target, attributes)))) {
2624
2625                if (($truthy((inline_subs = replacement.$attributes().$delete("subs"))) && ($truthy((inline_subs = self.$expand_subs(inline_subs, "custom inline macro")))))) {
2626                  replacement['$text='](self.$apply_subs(replacement.$text(), inline_subs))
2627                };
2628                return replacement.$convert();
2629              } else if ($truthy(replacement)) {
2630
2631                $send(self.$logger(), 'info', [], function $$13(){
2632                  return "expected substitution value for custom inline macro to be of type Inline; got " + (replacement.$class()) + ": " + (match)});
2633                return replacement;
2634              } else {
2635                return ""
2636              };}, {$$s: self}));}, {$$s: self})
2637        };
2638        if ($truthy(doc_attrs['$key?']("experimental"))) {
2639
2640          if (($truthy(found_macroish_short) && (($truthy(text['$include?']("kbd:")) || ($truthy(text['$include?']("btn:"))))))) {
2641            text = $send(text, 'gsub', [$$('InlineKbdBtnMacroRx')], function $$14(){var $a, self = $$14.$$s == null ? this : $$14.$$s, keys = nil, delim_idx = nil, delim = nil;
2642
2643              if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
2644                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2645              } else if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), "kbd")) {
2646
2647                if ($truthy((keys = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$strip())['$include?']($$('R_SB')))) {
2648                  keys = keys.$gsub($$('ESC_R_SB'), $$('R_SB'))
2649                };
2650                if (($truthy($rb_gt(keys.$length(), 1)) && ($truthy((delim_idx = ($truthy((delim_idx = keys.$index(",", 1))) ? ([delim_idx, keys.$index("+", 1)].$compact().$min()) : (keys.$index("+", 1)))))))) {
2651
2652                  delim = keys.$slice(delim_idx, 1);
2653                  if ($truthy(keys['$end_with?'](delim))) {
2654
2655                    keys = $send(keys.$chop().$split(delim, -1), 'map', [], function $$15(key){
2656
2657                      if (key == null) key = nil;
2658                      return key.$strip();});
2659                    keys['$[]='](-1, $rb_plus(keys['$[]'](-1), delim));
2660                  } else {
2661                    keys = $send(keys.$split(delim), 'map', [], function $$16(key){
2662
2663                      if (key == null) key = nil;
2664                      return key.$strip();})
2665                  };
2666                } else {
2667                  keys = [keys]
2668                };
2669                return $$('Inline').$new(self, "kbd", nil, $hash2(["attributes"], {"attributes": $hash2(["keys"], {"keys": keys})})).$convert();
2670              } else {
2671                return $$('Inline').$new(self, "button", self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)), true, true)).$convert()
2672              }}, {$$s: self})
2673          };
2674          if (($truthy(found_macroish) && ($truthy(text['$include?']("menu:"))))) {
2675            text = $send(text, 'gsub', [$$('InlineMenuMacroRx')], function $$17(){var $a, self = $$17.$$s == null ? this : $$17.$$s, menu = nil, items = nil, delim = nil, submenus = nil, menuitem = nil;
2676
2677
2678              if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2679                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2680              };
2681              menu = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1));
2682              if ($truthy((items = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) {
2683
2684                if ($truthy(items['$include?']($$('R_SB')))) {
2685                  items = items.$gsub($$('ESC_R_SB'), $$('R_SB'))
2686                };
2687                if ($truthy((delim = ($truthy(items['$include?']("&gt;")) ? ("&gt;") : (($truthy(items['$include?'](",")) ? (",") : (nil))))))) {
2688
2689                  submenus = $send(items.$split(delim), 'map', [], function $$18(it){
2690
2691                    if (it == null) it = nil;
2692                    return it.$strip();});
2693                  menuitem = submenus.$pop();
2694                } else {
2695                  $a = [[], items.$rstrip()], (submenus = $a[0]), (menuitem = $a[1]), $a
2696                };
2697              } else {
2698                $a = [[], nil], (submenus = $a[0]), (menuitem = $a[1]), $a
2699              };
2700              return $$('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, {$$s: self})
2701          };
2702          if (($truthy(text['$include?']("\"")) && ($truthy(text['$include?']("&gt;"))))) {
2703            text = $send(text, 'gsub', [$$('InlineMenuRx')], function $$19(){var $a, $b, $c, self = $$19.$$s == null ? this : $$19.$$s, menu = nil, submenus = nil, menuitem = nil;
2704
2705
2706              if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2707                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2708              };
2709              $b = $send((($c = $gvars['~']) === nil ? nil : $c['$[]'](1)).$split("&gt;"), 'map', [], function $$20(it){
2710
2711                if (it == null) it = nil;
2712                return it.$strip();}), $a = $to_ary($b), (menu = ($a[0] == null ? nil : $a[0])), (submenus = $slice($a, 1)), $b;
2713              menuitem = submenus.$pop();
2714              return $$('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, {$$s: self})
2715          };
2716        };
2717        if (($truthy(found_macroish) && (($truthy(text['$include?']("image:")) || ($truthy(text['$include?']("icon:"))))))) {
2718          text = $send(text, 'gsub', [$$('InlineImageMacroRx')], function $$21(){var $a, self = $$21.$$s == null ? this : $$21.$$s, type = nil, posattrs = nil, target = nil, attrs = nil;
2719
2720
2721            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2722              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2723            } else if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']("icon:"))) {
2724              $a = ["icon", ["size"]], (type = $a[0]), (posattrs = $a[1]), $a
2725            } else {
2726              $a = ["image", ["alt", "width", "height"]], (type = $a[0]), (posattrs = $a[1]), $a
2727            };
2728            target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1));
2729            attrs = self.$parse_attributes((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), posattrs, $hash2(["unescape_input"], {"unescape_input": true}));
2730            if (!$eqeq(type, "icon")) {
2731
2732              doc.$register("images", target);
2733              attrs['$[]=']("imagesdir", doc_attrs['$[]']("imagesdir"));
2734            };
2735            if ($truthy(($ret_or_1 = attrs['$[]']("alt")))) {
2736              $ret_or_1
2737            } else {
2738              attrs['$[]=']("alt", ($a = ["default-alt", $$('Helpers').$basename(target, true).$tr("_-", " ")], $send(attrs, '[]=', $a), $a[$a.length - 1]))
2739            };
2740            return $$('Inline').$new(self, "image", nil, $hash2(["type", "target", "attributes"], {"type": type, "target": target, "attributes": attrs})).$convert();}, {$$s: self})
2741        };
2742        if ((($truthy(text['$include?']("((")) && ($truthy(text['$include?']("))")))) || (($truthy(found_macroish_short) && ($truthy(text['$include?']("dexterm"))))))) {
2743          text = $send(text, 'gsub', [$$('InlineIndextermMacroRx')], function $$22(){var $a, $b, self = $$22.$$s == null ? this : $$22.$$s, attrlist = nil, primary = nil, attrs = nil, see_also = nil, term = nil, $ret_or_2 = nil, $ret_or_3 = nil, encl_text = nil, visible = nil, before = nil, after = nil, _ = nil, see = nil, subbed_term = nil, terms = nil;
2744
2745
2746            switch ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) {
2747              case "indexterm":
2748
2749                if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2750                  return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2751                };
2752                if ($truthy((attrlist = self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), true, true))['$include?']("="))) {
2753                  if ($truthy((primary = (attrs = $$('AttributeList').$new(attrlist, self).$parse())['$[]'](1)))) {
2754
2755                    attrs['$[]=']("terms", [primary]);
2756                    if ($truthy((see_also = attrs['$[]']("see-also")))) {
2757                      attrs['$[]=']("see-also", ($truthy(see_also['$include?'](",")) ? ($send(see_also.$split(","), 'map', [], function $$23(it){
2758
2759                        if (it == null) it = nil;
2760                        return it.$lstrip();})) : ([see_also])))
2761                    };
2762                  } else {
2763                    attrs = $hash2(["terms"], {"terms": attrlist})
2764                  }
2765                } else {
2766                  attrs = $hash2(["terms"], {"terms": self.$split_simple_csv(attrlist)})
2767                };
2768                return $$('Inline').$new(self, "indexterm", nil, $hash2(["attributes"], {"attributes": attrs})).$convert();
2769              case "indexterm2":
2770
2771                if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2772                  return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2773                };
2774                if ($truthy((term = self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), true, true))['$include?']("="))) {
2775
2776                  term = ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = (attrs = $$('AttributeList').$new(term, self).$parse())['$[]'](1))) ? ($ret_or_3) : ((attrs = nil))))) ? ($ret_or_2) : (term));
2777                  if (($truthy(attrs) && ($truthy((see_also = attrs['$[]']("see-also")))))) {
2778                    attrs['$[]=']("see-also", ($truthy(see_also['$include?'](",")) ? ($send(see_also.$split(","), 'map', [], function $$24(it){
2779
2780                      if (it == null) it = nil;
2781                      return it.$lstrip();})) : ([see_also])))
2782                  };
2783                };
2784                return $$('Inline').$new(self, "indexterm", term, $hash2(["attributes", "type"], {"attributes": attrs, "type": "visible"})).$convert();
2785              default:
2786
2787                encl_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3));
2788                if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2789                  if (($truthy(encl_text['$start_with?']("(")) && ($truthy(encl_text['$end_with?'](")"))))) {
2790
2791                    encl_text = encl_text.$slice(1, $rb_minus(encl_text.$length(), 2));
2792                    $a = [true, "(", ")"], (visible = $a[0]), (before = $a[1]), (after = $a[2]), $a;
2793                  } else {
2794                    return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2795                  }
2796                } else {
2797
2798                  visible = true;
2799                  if ($truthy(encl_text['$start_with?']("("))) {
2800                    if ($truthy(encl_text['$end_with?'](")"))) {
2801                      $a = [encl_text.$slice(1, $rb_minus(encl_text.$length(), 2)), false], (encl_text = $a[0]), (visible = $a[1]), $a
2802                    } else {
2803                      $a = [encl_text.$slice(1, encl_text.$length()), "(", ""], (encl_text = $a[0]), (before = $a[1]), (after = $a[2]), $a
2804                    }
2805                  } else if ($truthy(encl_text['$end_with?'](")"))) {
2806                    $a = [encl_text.$chop(), "", ")"], (encl_text = $a[0]), (before = $a[1]), (after = $a[2]), $a
2807                  };
2808                };
2809                if ($truthy(visible)) {
2810
2811                  if ($truthy((term = self.$normalize_text(encl_text, true))['$include?'](";&"))) {
2812                    if ($truthy(term['$include?'](" &gt;&gt; "))) {
2813
2814                      $b = term.$partition(" &gt;&gt; "), $a = $to_ary($b), (term = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (see = ($a[2] == null ? nil : $a[2])), $b;
2815                      attrs = $hash2(["see"], {"see": see});
2816                    } else if ($truthy(term['$include?'](" &amp;&gt; "))) {
2817
2818                      $b = term.$split(" &amp;&gt; "), $a = $to_ary($b), (term = ($a[0] == null ? nil : $a[0])), (see_also = $slice($a, 1)), $b;
2819                      attrs = $hash2(["see-also"], {"see-also": see_also});
2820                    }
2821                  };
2822                  subbed_term = $$('Inline').$new(self, "indexterm", term, $hash2(["attributes", "type"], {"attributes": attrs, "type": "visible"})).$convert();
2823                } else {
2824
2825                  attrs = $hash2([], {});
2826                  if ($truthy((terms = self.$normalize_text(encl_text, true))['$include?'](";&"))) {
2827                    if ($truthy(terms['$include?'](" &gt;&gt; "))) {
2828
2829                      $b = terms.$partition(" &gt;&gt; "), $a = $to_ary($b), (terms = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (see = ($a[2] == null ? nil : $a[2])), $b;
2830                      attrs['$[]=']("see", see);
2831                    } else if ($truthy(terms['$include?'](" &amp;&gt; "))) {
2832
2833                      $b = terms.$split(" &amp;&gt; "), $a = $to_ary($b), (terms = ($a[0] == null ? nil : $a[0])), (see_also = $slice($a, 1)), $b;
2834                      attrs['$[]=']("see-also", see_also);
2835                    }
2836                  };
2837                  attrs['$[]=']("terms", self.$split_simple_csv(terms));
2838                  subbed_term = $$('Inline').$new(self, "indexterm", nil, $hash2(["attributes"], {"attributes": attrs})).$convert();
2839                };
2840                if ($truthy(before)) {
2841                  return "" + (before) + (subbed_term) + (after)
2842                } else {
2843                  return subbed_term
2844                };
2845            }}, {$$s: self})
2846        };
2847        if (($truthy(found_colon) && ($truthy(text['$include?']("://"))))) {
2848          text = $send(text, 'gsub', [$$('InlineLinkRx')], function $$25(){var $a, $b, self = $$25.$$s == null ? this : $$25.$$s, target = nil, rs_idx = nil, prefix = nil, suffix = nil, link_text = nil, attrs = nil, link_opts = nil, new_link_text = nil, bare = nil;
2849
2850
2851            if ($truthy((target = $rb_plus((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), ($truthy(($ret_or_1 = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) ? ($ret_or_1) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](5))))))['$start_with?']($$('RS')))) {
2852              return $rb_plus((($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(0, (rs_idx = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)).$length())), (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice($rb_plus(rs_idx, 1), (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()))
2853            };
2854            $a = [(($b = $gvars['~']) === nil ? nil : $b['$[]'](1)), ""], (prefix = $a[0]), (suffix = $a[1]), $a;
2855            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)))) {
2856
2857              if ($eqeq(prefix, "link:")) {
2858                prefix = ""
2859              };
2860              if ($truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4)))['$empty?']())) {
2861                link_text = nil
2862              };
2863            } else {
2864
2865
2866              switch (prefix) {
2867                case "link:":
2868                case "\"":
2869                case "'":
2870                  return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
2871                default:
2872                  nil
2873              };
2874
2875              switch ((($a = $gvars['~']) === nil ? nil : $a['$[]'](6))) {
2876                case ";":
2877
2878                  if (($truthy(prefix['$start_with?']("&lt;")) && ($truthy(target['$end_with?']("&gt;"))))) {
2879
2880                    prefix = prefix.$slice(4, prefix.$length());
2881                    target = target.$slice(0, $rb_minus(target.$length(), 4));
2882                  } else if ($truthy((target = target.$chop())['$end_with?'](")"))) {
2883
2884                    target = target.$chop();
2885                    suffix = ");";
2886                  } else {
2887                    suffix = ";"
2888                  };
2889                  if ($truthy(target['$end_with?']("://"))) {
2890                    return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
2891                  };
2892                  break;
2893                case ":":
2894
2895                  if ($truthy((target = target.$chop())['$end_with?'](")"))) {
2896
2897                    target = target.$chop();
2898                    suffix = "):";
2899                  } else {
2900                    suffix = ":"
2901                  };
2902                  if ($truthy(target['$end_with?']("://"))) {
2903                    return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
2904                  };
2905                  break;
2906                default:
2907                  nil
2908              };
2909            };
2910            $a = [nil, $hash2(["type"], {"type": "link"})], (attrs = $a[0]), (link_opts = $a[1]), $a;
2911            if ($truthy(link_text)) {
2912
2913              if ($truthy(link_text['$include?']($$('R_SB')))) {
2914                new_link_text = (link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB')))
2915              };
2916              if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) {
2917
2918                $b = self.$extract_attributes_from_text(link_text, ""), $a = $to_ary($b), (link_text = ($a[0] == null ? nil : $a[0])), (attrs = ($a[1] == null ? nil : $a[1])), $b;
2919                new_link_text = link_text;
2920                link_opts['$[]=']("id", attrs['$[]']("id"));
2921              };
2922              if ($truthy(link_text['$end_with?']("^"))) {
2923
2924                new_link_text = (link_text = link_text.$chop());
2925                if ($truthy(attrs)) {
2926                  if ($truthy(($ret_or_1 = attrs['$[]']("window")))) {
2927                    $ret_or_1
2928                  } else {
2929                    attrs['$[]=']("window", "_blank")
2930                  }
2931                } else {
2932                  attrs = $hash2(["window"], {"window": "_blank"})
2933                };
2934              };
2935              if (($truthy(new_link_text) && ($truthy(new_link_text['$empty?']())))) {
2936
2937                link_text = ($truthy(doc_attrs['$key?']("hide-uri-scheme")) ? (target.$sub($$('UriSniffRx'), "")) : (target));
2938                bare = true;
2939              };
2940            } else {
2941
2942              link_text = ($truthy(doc_attrs['$key?']("hide-uri-scheme")) ? (target.$sub($$('UriSniffRx'), "")) : (target));
2943              bare = true;
2944            };
2945            if ($truthy(bare)) {
2946              if ($truthy(attrs)) {
2947                attrs['$[]=']("role", ($truthy(attrs['$key?']("role")) ? ("bare " + (attrs['$[]']("role"))) : ("bare")))
2948              } else {
2949                attrs = $hash2(["role"], {"role": "bare"})
2950              }
2951            };
2952            doc.$register("links", ($a = ["target", target], $send(link_opts, '[]=', $a), $a[$a.length - 1]));
2953            if ($truthy(attrs)) {
2954              link_opts['$[]=']("attributes", attrs)
2955            };
2956            return "" + (prefix) + ($$('Inline').$new(self, "anchor", link_text, link_opts).$convert()) + (suffix);}, {$$s: self})
2957        };
2958        if (($truthy(found_macroish) && (($truthy(text['$include?']("link:")) || ($truthy(text['$include?']("ilto:"))))))) {
2959          text = $send(text, 'gsub', [$$('InlineLinkMacroRx')], function $$26(){var $a, $b, self = $$26.$$s == null ? this : $$26.$$s, mailto = nil, target = nil, mailto_text = nil, attrs = nil, link_opts = nil, link_text = nil;
2960
2961
2962            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
2963              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
2964            } else if ($truthy((mailto = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) {
2965              target = $rb_plus("mailto:", (mailto_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))
2966            } else {
2967              target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))
2968            };
2969            $a = [nil, $hash2(["type"], {"type": "link"})], (attrs = $a[0]), (link_opts = $a[1]), $a;
2970            if (!$truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))['$empty?']())) {
2971
2972              if ($truthy(link_text['$include?']($$('R_SB')))) {
2973                link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB'))
2974              };
2975              if ($truthy(mailto)) {
2976                if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?'](","))))) {
2977
2978                  $b = self.$extract_attributes_from_text(link_text, ""), $a = $to_ary($b), (link_text = ($a[0] == null ? nil : $a[0])), (attrs = ($a[1] == null ? nil : $a[1])), $b;
2979                  link_opts['$[]=']("id", attrs['$[]']("id"));
2980                  if ($truthy(attrs['$key?'](2))) {
2981                    if ($truthy(attrs['$key?'](3))) {
2982                      target = "" + (target) + "?subject=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](2))) + "&amp;body=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](3)))
2983                    } else {
2984                      target = "" + (target) + "?subject=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](2)))
2985                    }
2986                  };
2987                }
2988              } else if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) {
2989
2990                $b = self.$extract_attributes_from_text(link_text, ""), $a = $to_ary($b), (link_text = ($a[0] == null ? nil : $a[0])), (attrs = ($a[1] == null ? nil : $a[1])), $b;
2991                link_opts['$[]=']("id", attrs['$[]']("id"));
2992              };
2993              if ($truthy(link_text['$end_with?']("^"))) {
2994
2995                link_text = link_text.$chop();
2996                if ($truthy(attrs)) {
2997                  if ($truthy(($ret_or_1 = attrs['$[]']("window")))) {
2998                    $ret_or_1
2999                  } else {
3000                    attrs['$[]=']("window", "_blank")
3001                  }
3002                } else {
3003                  attrs = $hash2(["window"], {"window": "_blank"})
3004                };
3005              };
3006            };
3007            if ($truthy(link_text['$empty?']())) {
3008              if ($truthy(mailto)) {
3009                link_text = mailto_text
3010              } else {
3011
3012                if ($truthy(doc_attrs['$key?']("hide-uri-scheme"))) {
3013                  if ($truthy((link_text = target.$sub($$('UriSniffRx'), ""))['$empty?']())) {
3014                    link_text = target
3015                  }
3016                } else {
3017                  link_text = target
3018                };
3019                if ($truthy(attrs)) {
3020                  attrs['$[]=']("role", ($truthy(attrs['$key?']("role")) ? ("bare " + (attrs['$[]']("role"))) : ("bare")))
3021                } else {
3022                  attrs = $hash2(["role"], {"role": "bare"})
3023                };
3024              }
3025            };
3026            doc.$register("links", ($a = ["target", target], $send(link_opts, '[]=', $a), $a[$a.length - 1]));
3027            if ($truthy(attrs)) {
3028              link_opts['$[]=']("attributes", attrs)
3029            };
3030            return $$('Inline').$new(self, "anchor", link_text, link_opts).$convert();}, {$$s: self})
3031        };
3032        if ($truthy(text['$include?']("@"))) {
3033          text = $send(text, 'gsub', [$$('InlineEmailRx')], function $$27(){var $a, self = $$27.$$s == null ? this : $$27.$$s, target = nil, address = nil;
3034
3035
3036            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
3037              return ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $$('RS')) ? ((($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))))
3038            };
3039            target = $rb_plus("mailto:", (address = (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))));
3040            doc.$register("links", target);
3041            return $$('Inline').$new(self, "anchor", address, $hash2(["type", "target"], {"type": "link", "target": target})).$convert();}, {$$s: self})
3042        };
3043        if ((($truthy(found_square_bracket) && ($eqeq(self.context, "list_item"))) && ($eqeq(self.parent.$style(), "bibliography")))) {
3044          text = $send(text, 'sub', [$$('InlineBiblioAnchorRx')], function $$28(){var $a, self = $$28.$$s == null ? this : $$28.$$s;
3045
3046            return $$('Inline').$new(self, "anchor", (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), $hash2(["type", "id"], {"type": "bibref", "id": (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))})).$convert()}, {$$s: self})
3047        };
3048        if ((($truthy(found_square_bracket) && ($truthy(text['$include?']("[[")))) || (($truthy(found_macroish) && ($truthy(text['$include?']("or:"))))))) {
3049          text = $send(text, 'gsub', [$$('InlineAnchorRx')], function $$29(){var $a, self = $$29.$$s == null ? this : $$29.$$s, id = nil, reftext = nil;
3050
3051
3052            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
3053              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
3054            };
3055            if ($truthy((id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) {
3056              reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3))
3057            } else {
3058
3059              id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4));
3060              if (($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)))) && ($truthy(reftext['$include?']($$('R_SB')))))) {
3061                reftext = reftext.$gsub($$('ESC_R_SB'), $$('R_SB'))
3062              };
3063            };
3064            return $$('Inline').$new(self, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id})).$convert();}, {$$s: self})
3065        };
3066        if ((($truthy(text['$include?']("&")) && ($truthy(text['$include?'](";&l")))) || (($truthy(found_macroish) && ($truthy(text['$include?']("xref:"))))))) {
3067          text = $send(text, 'gsub', [$$('InlineXrefMacroRx')], function $$30(){var $a, $b, self = $$30.$$s == null ? this : $$30.$$s, attrs = nil, refid = nil, _ = nil, link_text = nil, macro = nil, fragment = nil, hash_idx = nil, fragment_len = nil, path = nil, src2src = nil, target = nil;
3068
3069
3070            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
3071              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
3072            };
3073            attrs = $hash2([], {});
3074            if ($truthy((refid = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) {
3075              if ($truthy(refid['$include?'](","))) {
3076
3077                $b = refid.$partition(","), $a = $to_ary($b), (refid = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (link_text = ($a[2] == null ? nil : $a[2])), $b;
3078                if ($truthy((link_text = link_text.$lstrip())['$empty?']())) {
3079                  link_text = nil
3080                };
3081              }
3082            } else {
3083
3084              macro = true;
3085              refid = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2));
3086              if ($truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3))))) {
3087
3088                if ($truthy(link_text['$include?']($$('R_SB')))) {
3089                  link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB'))
3090                };
3091                if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) {
3092                  $b = self.$extract_attributes_from_text(link_text), $a = $to_ary($b), (link_text = ($a[0] == null ? nil : $a[0])), (attrs = ($a[1] == null ? nil : $a[1])), $b
3093                };
3094              };
3095            };
3096            if ($truthy(doc.$compat_mode())) {
3097              fragment = refid
3098            } else if (($truthy((hash_idx = refid.$index("#"))) && ($neqeq(refid['$[]']($rb_minus(hash_idx, 1)), "&")))) {
3099              if ($truthy($rb_gt(hash_idx, 0))) {
3100
3101                if ($truthy($rb_gt((fragment_len = $rb_minus($rb_minus(refid.$length(), 1), hash_idx)), 0))) {
3102                  $a = [refid.$slice(0, hash_idx), refid.$slice($rb_plus(hash_idx, 1), fragment_len)], (path = $a[0]), (fragment = $a[1]), $a
3103                } else {
3104                  path = refid.$chop()
3105                };
3106                if ($truthy(macro)) {
3107                  if ($truthy(path['$end_with?'](".adoc"))) {
3108                    src2src = (path = path.$slice(0, $rb_minus(path.$length(), 5)))
3109                  } else if ($not($$('Helpers')['$extname?'](path))) {
3110                    src2src = path
3111                  }
3112                } else if ($truthy($send(path, 'end_with?', $to_a($$('ASCIIDOC_EXTENSIONS').$keys())))) {
3113                  src2src = (path = path.$slice(0, path.$rindex(".")))
3114                } else {
3115                  src2src = path
3116                };
3117              } else {
3118                $a = [refid, refid.$slice(1, refid.$length())], (target = $a[0]), (fragment = $a[1]), $a
3119              }
3120            } else if ($truthy(macro)) {
3121              if ($truthy(refid['$end_with?'](".adoc"))) {
3122                src2src = (path = refid.$slice(0, $rb_minus(refid.$length(), 5)))
3123              } else if ($truthy($$('Helpers')['$extname?'](refid))) {
3124                path = refid
3125              } else {
3126                fragment = refid
3127              }
3128            } else {
3129              fragment = refid
3130            };
3131            if ($truthy(target)) {
3132
3133              refid = fragment;
3134              if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) {
3135                self.$logger().$info("possible invalid reference: " + (refid))
3136              };
3137            } else if ($truthy(path)) {
3138              if (($truthy(src2src) && (($eqeq(doc.$attributes()['$[]']("docname"), path) || ($truthy(doc.$catalog()['$[]']("includes")['$[]'](path))))))) {
3139                if ($truthy(fragment)) {
3140
3141                  $a = [fragment, nil, "#" + (fragment)], (refid = $a[0]), (path = $a[1]), (target = $a[2]), $a;
3142                  if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) {
3143                    self.$logger().$info("possible invalid reference: " + (refid))
3144                  };
3145                } else {
3146                  $a = [nil, nil, "#"], (refid = $a[0]), (path = $a[1]), (target = $a[2]), $a
3147                }
3148              } else {
3149
3150                $a = [path, "" + (($truthy(($ret_or_1 = doc.$attributes()['$[]']("relfileprefix"))) ? ($ret_or_1) : (""))) + (path) + (($truthy(src2src) ? (doc.$attributes().$fetch("relfilesuffix", doc.$outfilesuffix())) : ("")))], (refid = $a[0]), (path = $a[1]), $a;
3151                if ($truthy(fragment)) {
3152                  $a = ["" + (refid) + "#" + (fragment), "" + (path) + "#" + (fragment)], (refid = $a[0]), (target = $a[1]), $a
3153                } else {
3154                  target = path
3155                };
3156              }
3157            } else if (($truthy(doc.$compat_mode()) || ($not($$('Compliance').$natural_xrefs())))) {
3158
3159              $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]), $a;
3160              if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) {
3161                self.$logger().$info("possible invalid reference: " + (refid))
3162              };
3163            } else if ($truthy(doc.$catalog()['$[]']("refs")['$[]'](fragment))) {
3164              $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]), $a
3165            } else if ((($truthy(fragment['$include?'](" ")) || ($neqeq(fragment.$downcase(), fragment))) && ($truthy((refid = doc.$resolve_id(fragment)))))) {
3166              $a = [refid, "#" + (refid)], (fragment = $a[0]), (target = $a[1]), $a
3167            } else {
3168
3169              $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]), $a;
3170              if ($truthy(self.$logger()['$info?']())) {
3171                self.$logger().$info("possible invalid reference: " + (refid))
3172              };
3173            };
3174            attrs['$[]=']("path", path);
3175            attrs['$[]=']("fragment", fragment);
3176            attrs['$[]=']("refid", refid);
3177            return $$('Inline').$new(self, "anchor", link_text, $hash2(["type", "target", "attributes"], {"type": "xref", "target": target, "attributes": attrs})).$convert();}, {$$s: self})
3178        };
3179        if (($truthy(found_macroish) && ($truthy(text['$include?']("tnote"))))) {
3180          text = $send(text, 'gsub', [$$('InlineFootnoteMacroRx')], function $$31(){var $a, $b, $c, self = $$31.$$s == null ? this : $$31.$$s, id = nil, content = nil, footnote = nil, index = nil, type = nil, target = nil;
3181
3182
3183            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) {
3184              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
3185            };
3186            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
3187              if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) {
3188
3189                $b = (($c = $gvars['~']) === nil ? nil : $c['$[]'](3)).$split(",", 2), $a = $to_ary($b), (id = ($a[0] == null ? nil : $a[0])), (content = ($a[1] == null ? nil : $a[1])), $b;
3190                if (!$truthy(doc.$compat_mode())) {
3191                  self.$logger().$warn("found deprecated footnoteref macro: " + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))) + "; use footnote macro with target instead")
3192                };
3193              } else {
3194                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
3195              }
3196            } else {
3197
3198              id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2));
3199              content = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3));
3200            };
3201            if ($truthy(id)) {
3202              if ($truthy((footnote = $send(doc.$footnotes(), 'find', [], function $$32(candidate){
3203
3204                if (candidate == null) candidate = nil;
3205                return candidate.$id()['$=='](id);})))) {
3206
3207                $a = [footnote.$index(), footnote.$text()], (index = $a[0]), (content = $a[1]), $a;
3208                $a = ["xref", id, nil], (type = $a[0]), (target = $a[1]), (id = $a[2]), $a;
3209              } else if ($truthy(content)) {
3210
3211                content = self.$restore_passthroughs(self.$normalize_text(content, true, true));
3212                index = doc.$counter("footnote-number");
3213                doc.$register("footnotes", $$$($$('Document'), 'Footnote').$new(index, id, content));
3214                $a = ["ref", nil], (type = $a[0]), (target = $a[1]), $a;
3215              } else {
3216
3217                self.$logger().$warn("invalid footnote reference: " + (id));
3218                $a = ["xref", id, id, nil], (type = $a[0]), (target = $a[1]), (content = $a[2]), (id = $a[3]), $a;
3219              }
3220            } else if ($truthy(content)) {
3221
3222              content = self.$restore_passthroughs(self.$normalize_text(content, true, true));
3223              index = doc.$counter("footnote-number");
3224              doc.$register("footnotes", $$$($$('Document'), 'Footnote').$new(index, id, content));
3225              type = (target = nil);
3226            } else {
3227              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))
3228            };
3229            return $$('Inline').$new(self, "footnote", content, $hash2(["attributes", "id", "target", "type"], {"attributes": $hash2(["index"], {"index": index}), "id": id, "target": target, "type": type})).$convert();}, {$$s: self})
3230        };
3231        return text;
3232      });
3233
3234      $def(self, '$sub_post_replacements', function $$sub_post_replacements(text) {
3235        var self = this, lines = nil, last = nil;
3236        if (self.document == null) self.document = nil;
3237        if (self.attributes == null) self.attributes = nil;
3238
3239        if (($truthy(self.attributes['$[]']("hardbreaks-option")) || ($truthy(self.document.$attributes()['$[]']("hardbreaks-option"))))) {
3240
3241          lines = text.$split($$('LF'), -1);
3242          if ($truthy($rb_lt(lines.$size(), 2))) {
3243            return text
3244          };
3245          last = lines.$pop();
3246          return $send(lines, 'map', [], function $$33(line){var self = $$33.$$s == null ? this : $$33.$$s;
3247
3248
3249            if (line == null) line = nil;
3250            return $$('Inline').$new(self, "break", ($truthy(line['$end_with?']($$('HARD_LINE_BREAK'))) ? (line.$slice(0, $rb_minus(line.$length(), 2))) : (line)), $hash2(["type"], {"type": "line"})).$convert();}, {$$s: self})['$<<'](last).$join($$('LF'));
3251        } else if (($truthy(text['$include?']($$('PLUS'))) && ($truthy(text['$include?']($$('HARD_LINE_BREAK')))))) {
3252          return $send(text, 'gsub', [$$('HardLineBreakRx')], function $$34(){var $a, self = $$34.$$s == null ? this : $$34.$$s;
3253
3254            return $$('Inline').$new(self, "break", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $hash2(["type"], {"type": "line"})).$convert()}, {$$s: self})
3255        } else {
3256          return text
3257        }
3258      });
3259
3260      $def(self, '$sub_source', function $$sub_source(source, process_callouts) {
3261        var self = this;
3262
3263        if ($truthy(process_callouts)) {
3264          return self.$sub_callouts(self.$sub_specialchars(source))
3265        } else {
3266
3267          return self.$sub_specialchars(source);
3268        }
3269      });
3270
3271      $def(self, '$sub_callouts', function $$sub_callouts(text) {
3272        var self = this, callout_rx = nil, autonum = nil;
3273
3274
3275        callout_rx = ($truthy(self['$attr?']("line-comment")) ? ($$('CalloutSourceRxMap')['$[]'](self.$attr("line-comment"))) : ($$('CalloutSourceRx')));
3276        autonum = 0;
3277        return $send(text, 'gsub', [callout_rx], function $$35(){var $a, self = $$35.$$s == null ? this : $$35.$$s, $ret_or_1 = nil;
3278          if (self.document == null) self.document = nil;
3279
3280          if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) {
3281            return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$sub($$('RS'), "")
3282          } else {
3283            return $$('Inline').$new(self, "callout", ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)), ".") ? ((autonum = $rb_plus(autonum, 1)).$to_s()) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)))), $hash2(["id", "attributes"], {"id": self.document.$callouts().$read_next_id(), "attributes": $hash2(["guard"], {"guard": ($truthy(($ret_or_1 = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) ? ($ret_or_1) : (($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)), "--") ? (["<!--", "-->"]) : (nil))))})})).$convert()
3284          }}, {$$s: self});
3285      });
3286
3287      $def(self, '$highlight_source', function $$highlight_source(source, process_callouts) {
3288        var $a, $b, self = this, syntax_hl = nil, callout_marks = nil, doc_attrs = nil, syntax_hl_name = nil, start_line_number = nil, linenums_mode = nil, $ret_or_1 = nil, highlight_lines = nil, highlighted = nil, source_offset = nil;
3289        if (self.document == null) self.document = nil;
3290        if (self.passthroughs == null) self.passthroughs = nil;
3291
3292
3293        if (!($truthy((syntax_hl = self.document.$syntax_highlighter())) && ($truthy(syntax_hl['$highlight?']())))) {
3294          return self.$sub_source(source, process_callouts)
3295        };
3296        if ($truthy(process_callouts)) {
3297          $b = self.$extract_callouts(source), $a = $to_ary($b), (source = ($a[0] == null ? nil : $a[0])), (callout_marks = ($a[1] == null ? nil : $a[1])), $b
3298        };
3299        doc_attrs = self.document.$attributes();
3300        syntax_hl_name = syntax_hl.$name();
3301        if (($truthy((linenums_mode = ($truthy(self['$attr?']("linenums")) ? (($truthy(($ret_or_1 = doc_attrs['$[]']("" + (syntax_hl_name) + "-linenums-mode"))) ? ($ret_or_1) : ("table")).$to_sym()) : (nil)))) && ($truthy($rb_lt((start_line_number = self.$attr("start", 1).$to_i()), 1))))) {
3302          start_line_number = 1
3303        };
3304        if ($truthy(self['$attr?']("highlight"))) {
3305          highlight_lines = self.$resolve_lines_to_highlight(source, self.$attr("highlight"), start_line_number)
3306        };
3307        $b = syntax_hl.$highlight(self, source, self.$attr("language"), $hash2(["callouts", "css_mode", "highlight_lines", "number_lines", "start_line_number", "style"], {"callouts": callout_marks, "css_mode": ($truthy(($ret_or_1 = doc_attrs['$[]']("" + (syntax_hl_name) + "-css"))) ? ($ret_or_1) : ("class")).$to_sym(), "highlight_lines": highlight_lines, "number_lines": linenums_mode, "start_line_number": start_line_number, "style": doc_attrs['$[]']("" + (syntax_hl_name) + "-style")})), $a = $to_ary($b), (highlighted = ($a[0] == null ? nil : $a[0])), (source_offset = ($a[1] == null ? nil : $a[1])), $b;
3308        if (!$truthy(self.passthroughs['$empty?']())) {
3309          highlighted = highlighted.$gsub($$('HighlightedPassSlotRx'), "" + ($$('PASS_START')) + "\\1" + ($$('PASS_END')))
3310        };
3311        if ($truthy(callout_marks['$nil_or_empty?']())) {
3312          return highlighted
3313        } else {
3314
3315          return self.$restore_callouts(highlighted, callout_marks, source_offset);
3316        };
3317      });
3318
3319      $def(self, '$resolve_lines_to_highlight', function $$resolve_lines_to_highlight(source, spec, start) {
3320        var lines = nil, shift = nil;
3321
3322
3323        if (start == null) start = nil;
3324        lines = [];
3325        if ($truthy(spec['$include?'](" "))) {
3326          spec = spec.$delete(" ")
3327        };
3328        $send(($truthy(spec['$include?'](",")) ? (spec.$split(",")) : (spec.$split(";"))), 'map', [], function $$36(entry){var $a, $b, negate = nil, delim = nil, from = nil, _ = nil, to = nil, line = nil;
3329
3330
3331          if (entry == null) entry = nil;
3332          if ($truthy(entry['$start_with?']("!"))) {
3333
3334            entry = entry.$slice(1, entry.$length());
3335            negate = true;
3336          };
3337          if ($truthy((delim = ($truthy(entry['$include?']("..")) ? ("..") : (($truthy(entry['$include?']("-")) ? ("-") : (nil))))))) {
3338
3339            $b = entry.$partition(delim), $a = $to_ary($b), (from = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (to = ($a[2] == null ? nil : $a[2])), $b;
3340            if (($truthy(to['$empty?']()) || ($truthy($rb_lt((to = to.$to_i()), 0))))) {
3341              to = $rb_plus(source.$count($$('LF')), 1)
3342            };
3343            if ($truthy(negate)) {
3344              return (lines = $rb_minus(lines, Opal.Range.$new(from.$to_i(), to, false).$to_a()))
3345            } else {
3346              return (lines = lines['$|'](Opal.Range.$new(from.$to_i(), to, false).$to_a()))
3347            };
3348          } else if ($truthy(negate)) {
3349            return lines.$delete(entry.$to_i())
3350          } else if ($not(lines['$include?']((line = entry.$to_i())))) {
3351            return lines['$<<'](line)
3352          } else {
3353            return nil
3354          };});
3355        if (!$eqeq((shift = ($truthy(start) ? ($rb_minus(start, 1)) : (0))), 0)) {
3356          lines = $send(lines, 'map', [], function $$37(it){
3357
3358            if (it == null) it = nil;
3359            return $rb_minus(it, shift);})
3360        };
3361        return lines.$sort();
3362      }, -3);
3363
3364      $def(self, '$extract_passthroughs', function $$extract_passthroughs(text) {
3365        var $a, $b, self = this, compat_mode = nil, passthrus = nil, pass_inline_char1 = nil, pass_inline_char2 = nil, pass_inline_rx = nil;
3366        if (self.document == null) self.document = nil;
3367        if (self.passthroughs == null) self.passthroughs = nil;
3368
3369
3370        compat_mode = self.document.$compat_mode();
3371        passthrus = self.passthroughs;
3372        if ((($truthy(text['$include?']("++")) || ($truthy(text['$include?']("$$")))) || ($truthy(text['$include?']("ss:"))))) {
3373          text = $send(text, 'gsub', [$$('InlinePassMacroRx')], function $$38(){var $a, self = $$38.$$s == null ? this : $$38.$$s, boundary = nil, attrlist = nil, escape_count = nil, preceding = nil, old_behavior = nil, attributes = nil, subs = nil, passthru_key = nil, $ret_or_1 = nil;
3374
3375
3376            if ($truthy((boundary = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4))))) {
3377
3378              if (($truthy(compat_mode) && ($eqeq(boundary, "++")))) {
3379                return "" + (($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](2))) ? ("" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) + "[" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2))) + "]" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) : ("" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))))) + "++" + (self.$extract_passthroughs((($a = $gvars['~']) === nil ? nil : $a['$[]'](5)))) + "++"
3380              };
3381              if ($truthy((attrlist = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) {
3382                if ($truthy($rb_gt((escape_count = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$length()), 0))) {
3383                  return "" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) + "[" + (attrlist) + "]" + ($rb_times($$('RS'), $rb_minus(escape_count, 1))) + (boundary) + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](5))) + (boundary)
3384                } else if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $$('RS'))) {
3385                  preceding = "[" + (attrlist) + "]"
3386                } else if ($eqeq(boundary, "++")) {
3387                  if ($eqeq(attrlist, "x-")) {
3388
3389                    old_behavior = true;
3390                    attributes = $hash2([], {});
3391                  } else if ($truthy(attrlist['$end_with?'](" x-"))) {
3392
3393                    old_behavior = true;
3394                    attributes = self.$parse_quoted_text_attributes(attrlist.$slice(0, $rb_minus(attrlist.$length(), 3)));
3395                  } else {
3396                    attributes = self.$parse_quoted_text_attributes(attrlist)
3397                  }
3398                } else {
3399                  attributes = self.$parse_quoted_text_attributes(attrlist)
3400                }
3401              } else if ($truthy($rb_gt((escape_count = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$length()), 0))) {
3402                return "" + ($rb_times($$('RS'), $rb_minus(escape_count, 1))) + (boundary) + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](5))) + (boundary)
3403              };
3404              subs = ($eqeq(boundary, "+++") ? ([]) : ($$('BASIC_SUBS')));
3405              if ($truthy(attributes)) {
3406                if ($truthy(old_behavior)) {
3407                  passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type", "attributes"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": $$('NORMAL_SUBS'), "type": "monospaced", "attributes": attributes}))
3408                } else {
3409                  passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type", "attributes"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": subs, "type": "unquoted", "attributes": attributes}))
3410                }
3411              } else {
3412                passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": subs}))
3413              };
3414            } else {
3415
3416              if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](6)), $$('RS'))) {
3417                return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length())
3418              };
3419              if ($truthy((subs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](7))))) {
3420                passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs"], {"text": self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](8)), nil, true), "subs": self.$resolve_pass_subs(subs)}))
3421              } else {
3422                passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text"], {"text": self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](8)), nil, true)}))
3423              };
3424            };
3425            return "" + (($truthy(($ret_or_1 = preceding)) ? ($ret_or_1) : (""))) + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self})
3426        };
3427        $b = $$('InlinePassRx')['$[]'](compat_mode), $a = $to_ary($b), (pass_inline_char1 = ($a[0] == null ? nil : $a[0])), (pass_inline_char2 = ($a[1] == null ? nil : $a[1])), (pass_inline_rx = ($a[2] == null ? nil : $a[2])), $b;
3428        if (($truthy(text['$include?'](pass_inline_char1)) || (($truthy(pass_inline_char2) && ($truthy(text['$include?'](pass_inline_char2))))))) {
3429          text = $send(text, 'gsub', [pass_inline_rx], function $$39(){var $c, self = $$39.$$s == null ? this : $$39.$$s, preceding = nil, attrlist = nil, $ret_or_1 = nil, escaped = nil, quoted_text = nil, format_mark = nil, content = nil, old_behavior = nil, old_behavior_forced = nil, attributes = nil, passthru_key = nil, subs = nil;
3430
3431
3432            preceding = (($c = $gvars['~']) === nil ? nil : $c['$[]'](1));
3433            attrlist = ($truthy(($ret_or_1 = (($c = $gvars['~']) === nil ? nil : $c['$[]'](4)))) ? ($ret_or_1) : ((($c = $gvars['~']) === nil ? nil : $c['$[]'](3))));
3434            if ($truthy((($c = $gvars['~']) === nil ? nil : $c['$[]'](5)))) {
3435              escaped = true
3436            };
3437            quoted_text = (($c = $gvars['~']) === nil ? nil : $c['$[]'](6));
3438            format_mark = (($c = $gvars['~']) === nil ? nil : $c['$[]'](7));
3439            content = (($c = $gvars['~']) === nil ? nil : $c['$[]'](8));
3440            if ($truthy(compat_mode)) {
3441              old_behavior = true
3442            } else if (($truthy(attrlist) && (($eqeq(attrlist, "x-") || ($truthy(attrlist['$end_with?'](" x-"))))))) {
3443              old_behavior = (old_behavior_forced = true)
3444            };
3445            if ($truthy(attrlist)) {
3446              if ($truthy(escaped)) {
3447                return "" + (preceding) + "[" + (attrlist) + "]" + (quoted_text.$slice(1, quoted_text.$length()))
3448              } else if ($eqeq(preceding, $$('RS'))) {
3449
3450                if (($truthy(old_behavior_forced) && ($eqeq(format_mark, "`")))) {
3451                  return "" + (preceding) + "[" + (attrlist) + "]" + (quoted_text)
3452                };
3453                preceding = "[" + (attrlist) + "]";
3454              } else if ($truthy(old_behavior_forced)) {
3455                attributes = ($eqeq(attrlist, "x-") ? ($hash2([], {})) : (self.$parse_quoted_text_attributes(attrlist.$slice(0, $rb_minus(attrlist.$length(), 3)))))
3456              } else {
3457                attributes = self.$parse_quoted_text_attributes(attrlist)
3458              }
3459            } else if ($truthy(escaped)) {
3460              return "" + (preceding) + (quoted_text.$slice(1, quoted_text.$length()))
3461            } else if (($truthy(compat_mode) && ($eqeq(preceding, $$('RS'))))) {
3462              return quoted_text
3463            };
3464            if ($truthy(compat_mode)) {
3465              passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": $$('BASIC_SUBS'), "attributes": attributes, "type": "monospaced"}))
3466            } else if ($truthy(attributes)) {
3467              if ($truthy(old_behavior)) {
3468
3469                subs = ($eqeq(format_mark, "`") ? ($$('BASIC_SUBS')) : ($$('NORMAL_SUBS')));
3470                passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": subs, "attributes": attributes, "type": "monospaced"}));
3471              } else {
3472                passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": $$('BASIC_SUBS'), "attributes": attributes, "type": "unquoted"}))
3473              }
3474            } else {
3475              passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs"], {"text": content, "subs": $$('BASIC_SUBS')}))
3476            };
3477            return "" + (preceding) + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self})
3478        };
3479        if (($truthy(text['$include?'](":")) && (($truthy(text['$include?']("stem:")) || ($truthy(text['$include?']("math:"))))))) {
3480          text = $send(text, 'gsub', [$$('InlineStemMacroRx')], function $$40(){var $c, self = $$40.$$s == null ? this : $$40.$$s, type = nil, subs = nil, content = nil, passthru_key = nil;
3481            if (self.document == null) self.document = nil;
3482
3483
3484            if ($truthy((($c = $gvars['~']) === nil ? nil : $c['$[]'](0))['$start_with?']($$('RS')))) {
3485              return (($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$slice(1, (($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$length())
3486            };
3487            if ($eqeq((type = (($c = $gvars['~']) === nil ? nil : $c['$[]'](1)).$to_sym()), "stem")) {
3488              type = $$('STEM_TYPE_ALIASES')['$[]'](self.document.$attributes()['$[]']("stem")).$to_sym()
3489            };
3490            subs = (($c = $gvars['~']) === nil ? nil : $c['$[]'](2));
3491            content = self.$normalize_text((($c = $gvars['~']) === nil ? nil : $c['$[]'](3)), nil, true);
3492            if ((($eqeq(type, "latexmath") && ($truthy(content['$start_with?']("$")))) && ($truthy(content['$end_with?']("$"))))) {
3493              content = content.$slice(1, $rb_minus(content.$length(), 2))
3494            };
3495            subs = ($truthy(subs) ? (self.$resolve_pass_subs(subs)) : (($truthy(self.document['$basebackend?']("html")) ? ($$('BASIC_SUBS')) : (nil))));
3496            passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type"], {"text": content, "subs": subs, "type": type}));
3497            return "" + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self})
3498        };
3499        return text;
3500      });
3501
3502      $def(self, '$restore_passthroughs', function $$restore_passthroughs(text) {
3503        var self = this, passthrus = nil;
3504        if (self.passthroughs == null) self.passthroughs = nil;
3505
3506
3507        passthrus = self.passthroughs;
3508        return $send(text, 'gsub', [$$('PassSlotRx')], function $$41(){var $a, self = $$41.$$s == null ? this : $$41.$$s, pass = nil, subbed_text = nil, type = nil, attributes = nil, id = nil;
3509
3510          if ($truthy((pass = passthrus['$[]']((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)).$to_i())))) {
3511
3512            subbed_text = self.$apply_subs(pass['$[]']("text"), pass['$[]']("subs"));
3513            if ($truthy((type = pass['$[]']("type")))) {
3514
3515              if ($truthy((attributes = pass['$[]']("attributes")))) {
3516                id = attributes['$[]']("id")
3517              };
3518              subbed_text = $$('Inline').$new(self, "quoted", subbed_text, $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert();
3519            };
3520            if ($truthy(subbed_text['$include?']($$('PASS_START')))) {
3521              return self.$restore_passthroughs(subbed_text)
3522            } else {
3523              return subbed_text
3524            };
3525          } else {
3526
3527            self.$logger().$error("unresolved passthrough detected: " + (text));
3528            return "??pass??";
3529          }}, {$$s: self});
3530      });
3531
3532      $def(self, '$resolve_subs', function $$resolve_subs(subs, type, defaults, subject) {
3533        var self = this, candidates = nil, modifiers_present = nil, resolved = nil, invalid = nil;
3534
3535
3536        if (type == null) type = "block";
3537        if (defaults == null) defaults = nil;
3538        if (subject == null) subject = nil;
3539        if ($truthy(subs['$nil_or_empty?']())) {
3540          return nil
3541        };
3542        candidates = nil;
3543        if ($truthy(subs['$include?'](" "))) {
3544          subs = subs.$delete(" ")
3545        };
3546        modifiers_present = $$('SubModifierSniffRx')['$match?'](subs);
3547        $send(subs.$split(","), 'each', [], function $$42(key){var modifier_operation = nil, first = nil, resolved_keys = nil, resolved_key = nil, candidate = nil, $ret_or_1 = nil;
3548
3549
3550          if (key == null) key = nil;
3551          modifier_operation = nil;
3552          if ($truthy(modifiers_present)) {
3553            if ($eqeq((first = key.$chr()), "+")) {
3554
3555              modifier_operation = "append";
3556              key = key.$slice(1, key.$length());
3557            } else if ($eqeq(first, "-")) {
3558
3559              modifier_operation = "remove";
3560              key = key.$slice(1, key.$length());
3561            } else if ($truthy(key['$end_with?']("+"))) {
3562
3563              modifier_operation = "prepend";
3564              key = key.$chop();
3565            }
3566          };
3567          key = key.$to_sym();
3568          if (($eqeq(type, "inline") && (($eqeq(key, "verbatim") || ($eqeq(key, "v")))))) {
3569            resolved_keys = $$('BASIC_SUBS')
3570          } else if ($truthy($$('SUB_GROUPS')['$key?'](key))) {
3571            resolved_keys = $$('SUB_GROUPS')['$[]'](key)
3572          } else if ((($eqeq(type, "inline") && ($eqeq(key.$length(), 1))) && ($truthy($$('SUB_HINTS')['$key?'](key))))) {
3573
3574            resolved_key = $$('SUB_HINTS')['$[]'](key);
3575            if ($truthy((candidate = $$('SUB_GROUPS')['$[]'](resolved_key)))) {
3576              resolved_keys = candidate
3577            } else {
3578              resolved_keys = [resolved_key]
3579            };
3580          } else {
3581            resolved_keys = [key]
3582          };
3583          if ($truthy(modifier_operation)) {
3584
3585            candidates = ($truthy(($ret_or_1 = candidates)) ? ($ret_or_1) : (($truthy(defaults) ? (defaults.$drop(0)) : ([]))));
3586
3587            switch (modifier_operation) {
3588              case "append":
3589                return (candidates = $rb_plus(candidates, resolved_keys))
3590              case "prepend":
3591                return (candidates = $rb_plus(resolved_keys, candidates))
3592              case "remove":
3593                return (candidates = $rb_minus(candidates, resolved_keys))
3594              default:
3595                return nil
3596            };
3597          } else {
3598
3599            candidates = ($truthy(($ret_or_1 = candidates)) ? ($ret_or_1) : ([]));
3600            return (candidates = $rb_plus(candidates, resolved_keys));
3601          };});
3602        if (!$truthy(candidates)) {
3603          return nil
3604        };
3605        resolved = candidates['$&']($$('SUB_OPTIONS')['$[]'](type));
3606        if (!$truthy($rb_minus(candidates, resolved)['$empty?']())) {
3607
3608          invalid = $rb_minus(candidates, resolved);
3609          self.$logger().$warn("invalid substitution type" + (($truthy($rb_gt(invalid.$size(), 1)) ? ("s") : (""))) + (($truthy(subject) ? (" for ") : (""))) + (subject) + ": " + (invalid.$join(", ")));
3610        };
3611        return resolved;
3612      }, -2);
3613
3614      $def(self, '$resolve_block_subs', function $$resolve_block_subs(subs, defaults, subject) {
3615        var self = this;
3616
3617        return self.$resolve_subs(subs, "block", defaults, subject)
3618      });
3619
3620      $def(self, '$resolve_pass_subs', function $$resolve_pass_subs(subs) {
3621        var self = this;
3622
3623        return self.$resolve_subs(subs, "inline", nil, "passthrough macro")
3624      });
3625
3626      $def(self, '$expand_subs', function $$expand_subs(subs, subject) {
3627        var self = this, $ret_or_1 = nil, $ret_or_2 = nil, expanded_subs = nil;
3628
3629
3630        if (subject == null) subject = nil;
3631        if ($eqeqeq($$$('Symbol'), ($ret_or_1 = subs))) {
3632          if ($eqeq(subs, "none")) {
3633            return nil
3634          } else if ($truthy(($ret_or_2 = $$('SUB_GROUPS')['$[]'](subs)))) {
3635            return $ret_or_2
3636          } else {
3637            return [subs]
3638          }
3639        } else if ($eqeqeq($$$('Array'), $ret_or_1)) {
3640
3641          expanded_subs = [];
3642          $send(subs, 'each', [], function $$43(key){var sub_group = nil;
3643
3644
3645            if (key == null) key = nil;
3646            if ($eqeq(key, "none")) {
3647              return nil
3648            } else if ($truthy((sub_group = $$('SUB_GROUPS')['$[]'](key)))) {
3649              return (expanded_subs = $rb_plus(expanded_subs, sub_group))
3650            } else {
3651              return expanded_subs['$<<'](key)
3652            };});
3653          if ($truthy(expanded_subs['$empty?']())) {
3654            return nil
3655          } else {
3656            return expanded_subs
3657          };
3658        } else {
3659          return self.$resolve_subs(subs, "inline", nil, subject)
3660        };
3661      }, -2);
3662
3663      $def(self, '$commit_subs', function $$commit_subs() {
3664        var self = this, default_subs = nil, custom_subs = nil, $ret_or_1 = nil, idx = nil, syntax_hl = nil;
3665        if (self.default_subs == null) self.default_subs = nil;
3666        if (self.content_model == null) self.content_model = nil;
3667        if (self.context == null) self.context = nil;
3668        if (self.subs == null) self.subs = nil;
3669        if (self.attributes == null) self.attributes = nil;
3670        if (self.document == null) self.document = nil;
3671        if (self.style == null) self.style = nil;
3672
3673
3674        if (!$truthy((default_subs = self.default_subs))) {
3675
3676          switch (self.content_model) {
3677            case "simple":
3678              default_subs = $$('NORMAL_SUBS')
3679              break;
3680            case "verbatim":
3681              default_subs = ($eqeq(self.context, "verse") ? ($$('NORMAL_SUBS')) : ($$('VERBATIM_SUBS')))
3682              break;
3683            case "raw":
3684              default_subs = ($eqeq(self.context, "stem") ? ($$('BASIC_SUBS')) : ($$('NO_SUBS')))
3685              break;
3686            default:
3687              return self.subs
3688          }
3689        };
3690        if ($truthy((custom_subs = self.attributes['$[]']("subs")))) {
3691          self.subs = ($truthy(($ret_or_1 = self.$resolve_block_subs(custom_subs, default_subs, self.context))) ? ($ret_or_1) : ([]))
3692        } else {
3693          self.subs = default_subs.$drop(0)
3694        };
3695        if ((((($eqeq(self.context, "listing") && ($eqeq(self.style, "source"))) && ($truthy((syntax_hl = self.document.$syntax_highlighter())))) && ($truthy(syntax_hl['$highlight?']()))) && ($truthy((idx = self.subs.$index("specialcharacters")))))) {
3696          self.subs['$[]='](idx, "highlight")
3697        };
3698        return nil;
3699      });
3700
3701      $def(self, '$parse_attributes', function $$parse_attributes(attrlist, posattrs, opts) {
3702        var self = this, block = nil, into = nil;
3703        if (self.document == null) self.document = nil;
3704
3705
3706        if (posattrs == null) posattrs = [];
3707        if (opts == null) opts = $hash2([], {});
3708        if ($truthy(($truthy(attrlist) ? (attrlist['$empty?']()) : (true)))) {
3709          return $hash2([], {})
3710        };
3711        if ($truthy(opts['$[]']("unescape_input"))) {
3712          attrlist = self.$normalize_text(attrlist, true, true)
3713        };
3714        if (($truthy(opts['$[]']("sub_input")) && ($truthy(attrlist['$include?']($$('ATTR_REF_HEAD')))))) {
3715          attrlist = self.document.$sub_attributes(attrlist)
3716        };
3717        if ($truthy(opts['$[]']("sub_result"))) {
3718          block = self
3719        };
3720        if ($truthy((into = opts['$[]']("into")))) {
3721          return $$('AttributeList').$new(attrlist, block).$parse_into(into, posattrs)
3722        } else {
3723          return $$('AttributeList').$new(attrlist, block).$parse(posattrs)
3724        };
3725      }, -2);
3726      self.$private();
3727
3728      $def(self, '$extract_attributes_from_text', function $$extract_attributes_from_text(text, default_text) {
3729        var self = this, attrlist = nil, resolved_text = nil, attrs = nil;
3730
3731
3732        if (default_text == null) default_text = nil;
3733        attrlist = ($truthy(text['$include?']($$('LF'))) ? (text.$tr($$('LF'), " ")) : (text));
3734        if ($truthy((resolved_text = (attrs = $$('AttributeList').$new(attrlist, self).$parse())['$[]'](1)))) {
3735          if ($eqeq(resolved_text, attrlist)) {
3736            return [text, attrs.$clear()]
3737          } else {
3738            return [resolved_text, attrs]
3739          }
3740        } else {
3741          return [default_text, attrs]
3742        };
3743      }, -2);
3744
3745      $def(self, '$extract_callouts', function $$extract_callouts(source) {
3746        var self = this, callout_marks = nil, autonum = nil, lineno = nil, last_lineno = nil, callout_rx = nil;
3747
3748
3749        callout_marks = $hash2([], {});
3750        autonum = (lineno = 0);
3751        last_lineno = nil;
3752        callout_rx = ($truthy(self['$attr?']("line-comment")) ? ($$('CalloutExtractRxMap')['$[]'](self.$attr("line-comment"))) : ($$('CalloutExtractRx')));
3753        source = $send(source.$split($$('LF'), -1), 'map', [], function $$44(line){
3754
3755          if (line == null) line = nil;
3756          lineno = $rb_plus(lineno, 1);
3757          return $send(line, 'gsub', [callout_rx], function $$45(){var $a, $ret_or_1 = nil;
3758
3759            if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) {
3760              return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$sub($$('RS'), "")
3761            } else {
3762
3763              ($truthy(($ret_or_1 = callout_marks['$[]'](lineno))) ? ($ret_or_1) : (($a = [lineno, []], $send(callout_marks, '[]=', $a), $a[$a.length - 1])))['$<<']([($truthy(($ret_or_1 = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) ? ($ret_or_1) : (($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)), "--") ? (["<!--", "-->"]) : (nil)))), ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)), ".") ? ((autonum = $rb_plus(autonum, 1)).$to_s()) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](4))))]);
3764              last_lineno = lineno;
3765              return "";
3766            }});}).$join($$('LF'));
3767        if ($truthy(last_lineno)) {
3768          if ($eqeq(last_lineno, lineno)) {
3769            source = "" + (source) + ($$('LF'))
3770          }
3771        } else {
3772          callout_marks = nil
3773        };
3774        return [source, callout_marks];
3775      });
3776
3777      $def(self, '$restore_callouts', function $$restore_callouts(source, callout_marks, source_offset) {
3778        var self = this, preamble = nil, lineno = nil;
3779
3780
3781        if (source_offset == null) source_offset = nil;
3782        if ($truthy(source_offset)) {
3783
3784          preamble = source.$slice(0, source_offset);
3785          source = source.$slice(source_offset, source.$length());
3786        } else {
3787          preamble = ""
3788        };
3789        lineno = 0;
3790        return $rb_plus(preamble, $send(source.$split($$('LF'), -1), 'map', [], function $$46(line){var $a, $b, self = $$46.$$s == null ? this : $$46.$$s, conums = nil, guard = nil, numeral = nil;
3791          if (self.document == null) self.document = nil;
3792
3793
3794          if (line == null) line = nil;
3795          if ($truthy((conums = callout_marks.$delete((lineno = $rb_plus(lineno, 1)))))) {
3796            if ($eqeq(conums.$size(), 1)) {
3797
3798              $b = conums['$[]'](0), $a = $to_ary($b), (guard = ($a[0] == null ? nil : $a[0])), (numeral = ($a[1] == null ? nil : $a[1])), $b;
3799              return "" + (line) + ($$('Inline').$new(self, "callout", numeral, $hash2(["id", "attributes"], {"id": self.document.$callouts().$read_next_id(), "attributes": $hash2(["guard"], {"guard": guard})})).$convert());
3800            } else {
3801              return "" + (line) + ($send(conums, 'map', [], function $$47(guard_it, numeral_it){var self = $$47.$$s == null ? this : $$47.$$s;
3802                if (self.document == null) self.document = nil;
3803
3804
3805                if (guard_it == null) guard_it = nil;
3806                if (numeral_it == null) numeral_it = nil;
3807                return $$('Inline').$new(self, "callout", numeral_it, $hash2(["id", "attributes"], {"id": self.document.$callouts().$read_next_id(), "attributes": $hash2(["guard"], {"guard": guard_it})})).$convert();}, {$$s: self}).$join(" "))
3808            }
3809          } else {
3810            return line
3811          };}, {$$s: self}).$join($$('LF')));
3812      }, -3);
3813
3814      $def(self, '$convert_quoted_text', function $$convert_quoted_text(match, type, scope) {
3815        var self = this, attrs = nil, unescaped_attrs = nil, attrlist = nil, id = nil, attributes = nil;
3816
3817
3818        if ($truthy(match['$[]'](0)['$start_with?']($$('RS')))) {
3819          if (($eqeq(scope, "constrained") && ($truthy((attrs = match['$[]'](2)))))) {
3820            unescaped_attrs = "[" + (attrs) + "]"
3821          } else {
3822            return match['$[]'](0).$slice(1, match['$[]'](0).$length())
3823          }
3824        };
3825        if ($eqeq(scope, "constrained")) {
3826          if ($truthy(unescaped_attrs)) {
3827            return "" + (unescaped_attrs) + ($$('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type"], {"type": type})).$convert())
3828          } else {
3829
3830            if ($truthy((attrlist = match['$[]'](2)))) {
3831
3832              id = (attributes = self.$parse_quoted_text_attributes(attrlist))['$[]']("id");
3833              if ($eqeq(type, "mark")) {
3834                type = "unquoted"
3835              };
3836            };
3837            return "" + (match['$[]'](1)) + ($$('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert());
3838          }
3839        } else {
3840
3841          if ($truthy((attrlist = match['$[]'](1)))) {
3842
3843            id = (attributes = self.$parse_quoted_text_attributes(attrlist))['$[]']("id");
3844            if ($eqeq(type, "mark")) {
3845              type = "unquoted"
3846            };
3847          };
3848          return $$('Inline').$new(self, "quoted", match['$[]'](2), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert();
3849        };
3850      });
3851
3852      $def(self, '$do_replacement', function $$do_replacement(m, replacement, restore) {
3853        var captured = nil;
3854
3855        if ($truthy((captured = m['$[]'](0))['$include?']($$('RS')))) {
3856          return captured.$sub($$('RS'), "")
3857        } else
3858        switch (restore) {
3859          case "none":
3860            return replacement
3861          case "bounding":
3862            return $rb_plus($rb_plus(m['$[]'](1), replacement), m['$[]'](2))
3863          default:
3864            return $rb_plus(m['$[]'](1), replacement)
3865        }
3866      });
3867      nil;
3868
3869      $def(self, '$parse_quoted_text_attributes', function $$parse_quoted_text_attributes(str) {
3870        var $a, $b, self = this, before = nil, _ = nil, after = nil, attrs = nil, id = nil, roles = nil;
3871
3872
3873        if ($truthy(str['$include?']($$('ATTR_REF_HEAD')))) {
3874          str = self.$sub_attributes(str)
3875        };
3876        if ($truthy(str['$include?'](","))) {
3877          str = str.$slice(0, str.$index(","))
3878        };
3879        if ($truthy((str = str.$strip())['$empty?']())) {
3880          return $hash2([], {})
3881        } else if (($truthy(str['$start_with?'](".", "#")) && ($truthy($$('Compliance').$shorthand_property_syntax())))) {
3882
3883          $b = str.$partition("#"), $a = $to_ary($b), (before = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (after = ($a[2] == null ? nil : $a[2])), $b;
3884          attrs = $hash2([], {});
3885          if ($truthy(after['$empty?']())) {
3886            if ($truthy($rb_gt(before.$length(), 1))) {
3887              attrs['$[]=']("role", before.$tr(".", " ").$lstrip())
3888            }
3889          } else {
3890
3891            $b = after.$partition("."), $a = $to_ary($b), (id = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (roles = ($a[2] == null ? nil : $a[2])), $b;
3892            if (!$truthy(id['$empty?']())) {
3893              attrs['$[]=']("id", id)
3894            };
3895            if ($truthy(roles['$empty?']())) {
3896              if ($truthy($rb_gt(before.$length(), 1))) {
3897                attrs['$[]=']("role", before.$tr(".", " ").$lstrip())
3898              }
3899            } else if ($truthy($rb_gt(before.$length(), 1))) {
3900              attrs['$[]=']("role", $rb_plus($rb_plus(before, "."), roles).$tr(".", " ").$lstrip())
3901            } else {
3902              attrs['$[]=']("role", roles.$tr(".", " "))
3903            };
3904          };
3905          return attrs;
3906        } else {
3907          return $hash2(["role"], {"role": str})
3908        };
3909      });
3910
3911      $def(self, '$normalize_text', function $$normalize_text(text, normalize_whitespace, unescape_closing_square_brackets) {
3912
3913
3914        if (normalize_whitespace == null) normalize_whitespace = nil;
3915        if (unescape_closing_square_brackets == null) unescape_closing_square_brackets = nil;
3916        if (!$truthy(text['$empty?']())) {
3917
3918          if ($truthy(normalize_whitespace)) {
3919            text = text.$strip().$tr($$('LF'), " ")
3920          };
3921          if (($truthy(unescape_closing_square_brackets) && ($truthy(text['$include?']($$('R_SB')))))) {
3922            text = text.$gsub($$('ESC_R_SB'), $$('R_SB'))
3923          };
3924        };
3925        return text;
3926      }, -2);
3927      return $def(self, '$split_simple_csv', function $$split_simple_csv(str) {
3928        var values = nil, accum = nil, quote_open = nil;
3929
3930        if ($truthy(str['$empty?']())) {
3931          return []
3932        } else if ($truthy(str['$include?']("\""))) {
3933
3934          values = [];
3935          accum = "";
3936          quote_open = nil;
3937          $send(str, 'each_char', [], function $$48(c){
3938
3939            if (c == null) c = nil;
3940
3941            switch (c) {
3942              case ",":
3943                if ($truthy(quote_open)) {
3944                  return (accum = $rb_plus(accum, c))
3945                } else {
3946
3947                  values['$<<'](accum.$strip());
3948                  return (accum = "");
3949                }
3950                break;
3951              case "\"":
3952                return (quote_open = quote_open['$!']())
3953              default:
3954                return (accum = $rb_plus(accum, c))
3955            };});
3956          return values['$<<'](accum.$strip());
3957        } else {
3958          return $send(str.$split(","), 'map', [], function $$49(it){
3959
3960            if (it == null) it = nil;
3961            return it.$strip();})
3962        }
3963      });
3964    })($nesting[0], $nesting)
3965  })($nesting[0], $nesting)
3966};
3967
3968Opal.modules["asciidoctor/version"] = function(Opal) {/* Generated by Opal 1.7.3 */
3969  "use strict";
3970  var $module = Opal.module, $const_set = Opal.const_set, $nesting = [], nil = Opal.nil;
3971
3972  return (function($base, $parent_nesting) {
3973    var self = $module($base, 'Asciidoctor');
3974
3975    var $nesting = [self].concat($parent_nesting);
3976
3977    return $const_set($nesting[0], 'VERSION', "2.0.20")
3978  })($nesting[0], $nesting)
3979};
3980
3981Opal.modules["asciidoctor/abstract_node"] = function(Opal) {/* Generated by Opal 1.7.3 */
3982  "use strict";
3983  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $eqeq = Opal.eqeq, $truthy = Opal.truthy, $def = Opal.def, $send = Opal.send, $rb_minus = Opal.rb_minus, $eqeqeq = Opal.eqeqeq, $rb_lt = Opal.rb_lt, $not = Opal.not, $to_ary = Opal.to_ary, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
3984
3985  Opal.add_stubs('include,attr_reader,attr_accessor,==,document,to_s,[],merge,raise,converter,attributes,key?,[]=,delete,tap,new,each_key,end_with?,<<,slice,-,length,update,split,include?,===,join,empty?,apply_reftext_subs,attr?,attr,extname?,image_uri,<,safe,normalize_web_path,uriish?,encode_spaces_in_uri,generate_data_uri_from_uri,generate_data_uri,extname,normalize_system_path,readable?,strict_encode64,binread,warn,logger,require_library,!,open_uri,content_type,read,base_dir,root?,path_resolver,system_path,web_path,!=,prepare_source_string,fetch,read_asset');
3986  return (function($base, $parent_nesting) {
3987    var self = $module($base, 'Asciidoctor');
3988
3989    var $nesting = [self].concat($parent_nesting);
3990
3991    return (function($base, $super, $parent_nesting) {
3992      var self = $klass($base, $super, 'AbstractNode');
3993
3994      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
3995
3996      $proto.document = $proto.attributes = $proto.parent = nil;
3997
3998      self.$include($$('Logging'));
3999      self.$include($$('Substitutors'));
4000      self.$attr_reader("attributes");
4001      self.$attr_reader("context");
4002      self.$attr_reader("document");
4003      self.$attr_accessor("id");
4004      self.$attr_reader("node_name");
4005      self.$attr_reader("parent");
4006
4007      $def(self, '$initialize', function $$initialize(parent, context, opts) {
4008        var self = this, attrs = nil;
4009
4010
4011        if (opts == null) opts = $hash2([], {});
4012        if ($eqeq(context, "document")) {
4013          self.document = self
4014        } else if ($truthy(parent)) {
4015          self.document = (self.parent = parent).$document()
4016        };
4017        self.node_name = (self.context = context).$to_s();
4018        self.attributes = ($truthy((attrs = opts['$[]']("attributes"))) ? (attrs.$merge()) : ($hash2([], {})));
4019        return (self.passthroughs = []);
4020      }, -3);
4021
4022      $def(self, '$block?', function $AbstractNode_block$ques$1() {
4023        var self = this;
4024
4025        return self.$raise($$$('NotImplementedError'))
4026      });
4027
4028      $def(self, '$inline?', function $AbstractNode_inline$ques$2() {
4029        var self = this;
4030
4031        return self.$raise($$$('NotImplementedError'))
4032      });
4033
4034      $def(self, '$converter', function $$converter() {
4035        var self = this;
4036
4037        return self.document.$converter()
4038      });
4039
4040      $def(self, '$parent=', function $AbstractNode_parent$eq$3(parent) {
4041        var $a, self = this;
4042
4043        return $a = [parent, parent.$document()], (self.parent = $a[0]), (self.document = $a[1]), $a
4044      });
4045
4046      $def(self, '$attr', function $$attr(name, default_value, fallback_name) {
4047        var self = this, $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil, $ret_or_4 = nil;
4048
4049
4050        if (default_value == null) default_value = nil;
4051        if (fallback_name == null) fallback_name = nil;
4052        if ($truthy(($ret_or_1 = self.attributes['$[]'](name.$to_s())))) {
4053          return $ret_or_1
4054        } else {
4055
4056          if ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = ($truthy(($ret_or_4 = fallback_name)) ? (self.parent) : ($ret_or_4)))) ? (self.document.$attributes()['$[]'](($eqeq(fallback_name, true) ? (name) : (fallback_name)).$to_s())) : ($ret_or_3))))) {
4057            return $ret_or_2
4058          } else {
4059            return default_value
4060          };
4061        };
4062      }, -2);
4063
4064      $def(self, '$attr?', function $AbstractNode_attr$ques$4(name, expected_value, fallback_name) {
4065        var self = this, $ret_or_1 = nil;
4066
4067
4068        if (expected_value == null) expected_value = nil;
4069        if (fallback_name == null) fallback_name = nil;
4070        if ($truthy(expected_value)) {
4071          return expected_value['$=='](($truthy(($ret_or_1 = self.attributes['$[]'](name.$to_s()))) ? ($ret_or_1) : ((($truthy(fallback_name) && ($truthy(self.parent))) ? (self.document.$attributes()['$[]'](($eqeq(fallback_name, true) ? (name) : (fallback_name)).$to_s())) : (nil)))))
4072        } else if ($truthy(($ret_or_1 = self.attributes['$key?'](name.$to_s())))) {
4073          return $ret_or_1
4074        } else {
4075
4076          if (($truthy(fallback_name) && ($truthy(self.parent)))) {
4077
4078            return self.document.$attributes()['$key?'](($eqeq(fallback_name, true) ? (name) : (fallback_name)).$to_s());
4079          } else {
4080            return false
4081          };
4082        };
4083      }, -2);
4084
4085      $def(self, '$set_attr', function $$set_attr(name, value, overwrite) {
4086        var self = this;
4087
4088
4089        if (value == null) value = "";
4090        if (overwrite == null) overwrite = true;
4091        if (($eqeq(overwrite, false) && ($truthy(self.attributes['$key?'](name))))) {
4092          return false
4093        } else {
4094
4095          self.attributes['$[]='](name, value);
4096          return true;
4097        };
4098      }, -2);
4099
4100      $def(self, '$remove_attr', function $$remove_attr(name) {
4101        var self = this;
4102
4103        return self.attributes.$delete(name)
4104      });
4105
4106      $def(self, '$option?', function $AbstractNode_option$ques$5(name) {
4107        var self = this;
4108
4109        if ($truthy(self.attributes['$[]']("" + (name) + "-option"))) {
4110          return true
4111        } else {
4112          return false
4113        }
4114      });
4115
4116      $def(self, '$set_option', function $$set_option(name) {
4117        var self = this;
4118
4119
4120        self.attributes['$[]=']("" + (name) + "-option", "");
4121        return nil;
4122      });
4123
4124      $def(self, '$enabled_options', function $$enabled_options() {
4125        var self = this;
4126
4127        return $send($$$('Set').$new(), 'tap', [], function $$6(accum){var self = $$6.$$s == null ? this : $$6.$$s;
4128          if (self.attributes == null) self.attributes = nil;
4129
4130
4131          if (accum == null) accum = nil;
4132          return $send(self.attributes, 'each_key', [], function $$7(k){
4133
4134            if (k == null) k = nil;
4135            if ($truthy(k.$to_s()['$end_with?']("-option"))) {
4136              return accum['$<<'](k.$slice(0, $rb_minus(k.$length(), 7)))
4137            } else {
4138              return nil
4139            };});}, {$$s: self})
4140      });
4141
4142      $def(self, '$update_attributes', function $$update_attributes(new_attributes) {
4143        var self = this;
4144
4145        return self.attributes.$update(new_attributes)
4146      });
4147
4148      $def(self, '$role', function $$role() {
4149        var self = this;
4150
4151        return self.attributes['$[]']("role")
4152      });
4153
4154      $def(self, '$roles', function $$roles() {
4155        var self = this, val = nil;
4156
4157        if ($truthy((val = self.attributes['$[]']("role")))) {
4158          return val.$split()
4159        } else {
4160          return []
4161        }
4162      });
4163
4164      $def(self, '$role?', function $AbstractNode_role$ques$8(expected_value) {
4165        var self = this;
4166
4167
4168        if (expected_value == null) expected_value = nil;
4169        if ($truthy(expected_value)) {
4170          return expected_value['$=='](self.attributes['$[]']("role"))
4171        } else {
4172
4173          return self.attributes['$key?']("role");
4174        };
4175      }, -1);
4176
4177      $def(self, '$has_role?', function $AbstractNode_has_role$ques$9(name) {
4178        var self = this, val = nil;
4179
4180        if ($truthy((val = self.attributes['$[]']("role")))) {
4181
4182          return (((" ") + (val)) + " ")['$include?'](" " + (name) + " ");
4183        } else {
4184          return false
4185        }
4186      });
4187
4188      $def(self, '$role=', function $AbstractNode_role$eq$10(names) {
4189        var $a, self = this;
4190
4191        return ($a = ["role", ($eqeqeq($$$('Array'), names) ? (names.$join(" ")) : (names))], $send(self.attributes, '[]=', $a), $a[$a.length - 1])
4192      });
4193
4194      $def(self, '$add_role', function $$add_role(name) {
4195        var self = this, val = nil;
4196
4197        if ($truthy((val = self.attributes['$[]']("role")))) {
4198          if ($truthy((((" ") + (val)) + " ")['$include?'](" " + (name) + " "))) {
4199            return false
4200          } else {
4201
4202            self.attributes['$[]=']("role", "" + (val) + " " + (name));
4203            return true;
4204          }
4205        } else {
4206
4207          self.attributes['$[]=']("role", name);
4208          return true;
4209        }
4210      });
4211
4212      $def(self, '$remove_role', function $$remove_role(name) {
4213        var self = this, val = nil;
4214
4215        if (($truthy((val = self.attributes['$[]']("role"))) && ($truthy((val = val.$split()).$delete(name))))) {
4216
4217          if ($truthy(val['$empty?']())) {
4218            self.attributes.$delete("role")
4219          } else {
4220            self.attributes['$[]=']("role", val.$join(" "))
4221          };
4222          return true;
4223        } else {
4224          return false
4225        }
4226      });
4227
4228      $def(self, '$reftext', function $$reftext() {
4229        var self = this, val = nil;
4230
4231        if ($truthy((val = self.attributes['$[]']("reftext")))) {
4232
4233          return self.$apply_reftext_subs(val);
4234        } else {
4235          return nil
4236        }
4237      });
4238
4239      $def(self, '$reftext?', function $AbstractNode_reftext$ques$11() {
4240        var self = this;
4241
4242        return self.attributes['$key?']("reftext")
4243      });
4244
4245      $def(self, '$icon_uri', function $$icon_uri(name) {
4246        var self = this, icon = nil;
4247
4248
4249        if ($truthy(self['$attr?']("icon"))) {
4250
4251          icon = self.$attr("icon");
4252          if (!$truthy($$('Helpers')['$extname?'](icon))) {
4253            icon = "" + (icon) + "." + (self.document.$attr("icontype", "png"))
4254          };
4255        } else {
4256          icon = "" + (name) + "." + (self.document.$attr("icontype", "png"))
4257        };
4258        return self.$image_uri(icon, "iconsdir");
4259      });
4260
4261      $def(self, '$image_uri', function $$image_uri(target_image, asset_dir_key) {
4262        var self = this, doc = nil, images_base = nil;
4263
4264
4265        if (asset_dir_key == null) asset_dir_key = "imagesdir";
4266        if (($truthy($rb_lt((doc = self.document).$safe(), $$$($$('SafeMode'), 'SECURE'))) && ($truthy(doc['$attr?']("data-uri"))))) {
4267          if ((($truthy($$('Helpers')['$uriish?'](target_image)) && ($truthy((target_image = $$('Helpers').$encode_spaces_in_uri(target_image))))) || (((($truthy(asset_dir_key) && ($truthy((images_base = doc.$attr(asset_dir_key))))) && ($truthy($$('Helpers')['$uriish?'](images_base)))) && ($truthy((target_image = self.$normalize_web_path(target_image, images_base, false)))))))) {
4268            if ($truthy(doc['$attr?']("allow-uri-read"))) {
4269
4270              return self.$generate_data_uri_from_uri(target_image, doc['$attr?']("cache-uri"));
4271            } else {
4272              return target_image
4273            }
4274          } else {
4275            return self.$generate_data_uri(target_image, asset_dir_key)
4276          }
4277        } else {
4278          return self.$normalize_web_path(target_image, ($truthy(asset_dir_key) ? (doc.$attr(asset_dir_key)) : (nil)))
4279        };
4280      }, -2);
4281
4282      $def(self, '$media_uri', function $$media_uri(target, asset_dir_key) {
4283        var self = this;
4284
4285
4286        if (asset_dir_key == null) asset_dir_key = "imagesdir";
4287        return self.$normalize_web_path(target, ($truthy(asset_dir_key) ? (self.document.$attr(asset_dir_key)) : (nil)));
4288      }, -2);
4289
4290      $def(self, '$generate_data_uri', function $$generate_data_uri(target_image, asset_dir_key) {
4291        var self = this, ext = nil, mimetype = nil, image_path = nil;
4292
4293
4294        if (asset_dir_key == null) asset_dir_key = nil;
4295        if ($truthy((ext = $$('Helpers').$extname(target_image, nil)))) {
4296          mimetype = ($eqeq(ext, ".svg") ? ("image/svg+xml") : ("image/" + (ext.$slice(1, ext.$length()))))
4297        } else {
4298          mimetype = "application/octet-stream"
4299        };
4300        if ($truthy(asset_dir_key)) {
4301          image_path = self.$normalize_system_path(target_image, self.document.$attr(asset_dir_key), nil, $hash2(["target_name"], {"target_name": "image"}))
4302        } else {
4303          image_path = self.$normalize_system_path(target_image)
4304        };
4305        if ($truthy($$$('File')['$readable?'](image_path))) {
4306          return "data:" + (mimetype) + ";base64," + ($$$('Base64').$strict_encode64($$$('File').$binread(image_path)))
4307        } else {
4308
4309          self.$logger().$warn("image to embed not found or not readable: " + (image_path));
4310          return "data:" + (mimetype) + ";base64,";
4311        };
4312      }, -2);
4313
4314      $def(self, '$generate_data_uri_from_uri', function $$generate_data_uri_from_uri(image_uri, cache_uri) {
4315        var $a, $b, self = this, mimetype = nil, bindata = nil;
4316
4317
4318        if (cache_uri == null) cache_uri = false;
4319        if ($truthy(cache_uri)) {
4320          $$('Helpers').$require_library("open-uri/cached", "open-uri-cached")
4321        } else if ($not($$('RUBY_ENGINE_OPAL'))) {
4322          $$$('OpenURI')
4323        };
4324
4325        try {
4326
4327          $b = $send($$$('OpenURI'), 'open_uri', [image_uri, $$('URI_READ_MODE')], function $$12(f){
4328
4329            if (f == null) f = nil;
4330            return [f.$content_type(), f.$read()];}), $a = $to_ary($b), (mimetype = ($a[0] == null ? nil : $a[0])), (bindata = ($a[1] == null ? nil : $a[1])), $b;
4331          return "data:" + (mimetype) + ";base64," + ($$$('Base64').$strict_encode64(bindata));
4332        } catch ($err) {
4333          if (Opal.rescue($err, [$$('StandardError')])) {
4334            try {
4335
4336              self.$logger().$warn("could not retrieve image data from URI: " + (image_uri));
4337              return image_uri;
4338            } finally { Opal.pop_exception(); }
4339          } else { throw $err; }
4340        };;
4341      }, -2);
4342
4343      $def(self, '$normalize_asset_path', function $$normalize_asset_path(asset_ref, asset_name, autocorrect) {
4344        var self = this;
4345
4346
4347        if (asset_name == null) asset_name = "path";
4348        if (autocorrect == null) autocorrect = true;
4349        return self.$normalize_system_path(asset_ref, self.document.$base_dir(), nil, $hash2(["target_name", "recover"], {"target_name": asset_name, "recover": autocorrect}));
4350      }, -2);
4351
4352      $def(self, '$normalize_system_path', function $$normalize_system_path(target, start, jail, opts) {
4353        var self = this, doc = nil, $ret_or_1 = nil;
4354
4355
4356        if (start == null) start = nil;
4357        if (jail == null) jail = nil;
4358        if (opts == null) opts = $hash2([], {});
4359        if ($truthy($rb_lt((doc = self.document).$safe(), $$$($$('SafeMode'), 'SAFE')))) {
4360          if ($truthy(start)) {
4361            if (!$truthy(doc.$path_resolver()['$root?'](start))) {
4362              start = $$$('File').$join(doc.$base_dir(), start)
4363            }
4364          } else {
4365            start = doc.$base_dir()
4366          }
4367        } else {
4368
4369          start = ($truthy(($ret_or_1 = start)) ? ($ret_or_1) : (doc.$base_dir()));
4370          jail = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (doc.$base_dir()));
4371        };
4372        return doc.$path_resolver().$system_path(target, start, jail, opts);
4373      }, -2);
4374
4375      $def(self, '$normalize_web_path', function $$normalize_web_path(target, start, preserve_uri_target) {
4376        var self = this;
4377
4378
4379        if (start == null) start = nil;
4380        if (preserve_uri_target == null) preserve_uri_target = true;
4381        if (($truthy(preserve_uri_target) && ($truthy($$('Helpers')['$uriish?'](target))))) {
4382          return $$('Helpers').$encode_spaces_in_uri(target)
4383        } else {
4384          return self.document.$path_resolver().$web_path(target, start)
4385        };
4386      }, -2);
4387
4388      $def(self, '$read_asset', function $$read_asset(path, opts) {
4389        var self = this, $ret_or_1 = nil;
4390
4391
4392        if (opts == null) opts = $hash2([], {});
4393        if (!$eqeqeq($$$('Hash'), opts)) {
4394          opts = $hash2(["warn_on_failure"], {"warn_on_failure": opts['$!='](false)})
4395        };
4396        if ($truthy($$$('File')['$readable?'](path))) {
4397          if ($truthy(opts['$[]']("normalize"))) {
4398
4399            return $$('Helpers').$prepare_source_string($$$('File').$read(path, $hash2(["mode"], {"mode": $$('FILE_READ_MODE')}))).$join($$('LF'));
4400          } else {
4401
4402            return $$$('File').$read(path, $hash2(["mode"], {"mode": $$('FILE_READ_MODE')}));
4403          }
4404        } else if ($truthy(opts['$[]']("warn_on_failure"))) {
4405
4406          self.$logger().$warn("" + (($truthy(($ret_or_1 = self.$attr("docfile"))) ? ($ret_or_1) : ("<stdin>"))) + ": " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("file"))) + " does not exist or cannot be read: " + (path));
4407          return nil;
4408        } else {
4409          return nil
4410        };
4411      }, -2);
4412
4413      $def(self, '$read_contents', function $$read_contents(target, opts) {
4414        var self = this, doc = nil, start = nil, contents = nil, $ret_or_1 = nil;
4415
4416
4417        if (opts == null) opts = $hash2([], {});
4418        doc = self.document;
4419        if (($truthy($$('Helpers')['$uriish?'](target)) || ((($truthy((start = opts['$[]']("start"))) && ($truthy($$('Helpers')['$uriish?'](start)))) && ($truthy((target = doc.$path_resolver().$web_path(target, start)))))))) {
4420          if ($truthy(doc['$attr?']("allow-uri-read"))) {
4421
4422            if ($truthy(doc['$attr?']("cache-uri"))) {
4423              $$('Helpers').$require_library("open-uri/cached", "open-uri-cached")
4424            };
4425
4426            try {
4427              if ($truthy(opts['$[]']("normalize"))) {
4428                contents = $$('Helpers').$prepare_source_string($send($$$('OpenURI'), 'open_uri', [target, $$('URI_READ_MODE')], function $$13(f){
4429
4430                  if (f == null) f = nil;
4431                  return f.$read();})).$join($$('LF'))
4432              } else {
4433                contents = $send($$$('OpenURI'), 'open_uri', [target, $$('URI_READ_MODE')], function $$14(f){
4434
4435                  if (f == null) f = nil;
4436                  return f.$read();})
4437              }
4438            } catch ($err) {
4439              if (Opal.rescue($err, [$$('StandardError')])) {
4440                try {
4441                  if ($truthy(opts.$fetch("warn_on_failure", true))) {
4442                    self.$logger().$warn("could not retrieve contents of " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))) + " at URI: " + (target))
4443                  }
4444                } finally { Opal.pop_exception(); }
4445              } else { throw $err; }
4446            };;
4447          } else if ($truthy(opts.$fetch("warn_on_failure", true))) {
4448            self.$logger().$warn("cannot retrieve contents of " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))) + " at URI: " + (target) + " (allow-uri-read attribute not enabled)")
4449          }
4450        } else {
4451
4452          target = self.$normalize_system_path(target, opts['$[]']("start"), nil, $hash2(["target_name"], {"target_name": ($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))}));
4453          contents = self.$read_asset(target, $hash2(["normalize", "warn_on_failure", "label"], {"normalize": opts['$[]']("normalize"), "warn_on_failure": opts.$fetch("warn_on_failure", true), "label": opts['$[]']("label")}));
4454        };
4455        if ((($truthy(contents) && ($truthy(opts['$[]']("warn_if_empty")))) && ($truthy(contents['$empty?']())))) {
4456          self.$logger().$warn("contents of " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))) + " is empty: " + (target))
4457        };
4458        return contents;
4459      }, -2);
4460      return $def(self, '$is_uri?', function $AbstractNode_is_uri$ques$15(str) {
4461
4462        return $$('Helpers')['$uriish?'](str)
4463      });
4464    })($nesting[0], null, $nesting)
4465  })($nesting[0], $nesting)
4466};
4467
4468Opal.modules["asciidoctor/abstract_block"] = function(Opal) {/* Generated by Opal 1.7.3 */
4469  "use strict";
4470  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $send2 = Opal.send2, $find_super = Opal.find_super, $eqeq = Opal.eqeq, $eqeqeq = Opal.eqeqeq, $def = Opal.def, $return_val = Opal.return_val, $truthy = Opal.truthy, $alias = Opal.alias, $send = Opal.send, $rb_plus = Opal.rb_plus, $not = Opal.not, $neqeq = Opal.neqeq, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
4471
4472  Opal.add_stubs('attr_reader,attr_writer,attr_accessor,==,===,level,file,lineno,playback_attributes,convert,converter,join,map,to_s,parent,parent=,<<,empty?,Integer,find_by_internal,to_proc,find_by,context,[],items,+,find_index,include?,next_adjacent_block,blocks,select,sub_specialchars,match?,sub_replacements,title,apply_title_subs,delete,!,reftext,nil_or_empty?,sub_placeholder,sub_quotes,compat_mode,attributes,chomp,increment_and_store_counter,index=,numbered,sectname,numeral=,counter,caption=,numeral,int_to_roman,each,assign_numeral,reindex_sections,protected,has_role?,raise,header?,!=,flatten,head,rows,merge,body,foot,style,inner_document');
4473  return (function($base, $parent_nesting) {
4474    var self = $module($base, 'Asciidoctor');
4475
4476    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
4477
4478    return (function($base, $super, $parent_nesting) {
4479      var self = $klass($base, $super, 'AbstractBlock');
4480
4481      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
4482
4483      $proto.source_location = $proto.document = $proto.attributes = $proto.blocks = $proto.numeral = $proto.context = $proto.parent = $proto.caption = $proto.style = $proto.converted_title = $proto.title = $proto.subs = $proto.next_section_index = $proto.next_section_ordinal = $proto.id = $proto.header = nil;
4484
4485      self.$attr_reader("blocks");
4486      self.$attr_writer("caption");
4487      self.$attr_accessor("content_model");
4488      self.$attr_accessor("level");
4489      self.$attr_accessor("numeral");
4490      self.$attr_accessor("source_location");
4491      self.$attr_accessor("style");
4492      self.$attr_reader("subs");
4493
4494      $def(self, '$initialize', function $$initialize(parent, context, opts) {
4495        var $yield = $$initialize.$$p || nil, self = this;
4496
4497        $$initialize.$$p = null;
4498
4499        if (opts == null) opts = $hash2([], {});
4500        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield);
4501        self.content_model = "compound";
4502        self.blocks = [];
4503        self.subs = [];
4504        self.id = (self.title = (self.caption = (self.numeral = (self.style = (self.default_subs = (self.source_location = nil))))));
4505        if (($eqeq(context, "document") || ($eqeq(context, "section")))) {
4506
4507          self.level = (self.next_section_index = 0);
4508          return (self.next_section_ordinal = 1);
4509        } else if ($eqeqeq($$('AbstractBlock'), parent)) {
4510          return (self.level = parent.$level())
4511        } else {
4512          return (self.level = nil)
4513        };
4514      }, -3);
4515
4516      $def(self, '$block?', $return_val(true));
4517
4518      $def(self, '$inline?', $return_val(false));
4519
4520      $def(self, '$file', function $$file() {
4521        var self = this, $ret_or_1 = nil;
4522
4523        if ($truthy(($ret_or_1 = self.source_location))) {
4524          return self.source_location.$file()
4525        } else {
4526          return $ret_or_1
4527        }
4528      });
4529
4530      $def(self, '$lineno', function $$lineno() {
4531        var self = this, $ret_or_1 = nil;
4532
4533        if ($truthy(($ret_or_1 = self.source_location))) {
4534          return self.source_location.$lineno()
4535        } else {
4536          return $ret_or_1
4537        }
4538      });
4539
4540      $def(self, '$convert', function $$convert() {
4541        var self = this;
4542
4543
4544        self.document.$playback_attributes(self.attributes);
4545        return self.$converter().$convert(self);
4546      });
4547      $alias(self, "render", "convert");
4548
4549      $def(self, '$content', function $$content() {
4550        var self = this;
4551
4552        return $send(self.blocks, 'map', [], function $$1(b){
4553
4554          if (b == null) b = nil;
4555          return b.$convert();}).$join($$('LF'))
4556      });
4557
4558      $def(self, '$context=', function $AbstractBlock_context$eq$2(context) {
4559        var self = this;
4560
4561        return (self.node_name = (self.context = context).$to_s())
4562      });
4563
4564      $def(self, '$<<', function $AbstractBlock_$lt$lt$3(block) {
4565        var self = this;
4566
4567
4568        if (!$eqeq(block.$parent(), self)) {
4569          block['$parent='](self)
4570        };
4571        self.blocks['$<<'](block);
4572        return self;
4573      });
4574      $alias(self, "append", "<<");
4575
4576      $def(self, '$blocks?', function $AbstractBlock_blocks$ques$4() {
4577        var self = this;
4578
4579        if ($truthy(self.blocks['$empty?']())) {
4580          return false
4581        } else {
4582          return true
4583        }
4584      });
4585
4586      $def(self, '$sections?', $return_val(false));
4587
4588      $def(self, '$number', function $$number() {
4589        var self = this;
4590
4591        try {
4592
4593          return self.$Integer(self.numeral);
4594        } catch ($err) {
4595          if (Opal.rescue($err, [$$('StandardError')])) {
4596            try {
4597              return self.numeral
4598            } finally { Opal.pop_exception(); }
4599          } else { throw $err; }
4600        }
4601      });
4602
4603      $def(self, '$number=', function $AbstractBlock_number$eq$5(val) {
4604        var self = this;
4605
4606        return (self.numeral = val.$to_s())
4607      });
4608
4609      $def(self, '$find_by', function $$find_by(selector) {
4610        var block = $$find_by.$$p || nil, self = this, result = nil;
4611
4612        $$find_by.$$p = null;
4613
4614        ;
4615        if (selector == null) selector = $hash2([], {});
4616        try {
4617          return $send(self, 'find_by_internal', [selector, (result = [])], block.$to_proc())
4618        } catch ($err) {
4619          if (Opal.rescue($err, [$$$('StopIteration')])) {
4620            try {
4621              return result
4622            } finally { Opal.pop_exception(); }
4623          } else { throw $err; }
4624        };
4625      }, -1);
4626      $alias(self, "query", "find_by");
4627
4628      $def(self, '$next_adjacent_block', function $$next_adjacent_block() {
4629        var self = this, p = nil, sib = nil;
4630
4631        if ($eqeq(self.context, "document")) {
4632          return nil
4633        } else if (($eqeq((p = self.parent).$context(), "dlist") && ($eqeq(self.context, "list_item")))) {
4634          if ($truthy((sib = p.$items()['$[]']($rb_plus($send(p.$items(), 'find_index', [], function $$6(terms, desc){var self = $$6.$$s == null ? this : $$6.$$s, $ret_or_1 = nil;
4635
4636
4637            if (terms == null) terms = nil;
4638            if (desc == null) desc = nil;
4639            if ($truthy(($ret_or_1 = terms['$include?'](self)))) {
4640              return $ret_or_1
4641            } else {
4642              return desc['$=='](self)
4643            };}, {$$s: self}), 1))))) {
4644            return sib
4645          } else {
4646            return p.$next_adjacent_block()
4647          }
4648        } else if ($truthy((sib = p.$blocks()['$[]']($rb_plus(p.$blocks().$find_index(self), 1))))) {
4649          return sib
4650        } else {
4651          return p.$next_adjacent_block()
4652        }
4653      });
4654
4655      $def(self, '$sections', function $$sections() {
4656        var self = this;
4657
4658        return $send(self.blocks, 'select', [], function $$7(block){
4659
4660          if (block == null) block = nil;
4661          return block.$context()['$==']("section");})
4662      });
4663
4664      $def(self, '$alt', function $$alt() {
4665        var self = this, text = nil;
4666
4667        if ($truthy((text = self.attributes['$[]']("alt")))) {
4668          if ($eqeq(text, self.attributes['$[]']("default-alt"))) {
4669            return self.$sub_specialchars(text)
4670          } else {
4671
4672            text = self.$sub_specialchars(text);
4673            if ($truthy($$('ReplaceableTextRx')['$match?'](text))) {
4674
4675              return self.$sub_replacements(text);
4676            } else {
4677              return text
4678            };
4679          }
4680        } else {
4681          return ""
4682        }
4683      });
4684
4685      $def(self, '$caption', function $$caption() {
4686        var self = this;
4687
4688        if ($eqeq(self.context, "admonition")) {
4689          return self.attributes['$[]']("textlabel")
4690        } else {
4691          return self.caption
4692        }
4693      });
4694
4695      $def(self, '$captioned_title', function $$captioned_title() {
4696        var self = this;
4697
4698        return "" + (self.caption) + (self.$title())
4699      });
4700
4701      $def(self, '$list_marker_keyword', function $$list_marker_keyword(list_type) {
4702        var self = this, $ret_or_1 = nil;
4703
4704
4705        if (list_type == null) list_type = nil;
4706        return $$('ORDERED_LIST_KEYWORDS')['$[]'](($truthy(($ret_or_1 = list_type)) ? ($ret_or_1) : (self.style)));
4707      }, -1);
4708
4709      $def(self, '$title', function $$title() {
4710        var self = this, $ret_or_1 = nil, $ret_or_2 = nil;
4711
4712        return (self.converted_title = ($truthy(($ret_or_1 = self.converted_title)) ? ($ret_or_1) : ($truthy(($ret_or_2 = self.title)) ? (self.$apply_title_subs(self.title)) : ($ret_or_2))))
4713      });
4714
4715      $def(self, '$title?', function $AbstractBlock_title$ques$8() {
4716        var self = this;
4717
4718        if ($truthy(self.title)) {
4719          return true
4720        } else {
4721          return false
4722        }
4723      });
4724
4725      $def(self, '$title=', function $AbstractBlock_title$eq$9(val) {
4726        var self = this;
4727
4728
4729        self.converted_title = nil;
4730        return (self.title = val);
4731      });
4732
4733      $def(self, '$sub?', function $AbstractBlock_sub$ques$10(name) {
4734        var self = this;
4735
4736        return self.subs['$include?'](name)
4737      });
4738
4739      $def(self, '$remove_sub', function $$remove_sub(sub) {
4740        var self = this;
4741
4742
4743        self.subs.$delete(sub);
4744        return nil;
4745      });
4746
4747      $def(self, '$xreftext', function $$xreftext(xrefstyle) {
4748        var self = this, val = nil, quoted_title = nil, prefix = nil, caption_attr_name = nil;
4749
4750
4751        if (xrefstyle == null) xrefstyle = nil;
4752        if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) {
4753          return val
4754        } else if ((($truthy(xrefstyle) && ($truthy(self.title))) && ($not(self.caption['$nil_or_empty?']())))) {
4755
4756          switch (xrefstyle) {
4757            case "full":
4758
4759              quoted_title = self.$sub_placeholder(self.$sub_quotes(($truthy(self.document.$compat_mode()) ? ("``%s''") : ("\"`%s`\""))), self.$title());
4760              if ((($truthy(self.numeral) && ($truthy((caption_attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](self.context))))) && ($truthy((prefix = self.document.$attributes()['$[]'](caption_attr_name)))))) {
4761                return "" + (prefix) + " " + (self.numeral) + ", " + (quoted_title)
4762              } else {
4763                return "" + (self.caption.$chomp(". ")) + ", " + (quoted_title)
4764              };
4765              break;
4766            case "short":
4767              if ((($truthy(self.numeral) && ($truthy((caption_attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](self.context))))) && ($truthy((prefix = self.document.$attributes()['$[]'](caption_attr_name)))))) {
4768                return "" + (prefix) + " " + (self.numeral)
4769              } else {
4770                return self.caption.$chomp(". ")
4771              }
4772              break;
4773            default:
4774              return self.$title()
4775          }
4776        } else {
4777          return self.$title()
4778        };
4779      }, -1);
4780
4781      $def(self, '$assign_caption', function $$assign_caption(value, caption_context) {
4782        var self = this, $ret_or_1 = nil, prefix = nil, attr_name = nil;
4783
4784
4785        if (caption_context == null) caption_context = self.context;
4786        if ((($truthy(self.caption) || ($not(self.title))) || ($truthy((self.caption = ($truthy(($ret_or_1 = value)) ? ($ret_or_1) : (self.document.$attributes()['$[]']("caption")))))))) {
4787          return nil
4788        } else if (($truthy((attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](caption_context))) && ($truthy((prefix = self.document.$attributes()['$[]'](attr_name)))))) {
4789
4790          self.caption = "" + (prefix) + " " + ((self.numeral = self.document.$increment_and_store_counter("" + (caption_context) + "-number", self))) + ". ";
4791          return nil;
4792        } else {
4793          return nil
4794        };
4795      }, -2);
4796
4797      $def(self, '$assign_numeral', function $$assign_numeral(section) {
4798        var $a, self = this, like = nil, sectname = nil, caption = nil;
4799
4800
4801        self.next_section_index = $rb_plus(($a = [self.next_section_index], $send(section, 'index=', $a), $a[$a.length - 1]), 1);
4802        if ($truthy((like = section.$numbered()))) {
4803          if ($eqeq((sectname = section.$sectname()), "appendix")) {
4804
4805            section['$numeral='](self.document.$counter("appendix-number", "A"));
4806            section['$caption='](($truthy((caption = self.document.$attributes()['$[]']("appendix-caption"))) ? ("" + (caption) + " " + (section.$numeral()) + ": ") : ("" + (section.$numeral()) + ". ")));
4807          } else if (($eqeq(sectname, "chapter") || ($eqeq(like, "chapter")))) {
4808            section['$numeral='](self.document.$counter("chapter-number", 1).$to_s())
4809          } else {
4810
4811            section['$numeral='](($eqeq(sectname, "part") ? ($$('Helpers').$int_to_roman(self.next_section_ordinal)) : (self.next_section_ordinal.$to_s())));
4812            self.next_section_ordinal = $rb_plus(self.next_section_ordinal, 1);
4813          }
4814        };
4815        return nil;
4816      });
4817
4818      $def(self, '$reindex_sections', function $$reindex_sections() {
4819        var self = this;
4820
4821
4822        self.next_section_index = 0;
4823        self.next_section_ordinal = 1;
4824        return $send(self.blocks, 'each', [], function $$11(block){var self = $$11.$$s == null ? this : $$11.$$s;
4825
4826
4827          if (block == null) block = nil;
4828          if ($eqeq(block.$context(), "section")) {
4829
4830            self.$assign_numeral(block);
4831            return block.$reindex_sections();
4832          } else {
4833            return nil
4834          };}, {$$s: self});
4835      });
4836      self.$protected();
4837      return $def(self, '$find_by_internal', function $$find_by_internal(selector, result) {
4838        var block = $$find_by_internal.$$p || nil, self = this, id_selector = nil, role_selector = nil, style_selector = nil, any_context = nil, context_selector = nil, verdict = nil;
4839
4840        $$find_by_internal.$$p = null;
4841
4842        ;
4843        if (selector == null) selector = $hash2([], {});
4844        if (result == null) result = [];
4845        if ((((($truthy((any_context = ($truthy((context_selector = selector['$[]']("context"))) ? (nil) : (true)))) || ($eqeq(context_selector, self.context))) && (($not((style_selector = selector['$[]']("style"))) || ($eqeq(style_selector, self.style))))) && (($not((role_selector = selector['$[]']("role"))) || ($truthy(self['$has_role?'](role_selector)))))) && (($not((id_selector = selector['$[]']("id"))) || ($eqeq(id_selector, self.id)))))) {
4846          if ((block !== nil)) {
4847            if ($truthy((verdict = Opal.yield1(block, self)))) {
4848
4849              switch (verdict) {
4850                case "prune":
4851
4852                  result['$<<'](self);
4853                  if ($truthy(id_selector)) {
4854                    self.$raise($$$('StopIteration'))
4855                  };
4856                  return result;
4857                case "reject":
4858
4859                  if ($truthy(id_selector)) {
4860                    self.$raise($$$('StopIteration'))
4861                  };
4862                  return result;
4863                case "stop":
4864                  self.$raise($$$('StopIteration'))
4865                  break;
4866                default:
4867
4868                  result['$<<'](self);
4869                  if ($truthy(id_selector)) {
4870                    self.$raise($$$('StopIteration'))
4871                  };
4872              }
4873            } else if ($truthy(id_selector)) {
4874              self.$raise($$$('StopIteration'))
4875            }
4876          } else {
4877
4878            result['$<<'](self);
4879            if ($truthy(id_selector)) {
4880              self.$raise($$$('StopIteration'))
4881            };
4882          }
4883        };
4884
4885        switch (self.context) {
4886          case "document":
4887            if (!$eqeq(context_selector, "document")) {
4888
4889              if (($truthy(self['$header?']()) && (($truthy(any_context) || ($eqeq(context_selector, "section")))))) {
4890                $send(self.header, 'find_by_internal', [selector, result], block.$to_proc())
4891              };
4892              $send(self.blocks, 'each', [], function $$12(b){
4893
4894                if (b == null) b = nil;
4895                if (($eqeq(context_selector, "section") && ($neqeq(b.$context(), "section")))) {
4896                  return nil
4897                };
4898                return $send(b, 'find_by_internal', [selector, result], block.$to_proc());});
4899            }
4900            break;
4901          case "dlist":
4902            if (($truthy(any_context) || ($neqeq(context_selector, "section")))) {
4903              $send(self.blocks.$flatten(), 'each', [], function $$13(b){
4904
4905                if (b == null) b = nil;
4906                if ($truthy(b)) {
4907                  return $send(b, 'find_by_internal', [selector, result], block.$to_proc())
4908                } else {
4909                  return nil
4910                };})
4911            }
4912            break;
4913          case "table":
4914            if ($truthy(selector['$[]']("traverse_documents"))) {
4915
4916              $send(self.$rows().$head(), 'each', [], function $$14(r){
4917
4918                if (r == null) r = nil;
4919                return $send(r, 'each', [], function $$15(c){
4920
4921                  if (c == null) c = nil;
4922                  return $send(c, 'find_by_internal', [selector, result], block.$to_proc());});});
4923              if ($eqeq(context_selector, "inner_document")) {
4924                selector = selector.$merge($hash2(["context"], {"context": "document"}))
4925              };
4926              $send($rb_plus(self.$rows().$body(), self.$rows().$foot()), 'each', [], function $$16(r){
4927
4928                if (r == null) r = nil;
4929                return $send(r, 'each', [], function $$17(c){
4930
4931                  if (c == null) c = nil;
4932                  $send(c, 'find_by_internal', [selector, result], block.$to_proc());
4933                  if ($eqeq(c.$style(), "asciidoc")) {
4934                    return $send(c.$inner_document(), 'find_by_internal', [selector, result], block.$to_proc())
4935                  } else {
4936                    return nil
4937                  };});});
4938            } else {
4939              $send($rb_plus($rb_plus(self.$rows().$head(), self.$rows().$body()), self.$rows().$foot()), 'each', [], function $$18(r){
4940
4941                if (r == null) r = nil;
4942                return $send(r, 'each', [], function $$19(c){
4943
4944                  if (c == null) c = nil;
4945                  return $send(c, 'find_by_internal', [selector, result], block.$to_proc());});})
4946            }
4947            break;
4948          default:
4949            $send(self.blocks, 'each', [], function $$20(b){
4950
4951              if (b == null) b = nil;
4952              if (($eqeq(context_selector, "section") && ($neqeq(b.$context(), "section")))) {
4953                return nil
4954              };
4955              return $send(b, 'find_by_internal', [selector, result], block.$to_proc());})
4956        };
4957        return result;
4958      }, -1);
4959    })($nesting[0], $$('AbstractNode'), $nesting)
4960  })($nesting[0], $nesting)
4961};
4962
4963Opal.modules["asciidoctor/attribute_list"] = function(Opal) {/* Generated by Opal 1.7.3 */
4964  "use strict";
4965  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $hash = Opal.hash, $regexp = Opal.regexp, $hash2 = Opal.hash2, $def = Opal.def, $truthy = Opal.truthy, $rb_plus = Opal.rb_plus, $send = Opal.send, $defs = Opal.defs, $eqeqeq = Opal.eqeqeq, $eqeq = Opal.eqeq, $rb_times = Opal.rb_times, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
4966
4967  Opal.add_stubs('new,[],update,parse,parse_attribute,eos?,skip_delimiter,+,rekey,each_with_index,[]=,private,skip_blank,===,peek,parse_attribute_value,get_byte,start_with?,scan_name,end_with?,rstrip,string,==,unscan,scan_to_delimiter,*,include?,delete,each,split,empty?,apply_subs,scan_to_quote,gsub,skip,scan');
4968  return (function($base, $parent_nesting) {
4969    var self = $module($base, 'Asciidoctor');
4970
4971    var $nesting = [self].concat($parent_nesting);
4972
4973    return (function($base, $super, $parent_nesting) {
4974      var self = $klass($base, $super, 'AttributeList');
4975
4976      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
4977
4978      $proto.attributes = $proto.scanner = $proto.delimiter = $proto.block = $proto.delimiter_skip_pattern = $proto.delimiter_boundary_pattern = nil;
4979
4980      $const_set($nesting[0], 'APOS', "'");
4981      $const_set($nesting[0], 'BACKSLASH', "\\");
4982      $const_set($nesting[0], 'QUOT', "\"");
4983      $const_set($nesting[0], 'BoundaryRx', $hash($$('QUOT'), /.*?[^\\](?=")/, $$('APOS'), /.*?[^\\](?=')/, ",", /.*?(?=[ \t]*(,|$))/));
4984      $const_set($nesting[0], 'EscapedQuotes', $hash($$('QUOT'), "\\\"", $$('APOS'), "\\'"));
4985      $const_set($nesting[0], 'NameRx', $regexp([$$('CG_WORD'), "[", $$('CC_WORD'), "\\-.]*"]));
4986      $const_set($nesting[0], 'BlankRx', /[ \t]+/);
4987      $const_set($nesting[0], 'SkipRx', $hash2([","], {",": /[ \t]*(,|$)/}));
4988
4989      $def(self, '$initialize', function $$initialize(source, block, delimiter) {
4990        var self = this;
4991
4992
4993        if (block == null) block = nil;
4994        if (delimiter == null) delimiter = ",";
4995        self.scanner = $$$('StringScanner').$new(source);
4996        self.block = block;
4997        self.delimiter = delimiter;
4998        self.delimiter_skip_pattern = $$('SkipRx')['$[]'](delimiter);
4999        self.delimiter_boundary_pattern = $$('BoundaryRx')['$[]'](delimiter);
5000        return (self.attributes = nil);
5001      }, -2);
5002
5003      $def(self, '$parse_into', function $$parse_into(attributes, positional_attrs) {
5004        var self = this;
5005
5006
5007        if (positional_attrs == null) positional_attrs = [];
5008        return attributes.$update(self.$parse(positional_attrs));
5009      }, -2);
5010
5011      $def(self, '$parse', function $$parse(positional_attrs) {
5012        var self = this, index = nil;
5013
5014
5015        if (positional_attrs == null) positional_attrs = [];
5016        if ($truthy(self.attributes)) {
5017          return self.attributes
5018        };
5019        self.attributes = $hash2([], {});
5020        index = 0;
5021        while ($truthy(self.$parse_attribute(index, positional_attrs))) {
5022
5023          if ($truthy(self.scanner['$eos?']())) {
5024            break
5025          };
5026          self.$skip_delimiter();
5027          index = $rb_plus(index, 1);
5028        };
5029        return self.attributes;
5030      }, -1);
5031
5032      $def(self, '$rekey', function $$rekey(positional_attrs) {
5033        var self = this;
5034
5035        return $$('AttributeList').$rekey(self.attributes, positional_attrs)
5036      });
5037      $defs(self, '$rekey', function $$rekey(attributes, positional_attrs) {
5038
5039
5040        $send(positional_attrs, 'each_with_index', [], function $$1(key, index){var $a, val = nil;
5041
5042
5043          if (key == null) key = nil;
5044          if (index == null) index = nil;
5045          if (($truthy(key) && ($truthy((val = attributes['$[]']($rb_plus(index, 1))))))) {
5046            return ($a = [key, val], $send(attributes, '[]=', $a), $a[$a.length - 1])
5047          } else {
5048            return nil
5049          };});
5050        return attributes;
5051      });
5052      self.$private();
5053
5054      $def(self, '$parse_attribute', function $$parse_attribute(index, positional_attrs) {
5055        var self = this, continue$ = nil, $ret_or_1 = nil, name = nil, single_quoted = nil, skipped = nil, $ret_or_2 = nil, $ret_or_3 = nil, c = nil, value = nil, positional_attr_name = nil;
5056
5057
5058        continue$ = true;
5059        self.$skip_blank();
5060        if ($eqeqeq($$('QUOT'), ($ret_or_1 = self.scanner.$peek(1)))) {
5061          name = self.$parse_attribute_value(self.scanner.$get_byte())
5062        } else if ($eqeqeq($$('APOS'), $ret_or_1)) {
5063
5064          name = self.$parse_attribute_value(self.scanner.$get_byte());
5065          if (!$truthy(name['$start_with?']($$('APOS')))) {
5066            single_quoted = true
5067          };
5068        } else {
5069
5070          skipped = ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = (name = self.$scan_name()))) ? (self.$skip_blank()) : ($ret_or_3)))) ? ($ret_or_2) : (0));
5071          if ($truthy(self.scanner['$eos?']())) {
5072
5073            if (!($truthy(name) || ($truthy(self.scanner.$string().$rstrip()['$end_with?'](self.delimiter))))) {
5074              return nil
5075            };
5076            continue$ = nil;
5077          } else if ($eqeq((c = self.scanner.$get_byte()), self.delimiter)) {
5078            self.scanner.$unscan()
5079          } else if ($truthy(name)) {
5080            if ($eqeq(c, "=")) {
5081
5082              self.$skip_blank();
5083              if ($eqeqeq($$('QUOT'), ($ret_or_2 = (c = self.scanner.$get_byte())))) {
5084                value = self.$parse_attribute_value(c)
5085              } else if ($eqeqeq($$('APOS'), $ret_or_2)) {
5086
5087                value = self.$parse_attribute_value(c);
5088                if (!$truthy(value['$start_with?']($$('APOS')))) {
5089                  single_quoted = true
5090                };
5091              } else if ($eqeqeq(self.delimiter, $ret_or_2)) {
5092
5093                value = "";
5094                self.scanner.$unscan();
5095              } else if ($eqeqeq(nil, $ret_or_2)) {
5096                value = ""
5097              } else {
5098
5099                value = "" + (c) + (self.$scan_to_delimiter());
5100                if ($eqeq(value, "None")) {
5101                  return true
5102                };
5103              };
5104            } else {
5105              name = "" + (name) + ($rb_times(" ", skipped)) + (c) + (self.$scan_to_delimiter())
5106            }
5107          } else {
5108            name = "" + (c) + (self.$scan_to_delimiter())
5109          };
5110        };
5111        if ($truthy(value)) {
5112
5113          switch (name) {
5114            case "options":
5115            case "opts":
5116              if ($truthy(value['$include?'](","))) {
5117
5118                if ($truthy(value['$include?'](" "))) {
5119                  value = value.$delete(" ")
5120                };
5121                $send(value.$split(","), 'each', [], function $$2(opt){var $a, self = $$2.$$s == null ? this : $$2.$$s;
5122                  if (self.attributes == null) self.attributes = nil;
5123
5124
5125                  if (opt == null) opt = nil;
5126                  if ($truthy(opt['$empty?']())) {
5127                    return nil
5128                  } else {
5129                    return ($a = ["" + (opt) + "-option", ""], $send(self.attributes, '[]=', $a), $a[$a.length - 1])
5130                  };}, {$$s: self});
5131              } else if (!$truthy(value['$empty?']())) {
5132                self.attributes['$[]=']("" + (value) + "-option", "")
5133              }
5134              break;
5135            default:
5136              if (($truthy(single_quoted) && ($truthy(self.block)))) {
5137
5138                switch (name) {
5139                  case "title":
5140                  case "reftext":
5141                    self.attributes['$[]='](name, value)
5142                    break;
5143                  default:
5144                    self.attributes['$[]='](name, self.block.$apply_subs(value))
5145                }
5146              } else {
5147                self.attributes['$[]='](name, value)
5148              }
5149          }
5150        } else {
5151
5152          if (($truthy(single_quoted) && ($truthy(self.block)))) {
5153            name = self.block.$apply_subs(name)
5154          };
5155          if (($truthy((positional_attr_name = positional_attrs['$[]'](index))) && ($truthy(name)))) {
5156            self.attributes['$[]='](positional_attr_name, name)
5157          };
5158          self.attributes['$[]=']($rb_plus(index, 1), name);
5159        };
5160        return continue$;
5161      });
5162
5163      $def(self, '$parse_attribute_value', function $$parse_attribute_value(quote) {
5164        var self = this, value = nil;
5165
5166        if ($eqeq(self.scanner.$peek(1), quote)) {
5167
5168          self.scanner.$get_byte();
5169          return "";
5170        } else if ($truthy((value = self.$scan_to_quote(quote)))) {
5171
5172          self.scanner.$get_byte();
5173          if ($truthy(value['$include?']($$('BACKSLASH')))) {
5174
5175            return value.$gsub($$('EscapedQuotes')['$[]'](quote), quote);
5176          } else {
5177            return value
5178          };
5179        } else {
5180          return "" + (quote) + (self.$scan_to_delimiter())
5181        }
5182      });
5183
5184      $def(self, '$skip_blank', function $$skip_blank() {
5185        var self = this;
5186
5187        return self.scanner.$skip($$('BlankRx'))
5188      });
5189
5190      $def(self, '$skip_delimiter', function $$skip_delimiter() {
5191        var self = this;
5192
5193        return self.scanner.$skip(self.delimiter_skip_pattern)
5194      });
5195
5196      $def(self, '$scan_name', function $$scan_name() {
5197        var self = this;
5198
5199        return self.scanner.$scan($$('NameRx'))
5200      });
5201
5202      $def(self, '$scan_to_delimiter', function $$scan_to_delimiter() {
5203        var self = this;
5204
5205        return self.scanner.$scan(self.delimiter_boundary_pattern)
5206      });
5207      return $def(self, '$scan_to_quote', function $$scan_to_quote(quote) {
5208        var self = this;
5209
5210        return self.scanner.$scan($$('BoundaryRx')['$[]'](quote))
5211      });
5212    })($nesting[0], null, $nesting)
5213  })($nesting[0], $nesting)
5214};
5215
5216Opal.modules["asciidoctor/block"] = function(Opal) {/* Generated by Opal 1.7.3 */
5217  "use strict";
5218  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $hash2 = Opal.hash2, $alias = Opal.alias, $send2 = Opal.send2, $find_super = Opal.find_super, $truthy = Opal.truthy, $eqeqeq = Opal.eqeqeq, $def = Opal.def, $rb_lt = Opal.rb_lt, $eqeq = Opal.eqeq, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
5219
5220  Opal.add_stubs('default=,context,attr_accessor,[],key?,===,drop,delete,[]=,to_s,commit_subs,nil_or_empty?,prepare_source_string,apply_subs,join,<,size,empty?,rstrip,shift,pop,==,warn,logger,class,object_id,inspect');
5221  return (function($base, $parent_nesting) {
5222    var self = $module($base, 'Asciidoctor');
5223
5224    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5225
5226    return (function($base, $super, $parent_nesting) {
5227      var self = $klass($base, $super, 'Block');
5228
5229      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
5230
5231      $proto.attributes = $proto.content_model = $proto.lines = $proto.subs = $proto.blocks = $proto.context = $proto.style = nil;
5232
5233      $const_set($nesting[0], 'DEFAULT_CONTENT_MODEL', $hash2(["audio", "image", "listing", "literal", "stem", "open", "page_break", "pass", "thematic_break", "video"], {"audio": "empty", "image": "empty", "listing": "verbatim", "literal": "verbatim", "stem": "raw", "open": "compound", "page_break": "empty", "pass": "raw", "thematic_break": "empty", "video": "empty"}))['$default=']("simple");
5234      $alias(self, "blockname", "context");
5235      self.$attr_accessor("lines");
5236
5237      $def(self, '$initialize', function $$initialize(parent, context, opts) {
5238        var $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil, subs = nil, raw_source = nil;
5239
5240        $$initialize.$$p = null;
5241
5242        if (opts == null) opts = $hash2([], {});
5243        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield);
5244        self.content_model = ($truthy(($ret_or_1 = opts['$[]']("content_model"))) ? ($ret_or_1) : ($$('DEFAULT_CONTENT_MODEL')['$[]'](context)));
5245        if ($truthy(opts['$key?']("subs"))) {
5246          if ($truthy((subs = opts['$[]']("subs")))) {
5247
5248            if ($eqeqeq("default", ($ret_or_1 = subs))) {
5249              self.default_subs = opts['$[]']("default_subs")
5250            } else if ($eqeqeq($$$('Array'), $ret_or_1)) {
5251
5252              self.default_subs = subs.$drop(0);
5253              self.attributes.$delete("subs");
5254            } else {
5255
5256              self.default_subs = nil;
5257              self.attributes['$[]=']("subs", subs.$to_s());
5258            };
5259            self.$commit_subs();
5260          } else {
5261
5262            self.default_subs = [];
5263            self.attributes.$delete("subs");
5264          }
5265        } else {
5266          self.default_subs = nil
5267        };
5268        if ($truthy((raw_source = opts['$[]']("source"))['$nil_or_empty?']())) {
5269          return (self.lines = [])
5270        } else if ($eqeqeq($$$('String'), raw_source)) {
5271          return (self.lines = $$('Helpers').$prepare_source_string(raw_source))
5272        } else {
5273          return (self.lines = raw_source.$drop(0))
5274        };
5275      }, -3);
5276
5277      $def(self, '$content', function $$content() {
5278        var $yield = $$content.$$p || nil, self = this, result = nil, $ret_or_2 = nil, first = nil, last = nil;
5279
5280        $$content.$$p = null;
5281
5282        switch (self.content_model) {
5283          case "compound":
5284            return $send2(self, $find_super(self, 'content', $$content, false, true), 'content', [], $yield)
5285          case "simple":
5286            return self.$apply_subs(self.lines.$join($$('LF')), self.subs)
5287          case "verbatim":
5288          case "raw":
5289
5290            result = self.$apply_subs(self.lines, self.subs);
5291            if ($truthy($rb_lt(result.$size(), 2))) {
5292              if ($truthy(($ret_or_2 = result['$[]'](0)))) {
5293                return $ret_or_2
5294              } else {
5295                return ""
5296              }
5297            } else {
5298
5299              while ($truthy(($truthy(($ret_or_2 = (first = result['$[]'](0)))) ? (first.$rstrip()['$empty?']()) : ($ret_or_2)))) {
5300              result.$shift()
5301              };
5302              while ($truthy(($truthy(($ret_or_2 = (last = result['$[]'](-1)))) ? (last.$rstrip()['$empty?']()) : ($ret_or_2)))) {
5303              result.$pop()
5304              };
5305              return result.$join($$('LF'));
5306            };
5307            break;
5308          default:
5309
5310            if (!$eqeq(self.content_model, "empty")) {
5311              self.$logger().$warn("unknown content model '" + (self.content_model) + "' for block: " + (self))
5312            };
5313            return nil;
5314        }
5315      });
5316
5317      $def(self, '$source', function $$source() {
5318        var self = this;
5319
5320        return self.lines.$join($$('LF'))
5321      });
5322      return $def(self, '$to_s', function $$to_s() {
5323        var self = this, content_summary = nil;
5324
5325
5326        content_summary = ($eqeq(self.content_model, "compound") ? ("blocks: " + (self.blocks.$size())) : ("lines: " + (self.lines.$size())));
5327        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", content_model: " + (self.content_model.$inspect()) + ", style: " + (self.style.$inspect()) + ", " + (content_summary) + "}>";
5328      });
5329    })($nesting[0], $$('AbstractBlock'), $nesting)
5330  })($nesting[0], $nesting)
5331};
5332
5333Opal.modules["asciidoctor/callouts"] = function(Opal) {/* Generated by Opal 1.7.3 */
5334  "use strict";
5335  var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $hash2 = Opal.hash2, $rb_plus = Opal.rb_plus, $truthy = Opal.truthy, $rb_le = Opal.rb_le, $rb_minus = Opal.rb_minus, $send = Opal.send, $eqeq = Opal.eqeq, $rb_lt = Opal.rb_lt, $nesting = [], nil = Opal.nil;
5336
5337  Opal.add_stubs('next_list,<<,current_list,to_i,generate_next_callout_id,+,<=,size,[],-,chop,join,map,==,<,private,generate_callout_id');
5338  return (function($base, $parent_nesting) {
5339    var self = $module($base, 'Asciidoctor');
5340
5341    var $nesting = [self].concat($parent_nesting);
5342
5343    return (function($base, $super) {
5344      var self = $klass($base, $super, 'Callouts');
5345
5346      var $proto = self.$$prototype;
5347
5348      $proto.co_index = $proto.lists = $proto.list_index = nil;
5349
5350
5351      $def(self, '$initialize', function $$initialize() {
5352        var self = this;
5353
5354
5355        self.lists = [];
5356        self.list_index = 0;
5357        return self.$next_list();
5358      });
5359
5360      $def(self, '$register', function $$register(li_ordinal) {
5361        var self = this, id = nil;
5362
5363
5364        self.$current_list()['$<<']($hash2(["ordinal", "id"], {"ordinal": li_ordinal.$to_i(), "id": (id = self.$generate_next_callout_id())}));
5365        self.co_index = $rb_plus(self.co_index, 1);
5366        return id;
5367      });
5368
5369      $def(self, '$read_next_id', function $$read_next_id() {
5370        var self = this, id = nil, list = nil;
5371
5372
5373        id = nil;
5374        list = self.$current_list();
5375        if ($truthy($rb_le(self.co_index, list.$size()))) {
5376          id = list['$[]']($rb_minus(self.co_index, 1))['$[]']("id")
5377        };
5378        self.co_index = $rb_plus(self.co_index, 1);
5379        return id;
5380      });
5381
5382      $def(self, '$callout_ids', function $$callout_ids(li_ordinal) {
5383        var self = this;
5384
5385        return $send(self.$current_list(), 'map', [], function $$1(it){
5386
5387          if (it == null) it = nil;
5388          if ($eqeq(it['$[]']("ordinal"), li_ordinal)) {
5389            return "" + (it['$[]']("id")) + " "
5390          } else {
5391            return ""
5392          };}).$join().$chop()
5393      });
5394
5395      $def(self, '$current_list', function $$current_list() {
5396        var self = this;
5397
5398        return self.lists['$[]']($rb_minus(self.list_index, 1))
5399      });
5400
5401      $def(self, '$next_list', function $$next_list() {
5402        var self = this;
5403
5404
5405        self.list_index = $rb_plus(self.list_index, 1);
5406        if ($truthy($rb_lt(self.lists.$size(), self.list_index))) {
5407          self.lists['$<<']([])
5408        };
5409        self.co_index = 1;
5410        return nil;
5411      });
5412
5413      $def(self, '$rewind', function $$rewind() {
5414        var self = this;
5415
5416
5417        self.list_index = 1;
5418        self.co_index = 1;
5419        return nil;
5420      });
5421      self.$private();
5422
5423      $def(self, '$generate_next_callout_id', function $$generate_next_callout_id() {
5424        var self = this;
5425
5426        return self.$generate_callout_id(self.list_index, self.co_index)
5427      });
5428      return $def(self, '$generate_callout_id', function $$generate_callout_id(list_index, co_index) {
5429
5430        return "CO" + (list_index) + "-" + (co_index)
5431      });
5432    })($nesting[0], null)
5433  })($nesting[0], $nesting)
5434};
5435
5436Opal.modules["asciidoctor/converter/composite"] = function(Opal) {/* Generated by Opal 1.7.3 */
5437  "use strict";
5438  var $module = Opal.module, $klass = Opal.klass, $slice = Opal.slice, $extract_kwargs = Opal.extract_kwargs, $ensure_kwargs = Opal.ensure_kwargs, $send = Opal.send, $truthy = Opal.truthy, $def = Opal.def, $thrower = Opal.thrower, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
5439
5440  Opal.add_stubs('attr_reader,each,respond_to?,composed,init_backend_traits,backend_traits,new,[]=,find_converter,convert,converter_for,node_name,[],handles?,raise');
5441  return (function($base, $parent_nesting) {
5442    var self = $module($base, 'Asciidoctor');
5443
5444    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5445
5446    return (function($base, $super) {
5447      var self = $klass($base, $super, 'CompositeConverter');
5448
5449      var $proto = self.$$prototype;
5450
5451      $proto.converter_cache = $proto.converters = nil;
5452
5453      self.$attr_reader("converters");
5454
5455      $def(self, '$initialize', function $$initialize(backend, $a, $b) {
5456        var $post_args, $kwargs, converters, backend_traits_source, self = this;
5457
5458
5459        $post_args = $slice(arguments, 1);
5460        $kwargs = $extract_kwargs($post_args);
5461        $kwargs = $ensure_kwargs($kwargs);
5462        converters = $post_args;
5463
5464        backend_traits_source = $kwargs.$$smap["backend_traits_source"];if (backend_traits_source == null) backend_traits_source = nil;
5465        self.backend = backend;
5466        $send((self.converters = converters), 'each', [], function $$1(converter){var self = $$1.$$s == null ? this : $$1.$$s;
5467
5468
5469          if (converter == null) converter = nil;
5470          if ($truthy(converter['$respond_to?']("composed"))) {
5471            return converter.$composed(self)
5472          } else {
5473            return nil
5474          };}, {$$s: self});
5475        if ($truthy(backend_traits_source)) {
5476          self.$init_backend_traits(backend_traits_source.$backend_traits())
5477        };
5478        return (self.converter_cache = $send($$$('Hash'), 'new', [], function $$2(hash, key){var $c, self = $$2.$$s == null ? this : $$2.$$s;
5479
5480
5481          if (hash == null) hash = nil;
5482          if (key == null) key = nil;
5483          return ($c = [key, self.$find_converter(key)], $send(hash, '[]=', $c), $c[$c.length - 1]);}, {$$s: self}));
5484      }, -2);
5485
5486      $def(self, '$convert', function $$convert(node, transform, opts) {
5487        var self = this, $ret_or_1 = nil;
5488
5489
5490        if (transform == null) transform = nil;
5491        if (opts == null) opts = nil;
5492        return self.$converter_for((transform = ($truthy(($ret_or_1 = transform)) ? ($ret_or_1) : (node.$node_name())))).$convert(node, transform, opts);
5493      }, -2);
5494
5495      $def(self, '$converter_for', function $$converter_for(transform) {
5496        var self = this;
5497
5498        return self.converter_cache['$[]'](transform)
5499      });
5500      return $def(self, '$find_converter', function $$find_converter(transform) {try { var $t_return = $thrower('return');
5501        var self = this;
5502
5503
5504        $send(self.converters, 'each', [], function $$3(candidate){
5505
5506          if (candidate == null) candidate = nil;
5507          if ($truthy(candidate['$handles?'](transform))) {
5508            $t_return.$throw(candidate)
5509          } else {
5510            return nil
5511          };}, {$$ret: $t_return});
5512        return self.$raise("Could not find a converter to handle transform: " + (transform));} catch($e) {
5513          if ($e === $t_return) return $e.$v;
5514          throw $e;
5515        }
5516      });
5517    })($$('Converter'), $$$($$('Converter'), 'Base'))
5518  })($nesting[0], $nesting)
5519};
5520
5521Opal.modules["asciidoctor/converter"] = function(Opal) {/* Generated by Opal 1.7.3 */
5522  "use strict";
5523  var $module = Opal.module, $hash2 = Opal.hash2, $def = Opal.def, $return_val = Opal.return_val, $truthy = Opal.truthy, $eqeq = Opal.eqeq, $defs = Opal.defs, $send = Opal.send, $alias = Opal.alias, $slice = Opal.slice, $to_a = Opal.to_a, $extract_kwargs = Opal.extract_kwargs, $ensure_kwargs = Opal.ensure_kwargs, $eqeqeq = Opal.eqeqeq, $Class = Opal.Class, $klass = Opal.klass, $class_variable_set = Opal.class_variable_set, $class_variable_get = Opal.class_variable_get, $rb_plus = Opal.rb_plus, $gvars = Opal.gvars, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
5524
5525  Opal.add_stubs('autoload,attr_reader,raise,class,[],sub,slice,length,==,[]=,backend_traits,derive_backend_traits,register,map,to_s,new,create,default,each,default=,registry,for,===,supports_templates?,merge,private,include,delete,clear,send,extend,private_class_method,node_name,+,name,receiver,warn,logger,respond_to?,content');
5526  return (function($base, $parent_nesting) {
5527    var self = $module($base, 'Asciidoctor');
5528
5529    var $nesting = [self].concat($parent_nesting);
5530
5531    return (function($base, $parent_nesting) {
5532      var self = $module($base, 'Converter');
5533
5534      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5535
5536
5537      self.$autoload("CompositeConverter", "" + ("asciidoctor") + "/converter/composite");
5538      nil;
5539      self.$attr_reader("backend");
5540
5541      $def(self, '$initialize', function $$initialize(backend, opts) {
5542        var self = this;
5543
5544
5545        if (opts == null) opts = $hash2([], {});
5546        return (self.backend = backend);
5547      }, -2);
5548
5549      $def(self, '$convert', function $$convert(node, transform, opts) {
5550        var self = this;
5551        if (self.backend == null) self.backend = nil;
5552
5553
5554        if (transform == null) transform = nil;
5555        if (opts == null) opts = nil;
5556        return self.$raise($$$('NotImplementedError'), "" + (self.$class()) + " (backend: " + (self.backend) + ") must implement the #" + ("convert") + " method");
5557      }, -2);
5558
5559      $def(self, '$handles?', $return_val(true));
5560      $defs(self, '$derive_backend_traits', function $$derive_backend_traits(backend, basebackend) {
5561        var outfilesuffix = nil, $ret_or_1 = nil, filetype = nil;
5562
5563
5564        if (basebackend == null) basebackend = nil;
5565        if (!$truthy(backend)) {
5566          return $hash2([], {})
5567        };
5568        if ($truthy((outfilesuffix = $$('DEFAULT_EXTENSIONS')['$[]']((basebackend = ($truthy(($ret_or_1 = basebackend)) ? ($ret_or_1) : (backend.$sub($$('TrailingDigitsRx'), "")))))))) {
5569          filetype = outfilesuffix.$slice(1, outfilesuffix.$length())
5570        } else {
5571          outfilesuffix = "." + ((filetype = basebackend))
5572        };
5573        if ($eqeq(filetype, "html")) {
5574          return $hash2(["basebackend", "filetype", "htmlsyntax", "outfilesuffix"], {"basebackend": basebackend, "filetype": filetype, "htmlsyntax": "html", "outfilesuffix": outfilesuffix})
5575        } else {
5576          return $hash2(["basebackend", "filetype", "outfilesuffix"], {"basebackend": basebackend, "filetype": filetype, "outfilesuffix": outfilesuffix})
5577        };
5578      }, -2);
5579      (function($base, $parent_nesting) {
5580        var self = $module($base, 'BackendTraits');
5581
5582        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5583
5584
5585
5586        $def(self, '$basebackend', function $$basebackend(value) {
5587          var $a, self = this;
5588
5589
5590          if (value == null) value = nil;
5591          if ($truthy(value)) {
5592
5593            return ($a = ["basebackend", value], $send(self.$backend_traits(value), '[]=', $a), $a[$a.length - 1]);
5594          } else {
5595            return self.$backend_traits()['$[]']("basebackend")
5596          };
5597        }, -1);
5598
5599        $def(self, '$filetype', function $$filetype(value) {
5600          var $a, self = this;
5601
5602
5603          if (value == null) value = nil;
5604          if ($truthy(value)) {
5605
5606            return ($a = ["filetype", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]);
5607          } else {
5608            return self.$backend_traits()['$[]']("filetype")
5609          };
5610        }, -1);
5611
5612        $def(self, '$htmlsyntax', function $$htmlsyntax(value) {
5613          var $a, self = this;
5614
5615
5616          if (value == null) value = nil;
5617          if ($truthy(value)) {
5618
5619            return ($a = ["htmlsyntax", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]);
5620          } else {
5621            return self.$backend_traits()['$[]']("htmlsyntax")
5622          };
5623        }, -1);
5624
5625        $def(self, '$outfilesuffix', function $$outfilesuffix(value) {
5626          var $a, self = this;
5627
5628
5629          if (value == null) value = nil;
5630          if ($truthy(value)) {
5631
5632            return ($a = ["outfilesuffix", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]);
5633          } else {
5634            return self.$backend_traits()['$[]']("outfilesuffix")
5635          };
5636        }, -1);
5637
5638        $def(self, '$supports_templates', function $$supports_templates(value) {
5639          var $a, self = this;
5640
5641
5642          if (value == null) value = true;
5643          return ($a = ["supports_templates", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]);
5644        }, -1);
5645
5646        $def(self, '$supports_templates?', function $BackendTraits_supports_templates$ques$1() {
5647          var self = this;
5648
5649          return self.$backend_traits()['$[]']("supports_templates")
5650        });
5651
5652        $def(self, '$init_backend_traits', function $$init_backend_traits(value) {
5653          var self = this, $ret_or_1 = nil;
5654
5655
5656          if (value == null) value = nil;
5657          return (self.backend_traits = ($truthy(($ret_or_1 = value)) ? ($ret_or_1) : ($hash2([], {}))));
5658        }, -1);
5659
5660        $def(self, '$backend_traits', function $$backend_traits(basebackend) {
5661          var self = this, $ret_or_1 = nil;
5662          if (self.backend_traits == null) self.backend_traits = nil;
5663          if (self.backend == null) self.backend = nil;
5664
5665
5666          if (basebackend == null) basebackend = nil;
5667          return (self.backend_traits = ($truthy(($ret_or_1 = self.backend_traits)) ? ($ret_or_1) : ($$('Converter').$derive_backend_traits(self.backend, basebackend))));
5668        }, -1);
5669        $alias(self, "backend_info", "backend_traits");
5670        return $defs(self, '$derive_backend_traits', function $$derive_backend_traits(backend, basebackend) {
5671
5672
5673          if (basebackend == null) basebackend = nil;
5674          return $$('Converter').$derive_backend_traits(backend, basebackend);
5675        }, -2);
5676      })($nesting[0], $nesting);
5677      (function($base, $parent_nesting) {
5678        var self = $module($base, 'Config');
5679
5680        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5681
5682        return $def(self, '$register_for', function $$register_for($a) {
5683          var $post_args, backends, self = this;
5684
5685
5686          $post_args = $slice(arguments);
5687          backends = $post_args;
5688          return $send($$('Converter'), 'register', [self].concat($to_a($send(backends, 'map', [], function $$2(backend){
5689
5690            if (backend == null) backend = nil;
5691            return backend.$to_s();}))));
5692        }, -1)
5693      })($nesting[0], $nesting);
5694      (function($base, $parent_nesting) {
5695        var self = $module($base, 'Factory');
5696
5697        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5698
5699
5700        $defs(self, '$new', function $Factory_new$3($a, $b) {
5701          var $post_args, $kwargs, converters, proxy_default;
5702
5703
5704          $post_args = $slice(arguments);
5705          $kwargs = $extract_kwargs($post_args);
5706          $kwargs = $ensure_kwargs($kwargs);
5707
5708          if ($post_args.length > 0) converters = $post_args.shift();if (converters == null) converters = nil;
5709
5710          proxy_default = $kwargs.$$smap["proxy_default"];if (proxy_default == null) proxy_default = true;
5711          if ($truthy(proxy_default)) {
5712
5713            return $$('DefaultFactoryProxy').$new(converters);
5714          } else {
5715
5716            return $$('CustomFactory').$new(converters);
5717          };
5718        }, -1);
5719        $defs(self, '$default', function $Factory_default$4($a) {
5720          var $post_args, args;
5721
5722
5723          $post_args = $slice(arguments);
5724          args = $post_args;
5725          return $$('Converter');
5726        }, -1);
5727        $defs(self, '$create', function $$create(backend, opts) {
5728          var self = this;
5729
5730
5731          if (opts == null) opts = $hash2([], {});
5732          return self.$default().$create(backend, opts);
5733        }, -2);
5734
5735        $def(self, '$register', function $$register(converter, $a) {
5736          var $post_args, backends, self = this;
5737
5738
5739          $post_args = $slice(arguments, 1);
5740          backends = $post_args;
5741          return $send(backends, 'each', [], function $$5(backend){var $b, self = $$5.$$s == null ? this : $$5.$$s;
5742
5743
5744            if (backend == null) backend = nil;
5745            if ($eqeq(backend, "*")) {
5746
5747              return ($b = [converter], $send(self.$registry(), 'default=', $b), $b[$b.length - 1]);
5748            } else {
5749
5750              return ($b = [backend, converter], $send(self.$registry(), '[]=', $b), $b[$b.length - 1]);
5751            };}, {$$s: self});
5752        }, -2);
5753
5754        $def(self, '$for', function $Factory_for$6(backend) {
5755          var self = this;
5756
5757          return self.$registry()['$[]'](backend)
5758        });
5759
5760        $def(self, '$create', function $$create(backend, opts) {
5761          var self = this, converter = nil, template_dirs = nil, delegate_backend = nil;
5762
5763
5764          if (opts == null) opts = $hash2([], {});
5765          if ($truthy((converter = self.$for(backend)))) {
5766
5767            if ($eqeqeq($Class, converter)) {
5768              converter = converter.$new(backend, opts)
5769            };
5770            if ((($truthy((template_dirs = opts['$[]']("template_dirs"))) && ($eqeqeq($$('BackendTraits'), converter))) && ($truthy(converter['$supports_templates?']())))) {
5771              return $$('CompositeConverter').$new(backend, $$('TemplateConverter').$new(backend, template_dirs, opts), converter, $hash2(["backend_traits_source"], {"backend_traits_source": converter}))
5772            } else {
5773              return converter
5774            };
5775          } else if ($truthy((template_dirs = opts['$[]']("template_dirs")))) {
5776            if (($truthy((delegate_backend = opts['$[]']("delegate_backend"))) && ($truthy((converter = self.$for(delegate_backend)))))) {
5777
5778              if ($eqeqeq($Class, converter)) {
5779                converter = converter.$new(delegate_backend, opts)
5780              };
5781              return $$('CompositeConverter').$new(backend, $$('TemplateConverter').$new(backend, template_dirs, opts), converter, $hash2(["backend_traits_source"], {"backend_traits_source": converter}));
5782            } else {
5783              return $$('TemplateConverter').$new(backend, template_dirs, opts)
5784            }
5785          } else {
5786            return nil
5787          };
5788        }, -2);
5789
5790        $def(self, '$converters', function $$converters() {
5791          var self = this;
5792
5793          return self.$registry().$merge()
5794        });
5795        self.$private();
5796        return $def(self, '$registry', function $$registry() {
5797          var self = this;
5798
5799          return self.$raise($$$('NotImplementedError'), "" + ($$('Factory')) + " subclass " + (self.$class()) + " must implement the #" + ("registry") + " method")
5800        });
5801      })($nesting[0], $nesting);
5802      (function($base, $super, $parent_nesting) {
5803        var self = $klass($base, $super, 'CustomFactory');
5804
5805        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5806
5807
5808        self.$include($$('Factory'));
5809
5810        $def(self, '$initialize', function $$initialize(seed_registry) {
5811          var self = this;
5812
5813
5814          if (seed_registry == null) seed_registry = nil;
5815          if ($truthy(seed_registry)) {
5816
5817            seed_registry['$default='](seed_registry.$delete("*"));
5818            return (self.registry = seed_registry);
5819          } else {
5820            return (self.registry = $hash2([], {}))
5821          };
5822        }, -1);
5823
5824        $def(self, '$unregister_all', function $$unregister_all() {
5825          var $a, self = this;
5826
5827          return ($a = [nil], $send(self.$registry().$clear(), 'default=', $a), $a[$a.length - 1])
5828        });
5829        self.$private();
5830        return self.$attr_reader("registry");
5831      })($nesting[0], null, $nesting);
5832      (function($base, $parent_nesting) {
5833        var self = $module($base, 'DefaultFactory');
5834
5835        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5836
5837
5838        self.$include($$('Factory'));
5839        self.$private();
5840        $class_variable_set($nesting[0], '@@registry', $hash2([], {}));
5841
5842        $def(self, '$registry', function $$registry() {
5843
5844          return $class_variable_get($nesting[0], '@@registry', false)
5845        });
5846        return nil;
5847      })($nesting[0], $nesting);
5848      (function($base, $super, $parent_nesting) {
5849        var self = $klass($base, $super, 'DefaultFactoryProxy');
5850
5851        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5852
5853
5854        self.$include($$('DefaultFactory'));
5855        return nil;
5856      })($nesting[0], $$('CustomFactory'), $nesting);
5857      $defs(self, '$included', function $$included(into) {
5858
5859
5860        into.$send("include", $$('BackendTraits'));
5861        return into.$extend($$('Config'));
5862      });
5863      self.$private_class_method("included");
5864      (function($base, $super, $parent_nesting) {
5865        var self = $klass($base, $super, 'Base');
5866
5867        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
5868
5869        $proto.backend = nil;
5870
5871        self.$include($$('Logging'));
5872        self.$include($$('Converter'));
5873
5874        $def(self, '$convert', function $$convert(node, transform, opts) {
5875          var self = this, ex = nil;
5876          if ($gvars["!"] == null) $gvars["!"] = nil;
5877
5878
5879          if (transform == null) transform = node.$node_name();
5880          if (opts == null) opts = nil;
5881          try {
5882            if ($truthy(opts)) {
5883
5884              return self.$send($rb_plus("convert_", transform), node, opts);
5885            } else {
5886
5887              return self.$send($rb_plus("convert_", transform), node);
5888            }
5889          } catch ($err) {
5890            if (Opal.rescue($err, [$$('StandardError')])) {
5891              try {
5892
5893                if (!(($eqeqeq($$$('NoMethodError'), (ex = $gvars["!"])) && ($eqeq(ex.$receiver(), self))) && ($eqeq(ex.$name().$to_s(), transform)))) {
5894                  self.$raise()
5895                };
5896                self.$logger().$warn("missing convert handler for " + (ex.$name()) + " node in " + (self.backend) + " backend (" + (self.$class()) + ")");
5897                return nil;
5898              } finally { Opal.pop_exception(); }
5899            } else { throw $err; }
5900          };
5901        }, -2);
5902
5903        $def(self, '$handles?', function $Base_handles$ques$7(transform) {
5904          var self = this;
5905
5906          return self['$respond_to?']("convert_" + (transform))
5907        });
5908
5909        $def(self, '$content_only', function $$content_only(node) {
5910
5911          return node.$content()
5912        });
5913        return $def(self, '$skip', $return_val(nil));
5914      })($nesting[0], null, $nesting);
5915      return self.$extend($$('DefaultFactory'));
5916    })($nesting[0], $nesting)
5917  })($nesting[0], $nesting)
5918};
5919
5920Opal.modules["asciidoctor/document"] = function(Opal) {/* Generated by Opal 1.7.3 */
5921  "use strict";
5922  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $send = Opal.send, $alias = Opal.alias, $truthy = Opal.truthy, $def = Opal.def, $hash2 = Opal.hash2, $not = Opal.not, $to_ary = Opal.to_ary, $return_ivar = Opal.return_ivar, $send2 = Opal.send2, $find_super = Opal.find_super, $rb_minus = Opal.rb_minus, $eqeq = Opal.eqeq, $eqeqeq = Opal.eqeqeq, $hash = Opal.hash, $rb_ge = Opal.rb_ge, $rb_plus = Opal.rb_plus, $neqeq = Opal.neqeq, $thrower = Opal.thrower, $rb_gt = Opal.rb_gt, $rb_lt = Opal.rb_lt, $gvars = Opal.gvars, $to_a = Opal.to_a, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
5923
5924  Opal.add_stubs('new,target,attr_reader,nil?,<<,[],[]=,main,include?,strip,squeeze,gsub,!,empty?,rpartition,attr_accessor,catalog,delete,base_dir,options,merge,instance_variable_get,attributes,safe,compat_mode,outfilesuffix,sourcemap,path_resolver,converter,extensions,syntax_highlighter,each,end_with?,start_with?,slice,-,length,chop,==,downcase,===,extname,value_for_name,key?,freeze,attribute_undefined,attribute_missing,update,&,keys,name_for_value,expand_path,pwd,to_s,>=,+,abs,to_i,delete_if,update_doctype_attributes,cursor,parse,restore_attributes,update_backend_attributes,fetch,fill_datetime_attributes,activate,groups,create,to_proc,preprocessors?,preprocessors,process_method,tree_processors?,tree_processors,!=,counter,nil_or_empty?,attribute_locked?,nextval,value,save_to,increment_and_store_counter,register,tap,xreftext,>,source,source_lines,doctitle,sectname=,title=,first_section,title,reftext,<,find,context,header?,assign_numeral,clear_playback_attributes,save_attributes,name,negate,rewind,replace,apply_attribute_value_subs,delete?,start,doctype,content_model,warn,logger,content,convert,postprocessors?,postprocessors,record,write,respond_to?,chomp,class,write_alternate_pages,map,split,resolve_docinfo_subs,normalize_system_path,read_asset,apply_subs,docinfo_processors?,join,concat,compact,docinfo_processors,object_id,inspect,size,private,=~,resolve_pass_subs,apply_header_subs,limit_bytesize,bytesize,valid_encoding?,byteslice,resolve_subs,utc,at,Integer,now,index,strftime,year,utc_offset,partition,create_converter,basebackend,filetype,htmlsyntax,derive_backend_traits,raise');
5925  return (function($base, $parent_nesting) {
5926    var self = $module($base, 'Asciidoctor');
5927
5928    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
5929
5930    return (function($base, $super, $parent_nesting) {
5931      var self = $klass($base, $super, 'Document');
5932
5933      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
5934
5935      $proto.attributes = $proto.safe = $proto.sourcemap = $proto.reader = $proto.base_dir = $proto.parsed = $proto.parent_document = $proto.extensions = $proto.options = $proto.counters = $proto.catalog = $proto.reftexts = $proto.next_section_index = $proto.header = $proto.blocks = $proto.header_attributes = $proto.attributes_modified = $proto.backend = $proto.attribute_overrides = $proto.timings = $proto.converter = $proto.outfilesuffix = $proto.docinfo_processor_extensions = $proto.document = $proto.max_attribute_value_size = $proto.id = $proto.doctype = nil;
5936
5937      $const_set($nesting[0], 'ImageReference', $send($$$('Struct'), 'new', ["target", "imagesdir"], function $Document$1(){var self = $Document$1.$$s == null ? this : $Document$1.$$s;
5938
5939        return $alias(self, "to_s", "target")}, {$$s: self}));
5940      $const_set($nesting[0], 'Footnote', $$$('Struct').$new("index", "id", "text"));
5941      (function($base, $super) {
5942        var self = $klass($base, $super, 'AttributeEntry');
5943
5944
5945
5946        self.$attr_reader("name", "value", "negate");
5947
5948        $def(self, '$initialize', function $$initialize(name, value, negate) {
5949          var self = this;
5950
5951
5952          if (negate == null) negate = nil;
5953          self.name = name;
5954          self.value = value;
5955          return (self.negate = ($truthy(negate['$nil?']()) ? (value['$nil?']()) : (negate)));
5956        }, -3);
5957        return $def(self, '$save_to', function $$save_to(block_attributes) {
5958          var $a, self = this, $ret_or_1 = nil;
5959
5960
5961          ($truthy(($ret_or_1 = block_attributes['$[]']("attribute_entries"))) ? ($ret_or_1) : (($a = ["attribute_entries", []], $send(block_attributes, '[]=', $a), $a[$a.length - 1])))['$<<'](self);
5962          return self;
5963        });
5964      })($nesting[0], null);
5965      (function($base, $super, $parent_nesting) {
5966        var self = $klass($base, $super, 'Title');
5967
5968        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
5969
5970        $proto.subtitle = nil;
5971
5972        self.$attr_reader("main");
5973        $alias(self, "title", "main");
5974        self.$attr_reader("subtitle");
5975        self.$attr_reader("combined");
5976
5977        $def(self, '$initialize', function $$initialize(val, opts) {
5978          var $a, $b, self = this, sep = nil, $ret_or_1 = nil, _ = nil;
5979
5980
5981          if (opts == null) opts = $hash2([], {});
5982          if (($truthy((self.sanitized = opts['$[]']("sanitize"))) && ($truthy(val['$include?']("<"))))) {
5983            val = val.$gsub($$('XmlSanitizeRx'), "").$squeeze(" ").$strip()
5984          };
5985          if (($truthy((sep = ($truthy(($ret_or_1 = opts['$[]']("separator"))) ? ($ret_or_1) : (":")))['$empty?']()) || ($not(val['$include?']((sep = "" + (sep) + " ")))))) {
5986
5987            self.main = val;
5988            self.subtitle = nil;
5989          } else {
5990            $b = val.$rpartition(sep), $a = $to_ary($b), (self.main = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (self.subtitle = ($a[2] == null ? nil : $a[2])), $b
5991          };
5992          return (self.combined = val);
5993        }, -2);
5994
5995        $def(self, '$sanitized?', $return_ivar("sanitized"));
5996
5997        $def(self, '$subtitle?', function $Title_subtitle$ques$2() {
5998          var self = this;
5999
6000          if ($truthy(self.subtitle)) {
6001            return true
6002          } else {
6003            return false
6004          }
6005        });
6006        return $def(self, '$to_s', $return_ivar("combined"));
6007      })($nesting[0], null, $nesting);
6008      $const_set($nesting[0], 'Author', $$$('Struct').$new("name", "firstname", "middlename", "lastname", "initials", "email"));
6009      self.$attr_reader("safe");
6010      self.$attr_reader("compat_mode");
6011      self.$attr_reader("backend");
6012      self.$attr_reader("doctype");
6013      self.$attr_accessor("sourcemap");
6014      self.$attr_reader("catalog");
6015      $alias(self, "references", "catalog");
6016      self.$attr_reader("counters");
6017      self.$attr_reader("header");
6018      self.$attr_reader("base_dir");
6019      self.$attr_reader("options");
6020      self.$attr_reader("outfilesuffix");
6021      self.$attr_reader("parent_document");
6022      self.$attr_reader("reader");
6023      self.$attr_reader("path_resolver");
6024      self.$attr_reader("converter");
6025      self.$attr_reader("syntax_highlighter");
6026      self.$attr_reader("extensions");
6027
6028      $def(self, '$initialize', function $$initialize(data, options) {
6029        var $a, $b, $c, $d, $e, $yield = $$initialize.$$p || nil, self = this, parent_doc = nil, $ret_or_1 = nil, attr_overrides = nil, parent_doctype = nil, initialize_extensions = nil, to_file = nil, safe_mode = nil, input_mtime = nil, standalone = nil, attrs = nil, safe_mode_name = nil, base_dir_val = nil, backend_val = nil, doctype_val = nil, size = nil, initial_backend = nil, ext_registry = nil, ext_block = nil;
6030
6031        $$initialize.$$p = null;
6032
6033        if (data == null) data = nil;
6034        if (options == null) options = $hash2([], {});
6035        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [self, "document"], null);
6036        if ($truthy((parent_doc = options.$delete("parent")))) {
6037
6038          self.parent_document = parent_doc;
6039          if ($truthy(($ret_or_1 = options['$[]']("base_dir")))) {
6040            $ret_or_1
6041          } else {
6042            options['$[]=']("base_dir", parent_doc.$base_dir())
6043          };
6044          if ($truthy(parent_doc.$options()['$[]']("catalog_assets"))) {
6045            options['$[]=']("catalog_assets", true)
6046          };
6047          if ($truthy(parent_doc.$options()['$[]']("to_dir"))) {
6048            options['$[]=']("to_dir", parent_doc.$options()['$[]']("to_dir"))
6049          };
6050          self.catalog = parent_doc.$catalog().$merge($hash2(["footnotes"], {"footnotes": []}));
6051          self.attribute_overrides = (attr_overrides = parent_doc.$instance_variable_get("@attribute_overrides").$merge(parent_doc.$attributes()));
6052          attr_overrides.$delete("compat-mode");
6053          parent_doctype = attr_overrides.$delete("doctype");
6054          attr_overrides.$delete("notitle");
6055          attr_overrides.$delete("showtitle");
6056          attr_overrides.$delete("toc");
6057          self.attributes['$[]=']("toc-placement", ($truthy(($ret_or_1 = attr_overrides.$delete("toc-placement"))) ? ($ret_or_1) : ("auto")));
6058          attr_overrides.$delete("toc-position");
6059          self.safe = parent_doc.$safe();
6060          if ($truthy((self.compat_mode = parent_doc.$compat_mode()))) {
6061            self.attributes['$[]=']("compat-mode", "")
6062          };
6063          self.outfilesuffix = parent_doc.$outfilesuffix();
6064          self.sourcemap = parent_doc.$sourcemap();
6065          self.timings = nil;
6066          self.path_resolver = parent_doc.$path_resolver();
6067          self.converter = parent_doc.$converter();
6068          initialize_extensions = nil;
6069          self.extensions = parent_doc.$extensions();
6070          self.syntax_highlighter = parent_doc.$syntax_highlighter();
6071        } else {
6072
6073          self.parent_document = nil;
6074          self.catalog = $hash2(["ids", "refs", "footnotes", "links", "images", "callouts", "includes"], {"ids": $hash2([], {}), "refs": $hash2([], {}), "footnotes": [], "links": [], "images": [], "callouts": $$('Callouts').$new(), "includes": $hash2([], {})});
6075          self.attribute_overrides = (attr_overrides = $hash2([], {}));
6076          $send(($truthy(($ret_or_1 = options['$[]']("attributes"))) ? ($ret_or_1) : ($hash2([], {}))), 'each', [], function $$3(key, val){var $a;
6077
6078
6079            if (key == null) key = nil;
6080            if (val == null) val = nil;
6081            if ($truthy(key['$end_with?']("@"))) {
6082              if ($truthy(key['$start_with?']("!"))) {
6083                $a = [key.$slice(1, $rb_minus(key.$length(), 2)), false], (key = $a[0]), (val = $a[1]), $a
6084              } else if ($truthy(key['$end_with?']("!@"))) {
6085                $a = [key.$slice(0, $rb_minus(key.$length(), 2)), false], (key = $a[0]), (val = $a[1]), $a
6086              } else {
6087                $a = [key.$chop(), "" + (val) + "@"], (key = $a[0]), (val = $a[1]), $a
6088              }
6089            } else if ($truthy(key['$start_with?']("!"))) {
6090              $a = [key.$slice(1, key.$length()), ($eqeq(val, "@") ? (false) : (nil))], (key = $a[0]), (val = $a[1]), $a
6091            } else if ($truthy(key['$end_with?']("!"))) {
6092              $a = [key.$chop(), ($eqeq(val, "@") ? (false) : (nil))], (key = $a[0]), (val = $a[1]), $a
6093            };
6094            return ($a = [key.$downcase(), val], $send(attr_overrides, '[]=', $a), $a[$a.length - 1]);});
6095          if ($eqeqeq($$$('String'), (to_file = options['$[]']("to_file")))) {
6096            attr_overrides['$[]=']("outfilesuffix", $$('Helpers').$extname(to_file))
6097          };
6098          if ($not((safe_mode = options['$[]']("safe")))) {
6099            self.safe = $$$($$('SafeMode'), 'SECURE')
6100          } else if ($eqeqeq($$$('Integer'), safe_mode)) {
6101            self.safe = safe_mode
6102          } else {
6103            self.safe = (function() { try {
6104
6105              return $$('SafeMode').$value_for_name(safe_mode);
6106            } catch ($err) {
6107              if (Opal.rescue($err, [$$('StandardError')])) {
6108                try {
6109                  return $$$($$('SafeMode'), 'SECURE')
6110                } finally { Opal.pop_exception(); }
6111              } else { throw $err; }
6112            }})()
6113          };
6114          input_mtime = options.$delete("input_mtime");
6115          self.compat_mode = attr_overrides['$key?']("compat-mode");
6116          self.sourcemap = options['$[]']("sourcemap");
6117          self.timings = options.$delete("timings");
6118          self.path_resolver = $$('PathResolver').$new();
6119          initialize_extensions = (($truthy((($b = $$$('::', 'Asciidoctor', 'skip_raise')) && ($a = $$$($b, 'Extensions', 'skip_raise')) ? 'constant' : nil)) || ($truthy(options['$key?']("extensions")))) ? ($$$($$$('Asciidoctor'), 'Extensions')) : (nil));
6120          self.extensions = nil;
6121          if (($truthy(options['$key?']("header_footer")) && ($not(options['$key?']("standalone"))))) {
6122            options['$[]=']("standalone", options['$[]']("header_footer"))
6123          };
6124        };
6125        self.parsed = (self.reftexts = (self.header = (self.header_attributes = nil)));
6126        self.counters = $hash2([], {});
6127        self.attributes_modified = $$$('Set').$new();
6128        self.docinfo_processor_extensions = $hash2([], {});
6129        standalone = options['$[]']("standalone");
6130        (self.options = options).$freeze();
6131        attrs = self.attributes;
6132        if (!$truthy(parent_doc)) {
6133
6134          attrs['$[]=']("attribute-undefined", $$('Compliance').$attribute_undefined());
6135          attrs['$[]=']("attribute-missing", $$('Compliance').$attribute_missing());
6136          attrs.$update($$('DEFAULT_ATTRIBUTES'));
6137        };
6138        if ($truthy(standalone)) {
6139
6140          attr_overrides['$[]=']("embedded", nil);
6141          attrs['$[]=']("copycss", "");
6142          attrs['$[]=']("iconfont-remote", "");
6143          attrs['$[]=']("stylesheet", "");
6144          attrs['$[]=']("webfonts", "");
6145        } else {
6146
6147          attr_overrides['$[]=']("embedded", "");
6148          if (($truthy(attr_overrides['$key?']("showtitle")) && ($eqeq(attr_overrides.$keys()['$&'](["notitle", "showtitle"])['$[]'](-1), "showtitle")))) {
6149            attr_overrides['$[]=']("notitle", $hash(nil, "", false, "@", "@", false)['$[]'](attr_overrides['$[]']("showtitle")))
6150          } else if ($truthy(attr_overrides['$key?']("notitle"))) {
6151            attr_overrides['$[]=']("showtitle", $hash(nil, "", false, "@", "@", false)['$[]'](attr_overrides['$[]']("notitle")))
6152          } else {
6153            attrs['$[]=']("notitle", "")
6154          };
6155        };
6156        attr_overrides['$[]=']("asciidoctor", "");
6157        attr_overrides['$[]=']("asciidoctor-version", $$$($$$('Asciidoctor'), 'VERSION'));
6158        attr_overrides['$[]=']("safe-mode-name", (safe_mode_name = $$('SafeMode').$name_for_value(self.safe)));
6159        attr_overrides['$[]=']("safe-mode-" + (safe_mode_name), "");
6160        attr_overrides['$[]=']("safe-mode-level", self.safe);
6161        if ($truthy(($ret_or_1 = attr_overrides['$[]']("max-include-depth")))) {
6162          $ret_or_1
6163        } else {
6164          attr_overrides['$[]=']("max-include-depth", 64)
6165        };
6166        if ($truthy(($ret_or_1 = attr_overrides['$[]']("allow-uri-read")))) {
6167          $ret_or_1
6168        } else {
6169          attr_overrides['$[]=']("allow-uri-read", nil)
6170        };
6171        if ($truthy(attr_overrides['$key?']("numbered"))) {
6172          attr_overrides['$[]=']("sectnums", attr_overrides.$delete("numbered"))
6173        };
6174        if ($truthy(attr_overrides['$key?']("hardbreaks"))) {
6175          attr_overrides['$[]=']("hardbreaks-option", attr_overrides.$delete("hardbreaks"))
6176        };
6177        if ($truthy((base_dir_val = options['$[]']("base_dir")))) {
6178          self.base_dir = ($c = ["docdir", $$$('File').$expand_path(base_dir_val)], $send(attr_overrides, '[]=', $c), $c[$c.length - 1])
6179        } else if ($truthy(attr_overrides['$[]']("docdir"))) {
6180          self.base_dir = attr_overrides['$[]']("docdir")
6181        } else {
6182          self.base_dir = ($c = ["docdir", $$$('Dir').$pwd()], $send(attr_overrides, '[]=', $c), $c[$c.length - 1])
6183        };
6184        if ($truthy((backend_val = options['$[]']("backend")))) {
6185          attr_overrides['$[]=']("backend", backend_val.$to_s())
6186        };
6187        if ($truthy((doctype_val = options['$[]']("doctype")))) {
6188          attr_overrides['$[]=']("doctype", doctype_val.$to_s())
6189        };
6190        if ($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SERVER')))) {
6191
6192          if ($truthy(($ret_or_1 = attr_overrides['$[]']("copycss")))) {
6193            $ret_or_1
6194          } else {
6195            attr_overrides['$[]=']("copycss", nil)
6196          };
6197          if ($truthy(($ret_or_1 = attr_overrides['$[]']("source-highlighter")))) {
6198            $ret_or_1
6199          } else {
6200            attr_overrides['$[]=']("source-highlighter", nil)
6201          };
6202          if ($truthy(($ret_or_1 = attr_overrides['$[]']("backend")))) {
6203            $ret_or_1
6204          } else {
6205            attr_overrides['$[]=']("backend", $$('DEFAULT_BACKEND'))
6206          };
6207          if (($not(parent_doc) && ($truthy(attr_overrides['$key?']("docfile"))))) {
6208            attr_overrides['$[]=']("docfile", attr_overrides['$[]']("docfile")['$[]'](Opal.Range.$new($rb_plus(attr_overrides['$[]']("docdir").$length(), 1), -1, false)))
6209          };
6210          attr_overrides['$[]=']("docdir", "");
6211          if ($truthy(($ret_or_1 = attr_overrides['$[]']("user-home")))) {
6212            $ret_or_1
6213          } else {
6214            attr_overrides['$[]=']("user-home", ".")
6215          };
6216          if ($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SECURE')))) {
6217
6218            if (!$truthy(attr_overrides['$key?']("max-attribute-value-size"))) {
6219              attr_overrides['$[]=']("max-attribute-value-size", 4096)
6220            };
6221            if (!$truthy(attr_overrides['$key?']("linkcss"))) {
6222              attr_overrides['$[]=']("linkcss", "")
6223            };
6224            if ($truthy(($ret_or_1 = attr_overrides['$[]']("icons")))) {
6225              $ret_or_1
6226            } else {
6227              attr_overrides['$[]=']("icons", nil)
6228            };
6229          };
6230        } else if ($truthy(($ret_or_1 = attr_overrides['$[]']("user-home")))) {
6231          $ret_or_1
6232        } else {
6233          attr_overrides['$[]=']("user-home", $$('USER_HOME'))
6234        };
6235        self.max_attribute_value_size = ($truthy((size = ($truthy(($ret_or_1 = attr_overrides['$[]']("max-attribute-value-size"))) ? ($ret_or_1) : (($c = ["max-attribute-value-size", nil], $send(attr_overrides, '[]=', $c), $c[$c.length - 1]))))) ? (size.$to_i().$abs()) : (nil));
6236        $send(attr_overrides, 'delete_if', [], function $$4(key, val){var $d, verdict = nil;
6237
6238
6239          if (key == null) key = nil;
6240          if (val == null) val = nil;
6241          if ($truthy(val)) {
6242
6243            if (($eqeqeq($$$('String'), val) && ($truthy(val['$end_with?']("@"))))) {
6244              $d = [val.$chop(), true], (val = $d[0]), (verdict = $d[1]), $d
6245            };
6246            attrs['$[]='](key, val);
6247          } else {
6248
6249            attrs.$delete(key);
6250            verdict = val['$=='](false);
6251          };
6252          return verdict;});
6253        if ($truthy(parent_doc)) {
6254
6255          self.backend = attrs['$[]']("backend");
6256          if (!$eqeq((self.doctype = ($c = ["doctype", parent_doctype], $send(attrs, '[]=', $c), $c[$c.length - 1])), $$('DEFAULT_DOCTYPE'))) {
6257            self.$update_doctype_attributes($$('DEFAULT_DOCTYPE'))
6258          };
6259          self.reader = $$('Reader').$new(data, options['$[]']("cursor"));
6260          if ($truthy(self.sourcemap)) {
6261            self.source_location = self.reader.$cursor()
6262          };
6263          $$('Parser').$parse(self.reader, self);
6264          self.$restore_attributes();
6265          return (self.parsed = true);
6266        } else {
6267
6268          self.backend = nil;
6269          if ($eqeq((initial_backend = ($truthy(($ret_or_1 = attrs['$[]']("backend"))) ? ($ret_or_1) : ($$('DEFAULT_BACKEND')))), "manpage")) {
6270            self.doctype = ($c = ["doctype", ($d = ["doctype", "manpage"], $send(attr_overrides, '[]=', $d), $d[$d.length - 1])], $send(attrs, '[]=', $c), $c[$c.length - 1])
6271          } else {
6272            self.doctype = ($truthy(($ret_or_1 = attrs['$[]']("doctype"))) ? ($ret_or_1) : (($c = ["doctype", $$('DEFAULT_DOCTYPE')], $send(attrs, '[]=', $c), $c[$c.length - 1])))
6273          };
6274          self.$update_backend_attributes(initial_backend, true);
6275          if ($truthy(($ret_or_1 = attrs['$[]']("stylesdir")))) {
6276            $ret_or_1
6277          } else {
6278            attrs['$[]=']("stylesdir", ".")
6279          };
6280          if ($truthy(($ret_or_1 = attrs['$[]']("iconsdir")))) {
6281            $ret_or_1
6282          } else {
6283            attrs['$[]=']("iconsdir", "" + (attrs.$fetch("imagesdir", "./images")) + "/icons")
6284          };
6285          self.$fill_datetime_attributes(attrs, input_mtime);
6286          if ($truthy(initialize_extensions)) {
6287            if ($truthy((ext_registry = options['$[]']("extension_registry")))) {
6288              if (($eqeqeq($$$($$('Extensions'), 'Registry'), ext_registry) || (($truthy((($e = $$$('::', 'AsciidoctorJ', 'skip_raise')) && ($d = $$$($e, 'Extensions', 'skip_raise')) && ($c = $$$($d, 'ExtensionRegistry', 'skip_raise')) ? 'constant' : nil)) && ($eqeqeq($$$($$$($$$('AsciidoctorJ'), 'Extensions'), 'ExtensionRegistry'), ext_registry)))))) {
6289                self.extensions = ext_registry.$activate(self)
6290              }
6291            } else if ($truthy((ext_block = options['$[]']("extensions"))['$nil?']())) {
6292              if (!$truthy($$('Extensions').$groups()['$empty?']())) {
6293                self.extensions = $$$($$('Extensions'), 'Registry').$new().$activate(self)
6294              }
6295            } else if ($eqeqeq($$$('Proc'), ext_block)) {
6296              self.extensions = $send($$('Extensions'), 'create', [], ext_block.$to_proc()).$activate(self)
6297            }
6298          };
6299          self.reader = $$('PreprocessorReader').$new(self, data, $$$($$('Reader'), 'Cursor').$new(attrs['$[]']("docfile"), self.base_dir), $hash2(["normalize"], {"normalize": true}));
6300          if ($truthy(self.sourcemap)) {
6301            return (self.source_location = self.reader.$cursor())
6302          } else {
6303            return nil
6304          };
6305        };
6306      }, -1);
6307
6308      $def(self, '$parse', function $$parse(data) {
6309        var self = this, doc = nil, exts = nil;
6310
6311
6312        if (data == null) data = nil;
6313        if ($truthy(self.parsed)) {
6314          return self
6315        } else {
6316
6317          doc = self;
6318          if ($truthy(data)) {
6319
6320            self.reader = $$('PreprocessorReader').$new(doc, data, $$$($$('Reader'), 'Cursor').$new(self.attributes['$[]']("docfile"), self.base_dir), $hash2(["normalize"], {"normalize": true}));
6321            if ($truthy(self.sourcemap)) {
6322              self.source_location = self.reader.$cursor()
6323            };
6324          };
6325          if (($truthy((exts = ($truthy(self.parent_document) ? (nil) : (self.extensions)))) && ($truthy(exts['$preprocessors?']())))) {
6326            $send(exts.$preprocessors(), 'each', [], function $$5(ext){var self = $$5.$$s == null ? this : $$5.$$s, $ret_or_1 = nil;
6327              if (self.reader == null) self.reader = nil;
6328
6329
6330              if (ext == null) ext = nil;
6331              return (self.reader = ($truthy(($ret_or_1 = ext.$process_method()['$[]'](doc, self.reader))) ? ($ret_or_1) : (self.reader)));}, {$$s: self})
6332          };
6333          $$('Parser').$parse(self.reader, doc, $hash2(["header_only"], {"header_only": self.options['$[]']("parse_header_only")}));
6334          self.$restore_attributes();
6335          if (($truthy(exts) && ($truthy(exts['$tree_processors?']())))) {
6336            $send(exts.$tree_processors(), 'each', [], function $$6(ext){var result = nil;
6337
6338
6339              if (ext == null) ext = nil;
6340              if ((($truthy((result = ext.$process_method()['$[]'](doc))) && ($eqeqeq($$('Document'), result))) && ($neqeq(result, doc)))) {
6341                return (doc = result)
6342              } else {
6343                return nil
6344              };})
6345          };
6346          self.parsed = true;
6347          return doc;
6348        };
6349      }, -1);
6350
6351      $def(self, '$parsed?', $return_ivar("parsed"));
6352
6353      $def(self, '$counter', function $$counter(name, seed) {
6354        var $a, self = this, curr_val = nil, locked = nil, next_val = nil;
6355
6356
6357        if (seed == null) seed = nil;
6358        if ($truthy(self.parent_document)) {
6359          return self.parent_document.$counter(name, seed)
6360        };
6361        if ((($truthy((locked = self['$attribute_locked?'](name))) && ($truthy((curr_val = self.counters['$[]'](name))))) || ($not((curr_val = self.attributes['$[]'](name))['$nil_or_empty?']())))) {
6362          next_val = ($a = [name, $$('Helpers').$nextval(curr_val)], $send(self.counters, '[]=', $a), $a[$a.length - 1])
6363        } else if ($truthy(seed)) {
6364          next_val = ($a = [name, ($eqeq(seed, seed.$to_i().$to_s()) ? (seed.$to_i()) : (seed))], $send(self.counters, '[]=', $a), $a[$a.length - 1])
6365        } else {
6366          next_val = ($a = [name, 1], $send(self.counters, '[]=', $a), $a[$a.length - 1])
6367        };
6368        if (!$truthy(locked)) {
6369          self.attributes['$[]='](name, next_val)
6370        };
6371        return next_val;
6372      }, -2);
6373
6374      $def(self, '$increment_and_store_counter', function $$increment_and_store_counter(counter_name, block) {
6375        var self = this;
6376
6377        return $$('AttributeEntry').$new(counter_name, self.$counter(counter_name)).$save_to(block.$attributes()).$value()
6378      });
6379      $alias(self, "counter_increment", "increment_and_store_counter");
6380
6381      $def(self, '$register', function $$register(type, value) {
6382        var self = this, id = nil, $logical_op_recvr_tmp_1 = nil, $ret_or_2 = nil, ref = nil;
6383
6384
6385        switch (type) {
6386          case "ids":
6387            return self.$register("refs", [(id = value['$[]'](0)), $$('Inline').$new(self, "anchor", value['$[]'](1), $hash2(["type", "id"], {"type": "ref", "id": id}))])
6388          case "refs":
6389
6390
6391            $logical_op_recvr_tmp_1 = self.catalog['$[]']("refs");
6392            if ($truthy(($ret_or_2 = $logical_op_recvr_tmp_1['$[]'](value['$[]'](0))))) {
6393              $ret_or_2
6394            } else {
6395              $logical_op_recvr_tmp_1['$[]='](value['$[]'](0), (ref = value['$[]'](1)))
6396            };;
6397            return ref;
6398          case "footnotes":
6399            return self.catalog['$[]'](type)['$<<'](value)
6400          default:
6401            if ($truthy(self.options['$[]']("catalog_assets"))) {
6402              return self.catalog['$[]'](type)['$<<'](($eqeq(type, "images") ? ($$('ImageReference').$new(value, self.attributes['$[]']("imagesdir"))) : (value)))
6403            } else {
6404              return nil
6405            }
6406        }
6407      });
6408
6409      $def(self, '$resolve_id', function $$resolve_id(text) {
6410        var self = this, resolved_id = nil, accum = nil;
6411
6412        if ($truthy(self.reftexts)) {
6413          return self.reftexts['$[]'](text)
6414        } else if ($truthy(self.parsed)) {
6415          return $send((self.reftexts = $hash2([], {})), 'tap', [], function $$7(accum){var self = $$7.$$s == null ? this : $$7.$$s;
6416            if (self.catalog == null) self.catalog = nil;
6417
6418
6419            if (accum == null) accum = nil;
6420            return $send(self.catalog['$[]']("refs"), 'each', [], function $$8(id, ref){var $a, $ret_or_1 = nil;
6421
6422
6423              if (id == null) id = nil;
6424              if (ref == null) ref = nil;
6425              if ($truthy(($ret_or_1 = accum['$[]'](ref.$xreftext())))) {
6426                return $ret_or_1
6427              } else {
6428                return ($a = [ref.$xreftext(), id], $send(accum, '[]=', $a), $a[$a.length - 1])
6429              };});}, {$$s: self})['$[]'](text)
6430        } else {
6431
6432          resolved_id = nil;
6433          self.reftexts = (accum = $hash2([], {}));
6434          (function(){try { var $t_break = $thrower('break'); return $send(self.catalog['$[]']("refs"), 'each', [], function $$9(id, ref){var $a, xreftext = nil, $ret_or_1 = nil;
6435
6436
6437            if (id == null) id = nil;
6438            if (ref == null) ref = nil;
6439            if ($eqeq((xreftext = ref.$xreftext()), text)) {
6440
6441              resolved_id = id;
6442              $t_break.$throw();
6443            };
6444            if ($truthy(($ret_or_1 = accum['$[]'](xreftext)))) {
6445              return $ret_or_1
6446            } else {
6447              return ($a = [xreftext, id], $send(accum, '[]=', $a), $a[$a.length - 1])
6448            };})} catch($e) {
6449            if ($e === $t_break) return $e.$v;
6450            throw $e;
6451          }})();
6452          self.reftexts = nil;
6453          return resolved_id;
6454        }
6455      });
6456
6457      $def(self, '$sections?', function $Document_sections$ques$10() {
6458        var self = this;
6459
6460        return $rb_gt(self.next_section_index, 0)
6461      });
6462
6463      $def(self, '$footnotes?', function $Document_footnotes$ques$11() {
6464        var self = this;
6465
6466        if ($truthy(self.catalog['$[]']("footnotes")['$empty?']())) {
6467          return false
6468        } else {
6469          return true
6470        }
6471      });
6472
6473      $def(self, '$footnotes', function $$footnotes() {
6474        var self = this;
6475
6476        return self.catalog['$[]']("footnotes")
6477      });
6478
6479      $def(self, '$callouts', function $$callouts() {
6480        var self = this;
6481
6482        return self.catalog['$[]']("callouts")
6483      });
6484
6485      $def(self, '$nested?', function $Document_nested$ques$12() {
6486        var self = this;
6487
6488        if ($truthy(self.parent_document)) {
6489          return true
6490        } else {
6491          return false
6492        }
6493      });
6494
6495      $def(self, '$embedded?', function $Document_embedded$ques$13() {
6496        var self = this;
6497
6498        return self.attributes['$key?']("embedded")
6499      });
6500
6501      $def(self, '$extensions?', function $Document_extensions$ques$14() {
6502        var self = this;
6503
6504        if ($truthy(self.extensions)) {
6505          return true
6506        } else {
6507          return false
6508        }
6509      });
6510
6511      $def(self, '$source', function $$source() {
6512        var self = this;
6513
6514        if ($truthy(self.reader)) {
6515          return self.reader.$source()
6516        } else {
6517          return nil
6518        }
6519      });
6520
6521      $def(self, '$source_lines', function $$source_lines() {
6522        var self = this;
6523
6524        if ($truthy(self.reader)) {
6525          return self.reader.$source_lines()
6526        } else {
6527          return nil
6528        }
6529      });
6530
6531      $def(self, '$basebackend?', function $Document_basebackend$ques$15(base) {
6532        var self = this;
6533
6534        return self.attributes['$[]']("basebackend")['$=='](base)
6535      });
6536
6537      $def(self, '$title', function $$title() {
6538        var self = this;
6539
6540        return self.$doctitle()
6541      });
6542
6543      $def(self, '$title=', function $Document_title$eq$16(title) {
6544        var $a, self = this, sect = nil;
6545
6546
6547        if (!$truthy((sect = self.header))) {
6548          (sect = (self.header = $$('Section').$new(self, 0)))['$sectname=']("header")
6549        };
6550        return ($a = [title], $send(sect, 'title=', $a), $a[$a.length - 1]);
6551      });
6552
6553      $def(self, '$doctitle', function $$doctitle(opts) {
6554        var self = this, val = nil, sect = nil, $ret_or_1 = nil, separator = nil;
6555
6556
6557        if (opts == null) opts = $hash2([], {});
6558        if (!$truthy((val = self.attributes['$[]']("title")))) {
6559          if ($truthy((sect = self.$first_section()))) {
6560            val = sect.$title()
6561          } else if ($not(($truthy(($ret_or_1 = opts['$[]']("use_fallback"))) ? ((val = self.attributes['$[]']("untitled-label"))) : ($ret_or_1)))) {
6562            return nil
6563          }
6564        };
6565        if ($truthy((separator = opts['$[]']("partition")))) {
6566          return $$('Title').$new(val, opts.$merge($hash2(["separator"], {"separator": ($eqeq(separator, true) ? (self.attributes['$[]']("title-separator")) : (separator))})))
6567        } else if (($truthy(opts['$[]']("sanitize")) && ($truthy(val['$include?']("<"))))) {
6568          return val.$gsub($$('XmlSanitizeRx'), "").$squeeze(" ").$strip()
6569        } else {
6570          return val
6571        };
6572      }, -1);
6573      $alias(self, "name", "doctitle");
6574
6575      $def(self, '$xreftext', function $$xreftext(xrefstyle) {
6576        var self = this, val = nil;
6577
6578
6579        if (xrefstyle == null) xrefstyle = nil;
6580        if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) {
6581          return val
6582        } else {
6583          return self.$title()
6584        };
6585      }, -1);
6586
6587      $def(self, '$author', function $$author() {
6588        var self = this;
6589
6590        return self.attributes['$[]']("author")
6591      });
6592
6593      $def(self, '$authors', function $$authors() {
6594        var self = this, attrs = nil, authors = nil, num_authors = nil, $ret_or_1 = nil, idx = nil;
6595
6596        if ($truthy((attrs = self.attributes)['$key?']("author"))) {
6597
6598          authors = [$$('Author').$new(attrs['$[]']("author"), attrs['$[]']("firstname"), attrs['$[]']("middlename"), attrs['$[]']("lastname"), attrs['$[]']("authorinitials"), attrs['$[]']("email"))];
6599          if ($truthy($rb_gt((num_authors = ($truthy(($ret_or_1 = attrs['$[]']("authorcount"))) ? ($ret_or_1) : (0))), 1))) {
6600
6601            idx = 1;
6602            while ($truthy($rb_lt(idx, num_authors))) {
6603
6604              idx = $rb_plus(idx, 1);
6605              authors['$<<']($$('Author').$new(attrs['$[]']("author_" + (idx)), attrs['$[]']("firstname_" + (idx)), attrs['$[]']("middlename_" + (idx)), attrs['$[]']("lastname_" + (idx)), attrs['$[]']("authorinitials_" + (idx)), attrs['$[]']("email_" + (idx))));
6606            };
6607          };
6608          return authors;
6609        } else {
6610          return []
6611        }
6612      });
6613
6614      $def(self, '$revdate', function $$revdate() {
6615        var self = this;
6616
6617        return self.attributes['$[]']("revdate")
6618      });
6619
6620      $def(self, '$notitle', function $$notitle() {
6621        var self = this;
6622
6623        return self.attributes['$key?']("notitle")
6624      });
6625
6626      $def(self, '$noheader', function $$noheader() {
6627        var self = this;
6628
6629        return self.attributes['$key?']("noheader")
6630      });
6631
6632      $def(self, '$nofooter', function $$nofooter() {
6633        var self = this;
6634
6635        return self.attributes['$key?']("nofooter")
6636      });
6637
6638      $def(self, '$first_section', function $$first_section() {
6639        var self = this, $ret_or_1 = nil;
6640
6641        if ($truthy(($ret_or_1 = self.header))) {
6642          return $ret_or_1
6643        } else {
6644          return $send(self.blocks, 'find', [], function $$17(e){
6645
6646            if (e == null) e = nil;
6647            return e.$context()['$==']("section");})
6648        }
6649      });
6650
6651      $def(self, '$header?', function $Document_header$ques$18() {
6652        var self = this;
6653
6654        if ($truthy(self.header)) {
6655          return true
6656        } else {
6657          return false
6658        }
6659      });
6660      $alias(self, "has_header?", "header?");
6661
6662      $def(self, '$<<', function $Document_$lt$lt$19(block) {
6663        var $yield = $Document_$lt$lt$19.$$p || nil, self = this;
6664
6665        $Document_$lt$lt$19.$$p = null;
6666
6667        if ($eqeq(block.$context(), "section")) {
6668          self.$assign_numeral(block)
6669        };
6670        return $send2(self, $find_super(self, '<<', $Document_$lt$lt$19, false, true), '<<', [block], $yield);
6671      });
6672
6673      $def(self, '$finalize_header', function $$finalize_header(unrooted_attributes, header_valid) {
6674        var self = this;
6675
6676
6677        if (header_valid == null) header_valid = true;
6678        self.$clear_playback_attributes(unrooted_attributes);
6679        self.$save_attributes();
6680        if (!$truthy(header_valid)) {
6681          unrooted_attributes['$[]=']("invalid-header", true)
6682        };
6683        return unrooted_attributes;
6684      }, -2);
6685
6686      $def(self, '$playback_attributes', function $$playback_attributes(block_attributes) {
6687        var self = this;
6688
6689        if ($truthy(block_attributes['$key?']("attribute_entries"))) {
6690          return $send(block_attributes['$[]']("attribute_entries"), 'each', [], function $$20(entry){var self = $$20.$$s == null ? this : $$20.$$s, name = nil;
6691            if (self.attributes == null) self.attributes = nil;
6692
6693
6694            if (entry == null) entry = nil;
6695            name = entry.$name();
6696            if ($truthy(entry.$negate())) {
6697
6698              self.attributes.$delete(name);
6699              if ($eqeq(name, "compat-mode")) {
6700                return (self.compat_mode = false)
6701              } else {
6702                return nil
6703              };
6704            } else {
6705
6706              self.attributes['$[]='](name, entry.$value());
6707              if ($eqeq(name, "compat-mode")) {
6708                return (self.compat_mode = true)
6709              } else {
6710                return nil
6711              };
6712            };}, {$$s: self})
6713        } else {
6714          return nil
6715        }
6716      });
6717
6718      $def(self, '$restore_attributes', function $$restore_attributes() {
6719        var self = this;
6720
6721
6722        if (!$truthy(self.parent_document)) {
6723          self.catalog['$[]']("callouts").$rewind()
6724        };
6725        return self.attributes.$replace(self.header_attributes);
6726      });
6727
6728      $def(self, '$set_attribute', function $$set_attribute(name, value) {
6729        var self = this, $ret_or_2 = nil;
6730
6731
6732        if (value == null) value = "";
6733        if ($truthy(self['$attribute_locked?'](name))) {
6734          return nil
6735        } else {
6736
6737          if (!$truthy(value['$empty?']())) {
6738            value = self.$apply_attribute_value_subs(value)
6739          };
6740          if ($truthy(self.header_attributes)) {
6741            self.attributes['$[]='](name, value)
6742          } else {
6743
6744
6745            switch (name) {
6746              case "backend":
6747                self.$update_backend_attributes(value, ($truthy(($ret_or_2 = self.attributes_modified['$delete?']("htmlsyntax"))) ? (value['$=='](self.backend)) : ($ret_or_2)))
6748                break;
6749              case "doctype":
6750                self.$update_doctype_attributes(value)
6751                break;
6752              default:
6753                self.attributes['$[]='](name, value)
6754            };
6755            self.attributes_modified['$<<'](name);
6756          };
6757          return value;
6758        };
6759      }, -2);
6760
6761      $def(self, '$delete_attribute', function $$delete_attribute(name) {
6762        var self = this;
6763
6764        if ($truthy(self['$attribute_locked?'](name))) {
6765          return false
6766        } else {
6767
6768          self.attributes.$delete(name);
6769          self.attributes_modified['$<<'](name);
6770          return true;
6771        }
6772      });
6773
6774      $def(self, '$attribute_locked?', function $Document_attribute_locked$ques$21(name) {
6775        var self = this;
6776
6777        return self.attribute_overrides['$key?'](name)
6778      });
6779
6780      $def(self, '$set_header_attribute', function $$set_header_attribute(name, value, overwrite) {
6781        var self = this, attrs = nil, $ret_or_1 = nil;
6782
6783
6784        if (value == null) value = "";
6785        if (overwrite == null) overwrite = true;
6786        attrs = ($truthy(($ret_or_1 = self.header_attributes)) ? ($ret_or_1) : (self.attributes));
6787        if (($eqeq(overwrite, false) && ($truthy(attrs['$key?'](name))))) {
6788          return false
6789        } else {
6790
6791          attrs['$[]='](name, value);
6792          return true;
6793        };
6794      }, -2);
6795
6796      $def(self, '$convert', function $$convert(opts) {
6797        var $a, self = this, block = nil, $ret_or_1 = nil, output = nil, transform = nil, exts = nil;
6798
6799
6800        if (opts == null) opts = $hash2([], {});
6801        if ($truthy(self.timings)) {
6802          self.timings.$start("convert")
6803        };
6804        if (!$truthy(self.parsed)) {
6805          self.$parse()
6806        };
6807        if (!($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SERVER'))) || ($truthy(opts['$empty?']())))) {
6808
6809          if (!$truthy(($a = ["outfile", opts['$[]']("outfile")], $send(self.attributes, '[]=', $a), $a[$a.length - 1]))) {
6810            self.attributes.$delete("outfile")
6811          };
6812          if (!$truthy(($a = ["outdir", opts['$[]']("outdir")], $send(self.attributes, '[]=', $a), $a[$a.length - 1]))) {
6813            self.attributes.$delete("outdir")
6814          };
6815        };
6816        if ($eqeq(self.$doctype(), "inline")) {
6817          if ($truthy((block = ($truthy(($ret_or_1 = self.blocks['$[]'](0))) ? ($ret_or_1) : (self.header))))) {
6818            if (($eqeq(block.$content_model(), "compound") || ($eqeq(block.$content_model(), "empty")))) {
6819              self.$logger().$warn("no inline candidate; use the inline doctype to convert a single paragragh, verbatim, or raw block")
6820            } else {
6821              output = block.$content()
6822            }
6823          }
6824        } else {
6825
6826          if ($truthy(opts['$key?']("standalone"))) {
6827            transform = ($truthy(opts['$[]']("standalone")) ? ("document") : ("embedded"))
6828          } else if ($truthy(opts['$key?']("header_footer"))) {
6829            transform = ($truthy(opts['$[]']("header_footer")) ? ("document") : ("embedded"))
6830          } else {
6831            transform = ($truthy(self.options['$[]']("standalone")) ? ("document") : ("embedded"))
6832          };
6833          output = self.converter.$convert(self, transform);
6834        };
6835        if (!$truthy(self.parent_document)) {
6836          if (($truthy((exts = self.extensions)) && ($truthy(exts['$postprocessors?']())))) {
6837            $send(exts.$postprocessors(), 'each', [], function $$22(ext){var self = $$22.$$s == null ? this : $$22.$$s;
6838
6839
6840              if (ext == null) ext = nil;
6841              return (output = ext.$process_method()['$[]'](self, output));}, {$$s: self})
6842          }
6843        };
6844        if ($truthy(self.timings)) {
6845          self.timings.$record("convert")
6846        };
6847        return output;
6848      }, -1);
6849      $alias(self, "render", "convert");
6850
6851      $def(self, '$write', function $$write(output, target) {
6852        var self = this;
6853
6854
6855        if ($truthy(self.timings)) {
6856          self.timings.$start("write")
6857        };
6858        if ($eqeqeq($$('Writer'), self.converter)) {
6859          self.converter.$write(output, target)
6860        } else {
6861
6862          if ($truthy(target['$respond_to?']("write"))) {
6863            if (!$truthy(output['$nil_or_empty?']())) {
6864
6865              target.$write(output.$chomp());
6866              target.$write($$('LF'));
6867            }
6868          } else {
6869            $$$('File').$write(target, output, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}))
6870          };
6871          if ((($eqeq(self.backend, "manpage") && ($eqeqeq($$$('String'), target))) && ($truthy(self.converter.$class()['$respond_to?']("write_alternate_pages"))))) {
6872            self.converter.$class().$write_alternate_pages(self.attributes['$[]']("mannames"), self.attributes['$[]']("manvolnum"), target)
6873          };
6874        };
6875        if ($truthy(self.timings)) {
6876          self.timings.$record("write")
6877        };
6878        return nil;
6879      });
6880
6881      $def(self, '$content', function $$content() {
6882        var $yield = $$content.$$p || nil, self = this;
6883
6884        $$content.$$p = null;
6885
6886        self.attributes.$delete("title");
6887        return $send2(self, $find_super(self, 'content', $$content, false, true), 'content', [], $yield);
6888      });
6889
6890      $def(self, '$docinfo', function $$docinfo(location, suffix) {
6891        var $a, self = this, qualifier = nil, $ret_or_1 = nil, docinfo = nil, content = nil, docinfo_file = nil, docinfo_dir = nil, docinfo_subs = nil, docinfo_path = nil, shared_docinfo = nil, private_docinfo = nil;
6892
6893
6894        if (location == null) location = "head";
6895        if (suffix == null) suffix = nil;
6896        if ($truthy($rb_lt(self.$safe(), $$$($$('SafeMode'), 'SECURE')))) {
6897
6898          if (!$eqeq(location, "head")) {
6899            qualifier = "-" + (location)
6900          };
6901          suffix = ($truthy(($ret_or_1 = suffix)) ? ($ret_or_1) : (self.outfilesuffix));
6902          if ($truthy((docinfo = self.attributes['$[]']("docinfo"))['$nil_or_empty?']())) {
6903            if ($truthy(self.attributes['$key?']("docinfo2"))) {
6904              docinfo = ["private", "shared"]
6905            } else if ($truthy(self.attributes['$key?']("docinfo1"))) {
6906              docinfo = ["shared"]
6907            } else {
6908              docinfo = ($truthy(docinfo) ? (["private"]) : (nil))
6909            }
6910          } else {
6911            docinfo = $send(docinfo.$split(","), 'map', [], function $$23(it){
6912
6913              if (it == null) it = nil;
6914              return it.$strip();})
6915          };
6916          if ($truthy(docinfo)) {
6917
6918            content = [];
6919            $a = ["docinfo" + (qualifier) + (suffix), self.attributes['$[]']("docinfodir"), self.$resolve_docinfo_subs()], (docinfo_file = $a[0]), (docinfo_dir = $a[1]), (docinfo_subs = $a[2]), $a;
6920            if (!$truthy(docinfo['$&'](["shared", "shared-" + (location)])['$empty?']())) {
6921
6922              docinfo_path = self.$normalize_system_path(docinfo_file, docinfo_dir);
6923              if ($truthy((shared_docinfo = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true}))))) {
6924                content['$<<'](self.$apply_subs(shared_docinfo, docinfo_subs))
6925              };
6926            };
6927            if (!($truthy(self.attributes['$[]']("docname")['$nil_or_empty?']()) || ($truthy(docinfo['$&'](["private", "private-" + (location)])['$empty?']())))) {
6928
6929              docinfo_path = self.$normalize_system_path("" + (self.attributes['$[]']("docname")) + "-" + (docinfo_file), docinfo_dir);
6930              if ($truthy((private_docinfo = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true}))))) {
6931                content['$<<'](self.$apply_subs(private_docinfo, docinfo_subs))
6932              };
6933            };
6934          };
6935        };
6936        if (($truthy(self.extensions) && ($truthy(self['$docinfo_processors?'](location))))) {
6937          return ($truthy(($ret_or_1 = content)) ? ($ret_or_1) : ([])).$concat($send(self.docinfo_processor_extensions['$[]'](location), 'map', [], function $$24(ext){var self = $$24.$$s == null ? this : $$24.$$s;
6938
6939
6940            if (ext == null) ext = nil;
6941            return ext.$process_method()['$[]'](self);}, {$$s: self}).$compact()).$join($$('LF'))
6942        } else if ($truthy(content)) {
6943          return content.$join($$('LF'))
6944        } else {
6945          return ""
6946        };
6947      }, -1);
6948
6949      $def(self, '$docinfo_processors?', function $Document_docinfo_processors$ques$25(location) {
6950        var $a, self = this;
6951
6952
6953        if (location == null) location = "head";
6954        if ($truthy(self.docinfo_processor_extensions['$key?'](location))) {
6955          return self.docinfo_processor_extensions['$[]'](location)['$!='](false)
6956        } else if (($truthy(self.extensions) && ($truthy(self.document.$extensions()['$docinfo_processors?'](location))))) {
6957          return ($a = [location, self.document.$extensions().$docinfo_processors(location)], $send(self.docinfo_processor_extensions, '[]=', $a), $a[$a.length - 1])['$!']()['$!']()
6958        } else {
6959          return ($a = [location, false], $send(self.docinfo_processor_extensions, '[]=', $a), $a[$a.length - 1])
6960        };
6961      }, -1);
6962
6963      $def(self, '$to_s', function $$to_s() {
6964        var self = this, $ret_or_1 = nil;
6965
6966        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {doctype: " + (self.$doctype().$inspect()) + ", doctitle: " + (($truthy(($ret_or_1 = self.header)) ? (self.header.$title()) : ($ret_or_1)).$inspect()) + ", blocks: " + (self.blocks.$size()) + "}>"
6967      });
6968      self.$private();
6969
6970      $def(self, '$apply_attribute_value_subs', function $$apply_attribute_value_subs(value) {
6971        var $a, self = this;
6972
6973
6974        if ($truthy($$('AttributeEntryPassMacroRx')['$=~'](value))) {
6975
6976          value = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2));
6977          if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
6978            value = self.$apply_subs(value, self.$resolve_pass_subs((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))
6979          };
6980        } else {
6981          value = self.$apply_header_subs(value)
6982        };
6983        if ($truthy(self.max_attribute_value_size)) {
6984
6985          return self.$limit_bytesize(value, self.max_attribute_value_size);
6986        } else {
6987          return value
6988        };
6989      });
6990
6991      $def(self, '$limit_bytesize', function $$limit_bytesize(str, max) {
6992
6993
6994        if ($truthy($rb_gt(str.$bytesize(), max))) {
6995          while (!($truthy((str = str.$byteslice(0, max))['$valid_encoding?']()))) {
6996          max = $rb_minus(max, 1)
6997          }
6998        };
6999        return str;
7000      });
7001
7002      $def(self, '$resolve_docinfo_subs', function $$resolve_docinfo_subs() {
7003        var self = this;
7004
7005        if ($truthy(self.attributes['$key?']("docinfosubs"))) {
7006
7007          return self.$resolve_subs(self.attributes['$[]']("docinfosubs"), "block", nil, "docinfo");
7008        } else {
7009          return ["attributes"]
7010        }
7011      });
7012
7013      $def(self, '$create_converter', function $$create_converter(backend, delegate_backend) {
7014        var self = this, converter_opts = nil, template_dirs = nil, $ret_or_1 = nil, opts = nil, converter = nil;
7015
7016
7017        converter_opts = $hash2(["document", "htmlsyntax"], {"document": self, "htmlsyntax": self.attributes['$[]']("htmlsyntax")});
7018        if ($truthy((template_dirs = ($truthy(($ret_or_1 = (opts = self.options)['$[]']("template_dirs"))) ? ($ret_or_1) : (opts['$[]']("template_dir")))))) {
7019
7020          converter_opts['$[]=']("template_dirs", [].concat($to_a(template_dirs)));
7021          converter_opts['$[]=']("template_cache", opts.$fetch("template_cache", true));
7022          converter_opts['$[]=']("template_engine", opts['$[]']("template_engine"));
7023          converter_opts['$[]=']("template_engine_options", opts['$[]']("template_engine_options"));
7024          converter_opts['$[]=']("eruby", opts['$[]']("eruby"));
7025          converter_opts['$[]=']("safe", self.safe);
7026          if ($truthy(delegate_backend)) {
7027            converter_opts['$[]=']("delegate_backend", delegate_backend)
7028          };
7029        };
7030        if ($truthy((converter = opts['$[]']("converter")))) {
7031          return $$$($$('Converter'), 'CustomFactory').$new($hash(backend, converter)).$create(backend, converter_opts)
7032        } else {
7033          return opts.$fetch("converter_factory", $$('Converter')).$create(backend, converter_opts)
7034        };
7035      });
7036
7037      $def(self, '$clear_playback_attributes', function $$clear_playback_attributes(attributes) {
7038
7039        return attributes.$delete("attribute_entries")
7040      });
7041
7042      $def(self, '$save_attributes', function $$save_attributes() {
7043        var self = this, doctitle_val = nil, attrs = nil, $ret_or_1 = nil, toc_val = nil, toc_position_val = nil, toc_placement_val = nil, default_toc_position = nil, default_toc_class = nil, position = nil, icons_val = nil, basebackend = nil, syntax_hl_name = nil, syntax_hl_factory = nil, syntax_hls = nil;
7044
7045
7046        if (!($truthy((attrs = self.attributes)['$key?']("doctitle")) || ($not((doctitle_val = self.$doctitle()))))) {
7047          attrs['$[]=']("doctitle", doctitle_val)
7048        };
7049        self.id = ($truthy(($ret_or_1 = self.id)) ? ($ret_or_1) : (attrs['$[]']("css-signature")));
7050        if ($truthy((toc_val = ($truthy(attrs.$delete("toc2")) ? ("left") : (attrs['$[]']("toc")))))) {
7051
7052          toc_position_val = (($truthy((toc_placement_val = attrs.$fetch("toc-placement", "macro"))) && ($neqeq(toc_placement_val, "auto"))) ? (toc_placement_val) : (attrs['$[]']("toc-position")));
7053          if (!($truthy(toc_val['$empty?']()) && ($truthy(toc_position_val['$nil_or_empty?']())))) {
7054
7055            default_toc_position = "left";
7056            default_toc_class = "toc2";
7057            position = ($truthy(toc_position_val['$nil_or_empty?']()) ? (($truthy(toc_val['$empty?']()) ? (default_toc_position) : (toc_val))) : (toc_position_val));
7058            attrs['$[]=']("toc", "");
7059            attrs['$[]=']("toc-placement", "auto");
7060
7061            switch (position) {
7062              case "left":
7063              case "<":
7064              case "&lt;":
7065                attrs['$[]=']("toc-position", "left")
7066                break;
7067              case "right":
7068              case ">":
7069              case "&gt;":
7070                attrs['$[]=']("toc-position", "right")
7071                break;
7072              case "top":
7073              case "^":
7074                attrs['$[]=']("toc-position", "top")
7075                break;
7076              case "bottom":
7077              case "v":
7078                attrs['$[]=']("toc-position", "bottom")
7079                break;
7080              case "preamble":
7081              case "macro":
7082
7083                attrs['$[]=']("toc-position", "content");
7084                attrs['$[]=']("toc-placement", position);
7085                default_toc_class = nil;
7086                break;
7087              default:
7088
7089                attrs.$delete("toc-position");
7090                default_toc_class = nil;
7091            };
7092            if ($truthy(default_toc_class)) {
7093              if ($truthy(($ret_or_1 = attrs['$[]']("toc-class")))) {
7094                $ret_or_1
7095              } else {
7096                attrs['$[]=']("toc-class", default_toc_class)
7097              }
7098            };
7099          };
7100        };
7101        if (($truthy((icons_val = attrs['$[]']("icons"))) && ($not(attrs['$key?']("icontype"))))) {
7102
7103          switch (icons_val) {
7104            case "":
7105            case "font":
7106
7107              break;
7108            default:
7109
7110              attrs['$[]=']("icons", "");
7111              if (!$eqeq(icons_val, "image")) {
7112                attrs['$[]=']("icontype", icons_val)
7113              };
7114          }
7115        };
7116        if (($truthy((self.compat_mode = attrs['$key?']("compat-mode"))) && ($truthy(attrs['$key?']("language"))))) {
7117          attrs['$[]=']("source-language", attrs['$[]']("language"))
7118        };
7119        if (!$truthy(self.parent_document)) {
7120
7121          if ($eqeq((basebackend = attrs['$[]']("basebackend")), "html")) {
7122            if (($truthy((syntax_hl_name = attrs['$[]']("source-highlighter"))) && ($not(attrs['$[]']("" + (syntax_hl_name) + "-unavailable"))))) {
7123              if ($truthy((syntax_hl_factory = self.options['$[]']("syntax_highlighter_factory")))) {
7124                self.syntax_highlighter = syntax_hl_factory.$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self}))
7125              } else if ($truthy((syntax_hls = self.options['$[]']("syntax_highlighters")))) {
7126                self.syntax_highlighter = $$$($$('SyntaxHighlighter'), 'DefaultFactoryProxy').$new(syntax_hls).$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self}))
7127              } else {
7128                self.syntax_highlighter = $$('SyntaxHighlighter').$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self}))
7129              }
7130            }
7131          } else if ($eqeq(basebackend, "docbook")) {
7132
7133            if (!($truthy(self['$attribute_locked?']("toc")) || ($truthy(self.attributes_modified['$include?']("toc"))))) {
7134              attrs['$[]=']("toc", "")
7135            };
7136            if (!($truthy(self['$attribute_locked?']("sectnums")) || ($truthy(self.attributes_modified['$include?']("sectnums"))))) {
7137              attrs['$[]=']("sectnums", "")
7138            };
7139          };
7140          self.outfilesuffix = attrs['$[]']("outfilesuffix");
7141          $send($$('FLEXIBLE_ATTRIBUTES'), 'each', [], function $$26(name){var self = $$26.$$s == null ? this : $$26.$$s;
7142            if (self.attribute_overrides == null) self.attribute_overrides = nil;
7143
7144
7145            if (name == null) name = nil;
7146            if (($truthy(self.attribute_overrides['$key?'](name)) && ($truthy(self.attribute_overrides['$[]'](name))))) {
7147              return self.attribute_overrides.$delete(name)
7148            } else {
7149              return nil
7150            };}, {$$s: self});
7151        };
7152        return (self.header_attributes = attrs.$merge());
7153      });
7154
7155      $def(self, '$fill_datetime_attributes', function $$fill_datetime_attributes(attrs, input_mtime) {
7156        var $a, self = this, now = nil, source_date_epoch = nil, localdate = nil, $ret_or_1 = nil, localtime = nil, $ret_or_2 = nil, docdate = nil, doctime = nil;
7157
7158
7159        now = ($truthy($$$('ENV')['$key?']("SOURCE_DATE_EPOCH")) ? ((source_date_epoch = $$$('Time').$at(self.$Integer($$$('ENV')['$[]']("SOURCE_DATE_EPOCH"))).$utc())) : ($$$('Time').$now()));
7160        if ($truthy((localdate = attrs['$[]']("localdate")))) {
7161          if ($truthy(($ret_or_1 = attrs['$[]']("localyear")))) {
7162            $ret_or_1
7163          } else {
7164            attrs['$[]=']("localyear", ($eqeq(localdate.$index("-"), 4) ? (localdate.$slice(0, 4)) : (nil)))
7165          }
7166        } else {
7167
7168          localdate = ($a = ["localdate", now.$strftime("%F")], $send(attrs, '[]=', $a), $a[$a.length - 1]);
7169          if ($truthy(($ret_or_1 = attrs['$[]']("localyear")))) {
7170            $ret_or_1
7171          } else {
7172            attrs['$[]=']("localyear", now.$year().$to_s())
7173          };
7174        };
7175        localtime = ($truthy(($ret_or_1 = attrs['$[]']("localtime"))) ? ($ret_or_1) : (($a = ["localtime", now.$strftime("%T " + (($eqeq(now.$utc_offset(), 0) ? ("UTC") : ("%z"))))], $send(attrs, '[]=', $a), $a[$a.length - 1])));
7176        if ($truthy(($ret_or_1 = attrs['$[]']("localdatetime")))) {
7177          $ret_or_1
7178        } else {
7179          attrs['$[]=']("localdatetime", "" + (localdate) + " " + (localtime))
7180        };
7181        input_mtime = ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = source_date_epoch)) ? ($ret_or_2) : (input_mtime)))) ? ($ret_or_1) : (now));
7182        if ($truthy((docdate = attrs['$[]']("docdate")))) {
7183          if ($truthy(($ret_or_1 = attrs['$[]']("docyear")))) {
7184            $ret_or_1
7185          } else {
7186            attrs['$[]=']("docyear", ($eqeq(docdate.$index("-"), 4) ? (docdate.$slice(0, 4)) : (nil)))
7187          }
7188        } else {
7189
7190          docdate = ($a = ["docdate", input_mtime.$strftime("%F")], $send(attrs, '[]=', $a), $a[$a.length - 1]);
7191          if ($truthy(($ret_or_1 = attrs['$[]']("docyear")))) {
7192            $ret_or_1
7193          } else {
7194            attrs['$[]=']("docyear", input_mtime.$year().$to_s())
7195          };
7196        };
7197        doctime = ($truthy(($ret_or_1 = attrs['$[]']("doctime"))) ? ($ret_or_1) : (($a = ["doctime", input_mtime.$strftime("%T " + (($eqeq(input_mtime.$utc_offset(), 0) ? ("UTC") : ("%z"))))], $send(attrs, '[]=', $a), $a[$a.length - 1])));
7198        if ($truthy(($ret_or_1 = attrs['$[]']("docdatetime")))) {
7199          $ret_or_1
7200        } else {
7201          attrs['$[]=']("docdatetime", "" + (docdate) + " " + (doctime))
7202        };
7203        return nil;
7204      });
7205
7206      $def(self, '$update_backend_attributes', function $$update_backend_attributes(new_backend, init) {
7207        var $a, $b, self = this, current_backend = nil, current_basebackend = nil, attrs = nil, current_doctype = nil, actual_backend = nil, _ = nil, $ret_or_1 = nil, delegate_backend = nil, converter = nil, new_basebackend = nil, new_filetype = nil, htmlsyntax = nil, backend_traits = nil, current_filetype = nil, page_width = nil;
7208
7209
7210        if (init == null) init = nil;
7211        if (($truthy(init) || ($neqeq(new_backend, self.backend)))) {
7212
7213          current_backend = self.backend;
7214          current_basebackend = (attrs = self.attributes)['$[]']("basebackend");
7215          current_doctype = self.doctype;
7216          if ($truthy(new_backend['$include?'](":"))) {
7217            $b = new_backend.$partition(":"), $a = $to_ary($b), (actual_backend = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (new_backend = ($a[2] == null ? nil : $a[2])), $b
7218          };
7219          if ($truthy(new_backend['$start_with?']("xhtml"))) {
7220
7221            attrs['$[]=']("htmlsyntax", "xml");
7222            new_backend = new_backend.$slice(1, new_backend.$length());
7223          } else if ($truthy(new_backend['$start_with?']("html"))) {
7224            if ($truthy(($ret_or_1 = attrs['$[]']("htmlsyntax")))) {
7225              $ret_or_1
7226            } else {
7227              attrs['$[]=']("htmlsyntax", "html")
7228            }
7229          };
7230          new_backend = ($truthy(($ret_or_1 = $$('BACKEND_ALIASES')['$[]'](new_backend))) ? ($ret_or_1) : (new_backend));
7231          if ($truthy(actual_backend)) {
7232            $a = [actual_backend, new_backend], (new_backend = $a[0]), (delegate_backend = $a[1]), $a
7233          };
7234          if ($truthy(current_doctype)) {
7235
7236            if ($truthy(current_backend)) {
7237
7238              attrs.$delete("backend-" + (current_backend));
7239              attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype));
7240            };
7241            attrs['$[]=']("backend-" + (new_backend) + "-doctype-" + (current_doctype), "");
7242            attrs['$[]=']("doctype-" + (current_doctype), "");
7243          } else if ($truthy(current_backend)) {
7244            attrs.$delete("backend-" + (current_backend))
7245          };
7246          attrs['$[]=']("backend-" + (new_backend), "");
7247          self.backend = ($a = ["backend", new_backend], $send(attrs, '[]=', $a), $a[$a.length - 1]);
7248          if ($eqeqeq($$$($$('Converter'), 'BackendTraits'), (converter = self.$create_converter(new_backend, delegate_backend)))) {
7249
7250            new_basebackend = converter.$basebackend();
7251            new_filetype = converter.$filetype();
7252            if ($truthy((htmlsyntax = converter.$htmlsyntax()))) {
7253              attrs['$[]=']("htmlsyntax", htmlsyntax)
7254            };
7255            if ($truthy(init)) {
7256              if ($truthy(($ret_or_1 = attrs['$[]']("outfilesuffix")))) {
7257                $ret_or_1
7258              } else {
7259                attrs['$[]=']("outfilesuffix", converter.$outfilesuffix())
7260              }
7261            } else if (!$truthy(self['$attribute_locked?']("outfilesuffix"))) {
7262              attrs['$[]=']("outfilesuffix", converter.$outfilesuffix())
7263            };
7264          } else if ($truthy(converter)) {
7265
7266            backend_traits = $$('Converter').$derive_backend_traits(new_backend);
7267            new_basebackend = backend_traits['$[]']("basebackend");
7268            new_filetype = backend_traits['$[]']("filetype");
7269            if ($truthy(init)) {
7270              if ($truthy(($ret_or_1 = attrs['$[]']("outfilesuffix")))) {
7271                $ret_or_1
7272              } else {
7273                attrs['$[]=']("outfilesuffix", backend_traits['$[]']("outfilesuffix"))
7274              }
7275            } else if (!$truthy(self['$attribute_locked?']("outfilesuffix"))) {
7276              attrs['$[]=']("outfilesuffix", backend_traits['$[]']("outfilesuffix"))
7277            };
7278          } else {
7279            self.$raise($$$('NotImplementedError'), "asciidoctor: FAILED: missing converter for backend '" + (new_backend) + "'. Processing aborted.")
7280          };
7281          self.converter = converter;
7282          if ($truthy((current_filetype = attrs['$[]']("filetype")))) {
7283            attrs.$delete("filetype-" + (current_filetype))
7284          };
7285          attrs['$[]=']("filetype", new_filetype);
7286          attrs['$[]=']("filetype-" + (new_filetype), "");
7287          if ($truthy((page_width = $$('DEFAULT_PAGE_WIDTHS')['$[]'](new_basebackend)))) {
7288            attrs['$[]=']("pagewidth", page_width)
7289          } else {
7290            attrs.$delete("pagewidth")
7291          };
7292          if ($neqeq(new_basebackend, current_basebackend)) {
7293
7294            if ($truthy(current_doctype)) {
7295
7296              if ($truthy(current_basebackend)) {
7297
7298                attrs.$delete("basebackend-" + (current_basebackend));
7299                attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype));
7300              };
7301              attrs['$[]=']("basebackend-" + (new_basebackend) + "-doctype-" + (current_doctype), "");
7302            } else if ($truthy(current_basebackend)) {
7303              attrs.$delete("basebackend-" + (current_basebackend))
7304            };
7305            attrs['$[]=']("basebackend-" + (new_basebackend), "");
7306            attrs['$[]=']("basebackend", new_basebackend);
7307          };
7308          return new_backend;
7309        } else {
7310          return nil
7311        };
7312      }, -2);
7313      return $def(self, '$update_doctype_attributes', function $$update_doctype_attributes(new_doctype) {
7314        var $a, self = this, attrs = nil, current_backend = nil, current_basebackend = nil, current_doctype = nil;
7315
7316        if (($truthy(new_doctype) && ($neqeq(new_doctype, self.doctype)))) {
7317
7318          $a = [self.backend, (attrs = self.attributes)['$[]']("basebackend"), self.doctype], (current_backend = $a[0]), (current_basebackend = $a[1]), (current_doctype = $a[2]), $a;
7319          if ($truthy(current_doctype)) {
7320
7321            attrs.$delete("doctype-" + (current_doctype));
7322            if ($truthy(current_backend)) {
7323
7324              attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype));
7325              attrs['$[]=']("backend-" + (current_backend) + "-doctype-" + (new_doctype), "");
7326            };
7327            if ($truthy(current_basebackend)) {
7328
7329              attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype));
7330              attrs['$[]=']("basebackend-" + (current_basebackend) + "-doctype-" + (new_doctype), "");
7331            };
7332          } else {
7333
7334            if ($truthy(current_backend)) {
7335              attrs['$[]=']("backend-" + (current_backend) + "-doctype-" + (new_doctype), "")
7336            };
7337            if ($truthy(current_basebackend)) {
7338              attrs['$[]=']("basebackend-" + (current_basebackend) + "-doctype-" + (new_doctype), "")
7339            };
7340          };
7341          attrs['$[]=']("doctype-" + (new_doctype), "");
7342          return (self.doctype = ($a = ["doctype", new_doctype], $send(attrs, '[]=', $a), $a[$a.length - 1]));
7343        } else {
7344          return nil
7345        }
7346      });
7347    })($nesting[0], $$('AbstractBlock'), $nesting)
7348  })($nesting[0], $nesting)
7349};
7350
7351Opal.modules["asciidoctor/inline"] = function(Opal) {/* Generated by Opal 1.7.3 */
7352  "use strict";
7353  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $send2 = Opal.send2, $find_super = Opal.find_super, $def = Opal.def, $return_val = Opal.return_val, $alias = Opal.alias, $truthy = Opal.truthy, $nesting = [], nil = Opal.nil;
7354
7355  Opal.add_stubs('attr_accessor,attr_reader,[],convert,converter,attr,==,apply_reftext_subs,reftext');
7356  return (function($base, $parent_nesting) {
7357    var self = $module($base, 'Asciidoctor');
7358
7359    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
7360
7361    return (function($base, $super) {
7362      var self = $klass($base, $super, 'Inline');
7363
7364      var $proto = self.$$prototype;
7365
7366      $proto.text = $proto.type = nil;
7367
7368      self.$attr_accessor("text");
7369      self.$attr_reader("type");
7370      self.$attr_accessor("target");
7371
7372      $def(self, '$initialize', function $$initialize(parent, context, text, opts) {
7373        var $yield = $$initialize.$$p || nil, self = this;
7374
7375        $$initialize.$$p = null;
7376
7377        if (text == null) text = nil;
7378        if (opts == null) opts = $hash2([], {});
7379        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], null);
7380        self.node_name = "inline_" + (context);
7381        self.text = text;
7382        self.id = opts['$[]']("id");
7383        self.type = opts['$[]']("type");
7384        return (self.target = opts['$[]']("target"));
7385      }, -3);
7386
7387      $def(self, '$block?', $return_val(false));
7388
7389      $def(self, '$inline?', $return_val(true));
7390
7391      $def(self, '$convert', function $$convert() {
7392        var self = this;
7393
7394        return self.$converter().$convert(self)
7395      });
7396      $alias(self, "render", "convert");
7397
7398      $def(self, '$alt', function $$alt() {
7399        var self = this, $ret_or_1 = nil;
7400
7401        if ($truthy(($ret_or_1 = self.$attr("alt")))) {
7402          return $ret_or_1
7403        } else {
7404          return ""
7405        }
7406      });
7407
7408      $def(self, '$reftext?', function $Inline_reftext$ques$1() {
7409        var self = this, $ret_or_1 = nil, $ret_or_2 = nil;
7410
7411        if ($truthy(($ret_or_1 = self.text))) {
7412
7413          if ($truthy(($ret_or_2 = self.type['$==']("ref")))) {
7414            return $ret_or_2
7415          } else {
7416            return self.type['$==']("bibref")
7417          };
7418        } else {
7419          return $ret_or_1
7420        }
7421      });
7422
7423      $def(self, '$reftext', function $$reftext() {
7424        var self = this, val = nil;
7425
7426        if ($truthy((val = self.text))) {
7427
7428          return self.$apply_reftext_subs(val);
7429        } else {
7430          return nil
7431        }
7432      });
7433      return $def(self, '$xreftext', function $$xreftext(xrefstyle) {
7434        var self = this;
7435
7436
7437        if (xrefstyle == null) xrefstyle = nil;
7438        return self.$reftext();
7439      }, -1);
7440    })($nesting[0], $$('AbstractNode'))
7441  })($nesting[0], $nesting)
7442};
7443
7444Opal.modules["asciidoctor/list"] = function(Opal) {/* Generated by Opal 1.7.3 */
7445  "use strict";
7446  var $module = Opal.module, $klass = Opal.klass, $alias = Opal.alias, $hash2 = Opal.hash2, $send2 = Opal.send2, $find_super = Opal.find_super, $def = Opal.def, $truthy = Opal.truthy, $eqeq = Opal.eqeq, $nesting = [], nil = Opal.nil;
7447
7448  Opal.add_stubs('blocks,blocks?,==,next_list,callouts,convert,class,object_id,inspect,size,items,parent,attr_accessor,level,drop,nil_or_empty?,apply_subs,attr_writer,empty?,===,[],outline?,!,simple?,source,shift,context');
7449  return (function($base, $parent_nesting) {
7450    var self = $module($base, 'Asciidoctor');
7451
7452    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
7453
7454
7455    (function($base, $super) {
7456      var self = $klass($base, $super, 'List');
7457
7458      var $proto = self.$$prototype;
7459
7460      $proto.context = $proto.document = $proto.style = nil;
7461
7462      $alias(self, "items", "blocks");
7463      $alias(self, "content", "blocks");
7464      $alias(self, "items?", "blocks?");
7465
7466      $def(self, '$initialize', function $$initialize(parent, context, opts) {
7467        var $yield = $$initialize.$$p || nil, self = this;
7468
7469        $$initialize.$$p = null;
7470
7471        if (opts == null) opts = $hash2([], {});
7472        return $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield);
7473      }, -3);
7474
7475      $def(self, '$outline?', function $List_outline$ques$1() {
7476        var self = this, $ret_or_1 = nil;
7477
7478        if ($truthy(($ret_or_1 = self.context['$==']("ulist")))) {
7479          return $ret_or_1
7480        } else {
7481          return self.context['$==']("olist")
7482        }
7483      });
7484
7485      $def(self, '$convert', function $$convert() {
7486        var $yield = $$convert.$$p || nil, self = this, result = nil;
7487
7488        $$convert.$$p = null;
7489        if ($eqeq(self.context, "colist")) {
7490
7491          result = $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [], $yield);
7492          self.document.$callouts().$next_list();
7493          return result;
7494        } else {
7495          return $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [], $yield)
7496        }
7497      });
7498      $alias(self, "render", "convert");
7499      return $def(self, '$to_s', function $$to_s() {
7500        var self = this;
7501
7502        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", style: " + (self.style.$inspect()) + ", items: " + (self.$items().$size()) + "}>"
7503      });
7504    })($nesting[0], $$('AbstractBlock'));
7505    return (function($base, $super, $parent_nesting) {
7506      var self = $klass($base, $super, 'ListItem');
7507
7508      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
7509
7510      $proto.text = $proto.subs = $proto.blocks = nil;
7511
7512      $alias(self, "list", "parent");
7513      self.$attr_accessor("marker");
7514
7515      $def(self, '$initialize', function $$initialize(parent, text) {
7516        var $yield = $$initialize.$$p || nil, self = this;
7517
7518        $$initialize.$$p = null;
7519
7520        if (text == null) text = nil;
7521        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "list_item"], null);
7522        self.text = text;
7523        self.level = parent.$level();
7524        return (self.subs = $$('NORMAL_SUBS').$drop(0));
7525      }, -2);
7526
7527      $def(self, '$text?', function $ListItem_text$ques$2() {
7528        var self = this;
7529
7530        if ($truthy(self.text['$nil_or_empty?']())) {
7531          return false
7532        } else {
7533          return true
7534        }
7535      });
7536
7537      $def(self, '$text', function $$text() {
7538        var self = this, $ret_or_1 = nil;
7539
7540        if ($truthy(($ret_or_1 = self.text))) {
7541
7542          return self.$apply_subs(self.text, self.subs);
7543        } else {
7544          return $ret_or_1
7545        }
7546      });
7547      self.$attr_writer("text");
7548
7549      $def(self, '$simple?', function $ListItem_simple$ques$3() {
7550        var self = this, $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil, blk = nil;
7551
7552        if ($truthy(($ret_or_1 = self.blocks['$empty?']()))) {
7553          return $ret_or_1
7554        } else {
7555
7556          if ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = self.blocks.$size()['$=='](1))) ? ($$('List')['$===']((blk = self.blocks['$[]'](0)))) : ($ret_or_3))))) {
7557            return blk['$outline?']()
7558          } else {
7559            return $ret_or_2
7560          };
7561        }
7562      });
7563
7564      $def(self, '$compound?', function $ListItem_compound$ques$4() {
7565        var self = this;
7566
7567        return self['$simple?']()['$!']()
7568      });
7569
7570      $def(self, '$fold_first', function $$fold_first() {
7571        var self = this;
7572
7573
7574        self.text = ($truthy(self.text['$nil_or_empty?']()) ? (self.blocks.$shift().$source()) : ("" + (self.text) + ($$('LF')) + (self.blocks.$shift().$source())));
7575        return nil;
7576      });
7577      return $def(self, '$to_s', function $$to_s() {
7578        var self = this, $ret_or_1 = nil;
7579
7580        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {list_context: " + (self.$parent().$context().$inspect()) + ", text: " + (self.text.$inspect()) + ", blocks: " + (($truthy(($ret_or_1 = self.blocks)) ? ($ret_or_1) : ([])).$size()) + "}>"
7581      });
7582    })($nesting[0], $$('AbstractBlock'), $nesting);
7583  })($nesting[0], $nesting)
7584};
7585
7586Opal.modules["asciidoctor/parser"] = function(Opal) {/* Generated by Opal 1.7.3 */
7587  "use strict";
7588  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $send = Opal.send, $truthy = Opal.truthy, $hash2 = Opal.hash2, $to_ary = Opal.to_ary, $defs = Opal.defs, $eqeq = Opal.eqeq, $not = Opal.not, $gvars = Opal.gvars, $neqeq = Opal.neqeq, $rb_plus = Opal.rb_plus, $rb_lt = Opal.rb_lt, $rb_gt = Opal.rb_gt, $to_a = Opal.to_a, $eqeqeq = Opal.eqeqeq, $rb_minus = Opal.rb_minus, $rb_times = Opal.rb_times, $thrower = Opal.thrower, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
7589
7590  Opal.add_stubs('include,new,proc,start_with?,match?,is_delimited_block?,private_class_method,parse_document_header,[],has_more_lines?,next_section,assign_numeral,<<,blocks,skip_blank_lines,parse_block_metadata_lines,attributes,is_next_line_doctitle?,[]=,finalize_header,nil_or_empty?,title=,sourcemap,cursor,parse_section_title,id=,include?,sub_specialchars,sub_attributes,source_location=,header,attribute_locked?,id,clear,delete,instance_variable_get,parse_header_metadata,==,!,register,process_authors,update,doctype,parse_manpage_header,=~,downcase,error,logger,message_with_context,cursor_at_line,backend,save,is_next_line_section?,initialize_section,join,map,read_lines_until,lstrip,split,title,restore_save,discard_save,header?,empty?,context,!=,attr?,attr,key?,document,+,level,special,sectname,to_i,<,>,warn,next_block,blocks?,style,style=,parent=,content_model,content_model=,lines,subs,size,context=,shift,unwrap_standalone_preamble,source_location,merge,fetch,parse_block_metadata_line,extensions,block_macros?,mark,read_line,terminator,to_s,masq,to_sym,registered_for_block?,debug?,debug,cursor_at_mark,strict_verbatim_paragraphs,unshift_line,markdown_syntax,keys,chr,uniform?,length,end_with?,parse_attributes,attribute_missing,tr,basename,assign_caption,registered_for_block_macro?,config,process_method,replace,parse_callout_list,callouts,===,parse_list,parse_description_list,underline_style_section_titles,is_section_title?,peek_line,atx_section_title?,generate_id,level=,read_paragraph_lines,adjust_indentation!,map!,slice,pop,build_block,apply_subs,chop,catalog_inline_anchors,rekey,index,strip,-,parse_table,each,raise,title?,update_attributes,commit_subs,sub?,catalog_callouts,source,remove_sub,block_terminates_paragraph,to_proc,nil?,parse_blocks,parse_list_item,items,scan,gsub,count,advance,dup,match,callout_ids,next_list,catalog_inline_anchor,marker=,catalog_inline_biblio_anchor,set_option,text=,resolve_ordered_list_marker,read_lines_for_list_item,skip_line_comments,unshift_lines,fold_first,text?,is_sibling_list_item?,concat,find,casecmp,sectname=,special=,numbered=,numbered,lineno,peek_lines,setext_section_title?,abs,cursor_at_prev_line,process_attribute_entries,next_line_empty?,apply_header_subs,rstrip,each_with_index,compact,to_h,squeeze,to_a,parse_style_attribute,process_attribute_entry,skip_comment_lines,store_attribute,sanitize_attribute_name,set_attribute,save_to,delete_attribute,ord,int_to_roman,resolve_list_marker,parse_colspecs,create_columns,has_header_option=,format,starts_with_delimiter?,close_open_cell,parse_cellspec,delimiter,match_delimiter,pre_match,post_match,buffer_has_unclosed_quotes?,skip_past_delimiter,buffer=,buffer,skip_past_escaped_delimiter,keep_cell_open,push_cellspec,close_cell,cell_open?,columns,assign_column_widths,partition_header_footer,upto,partition,shorthand_property_syntax,each_char,yield_buffered_attribute,any?,*,each_byte,%');
7591  return (function($base, $parent_nesting) {
7592    var self = $module($base, 'Asciidoctor');
7593
7594    var $nesting = [self].concat($parent_nesting);
7595
7596    return (function($base, $super, $parent_nesting) {
7597      var self = $klass($base, $super, 'Parser');
7598
7599      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
7600
7601
7602      self.$include($$('Logging'));
7603      $const_set($nesting[0], 'BlockMatchData', $$('Struct').$new("context", "masq", "tip", "terminator"));
7604      $const_set($nesting[0], 'TAB', "\t");
7605      $const_set($nesting[0], 'TabIndentRx', /^\t+/);
7606      $const_set($nesting[0], 'StartOfBlockProc', $send(self, 'proc', [], function $Parser$1(l){var self = $Parser$1.$$s == null ? this : $Parser$1.$$s, $ret_or_1 = nil, $ret_or_2 = nil;
7607
7608
7609        if (l == null) l = nil;
7610        if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = l['$start_with?']("["))) ? ($$('BlockAttributeLineRx')['$match?'](l)) : ($ret_or_2))))) {
7611          return $ret_or_1
7612        } else {
7613
7614          return self['$is_delimited_block?'](l);
7615        };}, {$$s: self}));
7616      $const_set($nesting[0], 'StartOfListProc', $send(self, 'proc', [], function $Parser$2(l){
7617
7618        if (l == null) l = nil;
7619        return $$('AnyListRx')['$match?'](l);}));
7620      $const_set($nesting[0], 'StartOfBlockOrListProc', $send(self, 'proc', [], function $Parser$3(l){var self = $Parser$3.$$s == null ? this : $Parser$3.$$s, $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil;
7621
7622
7623        if (l == null) l = nil;
7624        if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = self['$is_delimited_block?'](l))) ? ($ret_or_2) : (($truthy(($ret_or_3 = l['$start_with?']("["))) ? ($$('BlockAttributeLineRx')['$match?'](l)) : ($ret_or_3))))))) {
7625          return $ret_or_1
7626        } else {
7627
7628          return $$('AnyListRx')['$match?'](l);
7629        };}, {$$s: self}));
7630      $const_set($nesting[0], 'NoOp', nil);
7631      $const_set($nesting[0], 'AuthorKeys', ["author", "authorinitials", "firstname", "middlename", "lastname", "email"]);
7632      $const_set($nesting[0], 'TableCellHorzAlignments', $hash2(["<", ">", "^"], {"<": "left", ">": "right", "^": "center"}));
7633      $const_set($nesting[0], 'TableCellVertAlignments', $hash2(["<", ">", "^"], {"<": "top", ">": "bottom", "^": "middle"}));
7634      $const_set($nesting[0], 'TableCellStyles', $hash2(["d", "s", "e", "m", "h", "l", "a"], {"d": "none", "s": "strong", "e": "emphasis", "m": "monospaced", "h": "header", "l": "literal", "a": "asciidoc"}));
7635      self.$private_class_method("new");
7636      $defs(self, '$parse', function $$parse(reader, document, options) {
7637        var $a, $b, self = this, block_attributes = nil, header_only = nil, new_section = nil;
7638
7639
7640        if (options == null) options = $hash2([], {});
7641        block_attributes = self.$parse_document_header(reader, document, (header_only = options['$[]']("header_only")));
7642        if (!$truthy(header_only)) {
7643          while ($truthy(reader['$has_more_lines?']())) {
7644
7645            $b = self.$next_section(reader, document, block_attributes), $a = $to_ary($b), (new_section = ($a[0] == null ? nil : $a[0])), (block_attributes = ($a[1] == null ? nil : $a[1])), $b;
7646            if ($truthy(new_section)) {
7647
7648              document.$assign_numeral(new_section);
7649              document.$blocks()['$<<'](new_section);
7650            };
7651          }
7652        };
7653        return document;
7654      }, -3);
7655      $defs(self, '$parse_document_header', function $$parse_document_header(reader, document, header_only) {
7656        var $a, $b, $c, self = this, block_attrs = nil, doc_attrs = nil, implicit_doctitle = nil, val = nil, doctitle_attr_val = nil, source_location = nil, _ = nil, l0_section_title = nil, atx = nil, separator = nil, doc_id = nil, role = nil, reftext = nil, modified_attrs = nil, author = nil, author_metadata = nil;
7657
7658
7659        if (header_only == null) header_only = false;
7660        block_attrs = ($truthy(reader.$skip_blank_lines()) ? (self.$parse_block_metadata_lines(reader, document)) : ($hash2([], {})));
7661        doc_attrs = document.$attributes();
7662        if (($truthy((implicit_doctitle = self['$is_next_line_doctitle?'](reader, block_attrs, doc_attrs['$[]']("leveloffset")))) && ($truthy(block_attrs['$[]']("title"))))) {
7663
7664          doc_attrs['$[]=']("authorcount", 0);
7665          return document.$finalize_header(block_attrs, false);
7666        };
7667        if (!$truthy((val = doc_attrs['$[]']("doctitle"))['$nil_or_empty?']())) {
7668          document['$title=']((doctitle_attr_val = val))
7669        };
7670        if ($truthy(implicit_doctitle)) {
7671
7672          if ($truthy(document.$sourcemap())) {
7673            source_location = reader.$cursor()
7674          };
7675          $b = self.$parse_section_title(reader, document), $a = $to_ary($b), ($c = [($a[0] == null ? nil : $a[0])], $send(document, 'id=', $c), $c[$c.length - 1]), (_ = ($a[1] == null ? nil : $a[1])), (l0_section_title = ($a[2] == null ? nil : $a[2])), (_ = ($a[3] == null ? nil : $a[3])), (atx = ($a[4] == null ? nil : $a[4])), $b;
7676          if ($truthy(doctitle_attr_val)) {
7677            l0_section_title = nil
7678          } else {
7679
7680            document['$title='](l0_section_title);
7681            if ($truthy(($a = ["doctitle", (doctitle_attr_val = document.$sub_specialchars(l0_section_title))], $send(doc_attrs, '[]=', $a), $a[$a.length - 1])['$include?']($$('ATTR_REF_HEAD')))) {
7682              doc_attrs['$[]=']("doctitle", (doctitle_attr_val = document.$sub_attributes(doctitle_attr_val, $hash2(["attribute_missing"], {"attribute_missing": "skip"}))))
7683            };
7684          };
7685          if ($truthy(source_location)) {
7686            document.$header()['$source_location='](source_location)
7687          };
7688          if (!($truthy(atx) || ($truthy(document['$attribute_locked?']("compat-mode"))))) {
7689            doc_attrs['$[]=']("compat-mode", "")
7690          };
7691          if ($truthy((separator = block_attrs['$[]']("separator")))) {
7692            if (!$truthy(document['$attribute_locked?']("title-separator"))) {
7693              doc_attrs['$[]=']("title-separator", separator)
7694            }
7695          };
7696          if ($truthy((doc_id = block_attrs['$[]']("id")))) {
7697            document['$id='](doc_id)
7698          } else {
7699            doc_id = document.$id()
7700          };
7701          if ($truthy((role = block_attrs['$[]']("role")))) {
7702            doc_attrs['$[]=']("role", role)
7703          };
7704          if ($truthy((reftext = block_attrs['$[]']("reftext")))) {
7705            doc_attrs['$[]=']("reftext", reftext)
7706          };
7707          block_attrs.$clear();
7708          (modified_attrs = document.$instance_variable_get("@attributes_modified")).$delete("doctitle");
7709          self.$parse_header_metadata(reader, document, nil);
7710          if ($truthy(modified_attrs['$include?']("doctitle"))) {
7711            if (($truthy((val = doc_attrs['$[]']("doctitle"))['$nil_or_empty?']()) || ($eqeq(val, doctitle_attr_val)))) {
7712              doc_attrs['$[]=']("doctitle", doctitle_attr_val)
7713            } else {
7714              document['$title='](val)
7715            }
7716          } else if ($not(l0_section_title)) {
7717            modified_attrs['$<<']("doctitle")
7718          };
7719          if ($truthy(doc_id)) {
7720            document.$register("refs", [doc_id, document])
7721          };
7722        } else if ($truthy((author = doc_attrs['$[]']("author")))) {
7723
7724          author_metadata = self.$process_authors(author, true, false);
7725          if ($truthy(doc_attrs['$[]']("authorinitials"))) {
7726            author_metadata.$delete("authorinitials")
7727          };
7728          doc_attrs.$update(author_metadata);
7729        } else if ($truthy((author = doc_attrs['$[]']("authors")))) {
7730
7731          author_metadata = self.$process_authors(author, true);
7732          doc_attrs.$update(author_metadata);
7733        } else {
7734          doc_attrs['$[]=']("authorcount", 0)
7735        };
7736        if ($eqeq(document.$doctype(), "manpage")) {
7737          self.$parse_manpage_header(reader, document, block_attrs, header_only)
7738        };
7739        return document.$finalize_header(block_attrs);
7740      }, -3);
7741      $defs(self, '$parse_manpage_header', function $$parse_manpage_header(reader, document, block_attributes, header_only) {
7742        var $a, self = this, doc_attrs = nil, manvolnum = nil, mantitle = nil, $ret_or_1 = nil, $ret_or_2 = nil, manname = nil, name_section_level = nil, name_section = nil, name_section_buffer = nil, mannames = nil, manpurpose = nil, error_msg = nil;
7743
7744
7745        if (header_only == null) header_only = false;
7746        if ($truthy($$('ManpageTitleVolnumRx')['$=~']((doc_attrs = document.$attributes())['$[]']("doctitle")))) {
7747
7748          doc_attrs['$[]=']("manvolnum", (manvolnum = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))));
7749          doc_attrs['$[]=']("mantitle", ($truthy((mantitle = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))['$include?']($$('ATTR_REF_HEAD'))) ? (document.$sub_attributes(mantitle)) : (mantitle)).$downcase());
7750        } else {
7751
7752          self.$logger().$error(self.$message_with_context("non-conforming manpage title", $hash2(["source_location"], {"source_location": reader.$cursor_at_line(1)})));
7753          doc_attrs['$[]=']("mantitle", ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = doc_attrs['$[]']("doctitle"))) ? ($ret_or_2) : (doc_attrs['$[]']("docname"))))) ? ($ret_or_1) : ("command")));
7754          doc_attrs['$[]=']("manvolnum", (manvolnum = "1"));
7755        };
7756        if (($truthy((manname = doc_attrs['$[]']("manname"))) && ($truthy(doc_attrs['$[]']("manpurpose"))))) {
7757
7758          if ($truthy(($ret_or_1 = doc_attrs['$[]']("manname-title")))) {
7759            $ret_or_1
7760          } else {
7761            doc_attrs['$[]=']("manname-title", "Name")
7762          };
7763          doc_attrs['$[]=']("mannames", [manname]);
7764          if ($eqeq(document.$backend(), "manpage")) {
7765
7766            doc_attrs['$[]=']("docname", manname);
7767            doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum));
7768          };
7769        } else if (!$truthy(header_only)) {
7770
7771          reader.$skip_blank_lines();
7772          reader.$save();
7773          block_attributes.$update(self.$parse_block_metadata_lines(reader, document));
7774          if ($truthy((name_section_level = self['$is_next_line_section?'](reader, $hash2([], {}))))) {
7775            if ($eqeq(name_section_level, 1)) {
7776
7777              name_section = self.$initialize_section(reader, document, $hash2([], {}));
7778              name_section_buffer = $send(reader.$read_lines_until($hash2(["break_on_blank_lines", "skip_line_comments"], {"break_on_blank_lines": true, "skip_line_comments": true})), 'map', [], function $$4(l){
7779
7780                if (l == null) l = nil;
7781                return l.$lstrip();}).$join(" ");
7782              if ($truthy($$('ManpageNamePurposeRx')['$=~'](name_section_buffer))) {
7783
7784                if ($truthy((manname = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))['$include?']($$('ATTR_REF_HEAD')))) {
7785                  manname = document.$sub_attributes(manname)
7786                };
7787                if ($truthy(manname['$include?'](","))) {
7788                  manname = (mannames = $send(manname.$split(","), 'map', [], function $$5(n){
7789
7790                    if (n == null) n = nil;
7791                    return n.$lstrip();}))['$[]'](0)
7792                } else {
7793                  mannames = [manname]
7794                };
7795                if ($truthy((manpurpose = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))['$include?']($$('ATTR_REF_HEAD')))) {
7796                  manpurpose = document.$sub_attributes(manpurpose)
7797                };
7798                if ($truthy(($ret_or_1 = doc_attrs['$[]']("manname-title")))) {
7799                  $ret_or_1
7800                } else {
7801                  doc_attrs['$[]=']("manname-title", name_section.$title())
7802                };
7803                if ($truthy(name_section.$id())) {
7804                  doc_attrs['$[]=']("manname-id", name_section.$id())
7805                };
7806                doc_attrs['$[]=']("manname", manname);
7807                doc_attrs['$[]=']("mannames", mannames);
7808                doc_attrs['$[]=']("manpurpose", manpurpose);
7809                if ($eqeq(document.$backend(), "manpage")) {
7810
7811                  doc_attrs['$[]=']("docname", manname);
7812                  doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum));
7813                };
7814              } else {
7815                error_msg = "non-conforming name section body"
7816              };
7817            } else {
7818              error_msg = "name section must be at level 1"
7819            }
7820          } else {
7821            error_msg = "name section expected"
7822          };
7823          if ($truthy(error_msg)) {
7824
7825            reader.$restore_save();
7826            self.$logger().$error(self.$message_with_context(error_msg, $hash2(["source_location"], {"source_location": reader.$cursor()})));
7827            doc_attrs['$[]=']("manname", (manname = ($truthy(($ret_or_1 = doc_attrs['$[]']("docname"))) ? ($ret_or_1) : ("command"))));
7828            doc_attrs['$[]=']("mannames", [manname]);
7829            if ($eqeq(document.$backend(), "manpage")) {
7830
7831              doc_attrs['$[]=']("docname", manname);
7832              doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum));
7833            };
7834          } else {
7835            reader.$discard_save()
7836          };
7837        };
7838        return nil;
7839      }, -4);
7840      $defs(self, '$next_section', function $$next_section(reader, parent, attributes) {
7841        var $a, $b, self = this, preamble = nil, intro = nil, part = nil, has_header = nil, book = nil, document = nil, section = nil, current_level = nil, expected_next_level = nil, expected_next_level_alt = nil, title = nil, sectname = nil, next_level = nil, expected_condition = nil, new_section = nil, block_cursor = nil, new_block = nil, $ret_or_1 = nil, first_block = nil, child_block = nil;
7842
7843
7844        if (attributes == null) attributes = $hash2([], {});
7845        preamble = (intro = (part = false));
7846        if ((($eqeq(parent.$context(), "document") && ($truthy(parent.$blocks()['$empty?']()))) && ((($truthy((has_header = parent['$header?']())) || ($truthy(attributes.$delete("invalid-header")))) || ($not(self['$is_next_line_section?'](reader, attributes))))))) {
7847
7848          book = (document = parent).$doctype()['$==']("book");
7849          if (($truthy(has_header) || (($truthy(book) && ($neqeq(attributes['$[]'](1), "abstract")))))) {
7850
7851            preamble = (intro = $$('Block').$new(parent, "preamble", $hash2(["content_model"], {"content_model": "compound"})));
7852            if (($truthy(book) && ($truthy(parent['$attr?']("preface-title"))))) {
7853              preamble['$title='](parent.$attr("preface-title"))
7854            };
7855            parent.$blocks()['$<<'](preamble);
7856          };
7857          section = parent;
7858          current_level = 0;
7859          if ($truthy(parent.$attributes()['$key?']("fragment"))) {
7860            expected_next_level = -1
7861          } else if ($truthy(book)) {
7862            $a = [1, 0], (expected_next_level = $a[0]), (expected_next_level_alt = $a[1]), $a
7863          } else {
7864            expected_next_level = 1
7865          };
7866        } else {
7867
7868          book = (document = parent.$document()).$doctype()['$==']("book");
7869          section = self.$initialize_section(reader, parent, attributes);
7870          attributes = ($truthy((title = attributes['$[]']("title"))) ? ($hash2(["title"], {"title": title})) : ($hash2([], {})));
7871          expected_next_level = $rb_plus((current_level = section.$level()), 1);
7872          if ($eqeq(current_level, 0)) {
7873            part = book
7874          } else if (($eqeq(current_level, 1) && ($truthy(section.$special())))) {
7875            if (!(($eqeq((sectname = section.$sectname()), "appendix") || ($eqeq(sectname, "preface"))) || ($eqeq(sectname, "abstract")))) {
7876              expected_next_level = nil
7877            }
7878          };
7879        };
7880        reader.$skip_blank_lines();
7881        while ($truthy(reader['$has_more_lines?']())) {
7882
7883          self.$parse_block_metadata_lines(reader, document, attributes);
7884          if ($truthy((next_level = self['$is_next_line_section?'](reader, attributes)))) {
7885
7886            if ($truthy(document['$attr?']("leveloffset"))) {
7887
7888              next_level = $rb_plus(next_level, document.$attr("leveloffset").$to_i());
7889              if ($truthy($rb_lt(next_level, 0))) {
7890                next_level = 0
7891              };
7892            };
7893            if ($truthy($rb_gt(next_level, current_level))) {
7894
7895              if ($truthy(expected_next_level)) {
7896                if (!(($eqeq(next_level, expected_next_level) || (($truthy(expected_next_level_alt) && ($eqeq(next_level, expected_next_level_alt))))) || ($truthy($rb_lt(expected_next_level, 0))))) {
7897
7898                  expected_condition = ($truthy(expected_next_level_alt) ? ("expected levels " + (expected_next_level_alt) + " or " + (expected_next_level)) : ("expected level " + (expected_next_level)));
7899                  self.$logger().$warn(self.$message_with_context("section title out of sequence: " + (expected_condition) + ", got level " + (next_level), $hash2(["source_location"], {"source_location": reader.$cursor()})));
7900                }
7901              } else {
7902                self.$logger().$error(self.$message_with_context("" + (sectname) + " sections do not support nested sections", $hash2(["source_location"], {"source_location": reader.$cursor()})))
7903              };
7904              $b = self.$next_section(reader, section, attributes), $a = $to_ary($b), (new_section = ($a[0] == null ? nil : $a[0])), (attributes = ($a[1] == null ? nil : $a[1])), $b;
7905              section.$assign_numeral(new_section);
7906              section.$blocks()['$<<'](new_section);
7907            } else if (($eqeq(next_level, 0) && ($eqeq(section, document)))) {
7908
7909              if (!$truthy(book)) {
7910                self.$logger().$error(self.$message_with_context("level 0 sections can only be used when doctype is book", $hash2(["source_location"], {"source_location": reader.$cursor()})))
7911              };
7912              $b = self.$next_section(reader, section, attributes), $a = $to_ary($b), (new_section = ($a[0] == null ? nil : $a[0])), (attributes = ($a[1] == null ? nil : $a[1])), $b;
7913              section.$assign_numeral(new_section);
7914              section.$blocks()['$<<'](new_section);
7915            } else {
7916              break
7917            };
7918          } else {
7919
7920            block_cursor = reader.$cursor();
7921            if ($truthy((new_block = self.$next_block(reader, ($truthy(($ret_or_1 = intro)) ? ($ret_or_1) : (section)), attributes, $hash2(["parse_metadata"], {"parse_metadata": false}))))) {
7922
7923              if ($truthy(part)) {
7924                if ($not(section['$blocks?']())) {
7925                  if ($neqeq(new_block.$style(), "partintro")) {
7926                    if (($eqeq(new_block.$style(), "open") && ($eqeq(new_block.$context(), "open")))) {
7927                      new_block['$style=']("partintro")
7928                    } else {
7929
7930                      new_block['$parent=']((intro = $$('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"}))));
7931                      intro['$style=']("partintro");
7932                      section.$blocks()['$<<'](intro);
7933                    }
7934                  } else if ($eqeq(new_block.$content_model(), "simple")) {
7935
7936                    new_block['$content_model=']("compound");
7937                    new_block['$<<']($$('Block').$new(new_block, "paragraph", $hash2(["source", "subs"], {"source": new_block.$lines(), "subs": new_block.$subs()})));
7938                    new_block.$lines().$clear();
7939                    new_block.$subs().$clear();
7940                  }
7941                } else if ($eqeq(section.$blocks().$size(), 1)) {
7942
7943                  first_block = section.$blocks()['$[]'](0);
7944                  if (($not(intro) && ($eqeq(first_block.$content_model(), "compound")))) {
7945                    self.$logger().$error(self.$message_with_context("illegal block content outside of partintro block", $hash2(["source_location"], {"source_location": block_cursor})))
7946                  } else if ($neqeq(first_block.$content_model(), "compound")) {
7947
7948                    new_block['$parent=']((intro = $$('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"}))));
7949                    if ($eqeq(first_block.$style(), ($a = ["partintro"], $send(intro, 'style=', $a), $a[$a.length - 1]))) {
7950
7951                      first_block['$context=']("paragraph");
7952                      first_block['$style='](nil);
7953                    };
7954                    section.$blocks().$shift();
7955                    intro['$<<'](first_block);
7956                    section.$blocks()['$<<'](intro);
7957                  };
7958                }
7959              };
7960              ($truthy(($ret_or_1 = intro)) ? ($ret_or_1) : (section)).$blocks()['$<<'](new_block);
7961              attributes.$clear();
7962            };
7963          };
7964          if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) {
7965            $ret_or_1
7966          } else {
7967            break
7968          };
7969        };
7970        if ($truthy(part)) {
7971          if (!($truthy(section['$blocks?']()) && ($eqeq(section.$blocks()['$[]'](-1).$context(), "section")))) {
7972            self.$logger().$error(self.$message_with_context("invalid part, must have at least one section (e.g., chapter, appendix, etc.)", $hash2(["source_location"], {"source_location": reader.$cursor()})))
7973          }
7974        } else if ($truthy(preamble)) {
7975          if ($truthy(preamble['$blocks?']())) {
7976            if ((($truthy(book) || ($truthy(document.$blocks()['$[]'](1)))) || ($not($$('Compliance').$unwrap_standalone_preamble())))) {
7977              if ($truthy(document.$sourcemap())) {
7978                preamble['$source_location='](preamble.$blocks()['$[]'](0).$source_location())
7979              }
7980            } else {
7981
7982              document.$blocks().$shift();
7983              while ($truthy((child_block = preamble.$blocks().$shift()))) {
7984              document['$<<'](child_block)
7985              };
7986            }
7987          } else {
7988            document.$blocks().$shift()
7989          }
7990        };
7991        return [($eqeq(section, parent) ? (nil) : (section)), attributes.$merge()];
7992      }, -3);
7993      $defs(self, '$next_block', function $$next_block(reader, parent, attributes, options) {
7994        var $a, $b, self = this, skipped = nil, text_only = nil, document = nil, $ret_or_1 = nil, extensions = nil, block_extensions = nil, block_macro_extensions = nil, this_line = nil, doc_attrs = nil, style = nil, block = nil, block_context = nil, cloaked_context = nil, terminator = nil, delimited_block = nil, indented = nil, md_syntax = nil, ch0 = nil, layout_break_chars = nil, ll = nil, blk_ctx = nil, target = nil, blk_attrs = nil, posattrs = nil, expanded_target = nil, $ret_or_2 = nil, scaledwidth = nil, block_title = nil, extension = nil, report_unknown_block_macro = nil, content = nil, ext_config = nil, default_attrs = nil, float_id = nil, float_reftext = nil, float_level = nil, lines = nil, content_adjacent = nil, admonition_name = nil, credit_line = nil, attribution = nil, citetitle = nil, language = nil, comma_idx = nil, block_cursor = nil, block_reader = nil, content_model = nil, positional_attrs = nil, block_id = nil;
7995        if ($gvars["~"] == null) $gvars["~"] = nil;
7996
7997
7998        if (attributes == null) attributes = $hash2([], {});
7999        if (options == null) options = $hash2([], {});
8000        if (!$truthy((skipped = reader.$skip_blank_lines()))) {
8001          return nil
8002        };
8003        if (($truthy((text_only = options['$[]']("text_only"))) && ($truthy($rb_gt(skipped, 0))))) {
8004
8005          options.$delete("text_only");
8006          text_only = nil;
8007        };
8008        document = parent.$document();
8009        if ($truthy(options.$fetch("parse_metadata", true))) {
8010          while ($truthy(self.$parse_block_metadata_line(reader, document, attributes, options))) {
8011
8012            reader.$shift();
8013            if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) {
8014              $ret_or_1
8015            } else {
8016              return nil
8017            };
8018          }
8019        };
8020        if ($truthy((extensions = document.$extensions()))) {
8021          $a = [extensions['$blocks?'](), extensions['$block_macros?']()], (block_extensions = $a[0]), (block_macro_extensions = $a[1]), $a
8022        };
8023        reader.$mark();
8024        $a = [reader.$read_line(), document.$attributes(), attributes['$[]'](1)], (this_line = $a[0]), (doc_attrs = $a[1]), (style = $a[2]), $a;
8025        block = (block_context = (cloaked_context = (terminator = nil)));
8026        if ($truthy((delimited_block = self['$is_delimited_block?'](this_line, true)))) {
8027
8028          block_context = (cloaked_context = delimited_block.$context());
8029          terminator = delimited_block.$terminator();
8030          if ($truthy(style)) {
8031            if (!$eqeq(style, block_context.$to_s())) {
8032              if ($truthy(delimited_block.$masq()['$include?'](style))) {
8033                block_context = style.$to_sym()
8034              } else if (($truthy(delimited_block.$masq()['$include?']("admonition")) && ($truthy($$('ADMONITION_STYLES')['$include?'](style))))) {
8035                block_context = "admonition"
8036              } else if (($truthy(block_extensions) && ($truthy(extensions['$registered_for_block?'](style, block_context))))) {
8037                block_context = style.$to_sym()
8038              } else {
8039
8040                if ($truthy(self.$logger()['$debug?']())) {
8041                  self.$logger().$debug(self.$message_with_context("unknown style for " + (block_context) + " block: " + (style), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8042                };
8043                style = block_context.$to_s();
8044              }
8045            }
8046          } else {
8047            style = ($a = ["style", block_context.$to_s()], $send(attributes, '[]=', $a), $a[$a.length - 1])
8048          };
8049        };
8050        if (!$truthy(delimited_block)) {
8051          while ($truthy(true)) {
8052
8053            if ((($truthy(style) && ($truthy($$('Compliance').$strict_verbatim_paragraphs()))) && ($truthy($$('VERBATIM_STYLES')['$include?'](style))))) {
8054
8055              block_context = style.$to_sym();
8056              reader.$unshift_line(this_line);
8057              break;
8058            };
8059            if ($truthy(text_only)) {
8060              indented = this_line['$start_with?'](" ", $$('TAB'))
8061            } else {
8062
8063              md_syntax = $$('Compliance').$markdown_syntax();
8064              if ($truthy(this_line['$start_with?'](" "))) {
8065
8066                $a = [true, " "], (indented = $a[0]), (ch0 = $a[1]), $a;
8067                if ((($truthy(md_syntax) && ($truthy($send(this_line.$lstrip(), 'start_with?', $to_a($$('MARKDOWN_THEMATIC_BREAK_CHARS').$keys()))))) && ($truthy($$('MarkdownThematicBreakRx')['$match?'](this_line))))) {
8068
8069                  block = $$('Block').$new(parent, "thematic_break", $hash2(["content_model"], {"content_model": "empty"}));
8070                  break;
8071                };
8072              } else if ($truthy(this_line['$start_with?']($$('TAB')))) {
8073                $a = [true, $$('TAB')], (indented = $a[0]), (ch0 = $a[1]), $a
8074              } else {
8075
8076                $a = [false, this_line.$chr()], (indented = $a[0]), (ch0 = $a[1]), $a;
8077                layout_break_chars = ($truthy(md_syntax) ? ($$('HYBRID_LAYOUT_BREAK_CHARS')) : ($$('LAYOUT_BREAK_CHARS')));
8078                if (($truthy(layout_break_chars['$key?'](ch0)) && ($truthy(($truthy(md_syntax) ? ($$('ExtLayoutBreakRx')['$match?'](this_line)) : ($truthy(($ret_or_1 = self['$uniform?'](this_line, ch0, (ll = this_line.$length())))) ? ($rb_gt(ll, 2)) : ($ret_or_1))))))) {
8079
8080                  block = $$('Block').$new(parent, layout_break_chars['$[]'](ch0), $hash2(["content_model"], {"content_model": "empty"}));
8081                  break;
8082                } else if (($truthy(this_line['$end_with?']("]")) && ($truthy(this_line['$include?']("::"))))) {
8083                  if ((($eqeq(ch0, "i") || ($truthy(this_line['$start_with?']("video:", "audio:")))) && ($truthy($$('BlockMediaMacroRx')['$=~'](this_line))))) {
8084
8085                    $a = [(($b = $gvars['~']) === nil ? nil : $b['$[]'](1)).$to_sym(), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2)), (($b = $gvars['~']) === nil ? nil : $b['$[]'](3))], (blk_ctx = $a[0]), (target = $a[1]), (blk_attrs = $a[2]), $a;
8086                    block = $$('Block').$new(parent, blk_ctx, $hash2(["content_model"], {"content_model": "empty"}));
8087                    if ($truthy(blk_attrs)) {
8088
8089
8090                      switch (blk_ctx) {
8091                        case "video":
8092                          posattrs = ["poster", "width", "height"]
8093                          break;
8094                        case "audio":
8095                          posattrs = []
8096                          break;
8097                        default:
8098                          posattrs = ["alt", "width", "height"]
8099                      };
8100                      block.$parse_attributes(blk_attrs, posattrs, $hash2(["sub_input", "into"], {"sub_input": true, "into": attributes}));
8101                    };
8102                    if ($truthy(attributes['$key?']("style"))) {
8103                      attributes.$delete("style")
8104                    };
8105                    if ($truthy(target['$include?']($$('ATTR_REF_HEAD')))) {
8106                      if ((($truthy((expanded_target = block.$sub_attributes(target))['$empty?']()) && ($eqeq(($truthy(($ret_or_1 = doc_attrs['$[]']("attribute-missing"))) ? ($ret_or_1) : ($$('Compliance').$attribute_missing())), "drop-line"))) && ($truthy(block.$sub_attributes($rb_plus(target, " "), $hash2(["attribute_missing", "drop_line_severity"], {"attribute_missing": "drop-line", "drop_line_severity": "ignore"}))['$empty?']())))) {
8107
8108                        attributes.$clear();
8109                        return nil;
8110                      } else {
8111                        target = expanded_target
8112                      }
8113                    };
8114                    if ($eqeq(blk_ctx, "image")) {
8115
8116                      document.$register("images", target);
8117                      attributes['$[]=']("imagesdir", doc_attrs['$[]']("imagesdir"));
8118                      if ($truthy(($ret_or_1 = attributes['$[]']("alt")))) {
8119                        $ret_or_1
8120                      } else {
8121                        attributes['$[]=']("alt", ($truthy(($ret_or_2 = style)) ? ($ret_or_2) : (($a = ["default-alt", $$('Helpers').$basename(target, true).$tr("_-", " ")], $send(attributes, '[]=', $a), $a[$a.length - 1]))))
8122                      };
8123                      if (!$truthy((scaledwidth = attributes.$delete("scaledwidth"))['$nil_or_empty?']())) {
8124                        attributes['$[]=']("scaledwidth", ($truthy($$('TrailingDigitsRx')['$match?'](scaledwidth)) ? ("" + (scaledwidth) + "%") : (scaledwidth)))
8125                      };
8126                      if ($truthy(attributes['$[]']("title"))) {
8127
8128                        block['$title=']((block_title = attributes.$delete("title")));
8129                        block.$assign_caption(attributes.$delete("caption"), "figure");
8130                      };
8131                    };
8132                    attributes['$[]=']("target", target);
8133                    break;
8134                  } else if ((($eqeq(ch0, "t") && ($truthy(this_line['$start_with?']("toc:")))) && ($truthy($$('BlockTocMacroRx')['$=~'](this_line))))) {
8135
8136                    block = $$('Block').$new(parent, "toc", $hash2(["content_model"], {"content_model": "empty"}));
8137                    if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) {
8138                      block.$parse_attributes((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), [], $hash2(["into"], {"into": attributes}))
8139                    };
8140                    break;
8141                  } else if ($truthy(($truthy(block_macro_extensions) ? (($truthy(($ret_or_1 = ($truthy(($ret_or_2 = $$('CustomBlockMacroRx')['$=~'](this_line))) ? ((extension = extensions['$registered_for_block_macro?']((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) : ($ret_or_2)))) ? ($ret_or_1) : ((report_unknown_block_macro = self.$logger()['$debug?']())))) : (($truthy(($ret_or_1 = self.$logger()['$debug?']())) ? ((report_unknown_block_macro = $$('CustomBlockMacroRx')['$=~'](this_line))) : ($ret_or_1)))))) {
8142                    if ($truthy(report_unknown_block_macro)) {
8143                      self.$logger().$debug(self.$message_with_context("unknown name for block macro: " + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8144                    } else {
8145
8146                      content = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3));
8147                      if ($truthy((target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))['$include?']($$('ATTR_REF_HEAD')))) {
8148                        if ((($truthy((expanded_target = parent.$sub_attributes(target))['$empty?']()) && ($eqeq(($truthy(($ret_or_1 = doc_attrs['$[]']("attribute-missing"))) ? ($ret_or_1) : ($$('Compliance').$attribute_missing())), "drop-line"))) && ($truthy(parent.$sub_attributes($rb_plus(target, " "), $hash2(["attribute_missing", "drop_line_severity"], {"attribute_missing": "drop-line", "drop_line_severity": "ignore"}))['$empty?']())))) {
8149
8150                          attributes.$clear();
8151                          return nil;
8152                        } else {
8153                          target = expanded_target
8154                        }
8155                      };
8156                      if ($eqeq((ext_config = extension.$config())['$[]']("content_model"), "attributes")) {
8157                        if ($truthy(content)) {
8158                          document.$parse_attributes(content, ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = ext_config['$[]']("positional_attrs"))) ? ($ret_or_2) : (ext_config['$[]']("pos_attrs"))))) ? ($ret_or_1) : ([])), $hash2(["sub_input", "into"], {"sub_input": true, "into": attributes}))
8159                        }
8160                      } else {
8161                        attributes['$[]=']("text", ($truthy(($ret_or_1 = content)) ? ($ret_or_1) : ("")))
8162                      };
8163                      if ($truthy((default_attrs = ext_config['$[]']("default_attrs")))) {
8164                        $send(attributes, 'update', [default_attrs], function $$6(_, old_v){
8165
8166                          if (_ == null) _ = nil;
8167                          if (old_v == null) old_v = nil;
8168                          return old_v;})
8169                      };
8170                      if (($truthy((block = extension.$process_method()['$[]'](parent, target, attributes))) && ($neqeq(block, parent)))) {
8171
8172                        attributes.$replace(block.$attributes());
8173                        break;
8174                      } else {
8175
8176                        attributes.$clear();
8177                        return nil;
8178                      };
8179                    }
8180                  }
8181                };
8182              };
8183            };
8184            if ((($not(indented) && ($eqeq((ch0 = ($truthy(($ret_or_1 = ch0)) ? ($ret_or_1) : (this_line.$chr()))), "<"))) && ($truthy($$('CalloutListRx')['$=~'](this_line))))) {
8185
8186              reader.$unshift_line(this_line);
8187              block = self.$parse_callout_list(reader, $gvars["~"], parent, document.$callouts());
8188              attributes['$[]=']("style", "arabic");
8189              break;
8190            } else if ($truthy($$('UnorderedListRx')['$match?'](this_line))) {
8191
8192              reader.$unshift_line(this_line);
8193              if ((($not(style) && ($eqeqeq($$('Section'), parent))) && ($eqeq(parent.$sectname(), "bibliography")))) {
8194                attributes['$[]=']("style", (style = "bibliography"))
8195              };
8196              block = self.$parse_list(reader, "ulist", parent, style);
8197              break;
8198            } else if ($truthy($$('OrderedListRx')['$match?'](this_line))) {
8199
8200              reader.$unshift_line(this_line);
8201              block = self.$parse_list(reader, "olist", parent, style);
8202              if ($truthy(block.$style())) {
8203                attributes['$[]=']("style", block.$style())
8204              };
8205              break;
8206            } else if ((($truthy(this_line['$include?']("::")) || ($truthy(this_line['$include?'](";;")))) && ($truthy($$('DescriptionListRx')['$=~'](this_line))))) {
8207
8208              reader.$unshift_line(this_line);
8209              block = self.$parse_description_list(reader, $gvars["~"], parent);
8210              break;
8211            } else if ((($eqeq(style, "float") || ($eqeq(style, "discrete"))) && ($truthy(($truthy($$('Compliance').$underline_style_section_titles()) ? (self['$is_section_title?'](this_line, reader.$peek_line())) : ($truthy(($ret_or_1 = indented['$!']())) ? (self['$atx_section_title?'](this_line)) : ($ret_or_1))))))) {
8212
8213              reader.$unshift_line(this_line);
8214              $b = self.$parse_section_title(reader, document, attributes['$[]']("id")), $a = $to_ary($b), (float_id = ($a[0] == null ? nil : $a[0])), (float_reftext = ($a[1] == null ? nil : $a[1])), (block_title = ($a[2] == null ? nil : $a[2])), (float_level = ($a[3] == null ? nil : $a[3])), $b;
8215              if ($truthy(float_reftext)) {
8216                attributes['$[]=']("reftext", float_reftext)
8217              };
8218              block = $$('Block').$new(parent, "floating_title", $hash2(["content_model"], {"content_model": "empty"}));
8219              block['$title='](block_title);
8220              attributes.$delete("title");
8221              block['$id='](($truthy(($ret_or_1 = float_id)) ? ($ret_or_1) : (($truthy(doc_attrs['$key?']("sectids")) ? ($$('Section').$generate_id(block.$title(), document)) : (nil)))));
8222              block['$level='](float_level);
8223              break;
8224            } else if (($truthy(style) && ($neqeq(style, "normal")))) {
8225              if ($truthy($$('PARAGRAPH_STYLES')['$include?'](style))) {
8226
8227                block_context = style.$to_sym();
8228                cloaked_context = "paragraph";
8229                reader.$unshift_line(this_line);
8230                break;
8231              } else if ($truthy($$('ADMONITION_STYLES')['$include?'](style))) {
8232
8233                block_context = "admonition";
8234                cloaked_context = "paragraph";
8235                reader.$unshift_line(this_line);
8236                break;
8237              } else if (($truthy(block_extensions) && ($truthy(extensions['$registered_for_block?'](style, "paragraph"))))) {
8238
8239                block_context = style.$to_sym();
8240                cloaked_context = "paragraph";
8241                reader.$unshift_line(this_line);
8242                break;
8243              } else {
8244
8245                if ($truthy(self.$logger()['$debug?']())) {
8246                  self.$logger().$debug(self.$message_with_context("unknown style for paragraph: " + (style), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8247                };
8248                style = nil;
8249              }
8250            };
8251            reader.$unshift_line(this_line);
8252            if (($truthy(indented) && ($not(style)))) {
8253
8254              lines = self.$read_paragraph_lines(reader, (content_adjacent = ($eqeq(skipped, 0) ? (options['$[]']("list_type")) : (nil))), $hash2(["skip_line_comments"], {"skip_line_comments": text_only}));
8255              self['$adjust_indentation!'](lines);
8256              if (($truthy(text_only) || ($eqeq(content_adjacent, "dlist")))) {
8257                block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}))
8258              } else {
8259                block = $$('Block').$new(parent, "literal", $hash2(["content_model", "source", "attributes"], {"content_model": "verbatim", "source": lines, "attributes": attributes}))
8260              };
8261            } else {
8262
8263              lines = self.$read_paragraph_lines(reader, ($truthy(($ret_or_1 = skipped['$=='](0))) ? (options['$[]']("list_type")) : ($ret_or_1)), $hash2(["skip_line_comments"], {"skip_line_comments": true}));
8264              if ($truthy(text_only)) {
8265
8266                if (($truthy(indented) && ($eqeq(style, "normal")))) {
8267                  self['$adjust_indentation!'](lines)
8268                };
8269                block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
8270              } else if ((($truthy($$('ADMONITION_STYLE_HEADS')['$include?'](ch0)) && ($truthy(this_line['$include?'](":")))) && ($truthy($$('AdmonitionParagraphRx')['$=~'](this_line))))) {
8271
8272                lines['$[]='](0, (($a = $gvars['~']) === nil ? nil : $a.$post_match()));
8273                attributes['$[]=']("name", (admonition_name = ($a = ["style", (($b = $gvars['~']) === nil ? nil : $b['$[]'](1))], $send(attributes, '[]=', $a), $a[$a.length - 1]).$downcase()));
8274                attributes['$[]=']("textlabel", ($truthy(($ret_or_1 = attributes.$delete("caption"))) ? ($ret_or_1) : (doc_attrs['$[]']("" + (admonition_name) + "-caption"))));
8275                block = $$('Block').$new(parent, "admonition", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
8276              } else if ((($truthy(md_syntax) && ($eqeq(ch0, ">"))) && ($truthy(this_line['$start_with?']("> "))))) {
8277
8278                $send(lines, 'map!', [], function $$7(line){
8279
8280                  if (line == null) line = nil;
8281                  if ($eqeq(line, ">")) {
8282
8283                    return line.$slice(1, line.$length());
8284                  } else {
8285
8286                    if ($truthy(line['$start_with?']("> "))) {
8287
8288                      return line.$slice(2, line.$length());
8289                    } else {
8290                      return line
8291                    };
8292                  };});
8293                if ($truthy(lines['$[]'](-1)['$start_with?']("-- "))) {
8294
8295                  credit_line = (credit_line = lines.$pop()).$slice(3, credit_line.$length());
8296                  if (!$truthy(lines['$empty?']())) {
8297                    while ($truthy(lines['$[]'](-1)['$empty?']())) {
8298                    lines.$pop()
8299                    }
8300                  };
8301                };
8302                attributes['$[]=']("style", "quote");
8303                block = self.$build_block("quote", "compound", false, parent, $$('Reader').$new(lines), attributes);
8304                if ($truthy(credit_line)) {
8305
8306                  $b = block.$apply_subs(credit_line).$split(", ", 2), $a = $to_ary($b), (attribution = ($a[0] == null ? nil : $a[0])), (citetitle = ($a[1] == null ? nil : $a[1])), $b;
8307                  if ($truthy(attribution)) {
8308                    attributes['$[]=']("attribution", attribution)
8309                  };
8310                  if ($truthy(citetitle)) {
8311                    attributes['$[]=']("citetitle", citetitle)
8312                  };
8313                };
8314              } else if (((($eqeq(ch0, "\"") && ($truthy($rb_gt(lines.$size(), 1)))) && ($truthy(lines['$[]'](-1)['$start_with?']("-- ")))) && ($truthy(lines['$[]'](-2)['$end_with?']("\""))))) {
8315
8316                lines['$[]='](0, this_line.$slice(1, this_line.$length()));
8317                credit_line = (credit_line = lines.$pop()).$slice(3, credit_line.$length());
8318                while ($truthy(lines['$[]'](-1)['$empty?']())) {
8319                lines.$pop()
8320                };
8321                lines['$<<'](lines.$pop().$chop());
8322                attributes['$[]=']("style", "quote");
8323                block = $$('Block').$new(parent, "quote", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
8324                $b = block.$apply_subs(credit_line).$split(", ", 2), $a = $to_ary($b), (attribution = ($a[0] == null ? nil : $a[0])), (citetitle = ($a[1] == null ? nil : $a[1])), $b;
8325                if ($truthy(attribution)) {
8326                  attributes['$[]=']("attribution", attribution)
8327                };
8328                if ($truthy(citetitle)) {
8329                  attributes['$[]=']("citetitle", citetitle)
8330                };
8331              } else {
8332
8333                if (($truthy(indented) && ($eqeq(style, "normal")))) {
8334                  self['$adjust_indentation!'](lines)
8335                };
8336                block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
8337              };
8338              self.$catalog_inline_anchors(lines.$join($$('LF')), block, document, reader);
8339            };
8340            break;
8341          }
8342        };
8343        if (!$truthy(block)) {
8344
8345          switch (block_context) {
8346            case "listing":
8347            case "source":
8348
8349              if (($eqeq(block_context, "source") || (($not(attributes['$[]'](1)) && ($truthy((language = ($truthy(($ret_or_2 = attributes['$[]'](2))) ? ($ret_or_2) : (doc_attrs['$[]']("source-language")))))))))) {
8350
8351                if ($truthy(language)) {
8352
8353                  attributes['$[]=']("style", "source");
8354                  attributes['$[]=']("language", language);
8355                  $$('AttributeList').$rekey(attributes, [nil, nil, "linenums"]);
8356                } else {
8357
8358                  $$('AttributeList').$rekey(attributes, [nil, "language", "linenums"]);
8359                  if (!$truthy(attributes['$key?']("language"))) {
8360                    if ($truthy(doc_attrs['$key?']("source-language"))) {
8361                      attributes['$[]=']("language", doc_attrs['$[]']("source-language"))
8362                    }
8363                  };
8364                };
8365                if (!$truthy(attributes['$key?']("linenums"))) {
8366                  if (($truthy(attributes['$[]']("linenums-option")) || ($truthy(doc_attrs['$[]']("source-linenums-option"))))) {
8367                    attributes['$[]=']("linenums", "")
8368                  }
8369                };
8370                if (!$truthy(attributes['$key?']("indent"))) {
8371                  if ($truthy(doc_attrs['$key?']("source-indent"))) {
8372                    attributes['$[]=']("indent", doc_attrs['$[]']("source-indent"))
8373                  }
8374                };
8375              };
8376              block = self.$build_block("listing", "verbatim", terminator, parent, reader, attributes);
8377              break;
8378            case "fenced_code":
8379
8380              attributes['$[]=']("style", "source");
8381              if ($truthy($rb_gt((ll = this_line.$length()), 3))) {
8382                if ($truthy((comma_idx = (language = this_line.$slice(3, ll)).$index(",")))) {
8383                  if ($truthy($rb_gt(comma_idx, 0))) {
8384
8385                    language = language.$slice(0, comma_idx).$strip();
8386                    if ($truthy($rb_lt(comma_idx, $rb_minus(ll, 4)))) {
8387                      attributes['$[]=']("linenums", "")
8388                    };
8389                  } else if ($truthy($rb_gt(ll, 4))) {
8390                    attributes['$[]=']("linenums", "")
8391                  }
8392                } else {
8393                  language = language.$lstrip()
8394                }
8395              };
8396              if ($truthy(language['$nil_or_empty?']())) {
8397                if ($truthy(doc_attrs['$key?']("source-language"))) {
8398                  attributes['$[]=']("language", doc_attrs['$[]']("source-language"))
8399                }
8400              } else {
8401                attributes['$[]=']("language", language)
8402              };
8403              if (!$truthy(attributes['$key?']("linenums"))) {
8404                if (($truthy(attributes['$[]']("linenums-option")) || ($truthy(doc_attrs['$[]']("source-linenums-option"))))) {
8405                  attributes['$[]=']("linenums", "")
8406                }
8407              };
8408              if (!$truthy(attributes['$key?']("indent"))) {
8409                if ($truthy(doc_attrs['$key?']("source-indent"))) {
8410                  attributes['$[]=']("indent", doc_attrs['$[]']("source-indent"))
8411                }
8412              };
8413              terminator = terminator.$slice(0, 3);
8414              block = self.$build_block("listing", "verbatim", terminator, parent, reader, attributes);
8415              break;
8416            case "table":
8417
8418              block_cursor = reader.$cursor();
8419              block_reader = $$('Reader').$new(reader.$read_lines_until($hash2(["terminator", "skip_line_comments", "context", "cursor"], {"terminator": terminator, "skip_line_comments": true, "context": "table", "cursor": "at_mark"})), block_cursor);
8420              if (!$truthy(terminator['$start_with?']("|", "!"))) {
8421                if ($truthy(($ret_or_2 = attributes['$[]']("format")))) {
8422                  $ret_or_2
8423                } else {
8424                  attributes['$[]=']("format", ($truthy(terminator['$start_with?'](",")) ? ("csv") : ("dsv")))
8425                }
8426              };
8427              block = self.$parse_table(block_reader, parent, attributes);
8428              break;
8429            case "sidebar":
8430              block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes)
8431              break;
8432            case "admonition":
8433
8434              attributes['$[]=']("name", (admonition_name = style.$downcase()));
8435              attributes['$[]=']("textlabel", ($truthy(($ret_or_2 = attributes.$delete("caption"))) ? ($ret_or_2) : (doc_attrs['$[]']("" + (admonition_name) + "-caption"))));
8436              block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes);
8437              break;
8438            case "open":
8439            case "abstract":
8440            case "partintro":
8441              block = self.$build_block("open", "compound", terminator, parent, reader, attributes)
8442              break;
8443            case "literal":
8444              block = self.$build_block(block_context, "verbatim", terminator, parent, reader, attributes)
8445              break;
8446            case "example":
8447
8448              if ($truthy(attributes['$[]']("collapsible-option"))) {
8449                attributes['$[]=']("caption", "")
8450              };
8451              block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes);
8452              break;
8453            case "quote":
8454            case "verse":
8455
8456              $$('AttributeList').$rekey(attributes, [nil, "attribution", "citetitle"]);
8457              block = self.$build_block(block_context, ($eqeq(block_context, "verse") ? ("verbatim") : ("compound")), terminator, parent, reader, attributes);
8458              break;
8459            case "stem":
8460            case "latexmath":
8461            case "asciimath":
8462
8463              if ($eqeq(block_context, "stem")) {
8464                attributes['$[]=']("style", $$('STEM_TYPE_ALIASES')['$[]'](($truthy(($ret_or_2 = attributes['$[]'](2))) ? ($ret_or_2) : (doc_attrs['$[]']("stem")))))
8465              };
8466              block = self.$build_block("stem", "raw", terminator, parent, reader, attributes);
8467              break;
8468            case "pass":
8469              block = self.$build_block(block_context, "raw", terminator, parent, reader, attributes)
8470              break;
8471            case "comment":
8472
8473              self.$build_block(block_context, "skip", terminator, parent, reader, attributes);
8474              attributes.$clear();
8475              return nil;
8476            default:
8477              if (($truthy(block_extensions) && ($truthy((extension = extensions['$registered_for_block?'](block_context, cloaked_context)))))) {
8478
8479                if (!$eqeq((content_model = (ext_config = extension.$config())['$[]']("content_model")), "skip")) {
8480
8481                  if (!$truthy((positional_attrs = ($truthy(($ret_or_2 = ext_config['$[]']("positional_attrs"))) ? ($ret_or_2) : (ext_config['$[]']("pos_attrs"))))['$nil_or_empty?']())) {
8482                    $$('AttributeList').$rekey(attributes, $rb_plus([nil], positional_attrs))
8483                  };
8484                  if ($truthy((default_attrs = ext_config['$[]']("default_attrs")))) {
8485                    $send(default_attrs, 'each', [], function $$8(k, v){var $c;
8486
8487
8488                      if (k == null) k = nil;
8489                      if (v == null) v = nil;
8490                      if ($truthy(($ret_or_2 = attributes['$[]'](k)))) {
8491                        return $ret_or_2
8492                      } else {
8493                        return ($c = [k, v], $send(attributes, '[]=', $c), $c[$c.length - 1])
8494                      };})
8495                  };
8496                  attributes['$[]=']("cloaked-context", cloaked_context);
8497                };
8498                if (!$truthy((block = self.$build_block(block_context, content_model, terminator, parent, reader, attributes, $hash2(["extension"], {"extension": extension}))))) {
8499
8500                  attributes.$clear();
8501                  return nil;
8502                };
8503              } else {
8504                self.$raise("Unsupported block type " + (block_context) + " at " + (reader.$cursor()))
8505              }
8506          }
8507        };
8508        if ($truthy(document.$sourcemap())) {
8509          block['$source_location='](reader.$cursor_at_mark())
8510        };
8511        if ($truthy(attributes['$[]']("title"))) {
8512
8513          block['$title=']((block_title = attributes.$delete("title")));
8514          if ($truthy($$('CAPTION_ATTRIBUTE_NAMES')['$[]'](block.$context()))) {
8515            block.$assign_caption(attributes.$delete("caption"))
8516          };
8517        };
8518        block['$style='](attributes['$[]']("style"));
8519        if ($truthy((block_id = ($truthy(($ret_or_1 = block.$id())) ? ($ret_or_1) : (($a = [attributes['$[]']("id")], $send(block, 'id=', $a), $a[$a.length - 1])))))) {
8520
8521          if ($truthy(($truthy(block_title) ? (block_title['$include?']($$('ATTR_REF_HEAD'))) : (block['$title?']())))) {
8522            block.$title()
8523          };
8524          if (!$truthy(document.$register("refs", [block_id, block]))) {
8525            self.$logger().$warn(self.$message_with_context("id assigned to block already in use: " + (block_id), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8526          };
8527        };
8528        if (!$truthy(attributes['$empty?']())) {
8529          block.$update_attributes(attributes)
8530        };
8531        block.$commit_subs();
8532        if ($truthy(block['$sub?']("callouts"))) {
8533          if (!$truthy(self.$catalog_callouts(block.$source(), document))) {
8534            block.$remove_sub("callouts")
8535          }
8536        };
8537        return block;
8538      }, -3);
8539      $defs(self, '$read_paragraph_lines', function $$read_paragraph_lines(reader, break_at_list, opts) {
8540        var break_condition = nil;
8541
8542
8543        if (opts == null) opts = $hash2([], {});
8544        opts['$[]=']("break_on_blank_lines", true);
8545        opts['$[]=']("break_on_list_continuation", true);
8546        opts['$[]=']("preserve_last_line", true);
8547        break_condition = ($truthy(break_at_list) ? (($truthy($$('Compliance').$block_terminates_paragraph()) ? ($$('StartOfBlockOrListProc')) : ($$('StartOfListProc')))) : (($truthy($$('Compliance').$block_terminates_paragraph()) ? ($$('StartOfBlockProc')) : ($$('NoOp')))));
8548        return $send(reader, 'read_lines_until', [opts], break_condition.$to_proc());
8549      }, -3);
8550      $defs(self, '$is_delimited_block?', function $Parser_is_delimited_block$ques$9(line, return_match_data) {
8551        var $a, $b, self = this, line_len = nil, tip = nil, tip_len = nil, context = nil, masq = nil;
8552
8553
8554        if (return_match_data == null) return_match_data = nil;
8555        if (!($truthy($rb_gt((line_len = line.$length()), 1)) && ($truthy($$('DELIMITED_BLOCK_HEADS')['$[]'](line.$slice(0, 2)))))) {
8556          return nil
8557        };
8558        if ($eqeq(line_len, 2)) {
8559
8560          tip = line;
8561          tip_len = 2;
8562        } else {
8563
8564          if ($truthy($rb_lt(line_len, 5))) {
8565
8566            tip = line;
8567            tip_len = line_len;
8568          } else {
8569            tip = line.$slice(0, (tip_len = 4))
8570          };
8571          if (($truthy($$('Compliance').$markdown_syntax()) && ($truthy(tip['$start_with?']("`"))))) {
8572            if ($eqeq(tip_len, 4)) {
8573
8574              if (($eqeq(tip, "````") || ($neqeq((tip = tip.$chop()), "```")))) {
8575                return nil
8576              };
8577              line = tip;
8578              line_len = (tip_len = 3);
8579            } else if ($neqeq(tip, "```")) {
8580              return nil
8581            }
8582          } else if ($eqeq(tip_len, 3)) {
8583            return nil
8584          };
8585        };
8586        $b = $$('DELIMITED_BLOCKS')['$[]'](tip), $a = $to_ary($b), (context = ($a[0] == null ? nil : $a[0])), (masq = ($a[1] == null ? nil : $a[1])), $b;
8587        if (($truthy(context) && (($eqeq(line_len, tip_len) || ($truthy(self['$uniform?'](line.$slice(1, line_len), $$('DELIMITED_BLOCK_TAILS')['$[]'](tip), $rb_minus(line_len, 1)))))))) {
8588          if ($truthy(return_match_data)) {
8589
8590            return $$('BlockMatchData').$new(context, masq, tip, line);
8591          } else {
8592            return true
8593          }
8594        } else {
8595          return nil
8596        };
8597      }, -2);
8598      $defs(self, '$build_block', function $$build_block(block_context, content_model, terminator, parent, reader, attributes, options) {
8599        var $a, self = this, skip_processing = nil, parse_as_content_model = nil, lines = nil, block_reader = nil, block_cursor = nil, tab_size = nil, $ret_or_2 = nil, indent = nil, extension = nil, block = nil, $ret_or_1 = nil;
8600
8601
8602        if (options == null) options = $hash2([], {});
8603
8604        switch (content_model) {
8605          case "skip":
8606            $a = [true, "simple"], (skip_processing = $a[0]), (parse_as_content_model = $a[1]), $a
8607            break;
8608          case "raw":
8609            $a = [false, "simple"], (skip_processing = $a[0]), (parse_as_content_model = $a[1]), $a
8610            break;
8611          default:
8612            $a = [false, content_model], (skip_processing = $a[0]), (parse_as_content_model = $a[1]), $a
8613        };
8614        if ($truthy(terminator['$nil?']())) {
8615
8616          if ($eqeq(parse_as_content_model, "verbatim")) {
8617            lines = reader.$read_lines_until($hash2(["break_on_blank_lines", "break_on_list_continuation"], {"break_on_blank_lines": true, "break_on_list_continuation": true}))
8618          } else {
8619
8620            if ($eqeq(content_model, "compound")) {
8621              content_model = "simple"
8622            };
8623            lines = self.$read_paragraph_lines(reader, false, $hash2(["skip_line_comments", "skip_processing"], {"skip_line_comments": true, "skip_processing": skip_processing}));
8624          };
8625          block_reader = nil;
8626        } else if ($neqeq(parse_as_content_model, "compound")) {
8627
8628          lines = reader.$read_lines_until($hash2(["terminator", "skip_processing", "context", "cursor"], {"terminator": terminator, "skip_processing": skip_processing, "context": block_context, "cursor": "at_mark"}));
8629          block_reader = nil;
8630        } else if ($eqeq(terminator, false)) {
8631
8632          lines = nil;
8633          block_reader = reader;
8634        } else {
8635
8636          lines = nil;
8637          block_cursor = reader.$cursor();
8638          block_reader = $$('Reader').$new(reader.$read_lines_until($hash2(["terminator", "skip_processing", "context", "cursor"], {"terminator": terminator, "skip_processing": skip_processing, "context": block_context, "cursor": "at_mark"})), block_cursor);
8639        };
8640
8641        switch (content_model) {
8642          case "verbatim":
8643
8644            tab_size = ($truthy(($ret_or_2 = attributes['$[]']("tabsize"))) ? ($ret_or_2) : (parent.$document().$attributes()['$[]']("tabsize"))).$to_i();
8645            if ($truthy((indent = attributes['$[]']("indent")))) {
8646              self['$adjust_indentation!'](lines, indent.$to_i(), tab_size)
8647            } else if ($truthy($rb_gt(tab_size, 0))) {
8648              self['$adjust_indentation!'](lines, -1, tab_size)
8649            };
8650            break;
8651          case "skip":
8652            return nil
8653          default:
8654            nil
8655        };
8656        if ($truthy((extension = options['$[]']("extension")))) {
8657
8658          attributes.$delete("style");
8659          if (($truthy((block = extension.$process_method()['$[]'](parent, ($truthy(($ret_or_1 = block_reader)) ? ($ret_or_1) : ($$('Reader').$new(lines))), attributes.$merge()))) && ($neqeq(block, parent)))) {
8660
8661            attributes.$replace(block.$attributes());
8662            if ((($eqeq(block.$content_model(), "compound") && ($eqeqeq($$('Block'), block))) && ($not((lines = block.$lines())['$empty?']())))) {
8663
8664              content_model = "compound";
8665              block_reader = $$('Reader').$new(lines);
8666            };
8667          } else {
8668            return nil
8669          };
8670        } else {
8671          block = $$('Block').$new(parent, block_context, $hash2(["content_model", "source", "attributes"], {"content_model": content_model, "source": lines, "attributes": attributes}))
8672        };
8673        if ($eqeq(content_model, "compound")) {
8674          self.$parse_blocks(block_reader, block)
8675        };
8676        return block;
8677      }, -7);
8678      $defs(self, '$parse_blocks', function $$parse_blocks(reader, parent, attributes) {
8679        var self = this, $ret_or_1 = nil, $ret_or_2 = nil, block = nil;
8680
8681
8682        if (attributes == null) attributes = nil;
8683        if ($truthy(attributes)) {
8684          while ($truthy(($truthy(($ret_or_1 = ($truthy(($ret_or_2 = (block = self.$next_block(reader, parent, attributes.$merge())))) ? (parent.$blocks()['$<<'](block)) : ($ret_or_2)))) ? ($ret_or_1) : (reader['$has_more_lines?']())))) {
8685
8686          }
8687        } else {
8688          while ($truthy(($truthy(($ret_or_1 = ($truthy(($ret_or_2 = (block = self.$next_block(reader, parent)))) ? (parent.$blocks()['$<<'](block)) : ($ret_or_2)))) ? ($ret_or_1) : (reader['$has_more_lines?']())))) {
8689
8690          }
8691        };
8692        return nil;
8693      }, -3);
8694      $defs(self, '$parse_list', function $$parse_list(reader, list_type, parent, style) {
8695        var $a, self = this, list_block = nil, list_rx = nil, $ret_or_1 = nil, list_item = nil;
8696        if ($gvars["~"] == null) $gvars["~"] = nil;
8697
8698
8699        list_block = $$('List').$new(parent, list_type);
8700        list_rx = $$('ListRxMap')['$[]'](list_type);
8701        while ($truthy(($truthy(($ret_or_1 = reader['$has_more_lines?']())) ? (list_rx['$=~'](reader.$peek_line())) : ($ret_or_1)))) {
8702
8703          if ($truthy((list_item = self.$parse_list_item(reader, list_block, $gvars["~"], (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), style)))) {
8704            list_block.$items()['$<<'](list_item)
8705          };
8706          if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) {
8707            $ret_or_1
8708          } else {
8709            break
8710          };
8711        };
8712        return list_block;
8713      });
8714      $defs(self, '$catalog_callouts', function $$catalog_callouts(text, document) {
8715        var found = nil, autonum = nil;
8716
8717
8718        found = false;
8719        autonum = 0;
8720        if ($truthy(text['$include?']("<"))) {
8721          $send(text, 'scan', [$$('CalloutScanRx')], function $$10(){var $a;
8722
8723
8724            if (!$truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']("\\"))) {
8725              document.$callouts().$register(($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), ".") ? ((autonum = $rb_plus(autonum, 1)).$to_s()) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))))
8726            };
8727            return (found = true);})
8728        };
8729        return found;
8730      });
8731      $defs(self, '$catalog_inline_anchor', function $$catalog_inline_anchor(id, reftext, node, location, doc) {
8732        var self = this;
8733
8734
8735        if (doc == null) doc = node.$document();
8736        if (($truthy(reftext) && ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))))) {
8737          reftext = doc.$sub_attributes(reftext)
8738        };
8739        if (!$truthy(doc.$register("refs", [id, $$('Inline').$new(node, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id}))]))) {
8740
8741          if ($eqeqeq($$('Reader'), location)) {
8742            location = location.$cursor()
8743          };
8744          self.$logger().$warn(self.$message_with_context("id assigned to anchor already in use: " + (id), $hash2(["source_location"], {"source_location": location})));
8745        };
8746        return nil;
8747      }, -5);
8748      $defs(self, '$catalog_inline_anchors', function $$catalog_inline_anchors(text, block, document, reader) {
8749        var self = this;
8750
8751
8752        if (($truthy(text['$include?']("[[")) || ($truthy(text['$include?']("or:"))))) {
8753          $send(text, 'scan', [$$('InlineAnchorScanRx')], function $$11(){var $a, self = $$11.$$s == null ? this : $$11.$$s, id = nil, reftext = nil, location = nil, offset = nil;
8754
8755
8756            if ($truthy((id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) {
8757              if ((($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) && ($truthy(reftext['$include?']($$('ATTR_REF_HEAD'))))) && ($truthy((reftext = document.$sub_attributes(reftext))['$empty?']())))) {
8758                return nil
8759              }
8760            } else {
8761
8762              id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3));
8763              if ($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4))))) {
8764                if ($truthy(reftext['$include?']("]"))) {
8765
8766                  reftext = reftext.$gsub("\\]", "]");
8767                  if ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))) {
8768                    reftext = document.$sub_attributes(reftext)
8769                  };
8770                } else if ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))) {
8771                  if ($truthy((reftext = document.$sub_attributes(reftext))['$empty?']())) {
8772                    reftext = nil
8773                  }
8774                }
8775              };
8776            };
8777            if ($truthy(document.$register("refs", [id, $$('Inline').$new(block, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id}))]))) {
8778              return nil
8779            } else {
8780
8781              location = reader.$cursor_at_mark();
8782              if ($truthy($rb_gt((offset = $rb_plus((($a = $gvars['~']) === nil ? nil : $a.$pre_match()).$count($$('LF')), ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('LF'))) ? (1) : (0)))), 0))) {
8783                (location = location.$dup()).$advance(offset)
8784              };
8785              return self.$logger().$warn(self.$message_with_context("id assigned to anchor already in use: " + (id), $hash2(["source_location"], {"source_location": location})));
8786            };}, {$$s: self})
8787        };
8788        return nil;
8789      });
8790      $defs(self, '$catalog_inline_biblio_anchor', function $$catalog_inline_biblio_anchor(id, reftext, node, reader) {
8791        var self = this, $ret_or_1 = nil;
8792
8793
8794        if (!$truthy(node.$document().$register("refs", [id, $$('Inline').$new(node, "anchor", ($truthy(($ret_or_1 = reftext)) ? ("[" + (reftext) + "]") : ($ret_or_1)), $hash2(["type", "id"], {"type": "bibref", "id": id}))]))) {
8795          self.$logger().$warn(self.$message_with_context("id assigned to bibliography anchor already in use: " + (id), $hash2(["source_location"], {"source_location": reader.$cursor()})))
8796        };
8797        return nil;
8798      });
8799      $defs(self, '$parse_description_list', function $$parse_description_list(reader, match, parent) {
8800        var self = this, list_block = nil, sibling_pattern = nil, current_pair = nil, $ret_or_1 = nil, next_pair = nil;
8801        if ($gvars["~"] == null) $gvars["~"] = nil;
8802
8803
8804        list_block = $$('List').$new(parent, "dlist");
8805        sibling_pattern = $$('DescriptionListSiblingRx')['$[]'](match['$[]'](2));
8806        list_block.$items()['$<<']((current_pair = self.$parse_list_item(reader, list_block, match, sibling_pattern)));
8807        while ($truthy(($truthy(($ret_or_1 = reader['$has_more_lines?']())) ? (sibling_pattern['$=~'](reader.$peek_line())) : ($ret_or_1)))) {
8808
8809          next_pair = self.$parse_list_item(reader, list_block, $gvars["~"], sibling_pattern);
8810          if ($truthy(current_pair['$[]'](1))) {
8811            list_block.$items()['$<<']((current_pair = next_pair))
8812          } else {
8813
8814            current_pair['$[]'](0)['$<<'](next_pair['$[]'](0)['$[]'](0));
8815            current_pair['$[]='](1, next_pair['$[]'](1));
8816          };
8817        };
8818        return list_block;
8819      });
8820      $defs(self, '$parse_callout_list', function $$parse_callout_list(reader, match, parent, callouts) {
8821        var self = this, list_block = nil, next_index = nil, autonum = nil, $ret_or_1 = nil, $ret_or_2 = nil, num = nil, list_item = nil, coids = nil;
8822
8823
8824        list_block = $$('List').$new(parent, "colist");
8825        next_index = 1;
8826        autonum = 0;
8827        while ($truthy(($truthy(($ret_or_1 = match)) ? ($ret_or_1) : (($truthy(($ret_or_2 = (match = $$('CalloutListRx').$match(reader.$peek_line())))) ? (reader.$mark()) : ($ret_or_2)))))) {
8828
8829          if ($eqeq((num = match['$[]'](1)), ".")) {
8830            num = (autonum = $rb_plus(autonum, 1)).$to_s()
8831          };
8832          if (!$eqeq(num, next_index.$to_s())) {
8833            self.$logger().$warn(self.$message_with_context("callout list item index: expected " + (next_index) + ", got " + (num), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8834          };
8835          if ($truthy((list_item = self.$parse_list_item(reader, list_block, match, "<1>")))) {
8836
8837            list_block.$items()['$<<'](list_item);
8838            if ($truthy((coids = callouts.$callout_ids(list_block.$items().$size()))['$empty?']())) {
8839              self.$logger().$warn(self.$message_with_context("no callout found for <" + (list_block.$items().$size()) + ">", $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()})))
8840            } else {
8841              list_item.$attributes()['$[]=']("coids", coids)
8842            };
8843          };
8844          next_index = $rb_plus(next_index, 1);
8845          match = nil;
8846        };
8847        callouts.$next_list();
8848        return list_block;
8849      });
8850      $defs(self, '$parse_list_item', function $$parse_list_item(reader, list_block, match, sibling_trait, style) {
8851        var $a, $b, self = this, list_type = nil, dlist = nil, list_term = nil, term_text = nil, $ret_or_1 = nil, item_text = nil, has_text = nil, list_item = nil, sourcemap_assignment_deferred = nil, ordinal = nil, implicit_style = nil, $ret_or_2 = nil, $ret_or_3 = nil, block_cursor = nil, list_item_reader = nil, comment_lines = nil, subsequent_line = nil, content_adjacent = nil, block = nil, first_block = nil;
8852
8853
8854        if (style == null) style = nil;
8855        if ($eqeq((list_type = list_block.$context()), "dlist")) {
8856
8857          dlist = true;
8858          list_term = $$('ListItem').$new(list_block, (term_text = match['$[]'](1)));
8859          if (($truthy(term_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](term_text))))) {
8860            self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), ($truthy(($ret_or_1 = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) ? ($ret_or_1) : ((($a = $gvars['~']) === nil ? nil : $a.$post_match()).$lstrip())), list_term, reader)
8861          };
8862          if ($truthy((item_text = match['$[]'](3)))) {
8863            has_text = true
8864          };
8865          list_item = $$('ListItem').$new(list_block, item_text);
8866          if ($truthy(list_block.$document().$sourcemap())) {
8867
8868            list_term['$source_location='](reader.$cursor());
8869            if ($truthy(has_text)) {
8870              list_item['$source_location='](list_term.$source_location())
8871            } else {
8872              sourcemap_assignment_deferred = true
8873            };
8874          };
8875        } else {
8876
8877          has_text = true;
8878          list_item = $$('ListItem').$new(list_block, (item_text = match['$[]'](2)));
8879          if ($truthy(list_block.$document().$sourcemap())) {
8880            list_item['$source_location='](reader.$cursor())
8881          };
8882
8883          switch (list_type) {
8884            case "ulist":
8885
8886              list_item['$marker='](sibling_trait);
8887              if ($truthy(item_text['$start_with?']("["))) {
8888                if (($truthy(style) && ($eqeq(style, "bibliography")))) {
8889                  if ($truthy($$('InlineBiblioAnchorRx')['$=~'](item_text))) {
8890                    self.$catalog_inline_biblio_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader)
8891                  }
8892                } else if ($truthy(item_text['$start_with?']("[["))) {
8893                  if ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))) {
8894                    self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader)
8895                  }
8896                } else if ($truthy(item_text['$start_with?']("[ ] ", "[x] ", "[*] "))) {
8897
8898                  list_block.$set_option("checklist");
8899                  list_item.$attributes()['$[]=']("checkbox", "");
8900                  if (!$truthy(item_text['$start_with?']("[ "))) {
8901                    list_item.$attributes()['$[]=']("checked", "")
8902                  };
8903                  list_item['$text='](item_text.$slice(4, item_text.$length()));
8904                }
8905              };
8906              break;
8907            case "olist":
8908
8909              $b = self.$resolve_ordered_list_marker(sibling_trait, (ordinal = list_block.$items().$size()), true, reader), $a = $to_ary($b), (sibling_trait = ($a[0] == null ? nil : $a[0])), (implicit_style = ($a[1] == null ? nil : $a[1])), $b;
8910              list_item['$marker='](sibling_trait);
8911              if (($eqeq(ordinal, 0) && ($not(style)))) {
8912                list_block['$style='](($truthy(($ret_or_2 = implicit_style)) ? ($ret_or_2) : (($truthy(($ret_or_3 = $$('ORDERED_LIST_STYLES')['$[]']($rb_minus(sibling_trait.$length(), 1)))) ? ($ret_or_3) : ("arabic")).$to_s())))
8913              };
8914              if (($truthy(item_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))))) {
8915                self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader)
8916              };
8917              break;
8918            default:
8919
8920              list_item['$marker='](sibling_trait);
8921              if (($truthy(item_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))))) {
8922                self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader)
8923              };
8924          };
8925        };
8926        reader.$shift();
8927        block_cursor = reader.$cursor();
8928        list_item_reader = $$('Reader').$new(self.$read_lines_for_list_item(reader, list_type, sibling_trait, has_text), block_cursor);
8929        if ($truthy(list_item_reader['$has_more_lines?']())) {
8930
8931          if ($truthy(sourcemap_assignment_deferred)) {
8932            list_item['$source_location='](block_cursor)
8933          };
8934          comment_lines = list_item_reader.$skip_line_comments();
8935          if ($truthy((subsequent_line = list_item_reader.$peek_line()))) {
8936
8937            if (!$truthy(comment_lines['$empty?']())) {
8938              list_item_reader.$unshift_lines(comment_lines)
8939            };
8940            if (!$truthy(subsequent_line['$empty?']())) {
8941
8942              content_adjacent = true;
8943              if (!$truthy(dlist)) {
8944                has_text = nil
8945              };
8946            };
8947          };
8948          if ($truthy((block = self.$next_block(list_item_reader, list_item, $hash2([], {}), $hash2(["text_only", "list_type"], {"text_only": ($truthy(has_text) ? (nil) : (true)), "list_type": list_type}))))) {
8949            list_item.$blocks()['$<<'](block)
8950          };
8951          while ($truthy(list_item_reader['$has_more_lines?']())) {
8952          if ($truthy((block = self.$next_block(list_item_reader, list_item, $hash2([], {}), $hash2(["list_type"], {"list_type": list_type}))))) {
8953              list_item.$blocks()['$<<'](block)
8954            }
8955          };
8956          if ((($truthy(content_adjacent) && ($truthy((first_block = list_item.$blocks()['$[]'](0))))) && ($eqeq(first_block.$context(), "paragraph")))) {
8957            list_item.$fold_first()
8958          };
8959        };
8960        if ($truthy(dlist)) {
8961          return [[list_term], (($truthy(list_item['$text?']()) || ($truthy(list_item['$blocks?']()))) ? (list_item) : (nil))]
8962        } else {
8963          return list_item
8964        };
8965      }, -5);
8966      $defs(self, '$read_lines_for_list_item', function $$read_lines_for_list_item(reader, list_type, sibling_trait, has_text) {
8967        var $a, self = this, buffer = nil, continuation = nil, within_nested_list = nil, detached_continuation = nil, dlist = nil, this_line = nil, prev_line = nil, match = nil, block_attribute_lines = nil, next_line = nil, interrupt = nil, ch0 = nil, nested_list_type = nil, $ret_or_1 = nil, last_line = nil;
8968
8969
8970        if (sibling_trait == null) sibling_trait = nil;
8971        if (has_text == null) has_text = true;
8972        buffer = [];
8973        continuation = "inactive";
8974        within_nested_list = false;
8975        detached_continuation = nil;
8976        dlist = list_type['$==']("dlist");
8977        while ($truthy(reader['$has_more_lines?']())) {
8978
8979          this_line = reader.$read_line();
8980          if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) {
8981            break
8982          };
8983          prev_line = ($truthy(buffer['$empty?']()) ? (nil) : (buffer['$[]'](-1)));
8984          if ($eqeq(prev_line, $$('LIST_CONTINUATION'))) {
8985
8986            if ($eqeq(continuation, "inactive")) {
8987
8988              continuation = "active";
8989              has_text = true;
8990              if (!$truthy(within_nested_list)) {
8991                buffer['$[]='](-1, "")
8992              };
8993            };
8994            if ($eqeq(this_line, $$('LIST_CONTINUATION'))) {
8995
8996              if ($neqeq(continuation, "frozen")) {
8997
8998                continuation = "frozen";
8999                buffer['$<<'](this_line);
9000              };
9001              this_line = nil;
9002              continue;
9003            };
9004          };
9005          if ($truthy((match = self['$is_delimited_block?'](this_line, true)))) {
9006
9007            if (!$eqeq(continuation, "active")) {
9008              break
9009            };
9010            buffer['$<<'](this_line);
9011            buffer.$concat(reader.$read_lines_until($hash2(["terminator", "read_last_line", "context"], {"terminator": match.$terminator(), "read_last_line": true, "context": nil})));
9012            continuation = "inactive";
9013          } else if (((($truthy(dlist) && ($neqeq(continuation, "active"))) && ($truthy(this_line['$start_with?']("[")))) && ($truthy($$('BlockAttributeLineRx')['$match?'](this_line))))) {
9014
9015            block_attribute_lines = [this_line];
9016            while ($truthy((next_line = reader.$peek_line()))) {
9017
9018              if ($truthy(self['$is_delimited_block?'](next_line))) {
9019                interrupt = true
9020              } else if (($truthy(next_line['$empty?']()) || (($truthy(next_line['$start_with?']("[")) && ($truthy($$('BlockAttributeLineRx')['$match?'](next_line))))))) {
9021
9022                block_attribute_lines['$<<'](reader.$read_line());
9023                continue;
9024              } else if (($truthy($$('AnyListRx')['$match?'](next_line)) && ($not(self['$is_sibling_list_item?'](next_line, list_type, sibling_trait))))) {
9025                buffer.$concat(block_attribute_lines)
9026              } else {
9027                interrupt = true
9028              };
9029              break;
9030            };
9031            if ($truthy(interrupt)) {
9032
9033              reader.$unshift_lines(block_attribute_lines);
9034              break;
9035            };
9036          } else if (($eqeq(continuation, "active") && ($not(this_line['$empty?']())))) {
9037            if ($truthy($$('LiteralParagraphRx')['$match?'](this_line))) {
9038
9039              reader.$unshift_line(this_line);
9040              if ($truthy(dlist)) {
9041                buffer.$concat($send(reader, 'read_lines_until', [$hash2(["preserve_last_line", "break_on_blank_lines", "break_on_list_continuation"], {"preserve_last_line": true, "break_on_blank_lines": true, "break_on_list_continuation": true})], function $$12(line){var self = $$12.$$s == null ? this : $$12.$$s;
9042
9043
9044                  if (line == null) line = nil;
9045                  return self['$is_sibling_list_item?'](line, list_type, sibling_trait);}, {$$s: self}))
9046              } else {
9047                buffer.$concat(reader.$read_lines_until($hash2(["preserve_last_line", "break_on_blank_lines", "break_on_list_continuation"], {"preserve_last_line": true, "break_on_blank_lines": true, "break_on_list_continuation": true})))
9048              };
9049              continuation = "inactive";
9050            } else if (((($eqeq((ch0 = this_line.$chr()), ".") && ($truthy($$('BlockTitleRx')['$match?'](this_line)))) || (($eqeq(ch0, "[") && ($truthy($$('BlockAttributeLineRx')['$match?'](this_line)))))) || (($eqeq(ch0, ":") && ($truthy($$('AttributeEntryRx')['$match?'](this_line))))))) {
9051              buffer['$<<'](this_line)
9052            } else {
9053
9054              if ($truthy((nested_list_type = $send(($truthy(within_nested_list) ? (["dlist"]) : ($$('NESTABLE_LIST_CONTEXTS'))), 'find', [], function $$13(ctx){
9055
9056                if (ctx == null) ctx = nil;
9057                return $$('ListRxMap')['$[]'](ctx)['$match?'](this_line);})))) {
9058
9059                within_nested_list = true;
9060                if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) {
9061                  has_text = false
9062                };
9063              };
9064              buffer['$<<'](this_line);
9065              continuation = "inactive";
9066            }
9067          } else if (($truthy(prev_line) && ($truthy(prev_line['$empty?']())))) {
9068
9069            if ($truthy(this_line['$empty?']())) {
9070
9071              if (!$truthy((this_line = ($truthy(($ret_or_1 = reader.$skip_blank_lines())) ? (reader.$read_line()) : ($ret_or_1))))) {
9072                break
9073              };
9074              if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) {
9075                break
9076              };
9077            };
9078            if ($eqeq(this_line, $$('LIST_CONTINUATION'))) {
9079
9080              detached_continuation = buffer.$size();
9081              buffer['$<<'](this_line);
9082            } else if ($truthy(has_text)) {
9083              if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) {
9084                break
9085              } else if ($truthy((nested_list_type = $send($$('NESTABLE_LIST_CONTEXTS'), 'find', [], function $$14(ctx){
9086
9087                if (ctx == null) ctx = nil;
9088                return $$('ListRxMap')['$[]'](ctx)['$=~'](this_line);})))) {
9089
9090                buffer['$<<'](this_line);
9091                within_nested_list = true;
9092                if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) {
9093                  has_text = false
9094                };
9095              } else if ($truthy($$('LiteralParagraphRx')['$match?'](this_line))) {
9096
9097                reader.$unshift_line(this_line);
9098                if ($truthy(dlist)) {
9099                  buffer.$concat($send(reader, 'read_lines_until', [$hash2(["preserve_last_line", "break_on_blank_lines", "break_on_list_continuation"], {"preserve_last_line": true, "break_on_blank_lines": true, "break_on_list_continuation": true})], function $$15(line){var self = $$15.$$s == null ? this : $$15.$$s;
9100
9101
9102                    if (line == null) line = nil;
9103                    return self['$is_sibling_list_item?'](line, list_type, sibling_trait);}, {$$s: self}))
9104                } else {
9105                  buffer.$concat(reader.$read_lines_until($hash2(["preserve_last_line", "break_on_blank_lines", "break_on_list_continuation"], {"preserve_last_line": true, "break_on_blank_lines": true, "break_on_list_continuation": true})))
9106                };
9107              } else {
9108                break
9109              }
9110            } else {
9111
9112              if (!$truthy(within_nested_list)) {
9113                buffer.$pop()
9114              };
9115              buffer['$<<'](this_line);
9116              has_text = true;
9117            };
9118          } else {
9119
9120            if (!$truthy(this_line['$empty?']())) {
9121              has_text = true
9122            };
9123            if ($truthy((nested_list_type = $send(($truthy(within_nested_list) ? (["dlist"]) : ($$('NESTABLE_LIST_CONTEXTS'))), 'find', [], function $$16(ctx){
9124
9125              if (ctx == null) ctx = nil;
9126              return $$('ListRxMap')['$[]'](ctx)['$=~'](this_line);})))) {
9127
9128              within_nested_list = true;
9129              if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) {
9130                has_text = false
9131              };
9132            };
9133            buffer['$<<'](this_line);
9134          };
9135          this_line = nil;
9136        };
9137        if ($truthy(this_line)) {
9138          reader.$unshift_line(this_line)
9139        };
9140        if ($truthy(detached_continuation)) {
9141          buffer['$[]='](detached_continuation, "")
9142        };
9143        while (!($truthy(buffer['$empty?']()))) {
9144        if ($truthy((last_line = buffer['$[]'](-1))['$empty?']())) {
9145            buffer.$pop()
9146          } else {
9147
9148            if ($eqeq(last_line, $$('LIST_CONTINUATION'))) {
9149              buffer.$pop()
9150            };
9151            break;
9152          }
9153        };
9154        return buffer;
9155      }, -3);
9156      $defs(self, '$initialize_section', function $$initialize_section(reader, parent, attributes) {
9157        var $a, $b, self = this, document = nil, book = nil, doctype = nil, source_location = nil, sect_style = nil, sect_id = nil, sect_reftext = nil, sect_title = nil, sect_level = nil, sect_atx = nil, sect_name = nil, sect_special = nil, sect_numbered = nil, section = nil, $ret_or_1 = nil, id = nil, generated_id = nil;
9158
9159
9160        if (attributes == null) attributes = $hash2([], {});
9161        document = parent.$document();
9162        book = (doctype = document.$doctype())['$==']("book");
9163        if ($truthy(document.$sourcemap())) {
9164          source_location = reader.$cursor()
9165        };
9166        sect_style = attributes['$[]'](1);
9167        $b = self.$parse_section_title(reader, document, attributes['$[]']("id")), $a = $to_ary($b), (sect_id = ($a[0] == null ? nil : $a[0])), (sect_reftext = ($a[1] == null ? nil : $a[1])), (sect_title = ($a[2] == null ? nil : $a[2])), (sect_level = ($a[3] == null ? nil : $a[3])), (sect_atx = ($a[4] == null ? nil : $a[4])), $b;
9168        if ($truthy(sect_style)) {
9169          if (($truthy(book) && ($eqeq(sect_style, "abstract")))) {
9170            $a = ["chapter", 1], (sect_name = $a[0]), (sect_level = $a[1]), $a
9171          } else if (($truthy(sect_style['$start_with?']("sect")) && ($truthy($$('SectionLevelStyleRx')['$match?'](sect_style))))) {
9172            sect_name = "section"
9173          } else {
9174
9175            $a = [sect_style, true], (sect_name = $a[0]), (sect_special = $a[1]), $a;
9176            if ($eqeq(sect_level, 0)) {
9177              sect_level = 1
9178            };
9179            sect_numbered = sect_name['$==']("appendix");
9180          }
9181        } else if ($truthy(book)) {
9182          sect_name = ($eqeq(sect_level, 0) ? ("part") : (($truthy($rb_gt(sect_level, 1)) ? ("section") : ("chapter"))))
9183        } else if (($eqeq(doctype, "manpage") && ($eqeq(sect_title.$casecmp("synopsis"), 0)))) {
9184          $a = ["synopsis", true], (sect_name = $a[0]), (sect_special = $a[1]), $a
9185        } else {
9186          sect_name = "section"
9187        };
9188        if ($truthy(sect_reftext)) {
9189          attributes['$[]=']("reftext", sect_reftext)
9190        };
9191        section = $$('Section').$new(parent, sect_level);
9192        $a = [sect_id, sect_title, sect_name, source_location], ($b = [$a[0]], $send(section, 'id=', $b), $b[$b.length - 1]), ($b = [$a[1]], $send(section, 'title=', $b), $b[$b.length - 1]), ($b = [$a[2]], $send(section, 'sectname=', $b), $b[$b.length - 1]), ($b = [$a[3]], $send(section, 'source_location=', $b), $b[$b.length - 1]), $a;
9193        if ($truthy(sect_special)) {
9194
9195          section['$special='](true);
9196          if ($truthy(sect_numbered)) {
9197            section['$numbered='](true)
9198          } else if ($eqeq(document.$attributes()['$[]']("sectnums"), "all")) {
9199            section['$numbered=']((($truthy(book) && ($eqeq(sect_level, 1))) ? ("chapter") : (true)))
9200          };
9201        } else if (($truthy(document.$attributes()['$[]']("sectnums")) && ($truthy($rb_gt(sect_level, 0))))) {
9202          section['$numbered='](($truthy(section.$special()) ? (($truthy(($ret_or_1 = parent.$numbered())) || ($ret_or_1))) : (true)))
9203        } else if ((($truthy(book) && ($eqeq(sect_level, 0))) && ($truthy(document.$attributes()['$[]']("partnums"))))) {
9204          section['$numbered='](true)
9205        };
9206        if ($truthy((id = ($truthy(($ret_or_1 = section.$id())) ? ($ret_or_1) : (($a = [($truthy(document.$attributes()['$key?']("sectids")) ? ((generated_id = $$('Section').$generate_id(section.$title(), document))) : (nil))], $send(section, 'id=', $a), $a[$a.length - 1])))))) {
9207
9208          if (!($truthy(generated_id) || ($not(sect_title['$include?']($$('ATTR_REF_HEAD')))))) {
9209            section.$title()
9210          };
9211          if (!$truthy(document.$register("refs", [id, section]))) {
9212            self.$logger().$warn(self.$message_with_context("id assigned to section already in use: " + (id), $hash2(["source_location"], {"source_location": reader.$cursor_at_line($rb_minus(reader.$lineno(), ($truthy(sect_atx) ? (1) : (2))))})))
9213          };
9214        };
9215        section.$update_attributes(attributes);
9216        reader.$skip_blank_lines();
9217        return section;
9218      }, -3);
9219      $defs(self, '$is_next_line_section?', function $Parser_is_next_line_section$ques$17(reader, attributes) {
9220        var self = this, style = nil, next_lines = nil, $ret_or_1 = nil;
9221
9222
9223        if (($truthy((style = attributes['$[]'](1))) && (($eqeq(style, "discrete") || ($eqeq(style, "float")))))) {
9224          return nil
9225        };
9226        if ($truthy($$('Compliance').$underline_style_section_titles())) {
9227
9228          next_lines = reader.$peek_lines(2, ($truthy(($ret_or_1 = style)) ? (style['$==']("comment")) : ($ret_or_1)));
9229          return self['$is_section_title?'](($truthy(($ret_or_1 = next_lines['$[]'](0))) ? ($ret_or_1) : ("")), next_lines['$[]'](1));
9230        } else {
9231          return self['$atx_section_title?'](($truthy(($ret_or_1 = reader.$peek_line())) ? ($ret_or_1) : ("")))
9232        };
9233      });
9234      $defs(self, '$is_next_line_doctitle?', function $Parser_is_next_line_doctitle$ques$18(reader, attributes, leveloffset) {
9235        var self = this, $ret_or_1 = nil, sect_level = nil;
9236
9237        if ($truthy(leveloffset)) {
9238          if ($truthy(($ret_or_1 = (sect_level = self['$is_next_line_section?'](reader, attributes))))) {
9239
9240            return $rb_plus(sect_level, leveloffset.$to_i())['$=='](0);
9241          } else {
9242            return $ret_or_1
9243          }
9244        } else {
9245          return self['$is_next_line_section?'](reader, attributes)['$=='](0)
9246        }
9247      });
9248      $defs(self, '$is_section_title?', function $Parser_is_section_title$ques$19(line1, line2) {
9249        var self = this, $ret_or_1 = nil;
9250
9251
9252        if (line2 == null) line2 = nil;
9253        if ($truthy(($ret_or_1 = self['$atx_section_title?'](line1)))) {
9254          return $ret_or_1
9255        } else {
9256
9257          if ($truthy(line2['$nil_or_empty?']())) {
9258            return nil
9259          } else {
9260            return self['$setext_section_title?'](line1, line2)
9261          };
9262        };
9263      }, -2);
9264      $defs(self, '$atx_section_title?', function $Parser_atx_section_title$ques$20(line) {
9265        var $a, $ret_or_1 = nil;
9266
9267        if ($truthy(($truthy($$('Compliance').$markdown_syntax()) ? (($truthy(($ret_or_1 = line['$start_with?']("=", "#"))) ? ($$('ExtAtxSectionTitleRx')['$=~'](line)) : ($ret_or_1))) : (($truthy(($ret_or_1 = line['$start_with?']("="))) ? ($$('AtxSectionTitleRx')['$=~'](line)) : ($ret_or_1)))))) {
9268          return $rb_minus((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)).$length(), 1)
9269        } else {
9270          return nil
9271        }
9272      });
9273      $defs(self, '$setext_section_title?', function $Parser_setext_section_title$ques$21(line1, line2) {
9274        var self = this, line2_len = nil, level = nil, line2_ch0 = nil;
9275
9276        if (((($truthy((level = $$('SETEXT_SECTION_LEVELS')['$[]']((line2_ch0 = line2.$chr())))) && ($truthy(self['$uniform?'](line2, line2_ch0, (line2_len = line2.$length()))))) && ($truthy($$('SetextSectionTitleRx')['$match?'](line1)))) && ($truthy($rb_lt($rb_minus(line1.$length(), line2_len).$abs(), 2))))) {
9277          return level
9278        } else {
9279          return nil
9280        }
9281      });
9282      $defs(self, '$parse_section_title', function $$parse_section_title(reader, document, sect_id) {
9283        var $a, $b, self = this, sect_reftext = nil, line1 = nil, $ret_or_1 = nil, sect_level = nil, sect_title = nil, atx = nil, line2_len = nil, line2_ch0 = nil, line2 = nil;
9284
9285
9286        if (sect_id == null) sect_id = nil;
9287        sect_reftext = nil;
9288        line1 = reader.$read_line();
9289        if ($truthy(($truthy($$('Compliance').$markdown_syntax()) ? (($truthy(($ret_or_1 = line1['$start_with?']("=", "#"))) ? ($$('ExtAtxSectionTitleRx')['$=~'](line1)) : ($ret_or_1))) : (($truthy(($ret_or_1 = line1['$start_with?']("="))) ? ($$('AtxSectionTitleRx')['$=~'](line1)) : ($ret_or_1)))))) {
9290
9291          $a = [$rb_minus((($b = $gvars['~']) === nil ? nil : $b['$[]'](1)).$length(), 1), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2)), true], (sect_level = $a[0]), (sect_title = $a[1]), (atx = $a[2]), $a;
9292          if (!$truthy(sect_id)) {
9293            if ((($truthy(sect_title['$end_with?']("]]")) && ($truthy($$('InlineSectionAnchorRx')['$=~'](sect_title)))) && ($not((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))))) {
9294              $a = [sect_title.$slice(0, $rb_minus(sect_title.$length(), (($b = $gvars['~']) === nil ? nil : $b['$[]'](0)).$length())), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2)), (($b = $gvars['~']) === nil ? nil : $b['$[]'](3))], (sect_title = $a[0]), (sect_id = $a[1]), (sect_reftext = $a[2]), $a
9295            }
9296          };
9297        } else if (((((($truthy($$('Compliance').$underline_style_section_titles()) && ($truthy((line2 = reader.$peek_line(true))))) && ($truthy((sect_level = $$('SETEXT_SECTION_LEVELS')['$[]']((line2_ch0 = line2.$chr())))))) && ($truthy(self['$uniform?'](line2, line2_ch0, (line2_len = line2.$length()))))) && ($truthy((sect_title = ($truthy(($ret_or_1 = $$('SetextSectionTitleRx')['$=~'](line1))) ? ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) : ($ret_or_1)))))) && ($truthy($rb_lt($rb_minus(line1.$length(), line2_len).$abs(), 2))))) {
9298
9299          atx = false;
9300          if (!$truthy(sect_id)) {
9301            if ((($truthy(sect_title['$end_with?']("]]")) && ($truthy($$('InlineSectionAnchorRx')['$=~'](sect_title)))) && ($not((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))))) {
9302              $a = [sect_title.$slice(0, $rb_minus(sect_title.$length(), (($b = $gvars['~']) === nil ? nil : $b['$[]'](0)).$length())), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2)), (($b = $gvars['~']) === nil ? nil : $b['$[]'](3))], (sect_title = $a[0]), (sect_id = $a[1]), (sect_reftext = $a[2]), $a
9303            }
9304          };
9305          reader.$shift();
9306        } else {
9307          self.$raise("Unrecognized section at " + (reader.$cursor_at_prev_line()))
9308        };
9309        if ($truthy(document['$attr?']("leveloffset"))) {
9310
9311          sect_level = $rb_plus(sect_level, document.$attr("leveloffset").$to_i());
9312          if ($truthy($rb_lt(sect_level, 0))) {
9313            sect_level = 0
9314          };
9315        };
9316        return [sect_id, sect_reftext, sect_title, sect_level, atx];
9317      }, -3);
9318      $defs(self, '$parse_header_metadata', function $$parse_header_metadata(reader, document, retrieve) {
9319        var $a, self = this, doc_attrs = nil, $ret_or_1 = nil, authorcount = nil, implicit_author_metadata = nil, implicit_author = nil, implicit_authorinitials = nil, implicit_authors = nil, rev_line = nil, match = nil, rev_metadata = nil, component = nil, author_line = nil, author_metadata = nil, authors = nil, author_idx = nil, author_key = nil, explicit = nil, sparse = nil, author_override = nil;
9320
9321
9322        if (document == null) document = nil;
9323        if (retrieve == null) retrieve = true;
9324        doc_attrs = ($truthy(($ret_or_1 = document)) ? (document.$attributes()) : ($ret_or_1));
9325        self.$process_attribute_entries(reader, document);
9326        if (($truthy(reader['$has_more_lines?']()) && ($not(reader['$next_line_empty?']())))) {
9327
9328          authorcount = (implicit_author_metadata = self.$process_authors(reader.$read_line())).$delete("authorcount");
9329          if (($truthy(document) && ($truthy($rb_gt(($a = ["authorcount", authorcount], $send(doc_attrs, '[]=', $a), $a[$a.length - 1]), 0))))) {
9330
9331            $send(implicit_author_metadata, 'each', [], function $$22(key, val){var $b;
9332
9333
9334              if (key == null) key = nil;
9335              if (val == null) val = nil;
9336              if ($truthy(doc_attrs['$key?'](key))) {
9337                return nil
9338              } else {
9339                return ($b = [key, document.$apply_header_subs(val)], $send(doc_attrs, '[]=', $b), $b[$b.length - 1])
9340              };});
9341            implicit_author = doc_attrs['$[]']("author");
9342            implicit_authorinitials = doc_attrs['$[]']("authorinitials");
9343            implicit_authors = doc_attrs['$[]']("authors");
9344          };
9345          implicit_author_metadata['$[]=']("authorcount", authorcount);
9346          self.$process_attribute_entries(reader, document);
9347          if (($truthy(reader['$has_more_lines?']()) && ($not(reader['$next_line_empty?']())))) {
9348
9349            rev_line = reader.$read_line();
9350            if ($truthy((match = $$('RevisionInfoLineRx').$match(rev_line)))) {
9351
9352              rev_metadata = $hash2([], {});
9353              if ($truthy(match['$[]'](1))) {
9354                rev_metadata['$[]=']("revnumber", match['$[]'](1).$rstrip())
9355              };
9356              if (!$truthy((component = match['$[]'](2).$strip())['$empty?']())) {
9357                if (($not(match['$[]'](1)) && ($truthy(component['$start_with?']("v"))))) {
9358                  rev_metadata['$[]=']("revnumber", component.$slice(1, component.$length()))
9359                } else {
9360                  rev_metadata['$[]=']("revdate", component)
9361                }
9362              };
9363              if ($truthy(match['$[]'](3))) {
9364                rev_metadata['$[]=']("revremark", match['$[]'](3).$rstrip())
9365              };
9366              if (($truthy(document) && ($not(rev_metadata['$empty?']())))) {
9367                $send(rev_metadata, 'each', [], function $$23(key, val){var $b;
9368
9369
9370                  if (key == null) key = nil;
9371                  if (val == null) val = nil;
9372                  if ($truthy(doc_attrs['$key?'](key))) {
9373                    return nil
9374                  } else {
9375                    return ($b = [key, document.$apply_header_subs(val)], $send(doc_attrs, '[]=', $b), $b[$b.length - 1])
9376                  };})
9377              };
9378            } else {
9379              reader.$unshift_line(rev_line)
9380            };
9381          };
9382          self.$process_attribute_entries(reader, document);
9383          reader.$skip_blank_lines();
9384        } else {
9385          implicit_author_metadata = $hash2([], {})
9386        };
9387        if ($truthy(document)) {
9388
9389          if (($truthy(doc_attrs['$key?']("author")) && ($neqeq((author_line = doc_attrs['$[]']("author")), implicit_author)))) {
9390
9391            author_metadata = self.$process_authors(author_line, true, false);
9392            if ($neqeq(doc_attrs['$[]']("authorinitials"), implicit_authorinitials)) {
9393              author_metadata.$delete("authorinitials")
9394            };
9395          } else if (($truthy(doc_attrs['$key?']("authors")) && ($neqeq((author_line = doc_attrs['$[]']("authors")), implicit_authors)))) {
9396            author_metadata = self.$process_authors(author_line, true)
9397          } else {
9398
9399            $a = [[], 1, "author_1", false, false], (authors = $a[0]), (author_idx = $a[1]), (author_key = $a[2]), (explicit = $a[3]), (sparse = $a[4]), $a;
9400            while ($truthy(doc_attrs['$key?'](author_key))) {
9401
9402              if ($eqeq((author_override = doc_attrs['$[]'](author_key)), implicit_author_metadata['$[]'](author_key))) {
9403
9404                authors['$<<'](nil);
9405                sparse = true;
9406              } else {
9407
9408                authors['$<<'](author_override);
9409                explicit = true;
9410              };
9411              author_key = "author_" + ((author_idx = $rb_plus(author_idx, 1)));
9412            };
9413            if ($truthy(explicit)) {
9414
9415              if ($truthy(sparse)) {
9416                $send(authors, 'each_with_index', [], function $$24(author, idx){var $b, name_idx = nil;
9417
9418
9419                  if (author == null) author = nil;
9420                  if (idx == null) idx = nil;
9421                  if ($truthy(author)) {
9422                    return nil
9423                  };
9424                  return ($b = [idx, $send([implicit_author_metadata['$[]']("firstname_" + ((name_idx = $rb_plus(idx, 1)))), implicit_author_metadata['$[]']("middlename_" + (name_idx)), implicit_author_metadata['$[]']("lastname_" + (name_idx))].$compact(), 'map', [], function $$25(it){
9425
9426                    if (it == null) it = nil;
9427                    return it.$tr(" ", "_");}).$join(" ")], $send(authors, '[]=', $b), $b[$b.length - 1]);})
9428              };
9429              author_metadata = self.$process_authors(authors, true, false);
9430            } else {
9431              author_metadata = $hash2(["authorcount"], {"authorcount": 0})
9432            };
9433          };
9434          if ($eqeq(author_metadata['$[]']("authorcount"), 0)) {
9435            if ($truthy(authorcount)) {
9436              author_metadata = nil
9437            } else {
9438              doc_attrs['$[]=']("authorcount", 0)
9439            }
9440          } else {
9441
9442            doc_attrs.$update(author_metadata);
9443            if (($not(doc_attrs['$key?']("email")) && ($truthy(doc_attrs['$key?']("email_1"))))) {
9444              doc_attrs['$[]=']("email", doc_attrs['$[]']("email_1"))
9445            };
9446          };
9447        };
9448        if ($truthy(retrieve)) {
9449          return implicit_author_metadata.$merge(rev_metadata.$to_h(), author_metadata.$to_h())
9450        } else {
9451          return nil
9452        };
9453      }, -2);
9454      $defs(self, '$process_authors', function $$process_authors(author_line, names_only, multiple) {
9455        var author_metadata = nil, author_idx = nil;
9456
9457
9458        if (names_only == null) names_only = false;
9459        if (multiple == null) multiple = true;
9460        author_metadata = $hash2([], {});
9461        author_idx = 0;
9462        $send((($truthy(multiple) && ($truthy(author_line['$include?'](";")))) ? (author_line.$split($$('AuthorDelimiterRx'))) : ([].concat($to_a(author_line)))), 'each', [], function $$26(author_entry){var $a, key_map = nil, segments = nil, match = nil, author = nil, fname = nil, mname = nil, lname = nil, $ret_or_1 = nil;
9463
9464
9465          if (author_entry == null) author_entry = nil;
9466          if ($truthy(author_entry['$empty?']())) {
9467            return nil
9468          };
9469          key_map = $hash2([], {});
9470          if ($eqeq((author_idx = $rb_plus(author_idx, 1)), 1)) {
9471            $send($$('AuthorKeys'), 'each', [], function $$27(key){var $a;
9472
9473
9474              if (key == null) key = nil;
9475              return ($a = [key.$to_sym(), key], $send(key_map, '[]=', $a), $a[$a.length - 1]);})
9476          } else {
9477            $send($$('AuthorKeys'), 'each', [], function $$28(key){var $a;
9478
9479
9480              if (key == null) key = nil;
9481              return ($a = [key.$to_sym(), "" + (key) + "_" + (author_idx)], $send(key_map, '[]=', $a), $a[$a.length - 1]);})
9482          };
9483          if ($truthy(names_only)) {
9484
9485            if ($truthy(author_entry['$include?']("<"))) {
9486
9487              author_metadata['$[]='](key_map['$[]']("author"), author_entry.$tr("_", " "));
9488              author_entry = author_entry.$gsub($$('XmlSanitizeRx'), "");
9489            };
9490            if ($eqeq((segments = author_entry.$split(nil, 3)).$size(), 3)) {
9491              segments['$<<'](segments.$pop().$squeeze(" "))
9492            };
9493          } else if ($truthy((match = $$('AuthorInfoLineRx').$match(author_entry)))) {
9494            (segments = match.$to_a()).$shift()
9495          };
9496          if ($truthy(segments)) {
9497
9498            author = ($a = [key_map['$[]']("firstname"), (fname = segments['$[]'](0).$tr("_", " "))], $send(author_metadata, '[]=', $a), $a[$a.length - 1]);
9499            author_metadata['$[]='](key_map['$[]']("authorinitials"), fname.$chr());
9500            if ($truthy(segments['$[]'](1))) {
9501              if ($truthy(segments['$[]'](2))) {
9502
9503                author_metadata['$[]='](key_map['$[]']("middlename"), (mname = segments['$[]'](1).$tr("_", " ")));
9504                author_metadata['$[]='](key_map['$[]']("lastname"), (lname = segments['$[]'](2).$tr("_", " ")));
9505                author = $rb_plus($rb_plus($rb_plus($rb_plus(fname, " "), mname), " "), lname);
9506                author_metadata['$[]='](key_map['$[]']("authorinitials"), "" + (fname.$chr()) + (mname.$chr()) + (lname.$chr()));
9507              } else {
9508
9509                author_metadata['$[]='](key_map['$[]']("lastname"), (lname = segments['$[]'](1).$tr("_", " ")));
9510                author = $rb_plus($rb_plus(fname, " "), lname);
9511                author_metadata['$[]='](key_map['$[]']("authorinitials"), "" + (fname.$chr()) + (lname.$chr()));
9512              }
9513            };
9514            if ($truthy(($ret_or_1 = author_metadata['$[]'](key_map['$[]']("author"))))) {
9515              $ret_or_1
9516            } else {
9517              author_metadata['$[]='](key_map['$[]']("author"), author)
9518            };
9519            if (!($truthy(names_only) || ($not(segments['$[]'](3))))) {
9520              author_metadata['$[]='](key_map['$[]']("email"), segments['$[]'](3))
9521            };
9522          } else {
9523
9524            author_metadata['$[]='](key_map['$[]']("author"), ($a = [key_map['$[]']("firstname"), (fname = author_entry.$squeeze(" ").$strip())], $send(author_metadata, '[]=', $a), $a[$a.length - 1]));
9525            author_metadata['$[]='](key_map['$[]']("authorinitials"), fname.$chr());
9526          };
9527          if ($eqeq(author_idx, 1)) {
9528            return ($a = ["authors", author_metadata['$[]'](key_map['$[]']("author"))], $send(author_metadata, '[]=', $a), $a[$a.length - 1])
9529          } else {
9530
9531            if ($eqeq(author_idx, 2)) {
9532              $send($$('AuthorKeys'), 'each', [], function $$29(key){var $b;
9533
9534
9535                if (key == null) key = nil;
9536                if ($truthy(author_metadata['$key?'](key))) {
9537                  return ($b = ["" + (key) + "_1", author_metadata['$[]'](key)], $send(author_metadata, '[]=', $b), $b[$b.length - 1])
9538                } else {
9539                  return nil
9540                };})
9541            };
9542            return ($a = ["authors", "" + (author_metadata['$[]']("authors")) + ", " + (author_metadata['$[]'](key_map['$[]']("author")))], $send(author_metadata, '[]=', $a), $a[$a.length - 1]);
9543          };});
9544        author_metadata['$[]=']("authorcount", author_idx);
9545        return author_metadata;
9546      }, -2);
9547      $defs(self, '$parse_block_metadata_lines', function $$parse_block_metadata_lines(reader, document, attributes, options) {
9548        var self = this, $ret_or_1 = nil;
9549
9550
9551        if (attributes == null) attributes = $hash2([], {});
9552        if (options == null) options = $hash2([], {});
9553        while ($truthy(self.$parse_block_metadata_line(reader, document, attributes, options))) {
9554
9555          reader.$shift();
9556          if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) {
9557            $ret_or_1
9558          } else {
9559            break
9560          };
9561        };
9562        return attributes;
9563      }, -3);
9564      $defs(self, '$parse_block_metadata_line', function $$parse_block_metadata_line(reader, document, attributes, options) {
9565        var $a, self = this, normal = nil, next_line = nil, reftext = nil, current_style = nil, $ret_or_1 = nil, ll = nil;
9566        if ($gvars["~"] == null) $gvars["~"] = nil;
9567
9568
9569        if (options == null) options = $hash2([], {});
9570        if (($truthy((next_line = reader.$peek_line())) && ($truthy(($truthy(options['$[]']("text_only")) ? (next_line['$start_with?']("[", "/")) : ((normal = next_line['$start_with?']("[", ".", "/", ":")))))))) {
9571          if ($truthy(next_line['$start_with?']("["))) {
9572            if ($truthy(next_line['$start_with?']("[["))) {
9573              if (($truthy(next_line['$end_with?']("]]")) && ($truthy($$('BlockAnchorRx')['$=~'](next_line))))) {
9574
9575                attributes['$[]=']("id", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)));
9576                if ($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) {
9577                  attributes['$[]=']("reftext", ($truthy(reftext['$include?']($$('ATTR_REF_HEAD'))) ? (document.$sub_attributes(reftext)) : (reftext)))
9578                };
9579                return true;
9580              }
9581            } else if (($truthy(next_line['$end_with?']("]")) && ($truthy($$('BlockAttributeListRx')['$=~'](next_line))))) {
9582
9583              current_style = attributes['$[]'](1);
9584              if ($truthy(document.$parse_attributes((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), [], $hash2(["sub_input", "sub_result", "into"], {"sub_input": true, "sub_result": true, "into": attributes}))['$[]'](1))) {
9585                attributes['$[]='](1, ($truthy(($ret_or_1 = self.$parse_style_attribute(attributes, reader))) ? ($ret_or_1) : (current_style)))
9586              };
9587              return true;
9588            }
9589          } else if (($truthy(normal) && ($truthy(next_line['$start_with?']("."))))) {
9590            if ($truthy($$('BlockTitleRx')['$=~'](next_line))) {
9591
9592              attributes['$[]=']("title", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)));
9593              return true;
9594            }
9595          } else if (($not(normal) || ($truthy(next_line['$start_with?']("/"))))) {
9596            if ($truthy(next_line['$start_with?']("//"))) {
9597              if ($eqeq(next_line, "//")) {
9598                return true
9599              } else if (($truthy(normal) && ($truthy(self['$uniform?'](next_line, "/", (ll = next_line.$length())))))) {
9600                if (!$eqeq(ll, 3)) {
9601
9602                  reader.$read_lines_until($hash2(["terminator", "skip_first_line", "preserve_last_line", "skip_processing", "context"], {"terminator": next_line, "skip_first_line": true, "preserve_last_line": true, "skip_processing": true, "context": "comment"}));
9603                  return true;
9604                }
9605              } else if (!$truthy(next_line['$start_with?']("///"))) {
9606                return true
9607              }
9608            }
9609          } else if ((($truthy(normal) && ($truthy(next_line['$start_with?'](":")))) && ($truthy($$('AttributeEntryRx')['$=~'](next_line))))) {
9610
9611            self.$process_attribute_entry(reader, document, attributes, $gvars["~"]);
9612            return true;
9613          }
9614        };
9615        return nil;
9616      }, -4);
9617      $defs(self, '$process_attribute_entries', function $$process_attribute_entries(reader, document, attributes) {
9618        var self = this;
9619
9620
9621        if (attributes == null) attributes = nil;
9622        reader.$skip_comment_lines();
9623        while ($truthy(self.$process_attribute_entry(reader, document, attributes))) {
9624
9625          reader.$shift();
9626          reader.$skip_comment_lines();
9627        };
9628      }, -3);
9629      $defs(self, '$process_attribute_entry', function $$process_attribute_entry(reader, document, attributes, match) {
9630        var $a, self = this, value = nil, con = nil, $ret_or_1 = nil, next_line = nil, $ret_or_2 = nil, keep_open = nil;
9631
9632
9633        if (attributes == null) attributes = nil;
9634        if (match == null) match = nil;
9635        if (($truthy(match) || ($truthy((match = ($truthy(reader['$has_more_lines?']()) ? ($$('AttributeEntryRx').$match(reader.$peek_line())) : (nil))))))) {
9636
9637          if ($truthy((value = match['$[]'](2))['$nil_or_empty?']())) {
9638            value = ""
9639          } else if ($truthy(value['$end_with?']($$('LINE_CONTINUATION'), $$('LINE_CONTINUATION_LEGACY')))) {
9640
9641            $a = [value.$slice($rb_minus(value.$length(), 2), 2), value.$slice(0, $rb_minus(value.$length(), 2)).$rstrip()], (con = $a[0]), (value = $a[1]), $a;
9642            while ($truthy(($truthy(($ret_or_1 = reader.$advance())) ? ((next_line = ($truthy(($ret_or_2 = reader.$peek_line())) ? ($ret_or_2) : ("")))['$empty?']()['$!']()) : ($ret_or_1)))) {
9643
9644              next_line = next_line.$lstrip();
9645              if ($truthy((keep_open = next_line['$end_with?'](con)))) {
9646                next_line = next_line.$slice(0, $rb_minus(next_line.$length(), 2)).$rstrip()
9647              };
9648              value = "" + (value) + (($truthy(value['$end_with?']($$('HARD_LINE_BREAK'))) ? ($$('LF')) : (" "))) + (next_line);
9649              if (!$truthy(keep_open)) {
9650                break
9651              };
9652            };
9653          };
9654          self.$store_attribute(match['$[]'](1), value, document, attributes);
9655          return true;
9656        } else {
9657          return nil
9658        };
9659      }, -3);
9660      $defs(self, '$store_attribute', function $$store_attribute(name, value, doc, attrs) {
9661        var self = this, resolved_value = nil;
9662
9663
9664        if (doc == null) doc = nil;
9665        if (attrs == null) attrs = nil;
9666        if ($truthy(name['$end_with?']("!"))) {
9667
9668          name = name.$chop();
9669          value = nil;
9670        } else if ($truthy(name['$start_with?']("!"))) {
9671
9672          name = name.$slice(1, name.$length());
9673          value = nil;
9674        };
9675        if ($eqeq((name = self.$sanitize_attribute_name(name)), "numbered")) {
9676          name = "sectnums"
9677        } else if ($eqeq(name, "hardbreaks")) {
9678          name = "hardbreaks-option"
9679        } else if ($eqeq(name, "showtitle")) {
9680          self.$store_attribute("notitle", ($truthy(value) ? (nil) : ("")), doc, attrs)
9681        };
9682        if ($truthy(doc)) {
9683          if ($truthy(value)) {
9684
9685            if ($eqeq(name, "leveloffset")) {
9686              if ($truthy(value['$start_with?']("+"))) {
9687                value = $rb_plus(doc.$attr("leveloffset", 0).$to_i(), value.$slice(1, value.$length()).$to_i()).$to_s()
9688              } else if ($truthy(value['$start_with?']("-"))) {
9689                value = $rb_minus(doc.$attr("leveloffset", 0).$to_i(), value.$slice(1, value.$length()).$to_i()).$to_s()
9690              }
9691            };
9692            if ($truthy((resolved_value = doc.$set_attribute(name, value)))) {
9693
9694              value = resolved_value;
9695              if ($truthy(attrs)) {
9696                $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs)
9697              };
9698            };
9699          } else if (($truthy(doc.$delete_attribute(name)) && ($truthy(attrs)))) {
9700            $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs)
9701          }
9702        } else if ($truthy(attrs)) {
9703          $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs)
9704        };
9705        return [name, value];
9706      }, -3);
9707      $defs(self, '$resolve_list_marker', function $$resolve_list_marker(list_type, marker, ordinal, validate, reader) {
9708        var self = this;
9709
9710
9711        if (ordinal == null) ordinal = 0;
9712        if (validate == null) validate = false;
9713        if (reader == null) reader = nil;
9714
9715        switch (list_type) {
9716          case "ulist":
9717            return marker
9718          case "olist":
9719            return self.$resolve_ordered_list_marker(marker, ordinal, validate, reader)['$[]'](0)
9720          default:
9721            return "<1>"
9722        };
9723      }, -3);
9724      $defs(self, '$resolve_ordered_list_marker', function $$resolve_ordered_list_marker(marker, ordinal, validate, reader) {
9725        var self = this, style = nil, expected = nil, actual = nil;
9726
9727
9728        if (ordinal == null) ordinal = 0;
9729        if (validate == null) validate = false;
9730        if (reader == null) reader = nil;
9731        if ($truthy(marker['$start_with?']("."))) {
9732          return [marker]
9733        };
9734
9735        switch ((style = $send($$('ORDERED_LIST_STYLES'), 'find', [], function $$30(s){
9736
9737          if (s == null) s = nil;
9738          return $$('OrderedListMarkerRxMap')['$[]'](s)['$match?'](marker);}))) {
9739          case "arabic":
9740
9741            if ($truthy(validate)) {
9742
9743              expected = $rb_plus(ordinal, 1);
9744              actual = marker.$to_i();
9745            };
9746            marker = "1.";
9747            break;
9748          case "loweralpha":
9749
9750            if ($truthy(validate)) {
9751
9752              expected = $rb_plus("a"['$[]'](0).$ord(), ordinal).$chr();
9753              actual = marker.$chop();
9754            };
9755            marker = "a.";
9756            break;
9757          case "upperalpha":
9758
9759            if ($truthy(validate)) {
9760
9761              expected = $rb_plus("A"['$[]'](0).$ord(), ordinal).$chr();
9762              actual = marker.$chop();
9763            };
9764            marker = "A.";
9765            break;
9766          case "lowerroman":
9767
9768            if ($truthy(validate)) {
9769
9770              expected = $$('Helpers').$int_to_roman($rb_plus(ordinal, 1)).$downcase();
9771              actual = marker.$chop();
9772            };
9773            marker = "i)";
9774            break;
9775          case "upperroman":
9776
9777            if ($truthy(validate)) {
9778
9779              expected = $$('Helpers').$int_to_roman($rb_plus(ordinal, 1));
9780              actual = marker.$chop();
9781            };
9782            marker = "I)";
9783            break;
9784          default:
9785            nil
9786        };
9787        if (($truthy(validate) && ($neqeq(expected, actual)))) {
9788          self.$logger().$warn(self.$message_with_context("list item index: expected " + (expected) + ", got " + (actual), $hash2(["source_location"], {"source_location": reader.$cursor()})))
9789        };
9790        return [marker, style];
9791      }, -2);
9792      $defs(self, '$is_sibling_list_item?', function $Parser_is_sibling_list_item$ques$31(line, list_type, sibling_trait) {
9793        var $a, self = this, $ret_or_1 = nil;
9794
9795        if ($eqeqeq($$$('Regexp'), sibling_trait)) {
9796          return sibling_trait['$match?'](line)
9797        } else if ($truthy(($ret_or_1 = $$('ListRxMap')['$[]'](list_type)['$=~'](line)))) {
9798          return sibling_trait['$=='](self.$resolve_list_marker(list_type, (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))
9799        } else {
9800          return $ret_or_1
9801        }
9802      });
9803      $defs(self, '$parse_table', function $$parse_table(table_reader, parent, attributes) {
9804        var $a, $b, $c, self = this, table = nil, colspecs = nil, explicit_colspecs = nil, skipped = nil, $ret_or_1 = nil, implicit_header = nil, parser_ctx = nil, format = nil, loop_idx = nil, implicit_header_boundary = nil, line = nil, beyond_first = nil, next_cellspec = nil, m = nil, pre_match = nil, post_match = nil, cell_text = nil, $logical_op_recvr_tmp_2 = nil;
9805
9806
9807        table = $$('Table').$new(parent, attributes);
9808        if (($truthy(attributes['$key?']("cols")) && ($not((colspecs = self.$parse_colspecs(attributes['$[]']("cols")))['$empty?']())))) {
9809
9810          table.$create_columns(colspecs);
9811          explicit_colspecs = true;
9812        };
9813        skipped = ($truthy(($ret_or_1 = table_reader.$skip_blank_lines())) ? ($ret_or_1) : (0));
9814        if ($truthy(attributes['$[]']("header-option"))) {
9815          table['$has_header_option='](true)
9816        } else if (($eqeq(skipped, 0) && ($not(attributes['$[]']("noheader-option"))))) {
9817
9818          table['$has_header_option=']("implicit");
9819          implicit_header = true;
9820        };
9821        parser_ctx = $$$($$('Table'), 'ParserContext').$new(table_reader, table, attributes);
9822        $a = [parser_ctx.$format(), -1, nil], (format = $a[0]), (loop_idx = $a[1]), (implicit_header_boundary = $a[2]), $a;
9823        while ($truthy((line = table_reader.$read_line()))) {
9824
9825          if (($truthy((beyond_first = $rb_gt((loop_idx = $rb_plus(loop_idx, 1)), 0))) && ($truthy(line['$empty?']())))) {
9826
9827            line = nil;
9828            if ($truthy(implicit_header_boundary)) {
9829              implicit_header_boundary = $rb_plus(implicit_header_boundary, 1)
9830            };
9831          } else if ($eqeq(format, "psv")) {
9832            if ($truthy(parser_ctx['$starts_with_delimiter?'](line))) {
9833
9834              line = line.$slice(1, line.$length());
9835              parser_ctx.$close_open_cell();
9836              if ($truthy(implicit_header_boundary)) {
9837                implicit_header_boundary = nil
9838              };
9839            } else {
9840
9841              $b = self.$parse_cellspec(line, "start", parser_ctx.$delimiter()), $a = $to_ary($b), (next_cellspec = ($a[0] == null ? nil : $a[0])), (line = ($a[1] == null ? nil : $a[1])), $b;
9842              if ($truthy(next_cellspec)) {
9843
9844                parser_ctx.$close_open_cell(next_cellspec);
9845                if ($truthy(implicit_header_boundary)) {
9846                  implicit_header_boundary = nil
9847                };
9848              } else if (($truthy(implicit_header_boundary) && ($eqeq(implicit_header_boundary, loop_idx)))) {
9849                table['$has_header_option=']((implicit_header = (implicit_header_boundary = nil)))
9850              };
9851            }
9852          };
9853          if (!$truthy(beyond_first)) {
9854
9855            table_reader.$mark();
9856            if ($truthy(implicit_header)) {
9857              if (($truthy(table_reader['$has_more_lines?']()) && ($truthy(table_reader.$peek_line()['$empty?']())))) {
9858                implicit_header_boundary = 1
9859              } else {
9860                table['$has_header_option=']((implicit_header = nil))
9861              }
9862            };
9863          };
9864          $a = false;while ($a || $truthy(true)) {$a = false;
9865          if (($truthy(line) && ($truthy((m = parser_ctx.$match_delimiter(line)))))) {
9866
9867              $b = [m.$pre_match(), m.$post_match()], (pre_match = $b[0]), (post_match = $b[1]), $b;
9868              if ($eqeqeq("csv", ($ret_or_1 = format))) {
9869
9870                if ($truthy(parser_ctx['$buffer_has_unclosed_quotes?'](pre_match))) {
9871
9872                  parser_ctx.$skip_past_delimiter(pre_match);
9873                  if ($truthy((line = post_match)['$empty?']())) {
9874                    break
9875                  };
9876                  $a = true;continue;
9877                };
9878                parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (pre_match));
9879              } else if ($eqeqeq("dsv", $ret_or_1)) {
9880
9881                if ($truthy(pre_match['$end_with?']("\\"))) {
9882
9883                  parser_ctx.$skip_past_escaped_delimiter(pre_match);
9884                  if ($truthy((line = post_match)['$empty?']())) {
9885
9886                    parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + ($$('LF')));
9887                    parser_ctx.$keep_cell_open();
9888                    break;
9889                  };
9890                  $a = true;continue;
9891                };
9892                parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (pre_match));
9893              } else {
9894
9895                if ($truthy(pre_match['$end_with?']("\\"))) {
9896
9897                  parser_ctx.$skip_past_escaped_delimiter(pre_match);
9898                  if ($truthy((line = post_match)['$empty?']())) {
9899
9900                    parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + ($$('LF')));
9901                    parser_ctx.$keep_cell_open();
9902                    break;
9903                  };
9904                  $a = true;continue;
9905                };
9906                $c = self.$parse_cellspec(pre_match), $b = $to_ary($c), (next_cellspec = ($b[0] == null ? nil : $b[0])), (cell_text = ($b[1] == null ? nil : $b[1])), $c;
9907                parser_ctx.$push_cellspec(next_cellspec);
9908                parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (cell_text));
9909              };
9910              if ($truthy((line = post_match)['$empty?']())) {
9911                line = nil
9912              };
9913              parser_ctx.$close_cell();
9914            } else {
9915
9916              parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (line) + ($$('LF')));
9917
9918              switch (format) {
9919                case "csv":
9920                  if ($truthy(parser_ctx['$buffer_has_unclosed_quotes?']())) {
9921
9922                    if (($truthy(implicit_header_boundary) && ($eqeq(loop_idx, 0)))) {
9923                      table['$has_header_option=']((implicit_header = (implicit_header_boundary = nil)))
9924                    };
9925                    parser_ctx.$keep_cell_open();
9926                  } else {
9927                    parser_ctx.$close_cell(true)
9928                  }
9929                  break;
9930                case "dsv":
9931                  parser_ctx.$close_cell(true)
9932                  break;
9933                default:
9934                  parser_ctx.$keep_cell_open()
9935              };
9936              break;
9937            }
9938          };
9939          if ($truthy(parser_ctx['$cell_open?']())) {
9940            if (!$truthy(table_reader['$has_more_lines?']())) {
9941              parser_ctx.$close_cell(true)
9942            }
9943          } else if ($truthy(($ret_or_1 = table_reader.$skip_blank_lines()))) {
9944            $ret_or_1
9945          } else {
9946            break
9947          };
9948        };
9949        if (!($eqeq((($logical_op_recvr_tmp_2 = table.$attributes()), ($truthy(($ret_or_1 = $logical_op_recvr_tmp_2['$[]']("colcount"))) ? ($ret_or_1) : (($a = ["colcount", table.$columns().$size()], $send($logical_op_recvr_tmp_2, '[]=', $a), $a[$a.length - 1])))), 0) || ($truthy(explicit_colspecs)))) {
9950          table.$assign_column_widths()
9951        };
9952        if ($truthy(implicit_header)) {
9953          table['$has_header_option='](true)
9954        };
9955        table.$partition_header_footer(attributes);
9956        return table;
9957      });
9958      $defs(self, '$parse_colspecs', function $$parse_colspecs(records) {
9959        var specs = nil;
9960
9961
9962        if ($truthy(records['$include?'](" "))) {
9963          records = records.$delete(" ")
9964        };
9965        if ($eqeq(records, records.$to_i().$to_s())) {
9966          return $send($$$('Array'), 'new', [records.$to_i()], function $$32(){
9967            return $hash2(["width"], {"width": 1})})
9968        };
9969        specs = [];
9970        $send(($truthy(records['$include?'](",")) ? (records.$split(",", -1)) : (records.$split(";", -1))), 'each', [], function $$33(record){var $a, $b, m = nil, spec = nil, colspec = nil, rowspec = nil, width = nil;
9971
9972
9973          if (record == null) record = nil;
9974          if ($truthy(record['$empty?']())) {
9975            return specs['$<<']($hash2(["width"], {"width": 1}))
9976          } else if ($truthy((m = $$('ColumnSpecRx').$match(record)))) {
9977
9978            spec = $hash2([], {});
9979            if ($truthy(m['$[]'](2))) {
9980
9981              $b = m['$[]'](2).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])), $b;
9982              if (($not(colspec['$nil_or_empty?']()) && ($truthy($$('TableCellHorzAlignments')['$key?'](colspec))))) {
9983                spec['$[]=']("halign", $$('TableCellHorzAlignments')['$[]'](colspec))
9984              };
9985              if (($not(rowspec['$nil_or_empty?']()) && ($truthy($$('TableCellVertAlignments')['$key?'](rowspec))))) {
9986                spec['$[]=']("valign", $$('TableCellVertAlignments')['$[]'](rowspec))
9987              };
9988            };
9989            if ($truthy((width = m['$[]'](3)))) {
9990              spec['$[]=']("width", ($eqeq(width, "~") ? (-1) : (width.$to_i())))
9991            } else {
9992              spec['$[]=']("width", 1)
9993            };
9994            if (($truthy(m['$[]'](4)) && ($truthy($$('TableCellStyles')['$key?'](m['$[]'](4)))))) {
9995              spec['$[]=']("style", $$('TableCellStyles')['$[]'](m['$[]'](4)))
9996            };
9997            if ($truthy(m['$[]'](1))) {
9998              return $send((1), 'upto', [m['$[]'](1).$to_i()], function $$34(){
9999                return specs['$<<'](spec.$merge())})
10000            } else {
10001              return specs['$<<'](spec)
10002            };
10003          } else {
10004            return nil
10005          };});
10006        return specs;
10007      });
10008      $defs(self, '$parse_cellspec', function $$parse_cellspec(line, pos, delimiter) {
10009        var $a, $b, m = nil, rest = nil, spec_part = nil, _ = nil, spec = nil, colspec = nil, rowspec = nil;
10010
10011
10012        if (pos == null) pos = "end";
10013        if (delimiter == null) delimiter = nil;
10014        $a = [nil, ""], (m = $a[0]), (rest = $a[1]), $a;
10015        if ($eqeq(pos, "start")) {
10016          if ($truthy(line['$include?'](delimiter))) {
10017
10018            $b = line.$partition(delimiter), $a = $to_ary($b), (spec_part = ($a[0] == null ? nil : $a[0])), (_ = ($a[1] == null ? nil : $a[1])), (rest = ($a[2] == null ? nil : $a[2])), $b;
10019            if ($truthy((m = $$('CellSpecStartRx').$match(spec_part)))) {
10020              if ($truthy(m['$[]'](0)['$empty?']())) {
10021                return [$hash2([], {}), rest]
10022              }
10023            } else {
10024              return [nil, line]
10025            };
10026          } else {
10027            return [nil, line]
10028          }
10029        } else if ($truthy((m = $$('CellSpecEndRx').$match(line)))) {
10030
10031          if ($truthy(m['$[]'](0).$lstrip()['$empty?']())) {
10032            return [$hash2([], {}), line.$rstrip()]
10033          };
10034          rest = m.$pre_match();
10035        } else {
10036          return [$hash2([], {}), line]
10037        };
10038        spec = $hash2([], {});
10039        if ($truthy(m['$[]'](1))) {
10040
10041          $b = m['$[]'](1).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])), $b;
10042          colspec = ($truthy(colspec['$nil_or_empty?']()) ? (1) : (colspec.$to_i()));
10043          rowspec = ($truthy(rowspec['$nil_or_empty?']()) ? (1) : (rowspec.$to_i()));
10044
10045          switch (m['$[]'](2)) {
10046            case "+":
10047
10048              if (!$eqeq(colspec, 1)) {
10049                spec['$[]=']("colspan", colspec)
10050              };
10051              if (!$eqeq(rowspec, 1)) {
10052                spec['$[]=']("rowspan", rowspec)
10053              };
10054              break;
10055            case "*":
10056              if (!$eqeq(colspec, 1)) {
10057                spec['$[]=']("repeatcol", colspec)
10058              }
10059              break;
10060            default:
10061              nil
10062          };
10063        };
10064        if ($truthy(m['$[]'](3))) {
10065
10066          $b = m['$[]'](3).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])), $b;
10067          if (($not(colspec['$nil_or_empty?']()) && ($truthy($$('TableCellHorzAlignments')['$key?'](colspec))))) {
10068            spec['$[]=']("halign", $$('TableCellHorzAlignments')['$[]'](colspec))
10069          };
10070          if (($not(rowspec['$nil_or_empty?']()) && ($truthy($$('TableCellVertAlignments')['$key?'](rowspec))))) {
10071            spec['$[]=']("valign", $$('TableCellVertAlignments')['$[]'](rowspec))
10072          };
10073        };
10074        if (($truthy(m['$[]'](4)) && ($truthy($$('TableCellStyles')['$key?'](m['$[]'](4)))))) {
10075          spec['$[]=']("style", $$('TableCellStyles')['$[]'](m['$[]'](4)))
10076        };
10077        return [spec, rest];
10078      }, -2);
10079      $defs(self, '$parse_style_attribute', function $$parse_style_attribute(attributes, reader) {
10080        var $a, self = this, raw_style = nil, name = nil, accum = nil, parsed_attrs = nil, parsed_style = nil, existing_role = nil;
10081
10082
10083        if (reader == null) reader = nil;
10084        if ((($truthy((raw_style = attributes['$[]'](1))) && ($not(raw_style['$include?'](" ")))) && ($truthy($$('Compliance').$shorthand_property_syntax())))) {
10085
10086          name = nil;
10087          accum = "";
10088          parsed_attrs = $hash2([], {});
10089          $send(raw_style, 'each_char', [], function $$35(c){var self = $$35.$$s == null ? this : $$35.$$s;
10090
10091
10092            if (c == null) c = nil;
10093
10094            switch (c) {
10095              case ".":
10096
10097                self.$yield_buffered_attribute(parsed_attrs, name, accum, reader);
10098                accum = "";
10099                return (name = "role");
10100              case "#":
10101
10102                self.$yield_buffered_attribute(parsed_attrs, name, accum, reader);
10103                accum = "";
10104                return (name = "id");
10105              case "%":
10106
10107                self.$yield_buffered_attribute(parsed_attrs, name, accum, reader);
10108                accum = "";
10109                return (name = "option");
10110              default:
10111                return (accum = $rb_plus(accum, c))
10112            };}, {$$s: self});
10113          if ($truthy(name)) {
10114
10115            self.$yield_buffered_attribute(parsed_attrs, name, accum, reader);
10116            if ($truthy((parsed_style = parsed_attrs['$[]']("style")))) {
10117              attributes['$[]=']("style", parsed_style)
10118            };
10119            if ($truthy(parsed_attrs['$key?']("id"))) {
10120              attributes['$[]=']("id", parsed_attrs['$[]']("id"))
10121            };
10122            if ($truthy(parsed_attrs['$key?']("role"))) {
10123              attributes['$[]=']("role", ($truthy((existing_role = attributes['$[]']("role"))['$nil_or_empty?']()) ? (parsed_attrs['$[]']("role").$join(" ")) : ("" + (existing_role) + " " + (parsed_attrs['$[]']("role").$join(" ")))))
10124            };
10125            if ($truthy(parsed_attrs['$key?']("option"))) {
10126              $send(parsed_attrs['$[]']("option"), 'each', [], function $$36(opt){var $a;
10127
10128
10129                if (opt == null) opt = nil;
10130                return ($a = ["" + (opt) + "-option", ""], $send(attributes, '[]=', $a), $a[$a.length - 1]);})
10131            };
10132            return parsed_style;
10133          } else {
10134            return ($a = ["style", raw_style], $send(attributes, '[]=', $a), $a[$a.length - 1])
10135          };
10136        } else {
10137          return ($a = ["style", raw_style], $send(attributes, '[]=', $a), $a[$a.length - 1])
10138        };
10139      }, -2);
10140      $defs(self, '$yield_buffered_attribute', function $$yield_buffered_attribute(attrs, name, value, reader) {
10141        var $a, self = this, $ret_or_1 = nil;
10142
10143
10144        if ($truthy(name)) {
10145          if ($truthy(value['$empty?']())) {
10146            if ($truthy(reader)) {
10147              self.$logger().$warn(self.$message_with_context("invalid empty " + (name) + " detected in style attribute", $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()})))
10148            } else {
10149              self.$logger().$warn("invalid empty " + (name) + " detected in style attribute")
10150            }
10151          } else if ($eqeq(name, "id")) {
10152
10153            if ($truthy(attrs['$key?']("id"))) {
10154              if ($truthy(reader)) {
10155                self.$logger().$warn(self.$message_with_context("multiple ids detected in style attribute", $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()})))
10156              } else {
10157                self.$logger().$warn("multiple ids detected in style attribute")
10158              }
10159            };
10160            attrs['$[]='](name, value);
10161          } else {
10162            ($truthy(($ret_or_1 = attrs['$[]'](name))) ? ($ret_or_1) : (($a = [name, []], $send(attrs, '[]=', $a), $a[$a.length - 1])))['$<<'](value)
10163          }
10164        } else if (!$truthy(value['$empty?']())) {
10165          attrs['$[]=']("style", value)
10166        };
10167        return nil;
10168      });
10169      $defs(self, '$adjust_indentation!', function $Parser_adjust_indentation$excl$37(lines, indent_size, tab_size) {
10170        var full_tab_space = nil, block_indent = nil, new_block_indent = nil;
10171
10172
10173        if (indent_size == null) indent_size = 0;
10174        if (tab_size == null) tab_size = 0;
10175        if ($truthy(lines['$empty?']())) {
10176          return nil
10177        };
10178        if (($truthy($rb_gt(tab_size, 0)) && ($truthy($send(lines, 'any?', [], function $$38(line){
10179
10180          if (line == null) line = nil;
10181          return line['$include?']($$('TAB'));}))))) {
10182
10183          full_tab_space = $rb_times(" ", tab_size);
10184          $send(lines, 'map!', [], function $$39(line){var tab_idx = nil, leading_tabs = nil, spaces_added = nil, idx = nil, result = nil;
10185
10186
10187            if (line == null) line = nil;
10188            if (($truthy(line['$empty?']()) || ($truthy((tab_idx = line.$index($$('TAB')))['$nil?']())))) {
10189              return line
10190            } else {
10191
10192              if ($eqeq(tab_idx, 0)) {
10193
10194                leading_tabs = 0;
10195                (function(){try { var $t_break = $thrower('break'); return $send(line, 'each_byte', [], function $$40(b){
10196
10197                  if (b == null) b = nil;
10198                  if (!$eqeq(b, 9)) {
10199                    $t_break.$throw()
10200                  };
10201                  return (leading_tabs = $rb_plus(leading_tabs, 1));})} catch($e) {
10202                  if ($e === $t_break) return $e.$v;
10203                  throw $e;
10204                }})();
10205                line = "" + ($rb_times(full_tab_space, leading_tabs)) + (line.$slice(leading_tabs, line.$length()));
10206                if (!$truthy(line['$include?']($$('TAB')))) {
10207                  return line
10208                };
10209              };
10210              spaces_added = 0;
10211              idx = 0;
10212              result = "";
10213              $send(line, 'each_char', [], function $$41(c){var offset = nil, spaces = nil;
10214
10215
10216                if (c == null) c = nil;
10217                if ($eqeq(c, $$('TAB'))) {
10218                  if ($eqeq((offset = $rb_plus(idx, spaces_added))['$%'](tab_size), 0)) {
10219
10220                    spaces_added = $rb_plus(spaces_added, $rb_minus(tab_size, 1));
10221                    result = $rb_plus(result, full_tab_space);
10222                  } else {
10223
10224                    if (!$eqeq((spaces = $rb_minus(tab_size, offset['$%'](tab_size))), 1)) {
10225                      spaces_added = $rb_plus(spaces_added, $rb_minus(spaces, 1))
10226                    };
10227                    result = $rb_plus(result, $rb_times(" ", spaces));
10228                  }
10229                } else {
10230                  result = $rb_plus(result, c)
10231                };
10232                return (idx = $rb_plus(idx, 1));});
10233              return result;
10234            };});
10235        };
10236        if ($truthy($rb_lt(indent_size, 0))) {
10237          return nil
10238        };
10239        block_indent = nil;
10240        (function(){try { var $t_break = $thrower('break'); return $send(lines, 'each', [], function $$42(line){var line_indent = nil;
10241
10242
10243          if (line == null) line = nil;
10244          if ($truthy(line['$empty?']())) {
10245            return nil
10246          };
10247          if ($eqeq((line_indent = $rb_minus(line.$length(), line.$lstrip().$length())), 0)) {
10248
10249            block_indent = nil;
10250            $t_break.$throw();
10251          };
10252          if (($truthy(block_indent) && ($truthy($rb_lt(block_indent, line_indent))))) {
10253            return nil
10254          } else {
10255            return (block_indent = line_indent)
10256          };})} catch($e) {
10257          if ($e === $t_break) return $e.$v;
10258          throw $e;
10259        }})();
10260        if ($eqeq(indent_size, 0)) {
10261          if ($truthy(block_indent)) {
10262            $send(lines, 'map!', [], function $$43(line){
10263
10264              if (line == null) line = nil;
10265              if ($truthy(line['$empty?']())) {
10266                return line
10267              } else {
10268
10269                return line.$slice(block_indent, line.$length());
10270              };})
10271          }
10272        } else {
10273
10274          new_block_indent = $rb_times(" ", indent_size);
10275          if ($truthy(block_indent)) {
10276            $send(lines, 'map!', [], function $$44(line){
10277
10278              if (line == null) line = nil;
10279              if ($truthy(line['$empty?']())) {
10280                return line
10281              } else {
10282                return $rb_plus(new_block_indent, line.$slice(block_indent, line.$length()))
10283              };})
10284          } else {
10285            $send(lines, 'map!', [], function $$45(line){
10286
10287              if (line == null) line = nil;
10288              if ($truthy(line['$empty?']())) {
10289                return line
10290              } else {
10291                return $rb_plus(new_block_indent, line)
10292              };})
10293          };
10294        };
10295        return nil;
10296      }, -2);
10297      $defs(self, '$uniform?', function $Parser_uniform$ques$46(str, chr, len) {
10298
10299        return str.$count(chr)['$=='](len)
10300      });
10301      return $defs(self, '$sanitize_attribute_name', function $$sanitize_attribute_name(name) {
10302
10303        return name.$gsub($$('InvalidAttributeNameCharsRx'), "").$downcase()
10304      });
10305    })($nesting[0], null, $nesting)
10306  })($nesting[0], $nesting)
10307};
10308
10309Opal.modules["asciidoctor/path_resolver"] = function(Opal) {/* Generated by Opal 1.7.3 */
10310  "use strict";
10311  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $truthy = Opal.truthy, $hash2 = Opal.hash2, $def = Opal.def, $eqeq = Opal.eqeq, $alias = Opal.alias, $rb_plus = Opal.rb_plus, $to_ary = Opal.to_ary, $send = Opal.send, $not = Opal.not, $neqeq = Opal.neqeq, $rb_gt = Opal.rb_gt, $gvars = Opal.gvars, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
10312
10313  Opal.add_stubs('include,attr_accessor,root?,posixify,expand_path,pwd,start_with?,==,match?,absolute_path?,+,length,descends_from?,slice,to_s,relative_path_from,new,include?,tr,partition_path,each,pop,<<,join_path,[],web_root?,unc?,index,split,delete,[]=,join,raise,!,fetch,warn,logger,empty?,nil_or_empty?,chomp,!=,>,size,extract_uri_prefix,end_with?,gsub,private,=~');
10314  return (function($base, $parent_nesting) {
10315    var self = $module($base, 'Asciidoctor');
10316
10317    var $nesting = [self].concat($parent_nesting);
10318
10319    return (function($base, $super, $parent_nesting) {
10320      var self = $klass($base, $super, 'PathResolver');
10321
10322      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
10323
10324      $proto.file_separator = $proto._partition_path_web = $proto._partition_path_sys = $proto.working_dir = nil;
10325
10326      self.$include($$('Logging'));
10327      $const_set($nesting[0], 'DOT', ".");
10328      $const_set($nesting[0], 'DOT_DOT', "..");
10329      $const_set($nesting[0], 'DOT_SLASH', "./");
10330      $const_set($nesting[0], 'SLASH', "/");
10331      $const_set($nesting[0], 'BACKSLASH', "\\");
10332      $const_set($nesting[0], 'DOUBLE_SLASH', "//");
10333      $const_set($nesting[0], 'URI_CLASSLOADER', "uri:classloader:");
10334      $const_set($nesting[0], 'WindowsRootRx', /^(?:[a-zA-Z]:)?[\\\/]/);
10335      self.$attr_accessor("file_separator");
10336      self.$attr_accessor("working_dir");
10337
10338      $def(self, '$initialize', function $$initialize(file_separator, working_dir) {
10339        var self = this, $ret_or_1 = nil, $ret_or_2 = nil;
10340
10341
10342        if (file_separator == null) file_separator = nil;
10343        if (working_dir == null) working_dir = nil;
10344        self.file_separator = ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = file_separator)) ? ($ret_or_2) : ($$$($$$('File'), 'ALT_SEPARATOR'))))) ? ($ret_or_1) : ($$$($$$('File'), 'SEPARATOR')));
10345        self.working_dir = ($truthy(working_dir) ? (($truthy(self['$root?'](working_dir)) ? (self.$posixify(working_dir)) : ($$$('File').$expand_path(working_dir)))) : ($$$('Dir').$pwd()));
10346        self._partition_path_sys = $hash2([], {});
10347        return (self._partition_path_web = $hash2([], {}));
10348      }, -1);
10349
10350      $def(self, '$absolute_path?', function $PathResolver_absolute_path$ques$1(path) {
10351        var self = this, $ret_or_1 = nil, $ret_or_2 = nil;
10352
10353        if ($truthy(($ret_or_1 = path['$start_with?']($$('SLASH'))))) {
10354          return $ret_or_1
10355        } else {
10356
10357          if ($truthy(($ret_or_2 = self.file_separator['$==']($$('BACKSLASH'))))) {
10358
10359            return $$('WindowsRootRx')['$match?'](path);
10360          } else {
10361            return $ret_or_2
10362          };
10363        }
10364      });
10365      if (($eqeq($$('RUBY_ENGINE'), "opal") && ($eqeq($$$('JAVASCRIPT_IO_MODULE'), "xmlhttprequest")))) {
10366
10367        $def(self, '$root?', function $PathResolver_root$ques$2(path) {
10368          var self = this, $ret_or_1 = nil;
10369
10370          if ($truthy(($ret_or_1 = self['$absolute_path?'](path)))) {
10371            return $ret_or_1
10372          } else {
10373
10374            return path['$start_with?']("file://", "http://", "https://");
10375          }
10376        })
10377      } else if ($eqeq($$$('RUBY_ENGINE'), "jruby")) {
10378
10379        $def(self, '$root?', function $PathResolver_root$ques$3(path) {
10380          var self = this, $ret_or_1 = nil;
10381
10382          if ($truthy(($ret_or_1 = self['$absolute_path?'](path)))) {
10383            return $ret_or_1
10384          } else {
10385
10386            return path['$start_with?']($$('URI_CLASSLOADER'));
10387          }
10388        })
10389      } else {
10390        $alias(self, "root?", "absolute_path?")
10391      };
10392
10393      $def(self, '$unc?', function $PathResolver_unc$ques$4(path) {
10394
10395        return path['$start_with?']($$('DOUBLE_SLASH'))
10396      });
10397
10398      $def(self, '$web_root?', function $PathResolver_web_root$ques$5(path) {
10399
10400        return path['$start_with?']($$('SLASH'))
10401      });
10402
10403      $def(self, '$descends_from?', function $PathResolver_descends_from$ques$6(path, base) {
10404        var $ret_or_1 = nil;
10405
10406        if ($eqeq(base, path)) {
10407          return 0
10408        } else if ($eqeq(base, $$('SLASH'))) {
10409          if ($truthy(($ret_or_1 = path['$start_with?']($$('SLASH'))))) {
10410            return 1
10411          } else {
10412            return $ret_or_1
10413          }
10414        } else if ($truthy(($ret_or_1 = path['$start_with?']($rb_plus(base, $$('SLASH')))))) {
10415
10416          return $rb_plus(base.$length(), 1);
10417        } else {
10418          return $ret_or_1
10419        }
10420      });
10421
10422      $def(self, '$relative_path', function $$relative_path(path, base) {
10423        var self = this, offset = nil;
10424
10425        if ($truthy(self['$root?'](path))) {
10426          if ($truthy((offset = self['$descends_from?'](path, base)))) {
10427            return path.$slice(offset, path.$length())
10428          } else {
10429
10430            try {
10431              return $$('Pathname').$new(path).$relative_path_from($$('Pathname').$new(base)).$to_s()
10432            } catch ($err) {
10433              if (Opal.rescue($err, [$$('StandardError')])) {
10434                try {
10435                  return path
10436                } finally { Opal.pop_exception(); }
10437              } else { throw $err; }
10438            };
10439          }
10440        } else {
10441          return path
10442        }
10443      });
10444
10445      $def(self, '$posixify', function $$posixify(path) {
10446        var self = this;
10447
10448        if ($truthy(path)) {
10449          if (($eqeq(self.file_separator, $$('BACKSLASH')) && ($truthy(path['$include?']($$('BACKSLASH')))))) {
10450
10451            return path.$tr($$('BACKSLASH'), $$('SLASH'));
10452          } else {
10453            return path
10454          }
10455        } else {
10456          return ""
10457        }
10458      });
10459      $alias(self, "posixfy", "posixify");
10460
10461      $def(self, '$expand_path', function $$expand_path(path) {
10462        var $a, $b, self = this, path_segments = nil, path_root = nil, resolved_segments = nil;
10463
10464
10465        $b = self.$partition_path(path), $a = $to_ary($b), (path_segments = ($a[0] == null ? nil : $a[0])), (path_root = ($a[1] == null ? nil : $a[1])), $b;
10466        if ($truthy(path['$include?']($$('DOT_DOT')))) {
10467
10468          resolved_segments = [];
10469          $send(path_segments, 'each', [], function $$7(segment){
10470
10471            if (segment == null) segment = nil;
10472            if ($eqeq(segment, $$('DOT_DOT'))) {
10473              return resolved_segments.$pop()
10474            } else {
10475              return resolved_segments['$<<'](segment)
10476            };});
10477          return self.$join_path(resolved_segments, path_root);
10478        } else {
10479          return self.$join_path(path_segments, path_root)
10480        };
10481      });
10482
10483      $def(self, '$partition_path', function $$partition_path(path, web) {
10484        var $a, self = this, result = nil, cache = nil, posix_path = nil, root = nil, path_segments = nil;
10485
10486
10487        if (web == null) web = nil;
10488        if ($truthy((result = (cache = ($truthy(web) ? (self._partition_path_web) : (self._partition_path_sys)))['$[]'](path)))) {
10489          return result
10490        };
10491        posix_path = self.$posixify(path);
10492        if ($truthy(web)) {
10493          if ($truthy(self['$web_root?'](posix_path))) {
10494            root = $$('SLASH')
10495          } else if ($truthy(posix_path['$start_with?']($$('DOT_SLASH')))) {
10496            root = $$('DOT_SLASH')
10497          }
10498        } else if ($truthy(self['$root?'](posix_path))) {
10499          if ($truthy(self['$unc?'](posix_path))) {
10500            root = $$('DOUBLE_SLASH')
10501          } else if ($truthy(posix_path['$start_with?']($$('SLASH')))) {
10502            root = $$('SLASH')
10503          } else if ($truthy(posix_path['$start_with?']($$('URI_CLASSLOADER')))) {
10504            root = posix_path.$slice(0, $$('URI_CLASSLOADER').$length())
10505          } else {
10506            root = posix_path.$slice(0, $rb_plus(posix_path.$index($$('SLASH')), 1))
10507          }
10508        } else if ($truthy(posix_path['$start_with?']($$('DOT_SLASH')))) {
10509          root = $$('DOT_SLASH')
10510        };
10511        path_segments = ($truthy(root) ? (posix_path.$slice(root.$length(), posix_path.$length())) : (posix_path)).$split($$('SLASH'));
10512        path_segments.$delete($$('DOT'));
10513        return ($a = [path, [path_segments, root]], $send(cache, '[]=', $a), $a[$a.length - 1]);
10514      }, -2);
10515
10516      $def(self, '$join_path', function $$join_path(segments, root) {
10517
10518
10519        if (root == null) root = nil;
10520        if ($truthy(root)) {
10521          return "" + (root) + (segments.$join($$('SLASH')))
10522        } else {
10523
10524          return segments.$join($$('SLASH'));
10525        };
10526      }, -2);
10527
10528      $def(self, '$system_path', function $$system_path(target, start, jail, opts) {
10529        var $a, $b, self = this, target_path = nil, $ret_or_1 = nil, target_segments = nil, jail_segments = nil, jail_root = nil, recheck = nil, start_segments = nil, start_root = nil, resolved_segments = nil, unresolved_segments = nil, warned = nil;
10530
10531
10532        if (start == null) start = nil;
10533        if (jail == null) jail = nil;
10534        if (opts == null) opts = $hash2([], {});
10535        if ($truthy(jail)) {
10536
10537          if (!$truthy(self['$root?'](jail))) {
10538            self.$raise($$$('SecurityError'), "Jail is not an absolute path: " + (jail))
10539          };
10540          jail = self.$posixify(jail);
10541        };
10542        if ($truthy(target)) {
10543          if ($truthy(self['$root?'](target))) {
10544
10545            target_path = self.$expand_path(target);
10546            if (($truthy(jail) && ($not(self['$descends_from?'](target_path, jail))))) {
10547              if ($truthy(opts.$fetch("recover", true))) {
10548
10549                self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail; recovering automatically");
10550                $b = self.$partition_path(target_path), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])), $b;
10551                $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])), (jail_root = ($a[1] == null ? nil : $a[1])), $b;
10552                return self.$join_path($rb_plus(jail_segments, target_segments), jail_root);
10553              } else {
10554                self.$raise($$$('SecurityError'), "" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " " + (target) + " is outside of jail: " + (jail) + " (disallowed in safe mode)")
10555              }
10556            };
10557            return target_path;
10558          } else {
10559            $b = self.$partition_path(target), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])), $b
10560          }
10561        } else {
10562          target_segments = []
10563        };
10564        if ($truthy(target_segments['$empty?']())) {
10565          if ($truthy(start['$nil_or_empty?']())) {
10566            return ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir))
10567          } else if ($truthy(self['$root?'](start))) {
10568            if ($truthy(jail)) {
10569              start = self.$posixify(start)
10570            } else {
10571              return self.$expand_path(start)
10572            }
10573          } else {
10574
10575            $b = self.$partition_path(start), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])), $b;
10576            start = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir));
10577          }
10578        } else if ($truthy(start['$nil_or_empty?']())) {
10579          start = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir))
10580        } else if ($truthy(self['$root?'](start))) {
10581          if ($truthy(jail)) {
10582            start = self.$posixify(start)
10583          }
10584        } else {
10585          start = "" + (($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir)).$chomp("/")) + "/" + (start)
10586        };
10587        if ((($truthy(jail) && ($truthy((recheck = self['$descends_from?'](start, jail)['$!']())))) && ($eqeq(self.file_separator, $$('BACKSLASH'))))) {
10588
10589          $b = self.$partition_path(start), $a = $to_ary($b), (start_segments = ($a[0] == null ? nil : $a[0])), (start_root = ($a[1] == null ? nil : $a[1])), $b;
10590          $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])), (jail_root = ($a[1] == null ? nil : $a[1])), $b;
10591          if ($neqeq(start_root, jail_root)) {
10592            if ($truthy(opts.$fetch("recover", true))) {
10593
10594              self.$logger().$warn("start path for " + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail root; recovering automatically");
10595              start_segments = jail_segments;
10596              recheck = false;
10597            } else {
10598              self.$raise($$$('SecurityError'), "start path for " + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " " + (start) + " refers to location outside jail root: " + (jail) + " (disallowed in safe mode)")
10599            }
10600          };
10601        } else {
10602          $b = self.$partition_path(start), $a = $to_ary($b), (start_segments = ($a[0] == null ? nil : $a[0])), (jail_root = ($a[1] == null ? nil : $a[1])), $b
10603        };
10604        if ($truthy((resolved_segments = $rb_plus(start_segments, target_segments))['$include?']($$('DOT_DOT')))) {
10605
10606          $a = [resolved_segments, []], (unresolved_segments = $a[0]), (resolved_segments = $a[1]), $a;
10607          if ($truthy(jail)) {
10608
10609            if (!$truthy(jail_segments)) {
10610              $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])), $b
10611            };
10612            warned = false;
10613            $send(unresolved_segments, 'each', [], function $$8(segment){var self = $$8.$$s == null ? this : $$8.$$s;
10614
10615
10616              if (segment == null) segment = nil;
10617              if ($eqeq(segment, $$('DOT_DOT'))) {
10618                if ($truthy($rb_gt(resolved_segments.$size(), jail_segments.$size()))) {
10619                  return resolved_segments.$pop()
10620                } else if ($truthy(opts.$fetch("recover", true))) {
10621                  if ($truthy(warned)) {
10622                    return nil
10623                  } else {
10624
10625                    self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " has illegal reference to ancestor of jail; recovering automatically");
10626                    return (warned = true);
10627                  }
10628                } else {
10629                  return self.$raise($$$('SecurityError'), "" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " " + (target) + " refers to location outside jail: " + (jail) + " (disallowed in safe mode)")
10630                }
10631              } else {
10632                return resolved_segments['$<<'](segment)
10633              };}, {$$s: self});
10634          } else {
10635            $send(unresolved_segments, 'each', [], function $$9(segment){
10636
10637              if (segment == null) segment = nil;
10638              if ($eqeq(segment, $$('DOT_DOT'))) {
10639                return resolved_segments.$pop()
10640              } else {
10641                return resolved_segments['$<<'](segment)
10642              };})
10643          };
10644        };
10645        if ($truthy(recheck)) {
10646
10647          target_path = self.$join_path(resolved_segments, jail_root);
10648          if ($truthy(self['$descends_from?'](target_path, jail))) {
10649            return target_path
10650          } else if ($truthy(opts.$fetch("recover", true))) {
10651
10652            self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail; recovering automatically");
10653            if (!$truthy(jail_segments)) {
10654              $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])), $b
10655            };
10656            return self.$join_path($rb_plus(jail_segments, target_segments), jail_root);
10657          } else {
10658            return self.$raise($$$('SecurityError'), "" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " " + (target) + " is outside of jail: " + (jail) + " (disallowed in safe mode)")
10659          };
10660        } else {
10661          return self.$join_path(resolved_segments, jail_root)
10662        };
10663      }, -2);
10664
10665      $def(self, '$web_path', function $$web_path(target, start) {
10666        var $a, $b, self = this, uri_prefix = nil, target_segments = nil, target_root = nil, resolved_segments = nil, resolved_path = nil;
10667
10668
10669        if (start == null) start = nil;
10670        target = self.$posixify(target);
10671        start = self.$posixify(start);
10672        if (!($truthy(start['$nil_or_empty?']()) || ($truthy(self['$web_root?'](target))))) {
10673          $b = self.$extract_uri_prefix("" + (start) + (($truthy(start['$end_with?']($$('SLASH'))) ? ("") : ($$('SLASH')))) + (target)), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (uri_prefix = ($a[1] == null ? nil : $a[1])), $b
10674        };
10675        $b = self.$partition_path(target, true), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])), (target_root = ($a[1] == null ? nil : $a[1])), $b;
10676        resolved_segments = [];
10677        $send(target_segments, 'each', [], function $$10(segment){
10678
10679          if (segment == null) segment = nil;
10680          if ($eqeq(segment, $$('DOT_DOT'))) {
10681            if ($truthy(resolved_segments['$empty?']())) {
10682              if (($truthy(target_root) && ($neqeq(target_root, $$('DOT_SLASH'))))) {
10683                return nil
10684              } else {
10685                return resolved_segments['$<<'](segment)
10686              }
10687            } else if ($eqeq(resolved_segments['$[]'](-1), $$('DOT_DOT'))) {
10688              return resolved_segments['$<<'](segment)
10689            } else {
10690              return resolved_segments.$pop()
10691            }
10692          } else {
10693            return resolved_segments['$<<'](segment)
10694          };});
10695        if ($truthy((resolved_path = self.$join_path(resolved_segments, target_root))['$include?'](" "))) {
10696          resolved_path = resolved_path.$gsub(" ", "%20")
10697        };
10698        if ($truthy(uri_prefix)) {
10699          return "" + (uri_prefix) + (resolved_path)
10700        } else {
10701          return resolved_path
10702        };
10703      }, -2);
10704      self.$private();
10705      return $def(self, '$extract_uri_prefix', function $$extract_uri_prefix(str) {
10706        var $a;
10707
10708        if (($truthy(str['$include?'](":")) && ($truthy($$('UriSniffRx')['$=~'](str))))) {
10709          return [str.$slice((($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length(), str.$length()), (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))]
10710        } else {
10711          return str
10712        }
10713      });
10714    })($nesting[0], null, $nesting)
10715  })($nesting[0], $nesting)
10716};
10717
10718Opal.modules["asciidoctor/reader"] = function(Opal) {/* Generated by Opal 1.7.3 */
10719  "use strict";
10720  var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $rb_plus = Opal.rb_plus, $alias = Opal.alias, $hash2 = Opal.hash2, $not = Opal.not, $eqeqeq = Opal.eqeqeq, $to_ary = Opal.to_ary, $truthy = Opal.truthy, $rb_gt = Opal.rb_gt, $send = Opal.send, $rb_minus = Opal.rb_minus, $thrower = Opal.thrower, $eqeq = Opal.eqeq, $rb_times = Opal.rb_times, $neqeq = Opal.neqeq, $to_a = Opal.to_a, $assign_ivar_val = Opal.assign_ivar_val, $send2 = Opal.send2, $find_super = Opal.find_super, $rb_ge = Opal.rb_ge, $gvars = Opal.gvars, $rb_lt = Opal.rb_lt, $hash = Opal.hash, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
10721
10722  Opal.add_stubs('include,attr_reader,+,line_info,attr_accessor,!,===,split,file,dir,dirname,path,basename,lineno,reverse,prepare_lines,empty?,nil_or_empty?,peek_line,[],>,slice,length,process_line,times,shift,read_line,<<,-,unshift_all,has_more_lines?,read_lines,join,unshift,unshift_line,unshift_lines,replace_next_line,start_with?,==,*,read_lines_until,size,clear,cursor,[]=,fetch,!=,cursor_at_mark,warn,logger,message_with_context,pop,push,respond_to?,reverse_each,new,tap,each,instance_variables,instance_variable_get,drop,instance_variable_set,class,object_id,inspect,private,prepare_source_array,prepare_source_string,chomp,valid_encoding?,to_s,raise,to_i,attributes,catalog,pop_include,parse,path=,dup,end_with?,keys,rindex,rootname,key?,attr,reverse!,>=,exceeds_max_depth?,nil?,include_processors?,extensions,extensions?,include_processors,map,skip_front_matter!,adjust_indentation!,include?,=~,preprocess_conditional_directive,preprocess_include_directive,downcase,error,none?,any?,all?,strip,send,resolve_expr_val,rstrip,sub_attributes,attribute_missing,info,parse_attributes,find,handles?,instance,process_method,safe,resolve_include_path,method,split_delimited_value,partition,<,to_a,uniq,sort,call,each_line,infinite?,push_include,delete,first,values,value?,create_include_cursor,delete_at,keep_if,read,uriish?,attr?,require_library,normalize_system_path,file?,relative_path,path_resolver,base_dir,to_f');
10723  return (function($base, $parent_nesting) {
10724    var self = $module($base, 'Asciidoctor');
10725
10726    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
10727
10728
10729    (function($base, $super, $parent_nesting) {
10730      var self = $klass($base, $super, 'Reader');
10731
10732      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
10733
10734      $proto.file = $proto.lines = $proto.look_ahead = $proto.unescape_next_line = $proto.lineno = $proto.process_lines = $proto.dir = $proto.path = $proto.mark = $proto.source_lines = $proto.saved = nil;
10735
10736      self.$include($$('Logging'));
10737      (function($base, $super) {
10738        var self = $klass($base, $super, 'Cursor');
10739
10740        var $proto = self.$$prototype;
10741
10742        $proto.lineno = $proto.path = nil;
10743
10744        self.$attr_reader("file", "dir", "path", "lineno");
10745
10746        $def(self, '$initialize', function $$initialize(file, dir, path, lineno) {
10747          var $a, self = this;
10748
10749
10750          if (dir == null) dir = nil;
10751          if (path == null) path = nil;
10752          if (lineno == null) lineno = 1;
10753          return $a = [file, dir, path, lineno], (self.file = $a[0]), (self.dir = $a[1]), (self.path = $a[2]), (self.lineno = $a[3]), $a;
10754        }, -2);
10755
10756        $def(self, '$advance', function $$advance(num) {
10757          var self = this;
10758
10759          return (self.lineno = $rb_plus(self.lineno, num))
10760        });
10761
10762        $def(self, '$line_info', function $$line_info() {
10763          var self = this;
10764
10765          return "" + (self.path) + ": line " + (self.lineno)
10766        });
10767        return $alias(self, "to_s", "line_info");
10768      })($nesting[0], null);
10769      self.$attr_reader("file");
10770      self.$attr_reader("dir");
10771      self.$attr_reader("path");
10772      self.$attr_reader("lineno");
10773      self.$attr_reader("source_lines");
10774      self.$attr_accessor("process_lines");
10775      self.$attr_accessor("unterminated");
10776
10777      $def(self, '$initialize', function $$initialize(data, cursor, opts) {
10778        var $a, $b, self = this, $ret_or_1 = nil;
10779
10780
10781        if (data == null) data = nil;
10782        if (cursor == null) cursor = nil;
10783        if (opts == null) opts = $hash2([], {});
10784        if ($not(cursor)) {
10785
10786          self.file = nil;
10787          self.dir = ".";
10788          self.path = "<stdin>";
10789          self.lineno = 1;
10790        } else if ($eqeqeq($$$('String'), cursor)) {
10791
10792          self.file = cursor;
10793          $b = $$$('File').$split(self.file), $a = $to_ary($b), (self.dir = ($a[0] == null ? nil : $a[0])), (self.path = ($a[1] == null ? nil : $a[1])), $b;
10794          self.lineno = 1;
10795        } else {
10796
10797          if ($truthy((self.file = cursor.$file()))) {
10798
10799            self.dir = ($truthy(($ret_or_1 = cursor.$dir())) ? ($ret_or_1) : ($$$('File').$dirname(self.file)));
10800            self.path = ($truthy(($ret_or_1 = cursor.$path())) ? ($ret_or_1) : ($$$('File').$basename(self.file)));
10801          } else {
10802
10803            self.dir = ($truthy(($ret_or_1 = cursor.$dir())) ? ($ret_or_1) : ("."));
10804            self.path = ($truthy(($ret_or_1 = cursor.$path())) ? ($ret_or_1) : ("<stdin>"));
10805          };
10806          self.lineno = ($truthy(($ret_or_1 = cursor.$lineno())) ? ($ret_or_1) : (1));
10807        };
10808        self.lines = (self.source_lines = self.$prepare_lines(data, opts)).$reverse();
10809        self.mark = nil;
10810        self.look_ahead = 0;
10811        self.process_lines = true;
10812        self.unescape_next_line = false;
10813        self.unterminated = nil;
10814        return (self.saved = nil);
10815      }, -1);
10816
10817      $def(self, '$has_more_lines?', function $Reader_has_more_lines$ques$1() {
10818        var self = this;
10819
10820        if ($truthy(self.lines['$empty?']())) {
10821
10822          self.look_ahead = 0;
10823          return false;
10824        } else {
10825          return true
10826        }
10827      });
10828
10829      $def(self, '$empty?', function $Reader_empty$ques$2() {
10830        var self = this;
10831
10832        if ($truthy(self.lines['$empty?']())) {
10833
10834          self.look_ahead = 0;
10835          return true;
10836        } else {
10837          return false
10838        }
10839      });
10840      $alias(self, "eof?", "empty?");
10841
10842      $def(self, '$next_line_empty?', function $Reader_next_line_empty$ques$3() {
10843        var self = this;
10844
10845        return self.$peek_line()['$nil_or_empty?']()
10846      });
10847
10848      $def(self, '$peek_line', function $$peek_line(direct) {
10849        var self = this, next_line = nil, line = nil;
10850
10851
10852        if (direct == null) direct = false;
10853        while ($truthy(true)) {
10854
10855          next_line = self.lines['$[]'](-1);
10856          if (($truthy(direct) || ($truthy($rb_gt(self.look_ahead, 0))))) {
10857            return ($truthy(self.unescape_next_line) ? (next_line.$slice(1, next_line.$length())) : (next_line))
10858          } else if ($truthy(next_line)) {
10859            if ($truthy((line = self.$process_line(next_line)))) {
10860              return line
10861            }
10862          } else {
10863
10864            self.look_ahead = 0;
10865            return nil;
10866          };
10867        };
10868      }, -1);
10869
10870      $def(self, '$peek_lines', function $$peek_lines(num, direct) {
10871        var self = this, old_look_ahead = nil, result = nil, $ret_or_1 = nil;
10872
10873
10874        if (num == null) num = nil;
10875        if (direct == null) direct = false;
10876        old_look_ahead = self.look_ahead;
10877        result = [];
10878        (function(){try { var $t_break = $thrower('break'); return $send(($truthy(($ret_or_1 = num)) ? ($ret_or_1) : ($$('MAX_INT'))), 'times', [], function $$4(){var self = $$4.$$s == null ? this : $$4.$$s, line = nil;
10879          if (self.lineno == null) self.lineno = nil;
10880
10881          if ($truthy((line = ($truthy(direct) ? (self.$shift()) : (self.$read_line()))))) {
10882            return result['$<<'](line)
10883          } else {
10884
10885            if ($truthy(direct)) {
10886              self.lineno = $rb_minus(self.lineno, 1)
10887            };
10888            $t_break.$throw();
10889          }}, {$$s: self})} catch($e) {
10890          if ($e === $t_break) return $e.$v;
10891          throw $e;
10892        }})();
10893        if (!$truthy(result['$empty?']())) {
10894
10895          self.$unshift_all(result);
10896          if ($truthy(direct)) {
10897            self.look_ahead = old_look_ahead
10898          };
10899        };
10900        return result;
10901      }, -1);
10902
10903      $def(self, '$read_line', function $$read_line() {
10904        var self = this;
10905
10906        if (($truthy($rb_gt(self.look_ahead, 0)) || ($truthy(self['$has_more_lines?']())))) {
10907          return self.$shift()
10908        } else {
10909          return nil
10910        }
10911      });
10912
10913      $def(self, '$read_lines', function $$read_lines() {
10914        var self = this, lines = nil;
10915
10916
10917        lines = [];
10918        while ($truthy(self['$has_more_lines?']())) {
10919        lines['$<<'](self.$shift())
10920        };
10921        return lines;
10922      });
10923      $alias(self, "readlines", "read_lines");
10924
10925      $def(self, '$read', function $$read() {
10926        var self = this;
10927
10928        return self.$read_lines().$join($$('LF'))
10929      });
10930
10931      $def(self, '$advance', function $$advance() {
10932        var self = this;
10933
10934        if ($truthy(self.$shift())) {
10935          return true
10936        } else {
10937          return false
10938        }
10939      });
10940
10941      $def(self, '$unshift_line', function $$unshift_line(line_to_restore) {
10942        var self = this;
10943
10944
10945        self.$unshift(line_to_restore);
10946        return nil;
10947      });
10948      $alias(self, "restore_line", "unshift_line");
10949
10950      $def(self, '$unshift_lines', function $$unshift_lines(lines_to_restore) {
10951        var self = this;
10952
10953        return self.$unshift_all(lines_to_restore)
10954      });
10955      $alias(self, "restore_lines", "unshift_lines");
10956
10957      $def(self, '$replace_next_line', function $$replace_next_line(replacement) {
10958        var self = this;
10959
10960
10961        self.$shift();
10962        self.$unshift(replacement);
10963        return true;
10964      });
10965      $alias(self, "replace_line", "replace_next_line");
10966
10967      $def(self, '$skip_blank_lines', function $$skip_blank_lines() {
10968        var self = this, num_skipped = nil, next_line = nil;
10969
10970
10971        if ($truthy(self['$empty?']())) {
10972          return nil
10973        };
10974        num_skipped = 0;
10975        while ($truthy((next_line = self.$peek_line()))) {
10976        if ($truthy(next_line['$empty?']())) {
10977
10978            self.$shift();
10979            num_skipped = $rb_plus(num_skipped, 1);
10980          } else {
10981            return num_skipped
10982          }
10983        };
10984      });
10985
10986      $def(self, '$skip_comment_lines', function $$skip_comment_lines() {
10987        var self = this, $ret_or_1 = nil, next_line = nil, ll = nil;
10988
10989
10990        if ($truthy(self['$empty?']())) {
10991          return nil
10992        };
10993        while ($truthy(($truthy(($ret_or_1 = (next_line = self.$peek_line()))) ? (next_line['$empty?']()['$!']()) : ($ret_or_1)))) {
10994        if ($truthy(next_line['$start_with?']("//"))) {
10995            if ($truthy(next_line['$start_with?']("///"))) {
10996              if (($truthy($rb_gt((ll = next_line.$length()), 3)) && ($eqeq(next_line, $rb_times("/", ll))))) {
10997                self.$read_lines_until($hash2(["terminator", "skip_first_line", "read_last_line", "skip_processing", "context"], {"terminator": next_line, "skip_first_line": true, "read_last_line": true, "skip_processing": true, "context": "comment"}))
10998              } else {
10999                break
11000              }
11001            } else {
11002              self.$shift()
11003            }
11004          } else {
11005            break
11006          }
11007        };
11008        return nil;
11009      });
11010
11011      $def(self, '$skip_line_comments', function $$skip_line_comments() {
11012        var self = this, comment_lines = nil, $ret_or_1 = nil, next_line = nil;
11013
11014
11015        if ($truthy(self['$empty?']())) {
11016          return []
11017        };
11018        comment_lines = [];
11019        while ($truthy(($truthy(($ret_or_1 = (next_line = self.$peek_line()))) ? (next_line['$empty?']()['$!']()) : ($ret_or_1)))) {
11020        if ($truthy(next_line['$start_with?']("//"))) {
11021            comment_lines['$<<'](self.$shift())
11022          } else {
11023            break
11024          }
11025        };
11026        return comment_lines;
11027      });
11028
11029      $def(self, '$terminate', function $$terminate() {
11030        var self = this;
11031
11032
11033        self.lineno = $rb_plus(self.lineno, self.lines.$size());
11034        self.lines.$clear();
11035        self.look_ahead = 0;
11036        return nil;
11037      });
11038
11039      $def(self, '$read_lines_until', function $$read_lines_until(options) {
11040        var $a, $yield = $$read_lines_until.$$p || nil, self = this, result = nil, restore_process_lines = nil, terminator = nil, start_cursor = nil, $ret_or_1 = nil, break_on_blank_lines = nil, break_on_list_continuation = nil, skip_comments = nil, line_read = nil, line_restored = nil, line = nil, $ret_or_2 = nil, $ret_or_3 = nil, $ret_or_4 = nil, $ret_or_5 = nil, context = nil;
11041
11042        $$read_lines_until.$$p = null;
11043
11044        if (options == null) options = $hash2([], {});
11045        result = [];
11046        if (($truthy(self.process_lines) && ($truthy(options['$[]']("skip_processing"))))) {
11047
11048          self.process_lines = false;
11049          restore_process_lines = true;
11050        };
11051        if ($truthy((terminator = options['$[]']("terminator")))) {
11052
11053          start_cursor = ($truthy(($ret_or_1 = options['$[]']("cursor"))) ? ($ret_or_1) : (self.$cursor()));
11054          break_on_blank_lines = false;
11055          break_on_list_continuation = false;
11056        } else {
11057
11058          break_on_blank_lines = options['$[]']("break_on_blank_lines");
11059          break_on_list_continuation = options['$[]']("break_on_list_continuation");
11060        };
11061        skip_comments = options['$[]']("skip_line_comments");
11062        line_read = (line_restored = nil);
11063        if ($truthy(options['$[]']("skip_first_line"))) {
11064          self.$shift()
11065        };
11066        while ($truthy((line = self.$read_line()))) {
11067
11068          if ($truthy(($truthy(terminator) ? (line['$=='](terminator)) : (($truthy(($ret_or_1 = ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = break_on_blank_lines)) ? (line['$empty?']()) : ($ret_or_3)))) ? ($ret_or_2) : (($truthy(($ret_or_3 = ($truthy(($ret_or_4 = ($truthy(($ret_or_5 = break_on_list_continuation)) ? (line_read) : ($ret_or_5)))) ? (line['$==']($$('LIST_CONTINUATION'))) : ($ret_or_4)))) ? (($a = ["preserve_last_line", true], $send(options, '[]=', $a), $a[$a.length - 1])) : ($ret_or_3)))))) ? ($ret_or_1) : (($truthy(($ret_or_2 = ($yield !== nil))) ? (Opal.yield1($yield, line)) : ($ret_or_2)))))))) {
11069
11070            if ($truthy(options['$[]']("read_last_line"))) {
11071              result['$<<'](line)
11072            };
11073            if ($truthy(options['$[]']("preserve_last_line"))) {
11074
11075              self.$unshift(line);
11076              line_restored = true;
11077            };
11078            break;
11079          };
11080          if (!(($truthy(skip_comments) && ($truthy(line['$start_with?']("//")))) && ($not(line['$start_with?']("///"))))) {
11081
11082            result['$<<'](line);
11083            line_read = true;
11084          };
11085        };
11086        if ($truthy(restore_process_lines)) {
11087
11088          self.process_lines = true;
11089          if (($truthy(line_restored) && ($not(terminator)))) {
11090            self.look_ahead = $rb_minus(self.look_ahead, 1)
11091          };
11092        };
11093        if ((($truthy(terminator) && ($neqeq(terminator, line))) && ($truthy((context = options.$fetch("context", terminator)))))) {
11094
11095          if ($eqeq(start_cursor, "at_mark")) {
11096            start_cursor = self.$cursor_at_mark()
11097          };
11098          self.$logger().$warn(self.$message_with_context("unterminated " + (context) + " block", $hash2(["source_location"], {"source_location": start_cursor})));
11099          self.unterminated = true;
11100        };
11101        return result;
11102      }, -1);
11103
11104      $def(self, '$shift', function $$shift() {
11105        var self = this;
11106
11107
11108        self.lineno = $rb_plus(self.lineno, 1);
11109        if (!$eqeq(self.look_ahead, 0)) {
11110          self.look_ahead = $rb_minus(self.look_ahead, 1)
11111        };
11112        return self.lines.$pop();
11113      });
11114
11115      $def(self, '$unshift', function $$unshift(line) {
11116        var self = this;
11117
11118
11119        self.lineno = $rb_minus(self.lineno, 1);
11120        self.look_ahead = $rb_plus(self.look_ahead, 1);
11121        self.lines.$push(line);
11122        return nil;
11123      });
11124      if ($eqeq($$$('RUBY_ENGINE'), "jruby")) {
11125
11126        $def(self, '$unshift_all', function $$unshift_all(lines_to_restore) {
11127          var self = this;
11128
11129
11130          self.lineno = $rb_minus(self.lineno, lines_to_restore.$size());
11131          self.look_ahead = $rb_plus(self.look_ahead, lines_to_restore.$size());
11132          if ($truthy(lines_to_restore['$respond_to?']("reverse"))) {
11133            $send(self.lines, 'push', $to_a(lines_to_restore.$reverse()))
11134          } else {
11135            $send(lines_to_restore, 'reverse_each', [], function $$5(it){var self = $$5.$$s == null ? this : $$5.$$s;
11136              if (self.lines == null) self.lines = nil;
11137
11138
11139              if (it == null) it = nil;
11140              return self.lines.$push(it);}, {$$s: self})
11141          };
11142          return nil;
11143        })
11144      } else {
11145
11146        $def(self, '$unshift_all', function $$unshift_all(lines_to_restore) {
11147          var self = this;
11148
11149
11150          self.lineno = $rb_minus(self.lineno, lines_to_restore.$size());
11151          self.look_ahead = $rb_plus(self.look_ahead, lines_to_restore.$size());
11152          $send(self.lines, 'push', $to_a(lines_to_restore.$reverse()));
11153          return nil;
11154        })
11155      };
11156
11157      $def(self, '$cursor', function $$cursor() {
11158        var self = this;
11159
11160        return $$('Cursor').$new(self.file, self.dir, self.path, self.lineno)
11161      });
11162
11163      $def(self, '$cursor_at_line', function $$cursor_at_line(lineno) {
11164        var self = this;
11165
11166        return $$('Cursor').$new(self.file, self.dir, self.path, lineno)
11167      });
11168
11169      $def(self, '$cursor_at_mark', function $$cursor_at_mark() {
11170        var self = this;
11171
11172        if ($truthy(self.mark)) {
11173          return $send($$('Cursor'), 'new', $to_a(self.mark))
11174        } else {
11175          return self.$cursor()
11176        }
11177      });
11178
11179      $def(self, '$cursor_before_mark', function $$cursor_before_mark() {
11180        var $a, $b, self = this, m_file = nil, m_dir = nil, m_path = nil, m_lineno = nil;
11181
11182        if ($truthy(self.mark)) {
11183
11184          $b = self.mark, $a = $to_ary($b), (m_file = ($a[0] == null ? nil : $a[0])), (m_dir = ($a[1] == null ? nil : $a[1])), (m_path = ($a[2] == null ? nil : $a[2])), (m_lineno = ($a[3] == null ? nil : $a[3])), $b;
11185          return $$('Cursor').$new(m_file, m_dir, m_path, $rb_minus(m_lineno, 1));
11186        } else {
11187          return $$('Cursor').$new(self.file, self.dir, self.path, $rb_minus(self.lineno, 1))
11188        }
11189      });
11190
11191      $def(self, '$cursor_at_prev_line', function $$cursor_at_prev_line() {
11192        var self = this;
11193
11194        return $$('Cursor').$new(self.file, self.dir, self.path, $rb_minus(self.lineno, 1))
11195      });
11196
11197      $def(self, '$mark', function $$mark() {
11198        var self = this;
11199
11200        return (self.mark = [self.file, self.dir, self.path, self.lineno])
11201      });
11202
11203      $def(self, '$line_info', function $$line_info() {
11204        var self = this;
11205
11206        return "" + (self.path) + ": line " + (self.lineno)
11207      });
11208
11209      $def(self, '$lines', function $$lines() {
11210        var self = this;
11211
11212        return self.lines.$reverse()
11213      });
11214
11215      $def(self, '$string', function $$string() {
11216        var self = this;
11217
11218        return self.lines.$reverse().$join($$('LF'))
11219      });
11220
11221      $def(self, '$source', function $$source() {
11222        var self = this;
11223
11224        return self.source_lines.$join($$('LF'))
11225      });
11226
11227      $def(self, '$save', function $$save() {
11228        var self = this;
11229
11230
11231        self.saved = $send($hash2([], {}), 'tap', [], function $$6(accum){var self = $$6.$$s == null ? this : $$6.$$s;
11232
11233
11234          if (accum == null) accum = nil;
11235          return $send(self.$instance_variables(), 'each', [], function $$7(name){var $a, self = $$7.$$s == null ? this : $$7.$$s, val = nil;
11236
11237
11238            if (name == null) name = nil;
11239            if (($eqeq(name, "@saved") || ($eqeq(name, "@source_lines")))) {
11240              return nil
11241            } else {
11242              return ($a = [name, ($eqeqeq($$$('Array'), (val = self.$instance_variable_get(name))) ? (val.$drop(0)) : (val))], $send(accum, '[]=', $a), $a[$a.length - 1])
11243            };}, {$$s: self});}, {$$s: self});
11244        return nil;
11245      });
11246
11247      $def(self, '$restore_save', function $$restore_save() {
11248        var self = this;
11249
11250        if ($truthy(self.saved)) {
11251
11252          $send(self.saved, 'each', [], function $$8(name, val){var self = $$8.$$s == null ? this : $$8.$$s;
11253
11254
11255            if (name == null) name = nil;
11256            if (val == null) val = nil;
11257            return self.$instance_variable_set(name, val);}, {$$s: self});
11258          return (self.saved = nil);
11259        } else {
11260          return nil
11261        }
11262      });
11263
11264      $def(self, '$discard_save', $assign_ivar_val("saved", nil));
11265
11266      $def(self, '$to_s', function $$to_s() {
11267        var self = this;
11268
11269        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {path: " + (self.path.$inspect()) + ", line: " + (self.lineno) + "}>"
11270      });
11271      self.$private();
11272
11273      $def(self, '$prepare_lines', function $$prepare_lines(data, opts) {
11274        var self = this, normalize = nil;
11275
11276
11277        if (opts == null) opts = $hash2([], {});
11278        try {
11279          if ($truthy((normalize = opts['$[]']("normalize")))) {
11280            if ($eqeqeq($$$('Array'), data)) {
11281
11282              return $$('Helpers').$prepare_source_array(data, normalize['$!=']("chomp"));
11283            } else {
11284
11285              return $$('Helpers').$prepare_source_string(data, normalize['$!=']("chomp"));
11286            }
11287          } else if ($eqeqeq($$$('Array'), data)) {
11288            return data.$drop(0)
11289          } else if ($truthy(data)) {
11290            return data.$chomp().$split($$('LF'), -1)
11291          } else {
11292            return []
11293          }
11294        } catch ($err) {
11295          if (Opal.rescue($err, [$$('StandardError')])) {
11296            try {
11297              if ($truthy(($eqeqeq($$$('Array'), data) ? (data.$join()) : (data.$to_s()))['$valid_encoding?']())) {
11298                return self.$raise()
11299              } else {
11300                return self.$raise($$$('ArgumentError'), "source is either binary or contains invalid Unicode data")
11301              }
11302            } finally { Opal.pop_exception(); }
11303          } else { throw $err; }
11304        };
11305      }, -2);
11306      return $def(self, '$process_line', function $$process_line(line) {
11307        var self = this;
11308
11309
11310        if ($truthy(self.process_lines)) {
11311          self.look_ahead = $rb_plus(self.look_ahead, 1)
11312        };
11313        return line;
11314      });
11315    })($nesting[0], null, $nesting);
11316    return (function($base, $super, $parent_nesting) {
11317      var self = $klass($base, $super, 'PreprocessorReader');
11318
11319      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
11320
11321      $proto.include_stack = $proto.lines = $proto.file = $proto.dir = $proto.path = $proto.lineno = $proto.maxdepth = $proto.process_lines = $proto.includes = $proto.document = $proto.unescape_next_line = $proto.include_processor_extensions = $proto.look_ahead = $proto.skipping = $proto.conditional_stack = nil;
11322
11323      self.$attr_reader("include_stack");
11324
11325      $def(self, '$initialize', function $$initialize(document, data, cursor, opts) {
11326        var $yield = $$initialize.$$p || nil, self = this, default_include_depth = nil, $ret_or_1 = nil;
11327
11328        $$initialize.$$p = null;
11329
11330        if (data == null) data = nil;
11331        if (cursor == null) cursor = nil;
11332        if (opts == null) opts = $hash2([], {});
11333        self.document = document;
11334        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [data, cursor, opts], null);
11335        if ($truthy($rb_gt((default_include_depth = ($truthy(($ret_or_1 = document.$attributes()['$[]']("max-include-depth"))) ? ($ret_or_1) : (64)).$to_i()), 0))) {
11336          self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": default_include_depth, "curr": default_include_depth, "rel": default_include_depth})
11337        } else {
11338          self.maxdepth = nil
11339        };
11340        self.include_stack = [];
11341        self.includes = document.$catalog()['$[]']("includes");
11342        self.skipping = false;
11343        self.conditional_stack = [];
11344        return (self.include_processor_extensions = nil);
11345      }, -2);
11346
11347      $def(self, '$has_more_lines?', function $PreprocessorReader_has_more_lines$ques$9() {
11348        var self = this;
11349
11350        if ($truthy(self.$peek_line())) {
11351          return true
11352        } else {
11353          return false
11354        }
11355      });
11356
11357      $def(self, '$empty?', function $PreprocessorReader_empty$ques$10() {
11358        var self = this;
11359
11360        if ($truthy(self.$peek_line())) {
11361          return false
11362        } else {
11363          return true
11364        }
11365      });
11366      $alias(self, "eof?", "empty?");
11367
11368      $def(self, '$peek_line', function $$peek_line(direct) {
11369        var $yield = $$peek_line.$$p || nil, self = this, line = nil;
11370
11371        $$peek_line.$$p = null;
11372
11373        if (direct == null) direct = false;
11374        if ($truthy((line = $send2(self, $find_super(self, 'peek_line', $$peek_line, false, true), 'peek_line', [direct], $yield)))) {
11375          return line
11376        } else if ($truthy(self.include_stack['$empty?']())) {
11377          return nil
11378        } else {
11379
11380          self.$pop_include();
11381          return self.$peek_line(direct);
11382        };
11383      }, -1);
11384
11385      $def(self, '$push_include', function $$push_include(data, file, path, lineno, attributes) {
11386        var self = this, dir = nil, $ret_or_1 = nil, rel_maxdepth = nil, curr_maxdepth = nil, abs_maxdepth = nil, leveloffset = nil;
11387
11388
11389        if (file == null) file = nil;
11390        if (path == null) path = nil;
11391        if (lineno == null) lineno = 1;
11392        if (attributes == null) attributes = $hash2([], {});
11393        self.include_stack['$<<']([self.lines, self.file, self.dir, self.path, self.lineno, self.maxdepth, self.process_lines]);
11394        if ($truthy((self.file = file))) {
11395
11396          if ($eqeqeq($$$('String'), file)) {
11397            self.dir = $$$('File').$dirname(file)
11398          } else if ($truthy($$('RUBY_ENGINE_OPAL'))) {
11399            self.dir = $$$('URI').$parse($$$('File').$dirname((file = file.$to_s())))
11400          } else {
11401
11402            (self.dir = file.$dup())['$path='](($eqeq((dir = $$$('File').$dirname(file.$path())), "/") ? ("") : (dir)));
11403            file = file.$to_s();
11404          };
11405          self.path = (path = ($truthy(($ret_or_1 = path)) ? ($ret_or_1) : ($$$('File').$basename(file))));
11406          if ($truthy((self.process_lines = $send(file, 'end_with?', $to_a($$('ASCIIDOC_EXTENSIONS').$keys()))))) {
11407            if ($truthy(($ret_or_1 = self.includes['$[]'](path.$slice(0, path.$rindex(".")))))) {
11408              $ret_or_1
11409            } else {
11410              self.includes['$[]='](path.$slice(0, path.$rindex(".")), ($truthy(attributes['$[]']("partial-option")) ? (nil) : (true)))
11411            }
11412          };
11413        } else {
11414
11415          self.dir = ".";
11416          self.process_lines = true;
11417          if ($truthy((self.path = path))) {
11418            if ($truthy(($ret_or_1 = self.includes['$[]']($$('Helpers').$rootname(path))))) {
11419              $ret_or_1
11420            } else {
11421              self.includes['$[]=']($$('Helpers').$rootname(path), ($truthy(attributes['$[]']("partial-option")) ? (nil) : (true)))
11422            }
11423          } else {
11424            self.path = "<stdin>"
11425          };
11426        };
11427        self.lineno = lineno;
11428        if (($truthy(self.maxdepth) && ($truthy(attributes['$key?']("depth"))))) {
11429          if ($truthy($rb_gt((rel_maxdepth = attributes['$[]']("depth").$to_i()), 0))) {
11430
11431            if ($truthy($rb_gt((curr_maxdepth = $rb_plus(self.include_stack.$size(), rel_maxdepth)), (abs_maxdepth = self.maxdepth['$[]']("abs"))))) {
11432              curr_maxdepth = (rel_maxdepth = abs_maxdepth)
11433            };
11434            self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": abs_maxdepth, "curr": curr_maxdepth, "rel": rel_maxdepth});
11435          } else {
11436            self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": self.maxdepth['$[]']("abs"), "curr": self.include_stack.$size(), "rel": 0})
11437          }
11438        };
11439        if ($truthy((self.lines = self.$prepare_lines(data, $hash2(["normalize", "condense", "indent"], {"normalize": ($truthy(($ret_or_1 = self.process_lines)) ? ($ret_or_1) : ("chomp")), "condense": false, "indent": attributes['$[]']("indent")})))['$empty?']())) {
11440          self.$pop_include()
11441        } else {
11442
11443          if ($truthy(attributes['$key?']("leveloffset"))) {
11444
11445            self.lines = $rb_plus($rb_plus([($truthy((leveloffset = self.document.$attr("leveloffset"))) ? (":leveloffset: " + (leveloffset)) : (":leveloffset!:")), ""], self.lines.$reverse()), ["", ":leveloffset: " + (attributes['$[]']("leveloffset"))]);
11446            self.lineno = $rb_minus(self.lineno, 2);
11447          } else {
11448            self.lines['$reverse!']()
11449          };
11450          self.look_ahead = 0;
11451        };
11452        return self;
11453      }, -2);
11454
11455      $def(self, '$include_depth', function $$include_depth() {
11456        var self = this;
11457
11458        return self.include_stack.$size()
11459      });
11460
11461      $def(self, '$exceeds_max_depth?', function $PreprocessorReader_exceeds_max_depth$ques$11() {
11462        var self = this, $ret_or_1 = nil, $ret_or_2 = nil;
11463
11464        if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = self.maxdepth)) ? ($rb_ge(self.include_stack.$size(), self.maxdepth['$[]']("curr"))) : ($ret_or_2))))) {
11465          return self.maxdepth['$[]']("rel")
11466        } else {
11467          return $ret_or_1
11468        }
11469      });
11470      $alias(self, "exceeded_max_depth?", "exceeds_max_depth?");
11471
11472      $def(self, '$shift', function $$shift() {
11473        var $yield = $$shift.$$p || nil, self = this, line = nil;
11474
11475        $$shift.$$p = null;
11476        if ($truthy(self.unescape_next_line)) {
11477
11478          self.unescape_next_line = false;
11479          return (line = $send2(self, $find_super(self, 'shift', $$shift, false, true), 'shift', [], $yield)).$slice(1, line.$length());
11480        } else {
11481          return $send2(self, $find_super(self, 'shift', $$shift, false, true), 'shift', [], $yield)
11482        }
11483      });
11484
11485      $def(self, '$include_processors?', function $PreprocessorReader_include_processors$ques$12() {
11486        var self = this;
11487
11488        if ($truthy(self.include_processor_extensions['$nil?']())) {
11489          if (($truthy(self.document['$extensions?']()) && ($truthy(self.document.$extensions()['$include_processors?']())))) {
11490            return (self.include_processor_extensions = self.document.$extensions().$include_processors())['$!']()['$!']()
11491          } else {
11492            return (self.include_processor_extensions = false)
11493          }
11494        } else {
11495          return self.include_processor_extensions['$!='](false)
11496        }
11497      });
11498
11499      $def(self, '$create_include_cursor', function $$create_include_cursor(file, path, lineno) {
11500        var dir = nil;
11501
11502
11503        if ($eqeqeq($$$('String'), file)) {
11504          dir = $$$('File').$dirname(file)
11505        } else if ($truthy($$('RUBY_ENGINE_OPAL'))) {
11506          dir = $$$('File').$dirname((file = file.$to_s()))
11507        } else {
11508
11509          dir = ($eqeq((dir = $$$('File').$dirname(file.$path())), "") ? ("/") : (dir));
11510          file = file.$to_s();
11511        };
11512        return $$('Cursor').$new(file, dir, path, lineno);
11513      });
11514
11515      $def(self, '$to_s', function $$to_s() {
11516        var self = this;
11517
11518        return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {path: " + (self.path.$inspect()) + ", line: " + (self.lineno) + ", include depth: " + (self.include_stack.$size()) + ", include stack: [" + ($send(self.include_stack, 'map', [], function $$13(inc){
11519
11520          if (inc == null) inc = nil;
11521          return inc.$to_s();}).$join(", ")) + "]}>"
11522      });
11523      self.$private();
11524
11525      $def(self, '$prepare_lines', function $$prepare_lines(data, opts) {
11526        var $yield = $$prepare_lines.$$p || nil, self = this, result = nil, front_matter = nil, $ret_or_1 = nil, last = nil;
11527
11528        $$prepare_lines.$$p = null;
11529
11530        if (opts == null) opts = $hash2([], {});
11531        result = $send2(self, $find_super(self, 'prepare_lines', $$prepare_lines, false, true), 'prepare_lines', [data, opts], $yield);
11532        if ((($truthy(self.document) && ($truthy(self.document.$attributes()['$[]']("skip-front-matter")))) && ($truthy((front_matter = self['$skip_front_matter!'](result)))))) {
11533          self.document.$attributes()['$[]=']("front-matter", front_matter.$join($$('LF')))
11534        };
11535        if ($truthy(opts.$fetch("condense", true))) {
11536          while ($truthy(($truthy(($ret_or_1 = (last = result['$[]'](-1)))) ? (last['$empty?']()) : ($ret_or_1)))) {
11537          result.$pop()
11538          }
11539        };
11540        if ($truthy(opts['$[]']("indent"))) {
11541          $$('Parser')['$adjust_indentation!'](result, opts['$[]']("indent").$to_i(), self.document.$attr("tabsize").$to_i())
11542        };
11543        return result;
11544      }, -2);
11545
11546      $def(self, '$process_line', function $$process_line(line) {
11547        var $a, self = this;
11548
11549
11550        if (!$truthy(self.process_lines)) {
11551          return line
11552        };
11553        if ($truthy(line['$empty?']())) {
11554
11555          self.look_ahead = $rb_plus(self.look_ahead, 1);
11556          return line;
11557        };
11558        if ((($truthy(line['$end_with?']("]")) && ($not(line['$start_with?']("[")))) && ($truthy(line['$include?']("::"))))) {
11559          if (($truthy(line['$include?']("if")) && ($truthy($$('ConditionalDirectiveRx')['$=~'](line))))) {
11560            if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), "\\")) {
11561
11562              self.unescape_next_line = true;
11563              self.look_ahead = $rb_plus(self.look_ahead, 1);
11564              return line.$slice(1, line.$length());
11565            } else if ($truthy(self.$preprocess_conditional_directive((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](4)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](5))))) {
11566
11567              self.$shift();
11568              return nil;
11569            } else {
11570
11571              self.look_ahead = $rb_plus(self.look_ahead, 1);
11572              return line;
11573            }
11574          } else if ($truthy(self.skipping)) {
11575
11576            self.$shift();
11577            return nil;
11578          } else if (($truthy(line['$start_with?']("inc", "\\inc")) && ($truthy($$('IncludeDirectiveRx')['$=~'](line))))) {
11579            if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), "\\")) {
11580
11581              self.unescape_next_line = true;
11582              self.look_ahead = $rb_plus(self.look_ahead, 1);
11583              return line.$slice(1, line.$length());
11584            } else if ($truthy(self.$preprocess_include_directive((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](3))))) {
11585              return nil
11586            } else {
11587
11588              self.look_ahead = $rb_plus(self.look_ahead, 1);
11589              return line;
11590            }
11591          } else {
11592
11593            self.look_ahead = $rb_plus(self.look_ahead, 1);
11594            return line;
11595          }
11596        } else if ($truthy(self.skipping)) {
11597
11598          self.$shift();
11599          return nil;
11600        } else {
11601
11602          self.look_ahead = $rb_plus(self.look_ahead, 1);
11603          return line;
11604        };
11605      });
11606
11607      $def(self, '$preprocess_conditional_directive', function $$preprocess_conditional_directive(keyword, target, delimiter, text) {
11608        var $a, self = this, no_target = nil, pair = nil, skip = nil, lhs = nil, op = nil, rhs = nil;
11609
11610
11611        if (!$truthy((no_target = target['$empty?']()))) {
11612          target = target.$downcase()
11613        };
11614        if ($eqeq(keyword, "endif")) {
11615
11616          if ($truthy(text)) {
11617            self.$logger().$error(self.$message_with_context("malformed preprocessor directive - text not permitted: endif::" + (target) + "[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})))
11618          } else if ($truthy(self.conditional_stack['$empty?']())) {
11619            self.$logger().$error(self.$message_with_context("unmatched preprocessor directive: endif::" + (target) + "[]", $hash2(["source_location"], {"source_location": self.$cursor()})))
11620          } else if (($truthy(no_target) || ($eqeq(target, (pair = self.conditional_stack['$[]'](-1))['$[]']("target"))))) {
11621
11622            self.conditional_stack.$pop();
11623            self.skipping = ($truthy(self.conditional_stack['$empty?']()) ? (false) : (self.conditional_stack['$[]'](-1)['$[]']("skipping")));
11624          } else {
11625            self.$logger().$error(self.$message_with_context("mismatched preprocessor directive: endif::" + (target) + "[], expected endif::" + (pair['$[]']("target")) + "[]", $hash2(["source_location"], {"source_location": self.$cursor()})))
11626          };
11627          return true;
11628        } else if ($truthy(self.skipping)) {
11629          skip = false
11630        } else
11631        switch (keyword) {
11632          case "ifdef":
11633
11634            if ($truthy(no_target)) {
11635
11636              self.$logger().$error(self.$message_with_context("malformed preprocessor directive - missing target: ifdef::[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})));
11637              return true;
11638            };
11639
11640            switch (delimiter) {
11641              case ",":
11642                skip = $send(target.$split(",", -1), 'none?', [], function $$14(name){var self = $$14.$$s == null ? this : $$14.$$s;
11643                  if (self.document == null) self.document = nil;
11644
11645
11646                  if (name == null) name = nil;
11647                  return self.document.$attributes()['$key?'](name);}, {$$s: self})
11648                break;
11649              case "+":
11650                skip = $send(target.$split("+", -1), 'any?', [], function $$15(name){var self = $$15.$$s == null ? this : $$15.$$s;
11651                  if (self.document == null) self.document = nil;
11652
11653
11654                  if (name == null) name = nil;
11655                  return self.document.$attributes()['$key?'](name)['$!']();}, {$$s: self})
11656                break;
11657              default:
11658                skip = self.document.$attributes()['$key?'](target)['$!']()
11659            };
11660            break;
11661          case "ifndef":
11662
11663            if ($truthy(no_target)) {
11664
11665              self.$logger().$error(self.$message_with_context("malformed preprocessor directive - missing target: ifndef::[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})));
11666              return true;
11667            };
11668
11669            switch (delimiter) {
11670              case ",":
11671                skip = $send(target.$split(",", -1), 'any?', [], function $$16(name){var self = $$16.$$s == null ? this : $$16.$$s;
11672                  if (self.document == null) self.document = nil;
11673
11674
11675                  if (name == null) name = nil;
11676                  return self.document.$attributes()['$key?'](name);}, {$$s: self})
11677                break;
11678              case "+":
11679                skip = $send(target.$split("+", -1), 'all?', [], function $$17(name){var self = $$17.$$s == null ? this : $$17.$$s;
11680                  if (self.document == null) self.document = nil;
11681
11682
11683                  if (name == null) name = nil;
11684                  return self.document.$attributes()['$key?'](name);}, {$$s: self})
11685                break;
11686              default:
11687                skip = self.document.$attributes()['$key?'](target)
11688            };
11689            break;
11690          case "ifeval":
11691            if ($truthy(no_target)) {
11692              if (($truthy(text) && ($truthy($$('EvalExpressionRx')['$=~'](text.$strip()))))) {
11693
11694                lhs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1));
11695                op = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2));
11696                rhs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3));
11697                skip = (function() { try {
11698                  if ($truthy(self.$resolve_expr_val(lhs).$send(op, self.$resolve_expr_val(rhs)))) {
11699                    return false
11700                  } else {
11701                    return true
11702                  }
11703                } catch ($err) {
11704                  if (Opal.rescue($err, [$$('StandardError')])) {
11705                    try {
11706                      return true
11707                    } finally { Opal.pop_exception(); }
11708                  } else { throw $err; }
11709                }})();
11710              } else {
11711
11712                self.$logger().$error(self.$message_with_context("malformed preprocessor directive - " + (($truthy(text) ? ("invalid expression") : ("missing expression"))) + ": ifeval::[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})));
11713                return true;
11714              }
11715            } else {
11716
11717              self.$logger().$error(self.$message_with_context("malformed preprocessor directive - target not permitted: ifeval::" + (target) + "[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})));
11718              return true;
11719            }
11720            break;
11721          default:
11722            nil
11723        };
11724        if (($eqeq(keyword, "ifeval") || ($not(text)))) {
11725
11726          if ($truthy(skip)) {
11727            self.skipping = true
11728          };
11729          self.conditional_stack['$<<']($hash2(["target", "skip", "skipping"], {"target": target, "skip": skip, "skipping": self.skipping}));
11730        } else if (!($truthy(self.skipping) || ($truthy(skip)))) {
11731
11732          self.$replace_next_line(text.$rstrip());
11733          self.$unshift("");
11734          if ($truthy(text['$start_with?']("include::"))) {
11735            self.look_ahead = $rb_minus(self.look_ahead, 1)
11736          };
11737        };
11738        return true;
11739      });
11740
11741      $def(self, '$preprocess_include_directive', function $$preprocess_include_directive(target, attrlist) {
11742        var $a, $b, self = this, doc = nil, expanded_target = nil, attr_missing = nil, $ret_or_1 = nil, ext = nil, parsed_attrs = nil, inc_path = nil, target_type = nil, relpath = nil, reader = nil, read_mode = nil, enc = nil, read_mode_params = nil, inc_linenos = nil, inc_tags = nil, tag = nil, inc_lines = nil, inc_offset = nil, inc_lineno = nil, tag_stack = nil, tags_selected = nil, active_tag = nil, select = nil, base_select = nil, wildcard = nil, missing_tags = nil, inc_content = nil;
11743
11744
11745        doc = self.document;
11746        if (($truthy((expanded_target = target)['$include?']($$('ATTR_REF_HEAD'))) && ($truthy((expanded_target = doc.$sub_attributes(target, $hash2(["attribute_missing"], {"attribute_missing": ($eqeq((attr_missing = ($truthy(($ret_or_1 = doc.$attributes()['$[]']("attribute-missing"))) ? ($ret_or_1) : ($$('Compliance').$attribute_missing()))), "warn") ? ("drop-line") : (attr_missing))})))['$empty?']())))) {
11747          if (($eqeq(attr_missing, "drop-line") && ($truthy(doc.$sub_attributes($rb_plus(target, " "), $hash2(["attribute_missing", "drop_line_severity"], {"attribute_missing": "drop-line", "drop_line_severity": "ignore"}))['$empty?']())))) {
11748
11749            $send(self.$logger(), 'info', [], function $$18(){var self = $$18.$$s == null ? this : $$18.$$s;
11750
11751              return self.$message_with_context("include dropped due to missing attribute: include::" + (target) + "[" + (attrlist) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))}, {$$s: self});
11752            self.$shift();
11753            return true;
11754          } else if ($truthy(doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true}))['$[]']("optional-option"))) {
11755
11756            $send(self.$logger(), 'info', [], function $$19(){var self = $$19.$$s == null ? this : $$19.$$s;
11757
11758              return self.$message_with_context("optional include dropped " + ((($eqeq(attr_missing, "warn") && ($truthy(doc.$sub_attributes($rb_plus(target, " "), $hash2(["attribute_missing", "drop_line_severity"], {"attribute_missing": "drop-line", "drop_line_severity": "ignore"}))['$empty?']()))) ? ("due to missing attribute") : ("because resolved target is blank"))) + ": include::" + (target) + "[" + (attrlist) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))}, {$$s: self});
11759            self.$shift();
11760            return true;
11761          } else {
11762
11763            self.$logger().$warn(self.$message_with_context("include dropped " + ((($eqeq(attr_missing, "warn") && ($truthy(doc.$sub_attributes($rb_plus(target, " "), $hash2(["attribute_missing", "drop_line_severity"], {"attribute_missing": "drop-line", "drop_line_severity": "ignore"}))['$empty?']()))) ? ("due to missing attribute") : ("because resolved target is blank"))) + ": include::" + (target) + "[" + (attrlist) + "]", $hash2(["source_location"], {"source_location": self.$cursor()})));
11764            return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (attrlist) + "]");
11765          }
11766        } else if (($truthy(self['$include_processors?']()) && ($truthy((ext = $send(self.include_processor_extensions, 'find', [], function $$20(candidate){
11767
11768          if (candidate == null) candidate = nil;
11769          return candidate.$instance()['$handles?'](expanded_target);})))))) {
11770
11771          self.$shift();
11772          ext.$process_method()['$[]'](doc, self, expanded_target, doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true})));
11773          return true;
11774        } else if ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SECURE')))) {
11775          return self.$replace_next_line("link:" + (expanded_target) + "[role=include]")
11776        } else if ($truthy(self.maxdepth)) {
11777
11778          if ($truthy($rb_ge(self.include_stack.$size(), self.maxdepth['$[]']("curr")))) {
11779
11780            self.$logger().$error(self.$message_with_context("maximum include depth of " + (self.maxdepth['$[]']("rel")) + " exceeded", $hash2(["source_location"], {"source_location": self.$cursor()})));
11781            return nil;
11782          };
11783          parsed_attrs = doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true}));
11784          $b = self.$resolve_include_path(expanded_target, attrlist, parsed_attrs), $a = $to_ary($b), (inc_path = ($a[0] == null ? nil : $a[0])), (target_type = ($a[1] == null ? nil : $a[1])), (relpath = ($a[2] == null ? nil : $a[2])), $b;
11785
11786          switch (target_type) {
11787            case "file":
11788
11789              reader = $$$('File').$method("open");
11790              read_mode = $$('FILE_READ_MODE');
11791              break;
11792            case "uri":
11793
11794              reader = $$$('OpenURI').$method("open_uri");
11795              read_mode = $$('URI_READ_MODE');
11796              break;
11797            default:
11798              return inc_path
11799          };
11800          if (!$truthy($$('RUBY_ENGINE_OPAL'))) {
11801            if (($truthy((enc = parsed_attrs['$[]']("encoding"))) && ($truthy((function() { try {
11802              return $$$('Encoding').$find(enc)
11803            } catch ($err) {
11804              if (Opal.rescue($err, [$$('StandardError')])) {
11805                try {
11806                  return nil
11807                } finally { Opal.pop_exception(); }
11808              } else { throw $err; }
11809            }})())))) {
11810
11811              (read_mode_params = read_mode.$split(":"))['$[]='](1, enc);
11812              read_mode = read_mode_params.$join(":");
11813            }
11814          };
11815          inc_linenos = (inc_tags = nil);
11816          if ($truthy(attrlist)) {
11817            if ($truthy(parsed_attrs['$key?']("lines"))) {
11818
11819              inc_linenos = [];
11820              $send(self.$split_delimited_value(parsed_attrs['$[]']("lines")), 'each', [], function $$21(linedef){var $c, $d, from = nil, _ = nil, to = nil;
11821
11822
11823                if (linedef == null) linedef = nil;
11824                if ($truthy(linedef['$include?'](".."))) {
11825
11826                  $d = linedef.$partition(".."), $c = $to_ary($d), (from = ($c[0] == null ? nil : $c[0])), (_ = ($c[1] == null ? nil : $c[1])), (to = ($c[2] == null ? nil : $c[2])), $d;
11827                  return (inc_linenos = $rb_plus(inc_linenos, (($truthy(to['$empty?']()) || ($truthy($rb_lt((to = to.$to_i()), 0)))) ? ([from.$to_i(), $$$($$$('Float'), 'INFINITY')]) : (Opal.Range.$new(from.$to_i(), to, false).$to_a()))));
11828                } else {
11829                  return inc_linenos['$<<'](linedef.$to_i())
11830                };});
11831              inc_linenos = ($truthy(inc_linenos['$empty?']()) ? (nil) : (inc_linenos.$sort().$uniq()));
11832            } else if ($truthy(parsed_attrs['$key?']("tag"))) {
11833              if (!($truthy((tag = parsed_attrs['$[]']("tag"))['$empty?']()) || ($eqeq(tag, "!")))) {
11834                inc_tags = ($truthy(tag['$start_with?']("!")) ? ($hash(tag.$slice(1, tag.$length()), false)) : ($hash(tag, true)))
11835              }
11836            } else if ($truthy(parsed_attrs['$key?']("tags"))) {
11837
11838              inc_tags = $hash2([], {});
11839              $send(self.$split_delimited_value(parsed_attrs['$[]']("tags")), 'each', [], function $$22(tagdef){var $c;
11840
11841
11842                if (tagdef == null) tagdef = nil;
11843                if (($truthy(tagdef['$empty?']()) || ($eqeq(tagdef, "!")))) {
11844                  return nil
11845                } else if ($truthy(tagdef['$start_with?']("!"))) {
11846                  return ($c = [tagdef.$slice(1, tagdef.$length()), false], $send(inc_tags, '[]=', $c), $c[$c.length - 1])
11847                } else {
11848                  return ($c = [tagdef, true], $send(inc_tags, '[]=', $c), $c[$c.length - 1])
11849                };});
11850              if ($truthy(inc_tags['$empty?']())) {
11851                inc_tags = nil
11852              };
11853            }
11854          };
11855          if ($truthy(inc_linenos)) {
11856
11857            $a = [[], nil, 0], (inc_lines = $a[0]), (inc_offset = $a[1]), (inc_lineno = $a[2]), $a;
11858
11859            try {
11860              $send(reader, 'call', [inc_path, read_mode], function $$23(f){var select_remaining = nil;
11861
11862
11863                if (f == null) f = nil;
11864                select_remaining = nil;
11865                return (function(){try { var $t_break = $thrower('break'); return $send(f, 'each_line', [], function $$24(l){var select = nil;
11866
11867
11868                  if (l == null) l = nil;
11869                  inc_lineno = $rb_plus(inc_lineno, 1);
11870                  if (($truthy(select_remaining) || (($eqeqeq($$$('Float'), (select = inc_linenos['$[]'](0))) && ($truthy((select_remaining = select['$infinite?']()))))))) {
11871
11872                    inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno));
11873                    return inc_lines['$<<'](l);
11874                  } else {
11875
11876                    if ($eqeq(select, inc_lineno)) {
11877
11878                      inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno));
11879                      inc_lines['$<<'](l);
11880                      inc_linenos.$shift();
11881                    };
11882                    if ($truthy(inc_linenos['$empty?']())) {
11883                      $t_break.$throw()
11884                    } else {
11885                      return nil
11886                    };
11887                  };})} catch($e) {
11888                  if ($e === $t_break) return $e.$v;
11889                  throw $e;
11890                }})();})
11891            } catch ($err) {
11892              if (Opal.rescue($err, [$$('StandardError')])) {
11893                try {
11894
11895                  self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()})));
11896                  return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]");
11897                } finally { Opal.pop_exception(); }
11898              } else { throw $err; }
11899            };;
11900            self.$shift();
11901            if ($truthy(inc_offset)) {
11902
11903              parsed_attrs['$[]=']("partial-option", "");
11904              self.$push_include(inc_lines, inc_path, relpath, inc_offset, parsed_attrs);
11905            };
11906          } else if ($truthy(inc_tags)) {
11907
11908            $a = [[], nil, 0, [], $$$('Set').$new(), nil], (inc_lines = $a[0]), (inc_offset = $a[1]), (inc_lineno = $a[2]), (tag_stack = $a[3]), (tags_selected = $a[4]), (active_tag = $a[5]), $a;
11909            if ($truthy(inc_tags['$key?']("**"))) {
11910
11911              select = (base_select = inc_tags.$delete("**"));
11912              if ($truthy(inc_tags['$key?']("*"))) {
11913                wildcard = inc_tags.$delete("*")
11914              } else if (($not(select) && ($eqeq(inc_tags.$values().$first(), false)))) {
11915                wildcard = true
11916              };
11917            } else if ($truthy(inc_tags['$key?']("*"))) {
11918              if ($eqeq(inc_tags.$keys().$first(), "*")) {
11919                select = (base_select = (wildcard = inc_tags.$delete("*"))['$!']())
11920              } else {
11921
11922                select = (base_select = false);
11923                wildcard = inc_tags.$delete("*");
11924              }
11925            } else {
11926              select = (base_select = inc_tags['$value?'](true)['$!']())
11927            };
11928
11929            try {
11930              $send(reader, 'call', [inc_path, read_mode], function $$25(f){var $c, self = $$25.$$s == null ? this : $$25.$$s, dbl_co = nil, dbl_sb = nil;
11931
11932
11933                if (f == null) f = nil;
11934                $c = ["::", "[]"], (dbl_co = $c[0]), (dbl_sb = $c[1]), $c;
11935                return $send(f, 'each_line', [], function $$26(l){var $d, $e, self = $$26.$$s == null ? this : $$26.$$s, this_tag = nil, include_cursor = nil, idx = nil;
11936
11937
11938                  if (l == null) l = nil;
11939                  inc_lineno = $rb_plus(inc_lineno, 1);
11940                  if ((($truthy(l['$include?'](dbl_co)) && ($truthy(l['$include?'](dbl_sb)))) && ($truthy($$('TagDirectiveRx')['$=~'](l))))) {
11941
11942                    this_tag = (($d = $gvars['~']) === nil ? nil : $d['$[]'](2));
11943                    if ($truthy((($d = $gvars['~']) === nil ? nil : $d['$[]'](1)))) {
11944                      if ($eqeq(this_tag, active_tag)) {
11945
11946                        tag_stack.$pop();
11947                        return $e = ($truthy(tag_stack['$empty?']()) ? ([nil, base_select]) : (tag_stack['$[]'](-1))), $d = $to_ary($e), (active_tag = ($d[0] == null ? nil : $d[0])), (select = ($d[1] == null ? nil : $d[1])), $e;
11948                      } else if ($truthy(inc_tags['$key?'](this_tag))) {
11949
11950                        include_cursor = self.$create_include_cursor(inc_path, expanded_target, inc_lineno);
11951                        if ($truthy((idx = $send(tag_stack, 'rindex', [], function $$27(key){
11952
11953                          if (key == null) key = nil;
11954                          return key['$=='](this_tag);}, {$$has_trailing_comma_in_args: true})))) {
11955
11956                          if ($eqeq(idx, 0)) {
11957                            tag_stack.$shift()
11958                          } else {
11959
11960                            tag_stack.$delete_at(idx);
11961                          };
11962                          return self.$logger().$warn(self.$message_with_context("mismatched end tag (expected '" + (active_tag) + "' but found '" + (this_tag) + "') at line " + (inc_lineno) + " of include " + (target_type) + ": " + (inc_path), $hash2(["source_location", "include_location"], {"source_location": self.$cursor(), "include_location": include_cursor})));
11963                        } else {
11964                          return self.$logger().$warn(self.$message_with_context("unexpected end tag '" + (this_tag) + "' at line " + (inc_lineno) + " of include " + (target_type) + ": " + (inc_path), $hash2(["source_location", "include_location"], {"source_location": self.$cursor(), "include_location": include_cursor})))
11965                        };
11966                      } else {
11967                        return nil
11968                      }
11969                    } else if ($truthy(inc_tags['$key?'](this_tag))) {
11970
11971                      if ($truthy((select = inc_tags['$[]'](this_tag)))) {
11972                        tags_selected['$<<'](this_tag)
11973                      };
11974                      return tag_stack['$<<']([(active_tag = this_tag), select, inc_lineno]);
11975                    } else if ($not(wildcard['$nil?']())) {
11976
11977                      select = (($truthy(active_tag) && ($not(select))) ? (false) : (wildcard));
11978                      return tag_stack['$<<']([(active_tag = this_tag), select, inc_lineno]);
11979                    } else {
11980                      return nil
11981                    };
11982                  } else if ($truthy(select)) {
11983
11984                    inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno));
11985                    return inc_lines['$<<'](l);
11986                  } else {
11987                    return nil
11988                  };}, {$$s: self});}, {$$s: self})
11989            } catch ($err) {
11990              if (Opal.rescue($err, [$$('StandardError')])) {
11991                try {
11992
11993                  self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()})));
11994                  return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]");
11995                } finally { Opal.pop_exception(); }
11996              } else { throw $err; }
11997            };;
11998            if (!$truthy(tag_stack['$empty?']())) {
11999              $send(tag_stack, 'each', [], function $$28(tag_name, _, tag_lineno){var self = $$28.$$s == null ? this : $$28.$$s;
12000
12001
12002                if (tag_name == null) tag_name = nil;
12003                if (_ == null) _ = nil;
12004                if (tag_lineno == null) tag_lineno = nil;
12005                return self.$logger().$warn(self.$message_with_context("detected unclosed tag '" + (tag_name) + "' starting at line " + (tag_lineno) + " of include " + (target_type) + ": " + (inc_path), $hash2(["source_location", "include_location"], {"source_location": self.$cursor(), "include_location": self.$create_include_cursor(inc_path, expanded_target, tag_lineno)})));}, {$$s: self})
12006            };
12007            if (!$truthy((missing_tags = $rb_minus($send(inc_tags, 'keep_if', [], function $$29(_, v){
12008
12009              if (_ == null) _ = nil;
12010              if (v == null) v = nil;
12011              return v;}).$keys(), tags_selected.$to_a()))['$empty?']())) {
12012              self.$logger().$warn(self.$message_with_context("tag" + (($truthy($rb_gt(missing_tags.$size(), 1)) ? ("s") : (""))) + " '" + (missing_tags.$join(", ")) + "' not found in include " + (target_type) + ": " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()})))
12013            };
12014            self.$shift();
12015            if ($truthy(inc_offset)) {
12016
12017              if (!(($truthy(base_select) && ($neqeq(wildcard, false))) && ($truthy(inc_tags['$empty?']())))) {
12018                parsed_attrs['$[]=']("partial-option", "")
12019              };
12020              self.$push_include(inc_lines, inc_path, relpath, inc_offset, parsed_attrs);
12021            };
12022          } else {
12023
12024            inc_content = nil;
12025
12026            try {
12027
12028              inc_content = $send(reader, 'call', [inc_path, read_mode], function $$30(f){
12029
12030                if (f == null) f = nil;
12031                return f.$read();});
12032              self.$shift();
12033            } catch ($err) {
12034              if (Opal.rescue($err, [$$('StandardError')])) {
12035                try {
12036
12037                  self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()})));
12038                  return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]");
12039                } finally { Opal.pop_exception(); }
12040              } else { throw $err; }
12041            };;
12042            self.$push_include(inc_content, inc_path, relpath, 1, parsed_attrs);
12043          };
12044          return true;
12045        } else {
12046          return nil
12047        };
12048      });
12049
12050      $def(self, '$resolve_include_path', function $$resolve_include_path(target, attrlist, attributes) {
12051        var $a, $b, self = this, doc = nil, inc_path = nil, relpath = nil;
12052
12053
12054        doc = self.document;
12055        if (($truthy($$('Helpers')['$uriish?'](target)) || ($truthy(($eqeqeq($$$('String'), self.dir) ? (nil) : ((target = "" + (self.dir) + "/" + (target)))))))) {
12056
12057          if (!$truthy(doc['$attr?']("allow-uri-read"))) {
12058            return self.$replace_next_line("link:" + (target) + "[role=include]")
12059          };
12060          if ($truthy(doc['$attr?']("cache-uri"))) {
12061            if (!$truthy((($b = $$$('::', 'OpenURI', 'skip_raise')) && ($a = $$$($b, 'Cache', 'skip_raise')) ? 'constant' : nil))) {
12062              $$('Helpers').$require_library("open-uri/cached", "open-uri-cached")
12063            }
12064          } else if ($not($$('RUBY_ENGINE_OPAL'))) {
12065            $$$('OpenURI')
12066          };
12067          return [$$$('URI').$parse(target), "uri", target];
12068        } else {
12069
12070          inc_path = doc.$normalize_system_path(target, self.dir, nil, $hash2(["target_name"], {"target_name": "include file"}));
12071          if (!$truthy($$$('File')['$file?'](inc_path))) {
12072            if ($truthy(attributes['$[]']("optional-option"))) {
12073
12074              $send(self.$logger(), 'info', [], function $$31(){var self = $$31.$$s == null ? this : $$31.$$s;
12075
12076                return self.$message_with_context("optional include dropped because include file not found: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))}, {$$s: self});
12077              self.$shift();
12078              return true;
12079            } else {
12080
12081              self.$logger().$error(self.$message_with_context("include file not found: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()})));
12082              return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (attrlist) + "]");
12083            }
12084          };
12085          relpath = doc.$path_resolver().$relative_path(inc_path, doc.$base_dir());
12086          return [inc_path, "file", relpath];
12087        };
12088      });
12089
12090      $def(self, '$pop_include', function $$pop_include() {
12091        var $a, $b, self = this;
12092
12093        if ($truthy(self.include_stack['$empty?']())) {
12094          return nil
12095        } else {
12096
12097          $b = self.include_stack.$pop(), $a = $to_ary($b), (self.lines = ($a[0] == null ? nil : $a[0])), (self.file = ($a[1] == null ? nil : $a[1])), (self.dir = ($a[2] == null ? nil : $a[2])), (self.path = ($a[3] == null ? nil : $a[3])), (self.lineno = ($a[4] == null ? nil : $a[4])), (self.maxdepth = ($a[5] == null ? nil : $a[5])), (self.process_lines = ($a[6] == null ? nil : $a[6])), $b;
12098          self.look_ahead = 0;
12099          return nil;
12100        }
12101      });
12102
12103      $def(self, '$split_delimited_value', function $$split_delimited_value(val) {
12104
12105        if ($truthy(val['$include?'](","))) {
12106
12107          return val.$split(",");
12108        } else {
12109
12110          return val.$split(";");
12111        }
12112      });
12113
12114      $def(self, '$skip_front_matter!', function $PreprocessorReader_skip_front_matter$excl$32(data, increment_linenos) {
12115        var self = this, delim = nil, original_data = nil, front_matter = nil, $ret_or_1 = nil, eof = nil;
12116
12117
12118        if (increment_linenos == null) increment_linenos = true;
12119        if (!$eqeq((delim = data['$[]'](0)), "---")) {
12120          return nil
12121        };
12122        original_data = data.$drop(0);
12123        data.$shift();
12124        front_matter = [];
12125        if ($truthy(increment_linenos)) {
12126          self.lineno = $rb_plus(self.lineno, 1)
12127        };
12128        while (!($truthy(($truthy(($ret_or_1 = (eof = data['$empty?']()))) ? ($ret_or_1) : (data['$[]'](0)['$=='](delim)))))) {
12129
12130          front_matter['$<<'](data.$shift());
12131          if ($truthy(increment_linenos)) {
12132            self.lineno = $rb_plus(self.lineno, 1)
12133          };
12134        };
12135        if ($truthy(eof)) {
12136
12137          $send(data, 'unshift', $to_a(original_data));
12138          if ($truthy(increment_linenos)) {
12139            self.lineno = $rb_minus(self.lineno, original_data.$size())
12140          };
12141          return nil;
12142        };
12143        data.$shift();
12144        if ($truthy(increment_linenos)) {
12145          self.lineno = $rb_plus(self.lineno, 1)
12146        };
12147        return front_matter;
12148      }, -2);
12149      return $def(self, '$resolve_expr_val', function $$resolve_expr_val(val) {
12150        var self = this, quoted = nil;
12151
12152
12153        if ((($truthy(val['$start_with?']("\"")) && ($truthy(val['$end_with?']("\"")))) || (($truthy(val['$start_with?']("'")) && ($truthy(val['$end_with?']("'"))))))) {
12154
12155          quoted = true;
12156          val = val.$slice(1, $rb_minus(val.$length(), 1));
12157        } else {
12158          quoted = false
12159        };
12160        if ($truthy(val['$include?']($$('ATTR_REF_HEAD')))) {
12161          val = self.document.$sub_attributes(val, $hash2(["attribute_missing"], {"attribute_missing": "drop"}))
12162        };
12163        if ($truthy(quoted)) {
12164          return val
12165        } else if ($truthy(val['$empty?']())) {
12166          return nil
12167        } else if ($eqeq(val, "true")) {
12168          return true
12169        } else if ($eqeq(val, "false")) {
12170          return false
12171        } else if ($truthy(val.$rstrip()['$empty?']())) {
12172          return " "
12173        } else if ($truthy(val['$include?']("."))) {
12174          return val.$to_f()
12175        } else {
12176          return val.$to_i()
12177        };
12178      });
12179    })($nesting[0], $$('Reader'), $nesting);
12180  })($nesting[0], $nesting)
12181};
12182
12183Opal.modules["asciidoctor/section"] = function(Opal) {/* Generated by Opal 1.7.3 */
12184  "use strict";
12185  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $send2 = Opal.send2, $find_super = Opal.find_super, $eqeqeq = Opal.eqeqeq, $truthy = Opal.truthy, $rb_plus = Opal.rb_plus, $def = Opal.def, $alias = Opal.alias, $rb_gt = Opal.rb_gt, $eqeq = Opal.eqeq, $not = Opal.not, $send = Opal.send, $defs = Opal.defs, $nesting = [], nil = Opal.nil;
12186
12187  Opal.add_stubs('attr_accessor,attr_reader,===,+,level,special,title,generate_id,>,==,sectnum,!,empty?,reftext,sub_placeholder,sub_quotes,compat_mode,[],attributes,context,assign_numeral,class,object_id,inspect,size,[]=,chr,length,gsub,downcase,delete,tr_s,end_with?,chop,start_with?,slice,key?,catalog,unique_id_start_index');
12188  return (function($base, $parent_nesting) {
12189    var self = $module($base, 'Asciidoctor');
12190
12191    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
12192
12193    return (function($base, $super, $parent_nesting) {
12194      var self = $klass($base, $super, 'Section');
12195
12196      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
12197
12198      $proto.document = $proto.next_section_index = $proto.parent = $proto.level = $proto.numeral = $proto.numbered = $proto.sectname = $proto.title = $proto.blocks = nil;
12199
12200      self.$attr_accessor("index");
12201      self.$attr_accessor("sectname");
12202      self.$attr_accessor("special");
12203      self.$attr_accessor("numbered");
12204      self.$attr_reader("caption");
12205
12206      $def(self, '$initialize', function $$initialize(parent, level, numbered, opts) {
12207        var $a, $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil;
12208
12209        $$initialize.$$p = null;
12210
12211        if (parent == null) parent = nil;
12212        if (level == null) level = nil;
12213        if (numbered == null) numbered = false;
12214        if (opts == null) opts = $hash2([], {});
12215        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "section", opts], null);
12216        if ($eqeqeq($$('Section'), parent)) {
12217          $a = [($truthy(($ret_or_1 = level)) ? ($ret_or_1) : ($rb_plus(parent.$level(), 1))), parent.$special()], (self.level = $a[0]), (self.special = $a[1]), $a
12218        } else {
12219          $a = [($truthy(($ret_or_1 = level)) ? ($ret_or_1) : (1)), false], (self.level = $a[0]), (self.special = $a[1]), $a
12220        };
12221        self.numbered = numbered;
12222        return (self.index = 0);
12223      }, -1);
12224      $alias(self, "name", "title");
12225
12226      $def(self, '$generate_id', function $$generate_id() {
12227        var self = this;
12228
12229        return $$('Section').$generate_id(self.$title(), self.document)
12230      });
12231
12232      $def(self, '$sections?', function $Section_sections$ques$1() {
12233        var self = this;
12234
12235        return $rb_gt(self.next_section_index, 0)
12236      });
12237
12238      $def(self, '$sectnum', function $$sectnum(delimiter, append) {
12239        var self = this, $ret_or_1 = nil;
12240
12241
12242        if (delimiter == null) delimiter = ".";
12243        if (append == null) append = nil;
12244        append = ($truthy(($ret_or_1 = append)) ? ($ret_or_1) : (($eqeq(append, false) ? ("") : (delimiter))));
12245        if (($truthy($rb_gt(self.level, 1)) && ($eqeqeq($$('Section'), self.parent)))) {
12246          return "" + (self.parent.$sectnum(delimiter, delimiter)) + (self.numeral) + (append)
12247        } else {
12248          return "" + (self.numeral) + (append)
12249        };
12250      }, -1);
12251
12252      $def(self, '$xreftext', function $$xreftext(xrefstyle) {
12253        var self = this, val = nil, type = nil, quoted_title = nil, signifier = nil;
12254
12255
12256        if (xrefstyle == null) xrefstyle = nil;
12257        if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) {
12258          return val
12259        } else if ($truthy(xrefstyle)) {
12260          if ($truthy(self.numbered)) {
12261
12262            switch (xrefstyle) {
12263              case "full":
12264
12265                if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) {
12266                  quoted_title = self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title())
12267                } else {
12268                  quoted_title = self.$sub_placeholder(self.$sub_quotes(($truthy(self.document.$compat_mode()) ? ("``%s''") : ("\"`%s`\""))), self.$title())
12269                };
12270                if ($truthy((signifier = self.document.$attributes()['$[]']("" + (type) + "-refsig")))) {
12271                  return "" + (signifier) + " " + (self.$sectnum(".", ",")) + " " + (quoted_title)
12272                } else {
12273                  return "" + (self.$sectnum(".", ",")) + " " + (quoted_title)
12274                };
12275                break;
12276              case "short":
12277                if ($truthy((signifier = self.document.$attributes()['$[]']("" + (self.sectname) + "-refsig")))) {
12278                  return "" + (signifier) + " " + (self.$sectnum(".", ""))
12279                } else {
12280                  return self.$sectnum(".", "")
12281                }
12282                break;
12283              default:
12284                if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) {
12285
12286                  return self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title());
12287                } else {
12288                  return self.$title()
12289                }
12290            }
12291          } else if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) {
12292
12293            return self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title());
12294          } else {
12295            return self.$title()
12296          }
12297        } else {
12298          return self.$title()
12299        };
12300      }, -1);
12301
12302      $def(self, '$<<', function $Section_$lt$lt$2(block) {
12303        var $yield = $Section_$lt$lt$2.$$p || nil, self = this;
12304
12305        $Section_$lt$lt$2.$$p = null;
12306
12307        if ($eqeq(block.$context(), "section")) {
12308          self.$assign_numeral(block)
12309        };
12310        return $send2(self, $find_super(self, '<<', $Section_$lt$lt$2, false, true), '<<', [block], $yield);
12311      });
12312
12313      $def(self, '$to_s', function $$to_s() {
12314        var $yield = $$to_s.$$p || nil, self = this, formal_title = nil;
12315
12316        $$to_s.$$p = null;
12317        if ($truthy(self.title)) {
12318
12319          formal_title = ($truthy(self.numbered) ? ("" + (self.$sectnum()) + " " + (self.title)) : (self.title));
12320          return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {level: " + (self.level) + ", title: " + (formal_title.$inspect()) + ", blocks: " + (self.blocks.$size()) + "}>";
12321        } else {
12322          return $send2(self, $find_super(self, 'to_s', $$to_s, false, true), 'to_s', [], $yield)
12323        }
12324      });
12325      return $defs(self, '$generate_id', function $$generate_id(title, document) {
12326        var $a, attrs = nil, pre = nil, $ret_or_1 = nil, sep = nil, no_sep = nil, sep_sub = nil, gen_id = nil, ids = nil, cnt = nil, candidate_id = nil;
12327
12328
12329        attrs = document.$attributes();
12330        pre = ($truthy(($ret_or_1 = attrs['$[]']("idprefix"))) ? ($ret_or_1) : ("_"));
12331        if ($truthy((sep = attrs['$[]']("idseparator")))) {
12332          if (($eqeq(sep.$length(), 1) || (($not((no_sep = sep['$empty?']())) && ($truthy((sep = ($a = ["idseparator", sep.$chr()], $send(attrs, '[]=', $a), $a[$a.length - 1])))))))) {
12333            sep_sub = (($eqeq(sep, "-") || ($eqeq(sep, "."))) ? (" .-") : (" " + (sep) + ".-"))
12334          }
12335        } else {
12336          $a = ["_", " _.-"], (sep = $a[0]), (sep_sub = $a[1]), $a
12337        };
12338        gen_id = "" + (pre) + (title.$downcase().$gsub($$('InvalidSectionIdCharsRx'), ""));
12339        if ($truthy(no_sep)) {
12340          gen_id = gen_id.$delete(" ")
12341        } else {
12342
12343          gen_id = gen_id.$tr_s(sep_sub, sep);
12344          if ($truthy(gen_id['$end_with?'](sep))) {
12345            gen_id = gen_id.$chop()
12346          };
12347          if (($truthy(pre['$empty?']()) && ($truthy(gen_id['$start_with?'](sep))))) {
12348            gen_id = gen_id.$slice(1, gen_id.$length())
12349          };
12350        };
12351        if ($truthy(document.$catalog()['$[]']("refs")['$key?'](gen_id))) {
12352
12353          ids = document.$catalog()['$[]']("refs");
12354          cnt = $$('Compliance').$unique_id_start_index();
12355          while ($truthy(ids['$[]']((candidate_id = "" + (gen_id) + (sep) + (cnt))))) {
12356          cnt = $rb_plus(cnt, 1)
12357          };
12358          return candidate_id;
12359        } else {
12360          return gen_id
12361        };
12362      });
12363    })($nesting[0], $$('AbstractBlock'), $nesting)
12364  })($nesting[0], $nesting)
12365};
12366
12367Opal.modules["asciidoctor/stylesheets"] = function(Opal) {/* Generated by Opal 1.7.3 */
12368  "use strict";
12369  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $return_ivar = Opal.return_ivar, $defs = Opal.defs, $def = Opal.def, $truthy = Opal.truthy, $hash2 = Opal.hash2, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
12370
12371  Opal.add_stubs('join,new,rstrip,read,primary_stylesheet_data,write,primary_stylesheet_name,stylesheet_basename,for,read_stylesheet,coderay_stylesheet_data,coderay_stylesheet_name,pygments_stylesheet_data,pygments_stylesheet_name');
12372  return (function($base, $parent_nesting) {
12373    var self = $module($base, 'Asciidoctor');
12374
12375    var $nesting = [self].concat($parent_nesting);
12376
12377    return (function($base, $super, $parent_nesting) {
12378      var self = $klass($base, $super, 'Stylesheets');
12379
12380      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
12381
12382      $proto.primary_stylesheet_data = nil;
12383
12384      $const_set($nesting[0], 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css");
12385      $const_set($nesting[0], 'STYLESHEETS_DIR', $$$('File').$join($$('DATA_DIR'), "stylesheets"));
12386      self.__instance__ = self.$new();
12387      $defs(self, '$instance', $return_ivar("__instance__"));
12388
12389      $def(self, '$primary_stylesheet_name', function $$primary_stylesheet_name() {
12390
12391        return $$('DEFAULT_STYLESHEET_NAME')
12392      });
12393
12394      $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() {
12395        var self = this, $ret_or_1 = nil;
12396
12397        return (self.primary_stylesheet_data = ($truthy(($ret_or_1 = self.primary_stylesheet_data)) ? ($ret_or_1) : ($$$('File').$read($$$('File').$join($$('STYLESHEETS_DIR'), "asciidoctor-default.css"), $hash2(["mode"], {"mode": $$('FILE_READ_MODE')})).$rstrip())))
12398      });
12399
12400      $def(self, '$embed_primary_stylesheet', function $$embed_primary_stylesheet() {
12401        var self = this;
12402
12403        return "<style>\n" + (self.$primary_stylesheet_data()) + "\n" + "</style>"
12404      });
12405
12406      $def(self, '$write_primary_stylesheet', function $$write_primary_stylesheet(target_dir) {
12407        var self = this;
12408
12409
12410        if (target_dir == null) target_dir = ".";
12411        return $$$('File').$write($$$('File').$join(target_dir, self.$primary_stylesheet_name()), self.$primary_stylesheet_data(), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}));
12412      }, -1);
12413
12414      $def(self, '$coderay_stylesheet_name', function $$coderay_stylesheet_name() {
12415
12416        return $$('SyntaxHighlighter').$for("coderay").$stylesheet_basename()
12417      });
12418
12419      $def(self, '$coderay_stylesheet_data', function $$coderay_stylesheet_data() {
12420
12421        return $$('SyntaxHighlighter').$for("coderay").$read_stylesheet()
12422      });
12423
12424      $def(self, '$embed_coderay_stylesheet', function $$embed_coderay_stylesheet() {
12425        var self = this;
12426
12427        return "<style>\n" + (self.$coderay_stylesheet_data()) + "\n" + "</style>"
12428      });
12429
12430      $def(self, '$write_coderay_stylesheet', function $$write_coderay_stylesheet(target_dir) {
12431        var self = this;
12432
12433
12434        if (target_dir == null) target_dir = ".";
12435        return $$$('File').$write($$$('File').$join(target_dir, self.$coderay_stylesheet_name()), self.$coderay_stylesheet_data(), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}));
12436      }, -1);
12437
12438      $def(self, '$pygments_stylesheet_name', function $$pygments_stylesheet_name(style) {
12439
12440
12441        if (style == null) style = nil;
12442        return $$('SyntaxHighlighter').$for("pygments").$stylesheet_basename(style);
12443      }, -1);
12444
12445      $def(self, '$pygments_stylesheet_data', function $$pygments_stylesheet_data(style) {
12446
12447
12448        if (style == null) style = nil;
12449        return $$('SyntaxHighlighter').$for("pygments").$read_stylesheet(style);
12450      }, -1);
12451
12452      $def(self, '$embed_pygments_stylesheet', function $$embed_pygments_stylesheet(style) {
12453        var self = this;
12454
12455
12456        if (style == null) style = nil;
12457        return "<style>\n" + (self.$pygments_stylesheet_data(style)) + "\n" + "</style>";
12458      }, -1);
12459      return $def(self, '$write_pygments_stylesheet', function $$write_pygments_stylesheet(target_dir, style) {
12460        var self = this;
12461
12462
12463        if (target_dir == null) target_dir = ".";
12464        if (style == null) style = nil;
12465        return $$$('File').$write($$$('File').$join(target_dir, self.$pygments_stylesheet_name(style)), self.$pygments_stylesheet_data(style), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}));
12466      }, -1);
12467    })($nesting[0], null, $nesting)
12468  })($nesting[0], $nesting)
12469};
12470
12471Opal.modules["asciidoctor/table"] = function(Opal) {/* Generated by Opal 1.7.3 */
12472  "use strict";
12473  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $def = Opal.def, $alias = Opal.alias, $hash2 = Opal.hash2, $send2 = Opal.send2, $find_super = Opal.find_super, $truthy = Opal.truthy, $rb_lt = Opal.rb_lt, $rb_gt = Opal.rb_gt, $eqeq = Opal.eqeq, $rb_times = Opal.rb_times, $rb_divide = Opal.rb_divide, $send = Opal.send, $rb_plus = Opal.rb_plus, $rb_minus = Opal.rb_minus, $return_val = Opal.return_val, $to_a = Opal.to_a, $gvars = Opal.gvars, $neqeq = Opal.neqeq, $return_ivar = Opal.return_ivar, $to_ary = Opal.to_ary, $regexp = Opal.regexp, $not = Opal.not, $thrower = Opal.thrower, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
12474
12475  Opal.add_stubs('attr_accessor,send,attr_reader,new,[],<,>,to_i,==,[]=,attributes,truncate,*,/,to_f,empty?,body,each,<<,size,+,assign_column_widths,warn,logger,-,update_attributes,assign_width,round,head=,map,shift,reinitialize,nil?,unshift,foot=,pop,parent,sourcemap,dup,header_row?,table,style,merge,delete,start_with?,rstrip,slice,length,advance,lstrip,strip,split,include?,readlines,catalog_inline_anchor,=~,apply_subs,attr_writer,convert,text,!=,file,lineno,include,to_set,mark,key?,nested?,document,error,message_with_context,cursor_at_prev_line,nil_or_empty?,escape,columns,match,chop,end_with?,gsub,!,push_cellspec,cell_open?,close_cell,take_cellspec,squeeze,upto,times,cursor_before_mark,rowspan,activate_rowspan,colspan,end_of_row?,close_row,private,rows,effective_column_visits');
12476  return (function($base, $parent_nesting) {
12477    var self = $module($base, 'Asciidoctor');
12478
12479    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
12480
12481
12482    (function($base, $super, $parent_nesting) {
12483      var self = $klass($base, $super, 'Table');
12484
12485      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
12486
12487      $proto.attributes = $proto.document = $proto.rows = $proto.has_header_option = $proto.columns = nil;
12488
12489      $const_set($nesting[0], 'DEFAULT_PRECISION', 4);
12490      (function($base, $super) {
12491        var self = $klass($base, $super, 'Rows');
12492
12493        var $proto = self.$$prototype;
12494
12495        $proto.head = $proto.body = $proto.foot = nil;
12496
12497        self.$attr_accessor("head", "foot", "body");
12498
12499        $def(self, '$initialize', function $$initialize(head, foot, body) {
12500          var self = this;
12501
12502
12503          if (head == null) head = [];
12504          if (foot == null) foot = [];
12505          if (body == null) body = [];
12506          self.head = head;
12507          self.foot = foot;
12508          return (self.body = body);
12509        }, -1);
12510        $alias(self, "[]", "send");
12511
12512        $def(self, '$by_section', function $$by_section() {
12513          var self = this;
12514
12515          return [["head", self.head], ["body", self.body], ["foot", self.foot]]
12516        });
12517        return $def(self, '$to_h', function $$to_h() {
12518          var self = this;
12519
12520          return $hash2(["head", "body", "foot"], {"head": self.head, "body": self.body, "foot": self.foot})
12521        });
12522      })($nesting[0], null);
12523      self.$attr_accessor("columns");
12524      self.$attr_accessor("rows");
12525      self.$attr_accessor("has_header_option");
12526      self.$attr_reader("caption");
12527
12528      $def(self, '$initialize', function $$initialize(parent, attributes) {
12529        var $a, $yield = $$initialize.$$p || nil, self = this, pcwidth = nil, pcwidth_intval = nil, abswidth_val = nil;
12530
12531        $$initialize.$$p = null;
12532
12533        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "table"], null);
12534        self.rows = $$('Rows').$new();
12535        self.columns = [];
12536        self.has_header_option = false;
12537        if ($truthy((pcwidth = attributes['$[]']("width")))) {
12538          if (($truthy($rb_gt((pcwidth_intval = pcwidth.$to_i()), 100)) || ($truthy($rb_lt(pcwidth_intval, 1))))) {
12539            if (!($eqeq(pcwidth_intval, 0) && (($eqeq(pcwidth, "0") || ($eqeq(pcwidth, "0%")))))) {
12540              pcwidth_intval = 100
12541            }
12542          }
12543        } else {
12544          pcwidth_intval = 100
12545        };
12546        self.attributes['$[]=']("tablepcwidth", pcwidth_intval);
12547        if ($truthy(self.document.$attributes()['$[]']("pagewidth"))) {
12548          self.attributes['$[]=']("tableabswidth", ($eqeq((abswidth_val = $rb_times($rb_divide(pcwidth_intval, 100), self.document.$attributes()['$[]']("pagewidth").$to_f()).$truncate($$('DEFAULT_PRECISION'))), abswidth_val.$to_i()) ? (abswidth_val.$to_i()) : (abswidth_val)))
12549        };
12550        if ($truthy(attributes['$[]']("rotate-option"))) {
12551          return ($a = ["orientation", "landscape"], $send(self.attributes, '[]=', $a), $a[$a.length - 1])
12552        } else {
12553          return nil
12554        };
12555      });
12556
12557      $def(self, '$header_row?', function $Table_header_row$ques$1() {
12558        var self = this, val = nil;
12559
12560        if (($truthy((val = self.has_header_option)) && ($truthy(self.rows.$body()['$empty?']())))) {
12561          return val
12562        } else {
12563          return nil
12564        }
12565      });
12566
12567      $def(self, '$create_columns', function $$create_columns(colspecs) {
12568        var self = this, cols = nil, autowidth_cols = nil, width_base = nil, num_cols = nil;
12569
12570
12571        cols = [];
12572        autowidth_cols = nil;
12573        width_base = 0;
12574        $send(colspecs, 'each', [], function $$2(colspec){var self = $$2.$$s == null ? this : $$2.$$s, colwidth = nil, $ret_or_1 = nil;
12575
12576
12577          if (colspec == null) colspec = nil;
12578          colwidth = colspec['$[]']("width");
12579          cols['$<<']($$('Column').$new(self, cols.$size(), colspec));
12580          if ($truthy($rb_lt(colwidth, 0))) {
12581            return (autowidth_cols = ($truthy(($ret_or_1 = autowidth_cols)) ? ($ret_or_1) : ([])))['$<<'](cols['$[]'](-1))
12582          } else {
12583            return (width_base = $rb_plus(width_base, colwidth))
12584          };}, {$$s: self});
12585        if ($truthy($rb_gt((num_cols = (self.columns = cols).$size()), 0))) {
12586
12587          self.attributes['$[]=']("colcount", num_cols);
12588          if (!($truthy($rb_gt(width_base, 0)) || ($truthy(autowidth_cols)))) {
12589            width_base = nil
12590          };
12591          self.$assign_column_widths(width_base, autowidth_cols);
12592        };
12593        return nil;
12594      });
12595
12596      $def(self, '$assign_column_widths', function $$assign_column_widths(width_base, autowidth_cols) {
12597        var self = this, precision = nil, total_width = nil, col_pcwidth = nil, autowidth = nil, autowidth_attrs = nil;
12598
12599
12600        if (width_base == null) width_base = nil;
12601        if (autowidth_cols == null) autowidth_cols = nil;
12602        precision = $$('DEFAULT_PRECISION');
12603        total_width = (col_pcwidth = 0);
12604        if ($truthy(width_base)) {
12605
12606          if ($truthy(autowidth_cols)) {
12607
12608            if ($truthy($rb_gt(width_base, 100))) {
12609
12610              autowidth = 0;
12611              self.$logger().$warn("total column width must not exceed 100% when using autowidth columns; got " + (width_base) + "%");
12612            } else {
12613
12614              autowidth = $rb_divide($rb_minus(100, width_base), autowidth_cols.$size()).$truncate(precision);
12615              if ($eqeq(autowidth.$to_i(), autowidth)) {
12616                autowidth = autowidth.$to_i()
12617              };
12618              width_base = 100;
12619            };
12620            autowidth_attrs = $hash2(["width", "autowidth-option"], {"width": autowidth, "autowidth-option": ""});
12621            $send(autowidth_cols, 'each', [], function $$3(col){
12622
12623              if (col == null) col = nil;
12624              return col.$update_attributes(autowidth_attrs);});
12625          };
12626          $send(self.columns, 'each', [], function $$4(col){
12627
12628            if (col == null) col = nil;
12629            return (total_width = $rb_plus(total_width, (col_pcwidth = col.$assign_width(nil, width_base, precision))));});
12630        } else {
12631
12632          col_pcwidth = $rb_divide(100, self.columns.$size()).$truncate(precision);
12633          if ($eqeq(col_pcwidth.$to_i(), col_pcwidth)) {
12634            col_pcwidth = col_pcwidth.$to_i()
12635          };
12636          $send(self.columns, 'each', [], function $$5(col){
12637
12638            if (col == null) col = nil;
12639            return (total_width = $rb_plus(total_width, col.$assign_width(col_pcwidth, nil, precision)));});
12640        };
12641        if (!$eqeq(total_width, 100)) {
12642          self.columns['$[]'](-1).$assign_width($rb_plus($rb_minus(100, total_width), col_pcwidth).$round(precision), nil, precision)
12643        };
12644        return nil;
12645      }, -1);
12646      return $def(self, '$partition_header_footer', function $$partition_header_footer(attrs) {
12647        var $a, self = this, num_body_rows = nil, body = nil;
12648
12649
12650        num_body_rows = ($a = ["rowcount", (body = self.rows.$body()).$size()], $send(self.attributes, '[]=', $a), $a[$a.length - 1]);
12651        if ($truthy($rb_gt(num_body_rows, 0))) {
12652          if ($truthy(self.has_header_option)) {
12653
12654            self.rows['$head=']([$send(body.$shift(), 'map', [], function $$6(cell){
12655
12656              if (cell == null) cell = nil;
12657              return cell.$reinitialize(true);})]);
12658            num_body_rows = $rb_minus(num_body_rows, 1);
12659          } else if ($truthy(self.has_header_option['$nil?']())) {
12660
12661            self.has_header_option = false;
12662            body.$unshift($send(body.$shift(), 'map', [], function $$7(cell){
12663
12664              if (cell == null) cell = nil;
12665              return cell.$reinitialize(false);}));
12666          }
12667        };
12668        if (($truthy($rb_gt(num_body_rows, 0)) && ($truthy(attrs['$[]']("footer-option"))))) {
12669          self.rows['$foot=']([body.$pop()])
12670        };
12671        return nil;
12672      });
12673    })($nesting[0], $$('AbstractBlock'), $nesting);
12674    (function($base, $super) {
12675      var self = $klass($base, $super, 'Column');
12676
12677      var $proto = self.$$prototype;
12678
12679      $proto.attributes = nil;
12680
12681      self.$attr_accessor("style");
12682
12683      $def(self, '$initialize', function $$initialize(table, index, attributes) {
12684        var $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil;
12685
12686        $$initialize.$$p = null;
12687
12688        if (attributes == null) attributes = $hash2([], {});
12689        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [table, "table_column"], null);
12690        self.style = attributes['$[]']("style");
12691        attributes['$[]=']("colnumber", $rb_plus(index, 1));
12692        if ($truthy(($ret_or_1 = attributes['$[]']("width")))) {
12693          $ret_or_1
12694        } else {
12695          attributes['$[]=']("width", 1)
12696        };
12697        if ($truthy(($ret_or_1 = attributes['$[]']("halign")))) {
12698          $ret_or_1
12699        } else {
12700          attributes['$[]=']("halign", "left")
12701        };
12702        if ($truthy(($ret_or_1 = attributes['$[]']("valign")))) {
12703          $ret_or_1
12704        } else {
12705          attributes['$[]=']("valign", "top")
12706        };
12707        return self.$update_attributes(attributes);
12708      }, -3);
12709      $alias(self, "table", "parent");
12710
12711      $def(self, '$assign_width', function $$assign_width(col_pcwidth, width_base, precision) {
12712        var $a, self = this, col_abswidth = nil;
12713
12714
12715        if ($truthy(width_base)) {
12716
12717          col_pcwidth = $rb_divide($rb_times(self.attributes['$[]']("width").$to_f(), 100), width_base).$truncate(precision);
12718          if ($eqeq(col_pcwidth.$to_i(), col_pcwidth)) {
12719            col_pcwidth = col_pcwidth.$to_i()
12720          };
12721        };
12722        if ($truthy(self.$parent().$attributes()['$[]']("tableabswidth"))) {
12723          self.attributes['$[]=']("colabswidth", ($eqeq((col_abswidth = $rb_times($rb_divide(col_pcwidth, 100), self.$parent().$attributes()['$[]']("tableabswidth")).$truncate(precision)), col_abswidth.$to_i()) ? (col_abswidth.$to_i()) : (col_abswidth)))
12724        };
12725        return ($a = ["colpcwidth", col_pcwidth], $send(self.attributes, '[]=', $a), $a[$a.length - 1]);
12726      });
12727
12728      $def(self, '$block?', $return_val(false));
12729      return $def(self, '$inline?', $return_val(false));
12730    })($$('Table'), $$('AbstractNode'));
12731    (function($base, $super, $parent_nesting) {
12732      var self = $klass($base, $super, 'Cell');
12733
12734      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
12735
12736      $proto.document = $proto.reinitialize_args = $proto.attributes = $proto.cursor = $proto.text = $proto.subs = $proto.style = $proto.inner_document = $proto.source_location = $proto.colspan = $proto.rowspan = nil;
12737
12738      $const_set($nesting[0], 'DOUBLE_LF', $rb_times($$('LF'), 2));
12739      self.$attr_accessor("colspan");
12740      self.$attr_accessor("rowspan");
12741      $alias(self, "column", "parent");
12742      self.$attr_reader("inner_document");
12743
12744      $def(self, '$initialize', function $$initialize(column, cell_text, attributes, opts) {
12745        var $a, $yield = $$initialize.$$p || nil, self = this, in_header_row = nil, cell_style = nil, $ret_or_1 = nil, $ret_or_2 = nil, asciidoc = nil, inner_document_cursor = nil, lines_advanced = nil, literal = nil, normal_psv = nil, parent_doctitle = nil, inner_document_lines = nil, unprocessed_line1 = nil, preprocessed_lines = nil;
12746
12747        $$initialize.$$p = null;
12748
12749        if (attributes == null) attributes = $hash2([], {});
12750        if (opts == null) opts = $hash2([], {});
12751        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [column, "table_cell"], null);
12752        self.cursor = (self.reinitialize_args = nil);
12753        if ($truthy(self.document.$sourcemap())) {
12754          self.source_location = opts['$[]']("cursor").$dup()
12755        };
12756        if ($truthy(column)) {
12757
12758          if ($truthy((in_header_row = column.$table()['$header_row?']()))) {
12759            if (($eqeq(in_header_row, "implicit") && ($truthy((cell_style = ($truthy(($ret_or_1 = column.$style())) ? ($ret_or_1) : (($truthy(($ret_or_2 = attributes)) ? (attributes['$[]']("style")) : ($ret_or_2))))))))) {
12760
12761              if (($eqeq(cell_style, "asciidoc") || ($eqeq(cell_style, "literal")))) {
12762                self.reinitialize_args = [column, cell_text, ($truthy(($ret_or_1 = attributes)) ? (attributes.$merge()) : ($ret_or_1)), opts]
12763              };
12764              cell_style = nil;
12765            }
12766          } else {
12767            cell_style = column.$style()
12768          };
12769          self.$update_attributes(column.$attributes());
12770        };
12771        if ($truthy(attributes)) {
12772
12773          if ($truthy(attributes['$empty?']())) {
12774            self.colspan = (self.rowspan = nil)
12775          } else {
12776
12777            $a = [attributes.$delete("colspan"), attributes.$delete("rowspan")], (self.colspan = $a[0]), (self.rowspan = $a[1]), $a;
12778            if (!$truthy(in_header_row)) {
12779              cell_style = ($truthy(($ret_or_1 = attributes['$[]']("style"))) ? ($ret_or_1) : (cell_style))
12780            };
12781            self.$update_attributes(attributes);
12782          };
12783
12784          switch (cell_style) {
12785            case "asciidoc":
12786
12787              asciidoc = true;
12788              inner_document_cursor = opts['$[]']("cursor");
12789              if ($truthy((cell_text = cell_text.$rstrip())['$start_with?']($$('LF')))) {
12790
12791                lines_advanced = 1;
12792                while ($truthy((cell_text = cell_text.$slice(1, cell_text.$length()))['$start_with?']($$('LF')))) {
12793                lines_advanced = $rb_plus(lines_advanced, 1)
12794                };
12795                inner_document_cursor.$advance(lines_advanced);
12796              } else {
12797                cell_text = cell_text.$lstrip()
12798              };
12799              break;
12800            case "literal":
12801
12802              literal = true;
12803              cell_text = cell_text.$rstrip();
12804              while ($truthy(cell_text['$start_with?']($$('LF')))) {
12805              cell_text = cell_text.$slice(1, cell_text.$length())
12806              };
12807              break;
12808            default:
12809
12810              normal_psv = true;
12811              cell_text = ($truthy(cell_text) ? (cell_text.$strip()) : (""));
12812          };
12813        } else {
12814
12815          self.colspan = (self.rowspan = nil);
12816          if ($eqeq(cell_style, "asciidoc")) {
12817
12818            asciidoc = true;
12819            inner_document_cursor = opts['$[]']("cursor");
12820          };
12821        };
12822        if ($truthy(asciidoc)) {
12823
12824          parent_doctitle = self.document.$attributes().$delete("doctitle");
12825          inner_document_lines = cell_text.$split($$('LF'), -1);
12826          if (!$truthy(inner_document_lines['$empty?']())) {
12827            if ($truthy((unprocessed_line1 = inner_document_lines['$[]'](0))['$include?']("::"))) {
12828
12829              preprocessed_lines = $$('PreprocessorReader').$new(self.document, [unprocessed_line1]).$readlines();
12830              if (!($eqeq(unprocessed_line1, preprocessed_lines['$[]'](0)) && ($truthy($rb_lt(preprocessed_lines.$size(), 2))))) {
12831
12832                inner_document_lines.$shift();
12833                if (!$truthy(preprocessed_lines['$empty?']())) {
12834                  $send(inner_document_lines, 'unshift', $to_a(preprocessed_lines))
12835                };
12836              };
12837            }
12838          };
12839          self.inner_document = $$('Document').$new(inner_document_lines, $hash2(["standalone", "parent", "cursor"], {"standalone": false, "parent": self.document, "cursor": inner_document_cursor}));
12840          if (!$truthy(parent_doctitle['$nil?']())) {
12841            self.document.$attributes()['$[]=']("doctitle", parent_doctitle)
12842          };
12843          self.subs = nil;
12844        } else if ($truthy(literal)) {
12845
12846          self.content_model = "verbatim";
12847          self.subs = $$('BASIC_SUBS');
12848        } else {
12849
12850          if ($truthy(normal_psv)) {
12851            if ($truthy(in_header_row)) {
12852              self.cursor = opts['$[]']("cursor")
12853            } else {
12854              self.$catalog_inline_anchor(cell_text, opts['$[]']("cursor"))
12855            }
12856          };
12857          self.content_model = "simple";
12858          self.subs = $$('NORMAL_SUBS');
12859        };
12860        self.text = cell_text;
12861        return (self.style = cell_style);
12862      }, -3);
12863
12864      $def(self, '$reinitialize', function $$reinitialize(has_header) {
12865        var self = this;
12866
12867
12868        if ($truthy(has_header)) {
12869          self.reinitialize_args = nil
12870        } else if ($truthy(self.reinitialize_args)) {
12871          return $send($$$($$('Table'), 'Cell'), 'new', $to_a(self.reinitialize_args))
12872        } else {
12873          self.style = self.attributes['$[]']("style")
12874        };
12875        if ($truthy(self.cursor)) {
12876          self.$catalog_inline_anchor()
12877        };
12878        return self;
12879      });
12880
12881      $def(self, '$catalog_inline_anchor', function $$catalog_inline_anchor(cell_text, cursor) {
12882        var $a, self = this;
12883
12884
12885        if (cell_text == null) cell_text = self.text;
12886        if (cursor == null) cursor = nil;
12887        if (!$truthy(cursor)) {
12888          $a = [self.cursor, nil], (cursor = $a[0]), (self.cursor = $a[1]), $a
12889        };
12890        if (($truthy(cell_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](cell_text))))) {
12891          return $$('Parser').$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), self, cursor, self.document)
12892        } else {
12893          return nil
12894        };
12895      }, -1);
12896
12897      $def(self, '$text', function $$text() {
12898        var self = this;
12899
12900        return self.$apply_subs(self.text, self.subs)
12901      });
12902      self.$attr_writer("text");
12903
12904      $def(self, '$content', function $$content() {
12905        var self = this, cell_style = nil, subbed_text = nil;
12906
12907        if ($eqeq((cell_style = self.style), "asciidoc")) {
12908          return self.inner_document.$convert()
12909        } else if ($truthy(self.text['$include?']($$('DOUBLE_LF')))) {
12910          return $send(self.$text().$split($$('BlankLineRx')), 'map', [], function $$8(para){var self = $$8.$$s == null ? this : $$8.$$s;
12911
12912
12913            if (para == null) para = nil;
12914            if (($truthy(cell_style) && ($neqeq(cell_style, "header")))) {
12915              return $$('Inline').$new(self.$parent(), "quoted", para, $hash2(["type"], {"type": cell_style})).$convert()
12916            } else {
12917              return para
12918            };}, {$$s: self})
12919        } else if ($truthy((subbed_text = self.$text())['$empty?']())) {
12920          return []
12921        } else if (($truthy(cell_style) && ($neqeq(cell_style, "header")))) {
12922          return [$$('Inline').$new(self.$parent(), "quoted", subbed_text, $hash2(["type"], {"type": cell_style})).$convert()]
12923        } else {
12924          return [subbed_text]
12925        }
12926      });
12927
12928      $def(self, '$lines', function $$lines() {
12929        var self = this;
12930
12931        return self.text.$split($$('LF'))
12932      });
12933
12934      $def(self, '$source', $return_ivar("text"));
12935
12936      $def(self, '$file', function $$file() {
12937        var self = this, $ret_or_1 = nil;
12938
12939        if ($truthy(($ret_or_1 = self.source_location))) {
12940          return self.source_location.$file()
12941        } else {
12942          return $ret_or_1
12943        }
12944      });
12945
12946      $def(self, '$lineno', function $$lineno() {
12947        var self = this, $ret_or_1 = nil;
12948
12949        if ($truthy(($ret_or_1 = self.source_location))) {
12950          return self.source_location.$lineno()
12951        } else {
12952          return $ret_or_1
12953        }
12954      });
12955      return $def(self, '$to_s', function $$to_s() {
12956        var $yield = $$to_s.$$p || nil, self = this, $ret_or_1 = nil;
12957
12958        $$to_s.$$p = null;
12959        return "" + ($send2(self, $find_super(self, 'to_s', $$to_s, false, true), 'to_s', [], $yield)) + " - [text: " + (self.text) + ", colspan: " + (($truthy(($ret_or_1 = self.colspan)) ? ($ret_or_1) : (1))) + ", rowspan: " + (($truthy(($ret_or_1 = self.rowspan)) ? ($ret_or_1) : (1))) + ", attributes: " + (self.attributes) + "]"
12960      });
12961    })($$('Table'), $$('AbstractBlock'), $nesting);
12962    return (function($base, $super, $parent_nesting) {
12963      var self = $klass($base, $super, 'ParserContext');
12964
12965      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
12966
12967      $proto.delimiter = $proto.delimiter_rx = $proto.buffer = $proto.cellspecs = $proto.cell_open = $proto.format = $proto.start_cursor_data = $proto.reader = $proto.table = $proto.current_row = $proto.colcount = $proto.column_visits = $proto.active_rowspans = $proto.linenum = nil;
12968
12969      self.$include($$('Logging'));
12970      $const_set($nesting[0], 'FORMATS', ["psv", "csv", "dsv", "tsv"].$to_set());
12971      $const_set($nesting[0], 'DELIMITERS', $hash2(["psv", "csv", "dsv", "tsv", "!sv"], {"psv": ["|", /\|/], "csv": [",", /,/], "dsv": [":", /:/], "tsv": ["\t", /\t/], "!sv": ["!", /!/]}));
12972      self.$attr_accessor("table");
12973      self.$attr_accessor("format");
12974      self.$attr_reader("colcount");
12975      self.$attr_accessor("buffer");
12976      self.$attr_reader("delimiter");
12977      self.$attr_reader("delimiter_re");
12978
12979      $def(self, '$initialize', function $$initialize(reader, table, attributes) {
12980        var $a, $b, self = this, xsv = nil, sep = nil;
12981
12982
12983        if (attributes == null) attributes = $hash2([], {});
12984        self.start_cursor_data = (self.reader = reader).$mark();
12985        self.table = table;
12986        if ($truthy(attributes['$key?']("format"))) {
12987          if ($truthy($$('FORMATS')['$include?']((xsv = attributes['$[]']("format"))))) {
12988            if ($eqeq(xsv, "tsv")) {
12989              self.format = "csv"
12990            } else if (($eqeq((self.format = xsv), "psv") && ($truthy(table.$document()['$nested?']())))) {
12991              xsv = "!sv"
12992            }
12993          } else {
12994
12995            self.$logger().$error(self.$message_with_context("illegal table format: " + (xsv), $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()})));
12996            $a = ["psv", ($truthy(table.$document()['$nested?']()) ? ("!sv") : ("psv"))], (self.format = $a[0]), (xsv = $a[1]), $a;
12997          }
12998        } else {
12999          $a = ["psv", ($truthy(table.$document()['$nested?']()) ? ("!sv") : ("psv"))], (self.format = $a[0]), (xsv = $a[1]), $a
13000        };
13001        if ($truthy(attributes['$key?']("separator"))) {
13002          if ($truthy((sep = attributes['$[]']("separator"))['$nil_or_empty?']())) {
13003            $b = $$('DELIMITERS')['$[]'](xsv), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])), $b
13004          } else if ($eqeq(sep, "\\t")) {
13005            $b = $$('DELIMITERS')['$[]']("tsv"), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])), $b
13006          } else {
13007            $a = [sep, $regexp([$$$('Regexp').$escape(sep)])], (self.delimiter = $a[0]), (self.delimiter_rx = $a[1]), $a
13008          }
13009        } else {
13010          $b = $$('DELIMITERS')['$[]'](xsv), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])), $b
13011        };
13012        self.colcount = ($truthy(table.$columns()['$empty?']()) ? (-1) : (table.$columns().$size()));
13013        self.buffer = "";
13014        self.cellspecs = [];
13015        self.cell_open = false;
13016        self.active_rowspans = [0];
13017        self.column_visits = 0;
13018        self.current_row = [];
13019        return (self.linenum = -1);
13020      }, -3);
13021
13022      $def(self, '$starts_with_delimiter?', function $ParserContext_starts_with_delimiter$ques$9(line) {
13023        var self = this;
13024
13025        return line['$start_with?'](self.delimiter)
13026      });
13027
13028      $def(self, '$match_delimiter', function $$match_delimiter(line) {
13029        var self = this;
13030
13031        return self.delimiter_rx.$match(line)
13032      });
13033
13034      $def(self, '$skip_past_delimiter', function $$skip_past_delimiter(pre) {
13035        var self = this;
13036
13037
13038        self.buffer = "" + (self.buffer) + (pre) + (self.delimiter);
13039        return nil;
13040      });
13041
13042      $def(self, '$skip_past_escaped_delimiter', function $$skip_past_escaped_delimiter(pre) {
13043        var self = this;
13044
13045
13046        self.buffer = "" + (self.buffer) + (pre.$chop()) + (self.delimiter);
13047        return nil;
13048      });
13049
13050      $def(self, '$buffer_has_unclosed_quotes?', function $ParserContext_buffer_has_unclosed_quotes$ques$10(append, q) {
13051        var self = this, record = nil, qq = nil, trailing_quote = nil, $ret_or_1 = nil;
13052
13053
13054        if (append == null) append = nil;
13055        if (q == null) q = "\"";
13056        if ($eqeq((record = ($truthy(append) ? ($rb_plus(self.buffer, append).$strip()) : (self.buffer.$strip()))), q)) {
13057          return true
13058        } else if ($truthy(record['$start_with?'](q))) {
13059
13060          qq = $rb_plus(q, q);
13061          if ((($truthy((trailing_quote = record['$end_with?'](q))) && ($truthy(record['$end_with?'](qq)))) || ($truthy(record['$start_with?'](qq))))) {
13062            if ($truthy(($ret_or_1 = (record = record.$gsub(qq, ""))['$start_with?'](q)))) {
13063              return record['$end_with?'](q)['$!']()
13064            } else {
13065              return $ret_or_1
13066            }
13067          } else {
13068            return trailing_quote['$!']()
13069          };
13070        } else {
13071          return false
13072        };
13073      }, -1);
13074
13075      $def(self, '$take_cellspec', function $$take_cellspec() {
13076        var self = this;
13077
13078        return self.cellspecs.$shift()
13079      });
13080
13081      $def(self, '$push_cellspec', function $$push_cellspec(cellspec) {
13082        var self = this, $ret_or_1 = nil;
13083
13084
13085        if (cellspec == null) cellspec = $hash2([], {});
13086        self.cellspecs['$<<'](($truthy(($ret_or_1 = cellspec)) ? ($ret_or_1) : ($hash2([], {}))));
13087        return nil;
13088      }, -1);
13089
13090      $def(self, '$keep_cell_open', function $$keep_cell_open() {
13091        var self = this;
13092
13093
13094        self.cell_open = true;
13095        return nil;
13096      });
13097
13098      $def(self, '$mark_cell_closed', function $$mark_cell_closed() {
13099        var self = this;
13100
13101
13102        self.cell_open = false;
13103        return nil;
13104      });
13105
13106      $def(self, '$cell_open?', $return_ivar("cell_open"));
13107
13108      $def(self, '$cell_closed?', function $ParserContext_cell_closed$ques$11() {
13109        var self = this;
13110
13111        return self.cell_open['$!']()
13112      });
13113
13114      $def(self, '$close_open_cell', function $$close_open_cell(next_cellspec) {
13115        var self = this;
13116
13117
13118        if (next_cellspec == null) next_cellspec = $hash2([], {});
13119        self.$push_cellspec(next_cellspec);
13120        if ($truthy(self['$cell_open?']())) {
13121          self.$close_cell(true)
13122        };
13123        self.$advance();
13124        return nil;
13125      }, -1);
13126
13127      $def(self, '$close_cell', function $$close_cell(eol) {try { var $t_return = $thrower('return');
13128        var self = this, cell_text = nil, cellspec = nil, repeat = nil, $ret_or_1 = nil, q = nil;
13129
13130
13131        if (eol == null) eol = false;
13132        if ($eqeq(self.format, "psv")) {
13133
13134          cell_text = self.buffer;
13135          self.buffer = "";
13136          if ($truthy((cellspec = self.$take_cellspec()))) {
13137            repeat = ($truthy(($ret_or_1 = cellspec.$delete("repeatcol"))) ? ($ret_or_1) : (1))
13138          } else {
13139
13140            self.$logger().$error(self.$message_with_context("table missing leading separator; recovering automatically", $hash2(["source_location"], {"source_location": $send($$$($$('Reader'), 'Cursor'), 'new', $to_a(self.start_cursor_data))})));
13141            cellspec = $hash2([], {});
13142            repeat = 1;
13143          };
13144        } else {
13145
13146          cell_text = self.buffer.$strip();
13147          self.buffer = "";
13148          cellspec = nil;
13149          repeat = 1;
13150          if ((($eqeq(self.format, "csv") && ($not(cell_text['$empty?']()))) && ($truthy(cell_text['$include?']((q = "\"")))))) {
13151            if (($truthy(cell_text['$start_with?'](q)) && ($truthy(cell_text['$end_with?'](q))))) {
13152              if ($truthy((cell_text = cell_text.$slice(1, $rb_minus(cell_text.$length(), 2))))) {
13153                cell_text = cell_text.$strip().$squeeze(q)
13154              } else {
13155
13156                self.$logger().$error(self.$message_with_context("unclosed quote in CSV data; setting cell to empty", $hash2(["source_location"], {"source_location": self.reader.$cursor_at_prev_line()})));
13157                cell_text = "";
13158              }
13159            } else {
13160              cell_text = cell_text.$squeeze(q)
13161            }
13162          };
13163        };
13164        $send((1), 'upto', [repeat], function $$12(i){var self = $$12.$$s == null ? this : $$12.$$s, column = nil, extra_cols = nil, offset = nil, cell = nil;
13165          if (self.colcount == null) self.colcount = nil;
13166          if (self.table == null) self.table = nil;
13167          if (self.current_row == null) self.current_row = nil;
13168          if (self.reader == null) self.reader = nil;
13169          if (self.column_visits == null) self.column_visits = nil;
13170          if (self.linenum == null) self.linenum = nil;
13171
13172
13173          if (i == null) i = nil;
13174          if ($eqeq(self.colcount, -1)) {
13175
13176            self.table.$columns()['$<<']((column = $$$($$('Table'), 'Column').$new(self.table, $rb_minus($rb_plus(self.table.$columns().$size(), i), 1))));
13177            if ((($truthy(cellspec) && ($truthy(cellspec['$key?']("colspan")))) && ($truthy($rb_gt((extra_cols = $rb_minus(cellspec['$[]']("colspan").$to_i(), 1)), 0))))) {
13178
13179              offset = self.table.$columns().$size();
13180              $send(extra_cols, 'times', [], function $$13(j){var self = $$13.$$s == null ? this : $$13.$$s;
13181                if (self.table == null) self.table = nil;
13182
13183
13184                if (j == null) j = nil;
13185                return self.table.$columns()['$<<']($$$($$('Table'), 'Column').$new(self.table, $rb_plus(offset, j)));}, {$$s: self});
13186            };
13187          } else if (!$truthy((column = self.table.$columns()['$[]'](self.current_row.$size())))) {
13188
13189            self.$logger().$error(self.$message_with_context("dropping cell because it exceeds specified number of columns", $hash2(["source_location"], {"source_location": self.reader.$cursor_before_mark()})));
13190            $t_return.$throw();
13191          };
13192          cell = $$$($$('Table'), 'Cell').$new(column, cell_text, cellspec, $hash2(["cursor"], {"cursor": self.reader.$cursor_before_mark()}));
13193          self.reader.$mark();
13194          if (!($not(cell.$rowspan()) || ($eqeq(cell.$rowspan(), 1)))) {
13195            self.$activate_rowspan(cell.$rowspan(), ($truthy(($ret_or_1 = cell.$colspan())) ? ($ret_or_1) : (1)))
13196          };
13197          self.column_visits = $rb_plus(self.column_visits, ($truthy(($ret_or_1 = cell.$colspan())) ? ($ret_or_1) : (1)));
13198          self.current_row['$<<'](cell);
13199          if (($truthy(self['$end_of_row?']()) && ((($neqeq(self.colcount, -1) || ($truthy($rb_gt(self.linenum, 0)))) || (($truthy(eol) && ($eqeq(i, repeat)))))))) {
13200            return self.$close_row()
13201          } else {
13202            return nil
13203          };}, {$$s: self, $$ret: $t_return});
13204        self.cell_open = false;
13205        return nil;} catch($e) {
13206          if ($e === $t_return) return $e.$v;
13207          throw $e;
13208        }
13209      }, -1);
13210      self.$private();
13211
13212      $def(self, '$close_row', function $$close_row() {
13213        var self = this, $ret_or_1 = nil;
13214
13215
13216        self.table.$rows().$body()['$<<'](self.current_row);
13217        if ($eqeq(self.colcount, -1)) {
13218          self.colcount = self.column_visits
13219        };
13220        self.column_visits = 0;
13221        self.current_row = [];
13222        self.active_rowspans.$shift();
13223        if ($truthy(($ret_or_1 = self.active_rowspans['$[]'](0)))) {
13224          $ret_or_1
13225        } else {
13226          self.active_rowspans['$[]='](0, 0)
13227        };
13228        return nil;
13229      });
13230
13231      $def(self, '$activate_rowspan', function $$activate_rowspan(rowspan, colspan) {
13232        var self = this;
13233
13234
13235        $send((1), 'upto', [$rb_minus(rowspan, 1)], function $$14(i){var $a, self = $$14.$$s == null ? this : $$14.$$s, $ret_or_1 = nil;
13236          if (self.active_rowspans == null) self.active_rowspans = nil;
13237
13238
13239          if (i == null) i = nil;
13240          return ($a = [i, $rb_plus(($truthy(($ret_or_1 = self.active_rowspans['$[]'](i))) ? ($ret_or_1) : (0)), colspan)], $send(self.active_rowspans, '[]=', $a), $a[$a.length - 1]);}, {$$s: self});
13241        return nil;
13242      });
13243
13244      $def(self, '$end_of_row?', function $ParserContext_end_of_row$ques$15() {
13245        var self = this, $ret_or_1 = nil;
13246
13247        if ($truthy(($ret_or_1 = self.colcount['$=='](-1)))) {
13248          return $ret_or_1
13249        } else {
13250          return self.$effective_column_visits()['$=='](self.colcount)
13251        }
13252      });
13253
13254      $def(self, '$effective_column_visits', function $$effective_column_visits() {
13255        var self = this;
13256
13257        return $rb_plus(self.column_visits, self.active_rowspans['$[]'](0))
13258      });
13259      return $def(self, '$advance', function $$advance() {
13260        var self = this;
13261
13262        return (self.linenum = $rb_plus(self.linenum, 1))
13263      });
13264    })($$('Table'), null, $nesting);
13265  })($nesting[0], $nesting)
13266};
13267
13268Opal.modules["asciidoctor/writer"] = function(Opal) {/* Generated by Opal 1.7.3 */
13269  "use strict";
13270  var $module = Opal.module, $truthy = Opal.truthy, $rb_plus = Opal.rb_plus, $hash2 = Opal.hash2, $def = Opal.def, $return_val = Opal.return_val, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13271
13272  Opal.add_stubs('respond_to?,write,+,chomp,include');
13273  return (function($base, $parent_nesting) {
13274    var self = $module($base, 'Asciidoctor');
13275
13276    var $nesting = [self].concat($parent_nesting);
13277
13278
13279    (function($base, $parent_nesting) {
13280      var self = $module($base, 'Writer');
13281
13282      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13283
13284      return $def(self, '$write', function $$write(output, target) {
13285
13286
13287        if ($truthy(target['$respond_to?']("write"))) {
13288          target.$write($rb_plus(output.$chomp(), $$('LF')))
13289        } else {
13290          $$$('File').$write(target, output, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}))
13291        };
13292        return nil;
13293      })
13294    })($nesting[0], $nesting);
13295    return (function($base, $parent_nesting) {
13296      var self = $module($base, 'VoidWriter');
13297
13298      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13299
13300
13301      self.$include($$('Writer'));
13302      return $def(self, '$write', $return_val(nil));
13303    })($nesting[0], $nesting);
13304  })($nesting[0], $nesting)
13305};
13306
13307Opal.modules["asciidoctor/load"] = function(Opal) {/* Generated by Opal 1.7.3 */
13308  "use strict";
13309  var $module = Opal.module, $hash2 = Opal.hash2, $truthy = Opal.truthy, $neqeq = Opal.neqeq, $not = Opal.not, $eqeqeq = Opal.eqeqeq, $send = Opal.send, $to_ary = Opal.to_ary, $rb_plus = Opal.rb_plus, $eqeq = Opal.eqeq, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13310
13311  Opal.add_stubs('merge,[],start,!=,logger,key?,logger=,new,!,===,dup,tap,each,partition,[]=,split,gsub,+,respond_to?,keys,raise,join,ancestors,class,==,at,to_i,mtime,absolute_path,path,dirname,basename,extname,read,rewind,drop,record,parse,exception,message,set_backtrace,backtrace,stack_trace=,stack_trace,open,load');
13312  return (function($base, $parent_nesting) {
13313    var self = $module($base, 'Asciidoctor');
13314
13315    var $nesting = [self].concat($parent_nesting);
13316
13317    return (function(self, $parent_nesting) {
13318      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13319
13320
13321
13322      $def(self, '$load', function $$load(input, options) {
13323        var $a, $b, $c, $d, self = this, timings = nil, logger = nil, $ret_or_1 = nil, attrs = nil, input_path = nil, source = nil, doc = nil, e = nil, context = nil, wrapped_e = nil;
13324
13325
13326        if (options == null) options = $hash2([], {});
13327        try {
13328
13329          options = options.$merge();
13330          if ($truthy((timings = options['$[]']("timings")))) {
13331            timings.$start("read")
13332          };
13333          if (($truthy(options['$key?']("logger")) && ($neqeq((logger = options['$[]']("logger")), $$('LoggerManager').$logger())))) {
13334            $$('LoggerManager')['$logger='](($truthy(($ret_or_1 = logger)) ? ($ret_or_1) : ($$('NullLogger').$new())))
13335          };
13336          if ($not((attrs = options['$[]']("attributes")))) {
13337            attrs = $hash2([], {})
13338          } else if ($eqeqeq($$$('Hash'), attrs)) {
13339            attrs = attrs.$merge()
13340          } else if (($truthy((($c = $$$('::', 'Java', 'skip_raise')) && ($b = $$$($c, 'JavaUtil', 'skip_raise')) && ($a = $$$($b, 'Map', 'skip_raise')) ? 'constant' : nil)) && ($eqeqeq($$$($$$($$$('Java'), 'JavaUtil'), 'Map'), attrs)))) {
13341            attrs = attrs.$dup()
13342          } else if ($eqeqeq($$$('Array'), attrs)) {
13343            attrs = $send($hash2([], {}), 'tap', [], function $$1(accum){
13344
13345              if (accum == null) accum = nil;
13346              return $send(attrs, 'each', [], function $$2(entry){var $d, $e, k = nil, _ = nil, v = nil;
13347
13348
13349                if (entry == null) entry = nil;
13350                $e = entry.$partition("="), $d = $to_ary($e), (k = ($d[0] == null ? nil : $d[0])), (_ = ($d[1] == null ? nil : $d[1])), (v = ($d[2] == null ? nil : $d[2])), $e;
13351                return ($d = [k, v], $send(accum, '[]=', $d), $d[$d.length - 1]);});})
13352          } else if ($eqeqeq($$$('String'), attrs)) {
13353            attrs = $send($hash2([], {}), 'tap', [], function $$3(accum){
13354
13355              if (accum == null) accum = nil;
13356              return $send(attrs.$gsub($$('SpaceDelimiterRx'), $rb_plus("\\1", $$('NULL'))).$gsub($$('EscapedSpaceRx'), "\\1").$split($$('NULL')), 'each', [], function $$4(entry){var $d, $e, k = nil, _ = nil, v = nil;
13357
13358
13359                if (entry == null) entry = nil;
13360                $e = entry.$partition("="), $d = $to_ary($e), (k = ($d[0] == null ? nil : $d[0])), (_ = ($d[1] == null ? nil : $d[1])), (v = ($d[2] == null ? nil : $d[2])), $e;
13361                return ($d = [k, v], $send(accum, '[]=', $d), $d[$d.length - 1]);});})
13362          } else if (($truthy(attrs['$respond_to?']("keys")) && ($truthy(attrs['$respond_to?']("[]"))))) {
13363            attrs = $send($hash2([], {}), 'tap', [], function $$5(accum){
13364
13365              if (accum == null) accum = nil;
13366              return $send(attrs.$keys(), 'each', [], function $$6(k){var $d;
13367
13368
13369                if (k == null) k = nil;
13370                return ($d = [k, attrs['$[]'](k)], $send(accum, '[]=', $d), $d[$d.length - 1]);});})
13371          } else {
13372            self.$raise($$$('ArgumentError'), "illegal type for attributes option: " + (attrs.$class().$ancestors().$join(" < ")))
13373          };
13374          if ($eqeqeq($$$('File'), input)) {
13375
13376            options['$[]=']("input_mtime", ($eqeq($$('RUBY_ENGINE'), "jruby") ? ($$$('Time').$at(input.$mtime().$to_i())) : (input.$mtime())));
13377            attrs['$[]=']("docfile", (input_path = $$$('File').$absolute_path(input.$path())));
13378            attrs['$[]=']("docdir", $$$('File').$dirname(input_path));
13379            attrs['$[]=']("docname", $$('Helpers').$basename(input_path, ($d = ["docfilesuffix", $$('Helpers').$extname(input_path)], $send(attrs, '[]=', $d), $d[$d.length - 1])));
13380            source = input.$read();
13381          } else if ($truthy(input['$respond_to?']("read"))) {
13382
13383            try {
13384              input.$rewind()
13385            } catch ($err) {
13386              if (Opal.rescue($err, [$$('StandardError')])) {
13387                try {
13388                  nil
13389                } finally { Opal.pop_exception(); }
13390              } else { throw $err; }
13391            };
13392            source = input.$read();
13393          } else if ($eqeqeq($$$('String'), input)) {
13394            source = input
13395          } else if ($eqeqeq($$$('Array'), input)) {
13396            source = input.$drop(0)
13397          } else if ($truthy(input)) {
13398            self.$raise($$$('ArgumentError'), "unsupported input type: " + (input.$class()))
13399          };
13400          if ($truthy(timings)) {
13401
13402            timings.$record("read");
13403            timings.$start("parse");
13404          };
13405          options['$[]=']("attributes", attrs);
13406          doc = ($eqeq(options['$[]']("parse"), false) ? ($$('Document').$new(source, options)) : ($$('Document').$new(source, options).$parse()));
13407          if ($truthy(timings)) {
13408            timings.$record("parse")
13409          };
13410          return doc;
13411        } catch ($err) {
13412          if (Opal.rescue($err, [$$('StandardError')])) {(e = $err)
13413            try {
13414
13415
13416              try {
13417
13418                context = "asciidoctor: FAILED: " + (($truthy(($ret_or_1 = attrs['$[]']("docfile"))) ? ($ret_or_1) : ("<stdin>"))) + ": Failed to load AsciiDoc document";
13419                if ($truthy(e['$respond_to?']("exception"))) {
13420
13421                  wrapped_e = e.$exception("" + (context) + " - " + (e.$message()));
13422                  wrapped_e.$set_backtrace(e.$backtrace());
13423                } else {
13424
13425                  wrapped_e = e.$class().$new(context, e);
13426                  wrapped_e['$stack_trace='](e.$stack_trace());
13427                };
13428              } catch ($err) {
13429                if (Opal.rescue($err, [$$('StandardError')])) {
13430                  try {
13431                    wrapped_e = e
13432                  } finally { Opal.pop_exception(); }
13433                } else { throw $err; }
13434              };;
13435              return self.$raise(wrapped_e);
13436            } finally { Opal.pop_exception(); }
13437          } else { throw $err; }
13438        };
13439      }, -2);
13440      return $def(self, '$load_file', function $$load_file(filename, options) {
13441        var self = this;
13442
13443
13444        if (options == null) options = $hash2([], {});
13445        return $send($$$('File'), 'open', [filename, $$('FILE_READ_MODE')], function $$7(file){var self = $$7.$$s == null ? this : $$7.$$s;
13446
13447
13448          if (file == null) file = nil;
13449          return self.$load(file, options);}, {$$s: self});
13450      }, -2);
13451    })(Opal.get_singleton_class(self), $nesting)
13452  })($nesting[0], $nesting)
13453};
13454
13455Opal.modules["asciidoctor/convert"] = function(Opal) {/* Generated by Opal 1.7.3 */
13456  "use strict";
13457  var $module = Opal.module, $hash2 = Opal.hash2, $eqeqeq = Opal.eqeqeq, $truthy = Opal.truthy, $eqeq = Opal.eqeq, $rb_ge = Opal.rb_ge, $not = Opal.not, $rb_lt = Opal.rb_lt, $neqeq = Opal.neqeq, $def = Opal.def, $send = Opal.send, $alias = Opal.alias, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13458
13459  Opal.add_stubs('delete,merge,===,absolute_path,path,load,respond_to?,[]=,key?,fetch,[],dirname,expand_path,join,attributes,outfilesuffix,==,raise,pwd,>=,safe,normalize_system_path,mkdir_p,directory?,!,convert,write,attr,uriish?,basebackend?,attr?,<,include?,syntax_highlighter,write_stylesheet?,write_primary_stylesheet,instance,to_s,read_asset,file?,!=,write_stylesheet,open,convert_file');
13460  return (function($base, $parent_nesting) {
13461    var self = $module($base, 'Asciidoctor');
13462
13463    var $nesting = [self].concat($parent_nesting);
13464
13465    return (function(self, $parent_nesting) {
13466      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13467
13468
13469
13470      $def(self, '$convert', function $$convert(input, options) {
13471        var self = this, to_dir = nil, mkdirs = nil, $ret_or_1 = nil, to_file = nil, write_to_target = nil, sibling_path = nil, stream_output = nil, outdir = nil, doc = nil, outfile = nil, working_dir = nil, jail = nil, output = nil, stylesdir = nil, stylesheet = nil, copy_asciidoctor_stylesheet = nil, copy_user_stylesheet = nil, copy_syntax_hl_stylesheet = nil, syntax_hl = nil, stylesoutdir = nil, stylesheet_src = nil, stylesheet_dest = nil, stylesheet_data = nil, stylesheet_outdir = nil;
13472
13473
13474        if (options == null) options = $hash2([], {});
13475        (options = options.$merge()).$delete("parse");
13476        to_dir = options.$delete("to_dir");
13477        mkdirs = options.$delete("mkdirs");
13478        if (($eqeqeq(true, ($ret_or_1 = (to_file = options.$delete("to_file")))) || ($eqeqeq(nil, $ret_or_1)))) {
13479
13480          if (!$truthy((write_to_target = to_dir))) {
13481            if ($eqeqeq($$$('File'), input)) {
13482              sibling_path = $$$('File').$absolute_path(input.$path())
13483            }
13484          };
13485          to_file = nil;
13486        } else if ($eqeqeq(false, $ret_or_1)) {
13487          to_file = nil
13488        } else if ($eqeqeq("/dev/null", $ret_or_1)) {
13489          return self.$load(input, options)
13490        } else if (!$truthy((stream_output = to_file['$respond_to?']("write")))) {
13491          options['$[]=']("to_file", (write_to_target = to_file))
13492        };
13493        if (!$truthy(options['$key?']("standalone"))) {
13494          if (($truthy(sibling_path) || ($truthy(write_to_target)))) {
13495            options['$[]=']("standalone", options.$fetch("header_footer", true))
13496          } else if ($truthy(options['$key?']("header_footer"))) {
13497            options['$[]=']("standalone", options['$[]']("header_footer"))
13498          }
13499        };
13500        if ($truthy(sibling_path)) {
13501          options['$[]=']("to_dir", (outdir = $$$('File').$dirname(sibling_path)))
13502        } else if ($truthy(write_to_target)) {
13503          if ($truthy(to_dir)) {
13504            if ($truthy(to_file)) {
13505              options['$[]=']("to_dir", $$$('File').$dirname($$$('File').$expand_path(to_file, to_dir)))
13506            } else {
13507              options['$[]=']("to_dir", $$$('File').$expand_path(to_dir))
13508            }
13509          } else if ($truthy(to_file)) {
13510            options['$[]=']("to_dir", $$$('File').$dirname($$$('File').$expand_path(to_file)))
13511          }
13512        };
13513        doc = self.$load(input, options);
13514        if ($truthy(sibling_path)) {
13515
13516          outfile = $$$('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix()));
13517          if ($eqeq(outfile, sibling_path)) {
13518            self.$raise($$$('IOError'), "input file and output file cannot be the same: " + (outfile))
13519          };
13520        } else if ($truthy(write_to_target)) {
13521
13522          working_dir = ($truthy(options['$key?']("base_dir")) ? ($$$('File').$expand_path(options['$[]']("base_dir"))) : ($$$('Dir').$pwd()));
13523          jail = ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (working_dir) : (nil));
13524          if ($truthy(to_dir)) {
13525
13526            outdir = doc.$normalize_system_path(to_dir, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
13527            if ($truthy(to_file)) {
13528
13529              outfile = doc.$normalize_system_path(to_file, outdir, nil, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
13530              outdir = $$$('File').$dirname(outfile);
13531            } else {
13532              outfile = $$$('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix()))
13533            };
13534          } else if ($truthy(to_file)) {
13535
13536            outfile = doc.$normalize_system_path(to_file, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
13537            outdir = $$$('File').$dirname(outfile);
13538          };
13539          if (($eqeqeq($$$('File'), input) && ($eqeq(outfile, $$$('File').$absolute_path(input.$path()))))) {
13540            self.$raise($$$('IOError'), "input file and output file cannot be the same: " + (outfile))
13541          };
13542          if ($truthy(mkdirs)) {
13543            $$('Helpers').$mkdir_p(outdir)
13544          } else if (!$truthy($$$('File')['$directory?'](outdir))) {
13545            self.$raise($$$('IOError'), "target directory does not exist: " + (to_dir) + " (hint: set :mkdirs option)")
13546          };
13547        } else {
13548
13549          outfile = to_file;
13550          outdir = nil;
13551        };
13552        if (($truthy(outfile) && ($not(stream_output)))) {
13553          output = doc.$convert($hash2(["outfile", "outdir"], {"outfile": outfile, "outdir": outdir}))
13554        } else {
13555          output = doc.$convert()
13556        };
13557        if ($truthy(outfile)) {
13558
13559          doc.$write(output, outfile);
13560          if (((((($not(stream_output) && ($truthy($rb_lt(doc.$safe(), $$$($$('SafeMode'), 'SECURE'))))) && ($truthy(doc['$attr?']("linkcss")))) && ($truthy(doc['$attr?']("copycss")))) && ($truthy(doc['$basebackend?']("html")))) && ($not(($truthy(($ret_or_1 = (stylesdir = doc.$attr("stylesdir")))) ? ($$('Helpers')['$uriish?'](stylesdir)) : ($ret_or_1)))))) {
13561
13562            if ($truthy((stylesheet = doc.$attr("stylesheet")))) {
13563              if ($truthy($$('DEFAULT_STYLESHEET_KEYS')['$include?'](stylesheet))) {
13564                copy_asciidoctor_stylesheet = true
13565              } else if ($not($$('Helpers')['$uriish?'](stylesheet))) {
13566                copy_user_stylesheet = true
13567              }
13568            };
13569            copy_syntax_hl_stylesheet = ($truthy(($ret_or_1 = (syntax_hl = doc.$syntax_highlighter()))) ? (syntax_hl['$write_stylesheet?'](doc)) : ($ret_or_1));
13570            if ((($truthy(copy_asciidoctor_stylesheet) || ($truthy(copy_user_stylesheet))) || ($truthy(copy_syntax_hl_stylesheet)))) {
13571
13572              stylesoutdir = doc.$normalize_system_path(stylesdir, outdir, ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (outdir) : (nil)));
13573              if ($truthy(mkdirs)) {
13574                $$('Helpers').$mkdir_p(stylesoutdir)
13575              } else if (!$truthy($$$('File')['$directory?'](stylesoutdir))) {
13576                self.$raise($$$('IOError'), "target stylesheet directory does not exist: " + (stylesoutdir) + " (hint: set :mkdirs option)")
13577              };
13578              if ($truthy(copy_asciidoctor_stylesheet)) {
13579                $$('Stylesheets').$instance().$write_primary_stylesheet(stylesoutdir)
13580              } else if ($truthy(copy_user_stylesheet)) {
13581
13582                if (($eqeq((stylesheet_src = doc.$attr("copycss")), "") || ($eqeq(stylesheet_src, true)))) {
13583                  stylesheet_src = doc.$normalize_system_path(stylesheet)
13584                } else {
13585                  stylesheet_src = doc.$normalize_system_path(stylesheet_src.$to_s())
13586                };
13587                stylesheet_dest = doc.$normalize_system_path(stylesheet, stylesoutdir, ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (outdir) : (nil)));
13588                if (($neqeq(stylesheet_src, stylesheet_dest) && ($truthy((stylesheet_data = doc.$read_asset(stylesheet_src, $hash2(["warn_on_failure", "label"], {"warn_on_failure": $$$('File')['$file?'](stylesheet_dest)['$!'](), "label": "stylesheet"}))))))) {
13589
13590                  if (($neqeq((stylesheet_outdir = $$$('File').$dirname(stylesheet_dest)), stylesoutdir) && ($not($$$('File')['$directory?'](stylesheet_outdir))))) {
13591                    if ($truthy(mkdirs)) {
13592                      $$('Helpers').$mkdir_p(stylesheet_outdir)
13593                    } else {
13594                      self.$raise($$$('IOError'), "target stylesheet directory does not exist: " + (stylesheet_outdir) + " (hint: set :mkdirs option)")
13595                    }
13596                  };
13597                  $$$('File').$write(stylesheet_dest, stylesheet_data, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')}));
13598                };
13599              };
13600              if ($truthy(copy_syntax_hl_stylesheet)) {
13601                syntax_hl.$write_stylesheet(doc, stylesoutdir)
13602              };
13603            };
13604          };
13605          return doc;
13606        } else {
13607          return output
13608        };
13609      }, -2);
13610
13611      $def(self, '$convert_file', function $$convert_file(filename, options) {
13612        var self = this;
13613
13614
13615        if (options == null) options = $hash2([], {});
13616        return $send($$$('File'), 'open', [filename, $$('FILE_READ_MODE')], function $$1(file){var self = $$1.$$s == null ? this : $$1.$$s;
13617
13618
13619          if (file == null) file = nil;
13620          return self.$convert(file, options);}, {$$s: self});
13621      }, -2);
13622      $alias(self, "render", "convert");
13623      return $alias(self, "render_file", "convert_file");
13624    })(Opal.get_singleton_class(self), $nesting)
13625  })($nesting[0], $nesting)
13626};
13627
13628Opal.modules["asciidoctor/syntax_highlighter/highlightjs"] = function(Opal) {/* Generated by Opal 1.7.3 */
13629  "use strict";
13630  var $module = Opal.module, $klass = Opal.klass, $slice = Opal.slice, $send2 = Opal.send2, $find_super = Opal.find_super, $to_a = Opal.to_a, $def = Opal.def, $hash2 = Opal.hash2, $send = Opal.send, $truthy = Opal.truthy, $return_val = Opal.return_val, $eqeq = Opal.eqeq, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13631
13632  Opal.add_stubs('register_for,merge,proc,[]=,attr,[],==,attr?,join,map,split,lstrip');
13633  return (function($base, $parent_nesting) {
13634    var self = $module($base, 'Asciidoctor');
13635
13636    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13637
13638    return (function($base, $super, $parent_nesting) {
13639      var self = $klass($base, $super, 'HighlightJsAdapter');
13640
13641      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13642
13643
13644      self.$register_for("highlightjs", "highlight.js");
13645
13646      $def(self, '$initialize', function $$initialize($a) {
13647        var $post_args, args, $yield = $$initialize.$$p || nil, self = this;
13648
13649        $$initialize.$$p = null;
13650
13651        $post_args = $slice(arguments);
13652        args = $post_args;
13653        $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', $to_a(args), $yield);
13654        return (self.name = (self.pre_class = "highlightjs"));
13655      }, -1);
13656
13657      $def(self, '$format', function $$format(node, lang, opts) {
13658        var $yield = $$format.$$p || nil, self = this;
13659
13660        $$format.$$p = null;
13661        return $send2(self, $find_super(self, 'format', $$format, false, true), 'format', [node, lang, opts.$merge($hash2(["transform"], {"transform": $send(self, 'proc', [], function $$1(_, code){var $a, $ret_or_1 = nil;
13662
13663
13664          if (_ == null) _ = nil;
13665          if (code == null) code = nil;
13666          return ($a = ["class", "language-" + (($truthy(($ret_or_1 = lang)) ? ($ret_or_1) : ("none"))) + " hljs"], $send(code, '[]=', $a), $a[$a.length - 1]);})}))], null)
13667      });
13668
13669      $def(self, '$docinfo?', $return_val(true));
13670      return $def(self, '$docinfo', function $$docinfo(location, doc, opts) {
13671        var base_url = nil;
13672
13673
13674        base_url = doc.$attr("highlightjsdir", "" + (opts['$[]']("cdn_base_url")) + "/highlight.js/" + ($$('HIGHLIGHT_JS_VERSION')));
13675        if ($eqeq(location, "head")) {
13676          return "<link rel=\"stylesheet\" href=\"" + (base_url) + "/styles/" + (doc.$attr("highlightjs-theme", "github")) + ".min.css\"" + (opts['$[]']("self_closing_tag_slash")) + ">"
13677        } else {
13678          return "<script src=\"" + (base_url) + "/highlight.min.js\"></script>\n" + (($truthy(doc['$attr?']("highlightjs-languages")) ? ($send(doc.$attr("highlightjs-languages").$split(","), 'map', [], function $$2(lang){
13679
13680            if (lang == null) lang = nil;
13681            return "<script src=\"" + (base_url) + "/languages/" + (lang.$lstrip()) + ".min.js\"></script>\n";}).$join()) : (""))) + "<script>\n" + "if (!hljs.initHighlighting.called) {\n" + "  hljs.initHighlighting.called = true\n" + "  ;[].slice.call(document.querySelectorAll('pre.highlight > code[data-lang]')).forEach(function (el) { hljs.highlightBlock(el) })\n" + "}\n" + "</script>"
13682        };
13683      });
13684    })($$('SyntaxHighlighter'), $$$($$('SyntaxHighlighter'), 'Base'), $nesting)
13685  })($nesting[0], $nesting)
13686};
13687
13688Opal.modules["asciidoctor/syntax_highlighter"] = function(Opal) {/* Generated by Opal 1.7.3 */
13689  "use strict";
13690  var $module = Opal.module, $hash2 = Opal.hash2, $def = Opal.def, $return_val = Opal.return_val, $defs = Opal.defs, $slice = Opal.slice, $send = Opal.send, $to_a = Opal.to_a, $truthy = Opal.truthy, $eqeqeq = Opal.eqeqeq, $Class = Opal.Class, $klass = Opal.klass, $class_variable_set = Opal.class_variable_set, $class_variable_get = Opal.class_variable_get, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13691
13692  Opal.add_stubs('attr_reader,raise,class,extend,private_class_method,register,map,to_s,each,[]=,registry,[],for,===,new,name,private,include,delete,join,content');
13693
13694  (function($base, $parent_nesting) {
13695    var self = $module($base, 'Asciidoctor');
13696
13697    var $nesting = [self].concat($parent_nesting);
13698
13699    return (function($base, $parent_nesting) {
13700      var self = $module($base, 'SyntaxHighlighter');
13701
13702      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13703
13704
13705      self.$attr_reader("name");
13706
13707      $def(self, '$initialize', function $$initialize(name, backend, opts) {
13708        var self = this;
13709
13710
13711        if (backend == null) backend = "html5";
13712        if (opts == null) opts = $hash2([], {});
13713        return (self.name = (self.pre_class = name));
13714      }, -2);
13715
13716      $def(self, '$docinfo?', $return_val(nil));
13717
13718      $def(self, '$docinfo', function $$docinfo(location, doc, opts) {
13719        var self = this;
13720
13721        return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("docinfo") + " method since #docinfo? returns true")
13722      });
13723
13724      $def(self, '$highlight?', $return_val(nil));
13725
13726      $def(self, '$highlight', function $$highlight(node, source, lang, opts) {
13727        var self = this;
13728
13729        return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("highlight") + " method since #highlight? returns true")
13730      });
13731
13732      $def(self, '$format', function $$format(node, lang, opts) {
13733        var self = this;
13734
13735        return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("format") + " method")
13736      });
13737
13738      $def(self, '$write_stylesheet?', $return_val(nil));
13739
13740      $def(self, '$write_stylesheet', function $$write_stylesheet(doc, to_dir) {
13741        var self = this;
13742
13743        return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("write_stylesheet") + " method since #write_stylesheet? returns true")
13744      });
13745      $defs(self, '$included', function $$included(into) {
13746
13747        return into.$extend($$('Config'))
13748      });
13749      self.$private_class_method("included");
13750      (function($base, $parent_nesting) {
13751        var self = $module($base, 'Config');
13752
13753        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13754
13755        return $def(self, '$register_for', function $$register_for($a) {
13756          var $post_args, names, self = this;
13757
13758
13759          $post_args = $slice(arguments);
13760          names = $post_args;
13761          return $send($$('SyntaxHighlighter'), 'register', [self].concat($to_a($send(names, 'map', [], function $$1(name){
13762
13763            if (name == null) name = nil;
13764            return name.$to_s();}))));
13765        }, -1)
13766      })($nesting[0], $nesting);
13767      (function($base, $parent_nesting) {
13768        var self = $module($base, 'Factory');
13769
13770        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13771
13772
13773
13774        $def(self, '$register', function $$register(syntax_highlighter, $a) {
13775          var $post_args, names, self = this;
13776
13777
13778          $post_args = $slice(arguments, 1);
13779          names = $post_args;
13780          return $send(names, 'each', [], function $$2(name){var $b, self = $$2.$$s == null ? this : $$2.$$s;
13781
13782
13783            if (name == null) name = nil;
13784            return ($b = [name, syntax_highlighter], $send(self.$registry(), '[]=', $b), $b[$b.length - 1]);}, {$$s: self});
13785        }, -2);
13786
13787        $def(self, '$for', function $Factory_for$3(name) {
13788          var self = this;
13789
13790          return self.$registry()['$[]'](name)
13791        });
13792
13793        $def(self, '$create', function $$create(name, backend, opts) {
13794          var self = this, syntax_hl = nil;
13795
13796
13797          if (backend == null) backend = "html5";
13798          if (opts == null) opts = $hash2([], {});
13799          if ($truthy((syntax_hl = self.$for(name)))) {
13800
13801            if ($eqeqeq($Class, syntax_hl)) {
13802              syntax_hl = syntax_hl.$new(name, backend, opts)
13803            };
13804            if (!$truthy(syntax_hl.$name())) {
13805              self.$raise($$$('NameError'), "" + (syntax_hl.$class()) + " must specify a value for `name'")
13806            };
13807            return syntax_hl;
13808          } else {
13809            return nil
13810          };
13811        }, -2);
13812        self.$private();
13813        return $def(self, '$registry', function $$registry() {
13814          var self = this;
13815
13816          return self.$raise($$$('NotImplementedError'), "" + ($$('Factory')) + " subclass " + (self.$class()) + " must implement the #" + ("registry") + " method")
13817        });
13818      })($nesting[0], $nesting);
13819      (function($base, $super, $parent_nesting) {
13820        var self = $klass($base, $super, 'CustomFactory');
13821
13822        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13823
13824
13825        self.$include($$('Factory'));
13826
13827        $def(self, '$initialize', function $$initialize(seed_registry) {
13828          var self = this, $ret_or_1 = nil;
13829
13830
13831          if (seed_registry == null) seed_registry = nil;
13832          return (self.registry = ($truthy(($ret_or_1 = seed_registry)) ? ($ret_or_1) : ($hash2([], {}))));
13833        }, -1);
13834        self.$private();
13835        return self.$attr_reader("registry");
13836      })($nesting[0], null, $nesting);
13837      (function($base, $parent_nesting) {
13838        var self = $module($base, 'DefaultFactory');
13839
13840        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13841
13842
13843        self.$include($$('Factory'));
13844        $class_variable_set($nesting[0], '@@registry', $hash2([], {}));
13845        self.$private();
13846
13847        $def(self, '$registry', function $$registry() {
13848
13849          return $class_variable_get($nesting[0], '@@registry', false)
13850        });
13851        return nil;
13852      })($nesting[0], $nesting);
13853      (function($base, $super, $parent_nesting) {
13854        var self = $klass($base, $super, 'DefaultFactoryProxy');
13855
13856        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
13857
13858
13859        self.$include($$('DefaultFactory'));
13860        return nil;
13861      })($nesting[0], $$('CustomFactory'), $nesting);
13862      (function($base, $super, $parent_nesting) {
13863        var self = $klass($base, $super, 'Base');
13864
13865        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
13866
13867        $proto.pre_class = nil;
13868
13869        self.$include($$('SyntaxHighlighter'));
13870        return $def(self, '$format', function $$format(node, lang, opts) {
13871          var self = this, class_attr_val = nil, transform = nil, pre = nil, code = nil;
13872
13873
13874          class_attr_val = ($truthy(opts['$[]']("nowrap")) ? ("" + (self.pre_class) + " highlight nowrap") : ("" + (self.pre_class) + " highlight"));
13875          if ($truthy((transform = opts['$[]']("transform")))) {
13876
13877            transform['$[]']((pre = $hash2(["class"], {"class": class_attr_val})), (code = ($truthy(lang) ? ($hash2(["data-lang"], {"data-lang": lang})) : ($hash2([], {})))));
13878            if ($truthy((lang = code.$delete("data-lang")))) {
13879              code['$[]=']("data-lang", lang)
13880            };
13881            return "<pre" + ($send(pre, 'map', [], function $$4(k, v){
13882
13883              if (k == null) k = nil;
13884              if (v == null) v = nil;
13885              return " " + (k) + "=\"" + (v) + "\"";}).$join()) + "><code" + ($send(code, 'map', [], function $$5(k, v){
13886
13887              if (k == null) k = nil;
13888              if (v == null) v = nil;
13889              return " " + (k) + "=\"" + (v) + "\"";}).$join()) + ">" + (node.$content()) + "</code></pre>";
13890          } else {
13891            return "<pre class=\"" + (class_attr_val) + "\"><code" + (($truthy(lang) ? (" data-lang=\"" + (lang) + "\"") : (""))) + ">" + (node.$content()) + "</code></pre>"
13892          };
13893        });
13894      })($nesting[0], null, $nesting);
13895      return self.$extend($$('DefaultFactory'));
13896    })($nesting[0], $nesting)
13897  })($nesting[0], $nesting);
13898  self.$require("asciidoctor/syntax_highlighter.rb"+ '/../' + "syntax_highlighter/highlightjs");
13899  return nil;
13900};
13901
13902Opal.modules["asciidoctor/timings"] = function(Opal) {/* Generated by Opal 1.7.3 */
13903  "use strict";
13904  var $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $def = Opal.def, $send = Opal.send, $rb_minus = Opal.rb_minus, $slice = Opal.slice, $rb_plus = Opal.rb_plus, $truthy = Opal.truthy, $rb_gt = Opal.rb_gt, $gvars = Opal.gvars, $eqeq = Opal.eqeq, $const_set = Opal.const_set, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
13905
13906  Opal.add_stubs('[]=,now,-,delete,reduce,+,[],>,time,puts,sprintf,to_f,read_parse,convert,read_parse_convert,private,==,const_defined?,clock_gettime');
13907  return (function($base, $parent_nesting) {
13908    var self = $module($base, 'Asciidoctor');
13909
13910    var $nesting = [self].concat($parent_nesting);
13911
13912    return (function($base, $super, $parent_nesting) {
13913      var self = $klass($base, $super, 'Timings');
13914
13915      var $a, $b, $c, $d, $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
13916
13917      $proto.timers = $proto.log = nil;
13918
13919
13920      $def(self, '$initialize', function $$initialize() {
13921        var self = this;
13922
13923
13924        self.log = $hash2([], {});
13925        return (self.timers = $hash2([], {}));
13926      });
13927
13928      $def(self, '$start', function $$start(key) {
13929        var $a, self = this;
13930
13931        return ($a = [key, self.$now()], $send(self.timers, '[]=', $a), $a[$a.length - 1])
13932      });
13933
13934      $def(self, '$record', function $$record(key) {
13935        var $a, self = this;
13936
13937        return ($a = [key, $rb_minus(self.$now(), self.timers.$delete(key))], $send(self.log, '[]=', $a), $a[$a.length - 1])
13938      });
13939
13940      $def(self, '$time', function $$time($a) {
13941        var $post_args, keys, self = this, time = nil;
13942
13943
13944        $post_args = $slice(arguments);
13945        keys = $post_args;
13946        time = $send(keys, 'reduce', [0], function $$1(sum, key){var self = $$1.$$s == null ? this : $$1.$$s, $ret_or_1 = nil;
13947          if (self.log == null) self.log = nil;
13948
13949
13950          if (sum == null) sum = nil;
13951          if (key == null) key = nil;
13952          return $rb_plus(sum, ($truthy(($ret_or_1 = self.log['$[]'](key))) ? ($ret_or_1) : (0)));}, {$$s: self});
13953        if ($truthy($rb_gt(time, 0))) {
13954          return time
13955        } else {
13956          return nil
13957        };
13958      }, -1);
13959
13960      $def(self, '$read', function $$read() {
13961        var self = this;
13962
13963        return self.$time("read")
13964      });
13965
13966      $def(self, '$parse', function $$parse() {
13967        var self = this;
13968
13969        return self.$time("parse")
13970      });
13971
13972      $def(self, '$read_parse', function $$read_parse() {
13973        var self = this;
13974
13975        return self.$time("read", "parse")
13976      });
13977
13978      $def(self, '$convert', function $$convert() {
13979        var self = this;
13980
13981        return self.$time("convert")
13982      });
13983
13984      $def(self, '$read_parse_convert', function $$read_parse_convert() {
13985        var self = this;
13986
13987        return self.$time("read", "parse", "convert")
13988      });
13989
13990      $def(self, '$write', function $$write() {
13991        var self = this;
13992
13993        return self.$time("write")
13994      });
13995
13996      $def(self, '$total', function $$total() {
13997        var self = this;
13998
13999        return self.$time("read", "parse", "convert", "write")
14000      });
14001
14002      $def(self, '$print_report', function $$print_report(to, subject) {
14003        var self = this;
14004        if ($gvars.stdout == null) $gvars.stdout = nil;
14005
14006
14007        if (to == null) to = $gvars.stdout;
14008        if (subject == null) subject = nil;
14009        if ($truthy(subject)) {
14010          to.$puts("Input file: " + (subject))
14011        };
14012        to.$puts("  Time to read and parse source: " + (self.$sprintf("%05.5f", self.$read_parse().$to_f())));
14013        to.$puts("  Time to convert document: " + (self.$sprintf("%05.5f", self.$convert().$to_f())));
14014        return to.$puts("  Total time (read, parse and convert): " + (self.$sprintf("%05.5f", self.$read_parse_convert().$to_f())));
14015      }, -1);
14016      self.$private();
14017      if (($truthy($$$('Process')['$const_defined?']("CLOCK_MONOTONIC", false)) && ($eqeq(((($a = $$$('::', 'Process', 'skip_raise')) && ($b = $a, $b) && ($c = $b) && ((($d = $c.$clock_gettime) && !$d.$$stub) || $c['$respond_to_missing?']('clock_gettime'))) ? 'method' : nil), "method")))) {
14018
14019        $const_set($nesting[0], 'CLOCK_ID', $$$($$$('Process'), 'CLOCK_MONOTONIC'));
14020        return $def(self, '$now', function $$now() {
14021
14022          return $$$('Process').$clock_gettime($$('CLOCK_ID'))
14023        });
14024      } else {
14025        return $def(self, '$now', function $$now() {
14026
14027          return $$$('Time').$now()
14028        })
14029      };
14030    })($nesting[0], null, $nesting)
14031  })($nesting[0], $nesting)
14032};
14033
14034Opal.modules["asciidoctor/converter/html5"] = function(Opal) {/* Generated by Opal 1.7.3 */
14035  "use strict";
14036  var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $hash2 = Opal.hash2, $regexp = Opal.regexp, $eqeq = Opal.eqeq, $def = Opal.def, $send2 = Opal.send2, $find_super = Opal.find_super, $truthy = Opal.truthy, $send = Opal.send, $rb_gt = Opal.rb_gt, $rb_plus = Opal.rb_plus, $not = Opal.not, $neqeq = Opal.neqeq, $rb_le = Opal.rb_le, $rb_lt = Opal.rb_lt, $to_ary = Opal.to_ary, $rb_times = Opal.rb_times, $rb_minus = Opal.rb_minus, $gvars = Opal.gvars, $return_val = Opal.return_val, $alias = Opal.alias, $eqeqeq = Opal.eqeqeq, $slice = Opal.slice, $to_a = Opal.to_a, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
14037
14038  Opal.add_stubs('register_for,default=,==,[],init_backend_traits,node_name,convert_inline_quoted,convert_paragraph,convert_inline_anchor,convert_section,convert_listing,convert_literal,convert_ulist,convert_olist,convert_dlist,convert_admonition,convert_colist,convert_embedded,convert_example,convert_floating_title,convert_image,convert_inline_break,convert_inline_button,convert_inline_callout,convert_inline_footnote,convert_inline_image,convert_inline_indexterm,convert_inline_kbd,convert_inline_menu,convert_open,convert_page_break,convert_preamble,convert_quote,convert_sidebar,convert_stem,convert_table,convert_thematic_break,convert_verse,convert_video,convert_document,convert_toc,convert_pass,convert_audio,empty?,attr,attr?,<<,include?,sub_replacements,gsub,extname,slice,length,doctitle,normalize_web_path,primary_stylesheet_data,instance,read_contents,syntax_highlighter,size,docinfo,id,sections?,doctype,role?,role,join,noheader,convert,converter,generate_manname_section,header?,notitle,title,header,each,authors,>,name,email,sub_macros,+,downcase,concat,content,!,footnotes?,footnotes,index,text,nofooter,docinfo?,[]=,delete_at,inspect,!=,to_i,attributes,document,sections,level,caption,captioned_title,<=,numbered,<,sectname,sectnum,convert_outline,title?,icon_uri,compact,media_uri,option?,append_boolean_attribute,style,items,blocks?,text?,chomp,safe,read_svg_contents,alt,image_uri,encode_attribute_value,append_link_constraint_attrs,highlight?,to_sym,format,*,-,count,end_with?,start_with?,list_marker_keyword,parent,warn,logger,context,error,content_only,new,columns,to_h,rows,colspan,rowspan,unshift,shift,split,pop,nil_or_empty?,type,===,catalog,get_root_document,xreftext,target,reftext,chop,sub,match,private,upcase,nested?,parent_document,handles?,to_s,send');
14039  return (function($base, $parent_nesting) {
14040    var self = $module($base, 'Asciidoctor');
14041
14042    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
14043
14044    return (function($base, $super, $parent_nesting) {
14045      var self = $klass($base, $super, 'Html5Converter');
14046
14047      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
14048
14049      $proto.void_element_slash = $proto.xml_mode = $proto.refs = $proto.resolving_xref = nil;
14050
14051      self.$register_for("html5");
14052      $const_set($nesting[0], 'QUOTE_TAGS', $hash2(["monospaced", "emphasis", "strong", "double", "single", "mark", "superscript", "subscript", "asciimath", "latexmath"], {"monospaced": ["<code>", "</code>", true], "emphasis": ["<em>", "</em>", true], "strong": ["<strong>", "</strong>", true], "double": ["&#8220;", "&#8221;"], "single": ["&#8216;", "&#8217;"], "mark": ["<mark>", "</mark>", true], "superscript": ["<sup>", "</sup>", true], "subscript": ["<sub>", "</sub>", true], "asciimath": ["\\$", "\\$"], "latexmath": ["\\(", "\\)"]}))['$default='](["", ""]);
14053      $const_set($nesting[0], 'DropAnchorRx', /<(?:a\b[^>]*|\/a)>/);
14054      $const_set($nesting[0], 'StemBreakRx', / *\\\n(?:\\?\n)*|\n\n+/);
14055
14056      $const_set($nesting[0], 'SvgPreambleRx', $regexp(["^", $$('CC_ALL'), "*?(?=<svg[\\s>])"]));
14057      $const_set($nesting[0], 'SvgStartTagRx', /^<svg(?:\s[^>]*)?>/);;
14058      $const_set($nesting[0], 'DimensionAttributeRx', $regexp(["\\s(?:width|height|style)=([\"'])", $$('CC_ANY'), "*?\\1"]));
14059
14060      $def(self, '$initialize', function $$initialize(backend, opts) {
14061        var self = this, syntax = nil;
14062
14063
14064        if (opts == null) opts = $hash2([], {});
14065        self.backend = backend;
14066        if ($eqeq(opts['$[]']("htmlsyntax"), "xml")) {
14067
14068          syntax = "xml";
14069          self.xml_mode = true;
14070          self.void_element_slash = "/";
14071        } else {
14072
14073          syntax = "html";
14074          self.xml_mode = nil;
14075          self.void_element_slash = "";
14076        };
14077        return self.$init_backend_traits($hash2(["basebackend", "filetype", "htmlsyntax", "outfilesuffix", "supports_templates"], {"basebackend": "html", "filetype": "html", "htmlsyntax": syntax, "outfilesuffix": ".html", "supports_templates": true}));
14078      }, -2);
14079
14080      $def(self, '$convert', function $$convert(node, transform, opts) {
14081        var $yield = $$convert.$$p || nil, self = this;
14082
14083        $$convert.$$p = null;
14084
14085        if (transform == null) transform = node.$node_name();
14086        if (opts == null) opts = nil;
14087
14088        switch (transform) {
14089          case "inline_quoted":
14090            return self.$convert_inline_quoted(node)
14091          case "paragraph":
14092            return self.$convert_paragraph(node)
14093          case "inline_anchor":
14094            return self.$convert_inline_anchor(node)
14095          case "section":
14096            return self.$convert_section(node)
14097          case "listing":
14098            return self.$convert_listing(node)
14099          case "literal":
14100            return self.$convert_literal(node)
14101          case "ulist":
14102            return self.$convert_ulist(node)
14103          case "olist":
14104            return self.$convert_olist(node)
14105          case "dlist":
14106            return self.$convert_dlist(node)
14107          case "admonition":
14108            return self.$convert_admonition(node)
14109          case "colist":
14110            return self.$convert_colist(node)
14111          case "embedded":
14112            return self.$convert_embedded(node)
14113          case "example":
14114            return self.$convert_example(node)
14115          case "floating_title":
14116            return self.$convert_floating_title(node)
14117          case "image":
14118            return self.$convert_image(node)
14119          case "inline_break":
14120            return self.$convert_inline_break(node)
14121          case "inline_button":
14122            return self.$convert_inline_button(node)
14123          case "inline_callout":
14124            return self.$convert_inline_callout(node)
14125          case "inline_footnote":
14126            return self.$convert_inline_footnote(node)
14127          case "inline_image":
14128            return self.$convert_inline_image(node)
14129          case "inline_indexterm":
14130            return self.$convert_inline_indexterm(node)
14131          case "inline_kbd":
14132            return self.$convert_inline_kbd(node)
14133          case "inline_menu":
14134            return self.$convert_inline_menu(node)
14135          case "open":
14136            return self.$convert_open(node)
14137          case "page_break":
14138            return self.$convert_page_break(node)
14139          case "preamble":
14140            return self.$convert_preamble(node)
14141          case "quote":
14142            return self.$convert_quote(node)
14143          case "sidebar":
14144            return self.$convert_sidebar(node)
14145          case "stem":
14146            return self.$convert_stem(node)
14147          case "table":
14148            return self.$convert_table(node)
14149          case "thematic_break":
14150            return self.$convert_thematic_break(node)
14151          case "verse":
14152            return self.$convert_verse(node)
14153          case "video":
14154            return self.$convert_video(node)
14155          case "document":
14156            return self.$convert_document(node)
14157          case "toc":
14158            return self.$convert_toc(node)
14159          case "pass":
14160            return self.$convert_pass(node)
14161          case "audio":
14162            return self.$convert_audio(node)
14163          default:
14164            return $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [node, transform, opts], $yield)
14165        };
14166      }, -2);
14167
14168      $def(self, '$convert_document', function $$convert_document(node) {
14169        var self = this, br = nil, slash = nil, asset_uri_scheme = nil, cdn_base_url = nil, linkcss = nil, max_width_attr = nil, result = nil, lang_attribute = nil, authors = nil, icon_href = nil, icon_type = nil, icon_ext = nil, webfonts = nil, iconfont_stylesheet = nil, syntax_hl = nil, syntax_hl_docinfo_head_idx = nil, docinfo_content = nil, id_attr = nil, sectioned = nil, classes = nil, details = nil, idx = nil, $ret_or_1 = nil, eqnums_val = nil, eqnums_opt = nil;
14170
14171
14172        br = "<br" + ((slash = self.void_element_slash)) + ">";
14173        if (!$truthy((asset_uri_scheme = node.$attr("asset-uri-scheme", "https"))['$empty?']())) {
14174          asset_uri_scheme = "" + (asset_uri_scheme) + ":"
14175        };
14176        cdn_base_url = "" + (asset_uri_scheme) + "//cdnjs.cloudflare.com/ajax/libs";
14177        linkcss = node['$attr?']("linkcss");
14178        max_width_attr = ($truthy(node['$attr?']("max-width")) ? (" style=\"max-width: " + (node.$attr("max-width")) + ";\"") : (""));
14179        result = ["<!DOCTYPE html>"];
14180        lang_attribute = ($truthy(node['$attr?']("nolang")) ? ("") : (" lang=\"" + (node.$attr("lang", "en")) + "\""));
14181        result['$<<']("<html" + (($truthy(self.xml_mode) ? (" xmlns=\"http://www.w3.org/1999/xhtml\"") : (""))) + (lang_attribute) + ">");
14182        result['$<<']("<head>\n" + "<meta charset=\"" + (node.$attr("encoding", "UTF-8")) + "\"" + (slash) + ">\n" + "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"" + (slash) + ">\n" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"" + (slash) + ">\n" + "<meta name=\"generator\" content=\"Asciidoctor " + (node.$attr("asciidoctor-version")) + "\"" + (slash) + ">");
14183        if ($truthy(node['$attr?']("app-name"))) {
14184          result['$<<']("<meta name=\"application-name\" content=\"" + (node.$attr("app-name")) + "\"" + (slash) + ">")
14185        };
14186        if ($truthy(node['$attr?']("description"))) {
14187          result['$<<']("<meta name=\"description\" content=\"" + (node.$attr("description")) + "\"" + (slash) + ">")
14188        };
14189        if ($truthy(node['$attr?']("keywords"))) {
14190          result['$<<']("<meta name=\"keywords\" content=\"" + (node.$attr("keywords")) + "\"" + (slash) + ">")
14191        };
14192        if ($truthy(node['$attr?']("authors"))) {
14193          result['$<<']("<meta name=\"author\" content=\"" + (($truthy((authors = node.$sub_replacements(node.$attr("authors")))['$include?']("<")) ? (authors.$gsub($$('XmlSanitizeRx'), "")) : (authors))) + "\"" + (slash) + ">")
14194        };
14195        if ($truthy(node['$attr?']("copyright"))) {
14196          result['$<<']("<meta name=\"copyright\" content=\"" + (node.$attr("copyright")) + "\"" + (slash) + ">")
14197        };
14198        if ($truthy(node['$attr?']("favicon"))) {
14199
14200          if ($truthy((icon_href = node.$attr("favicon"))['$empty?']())) {
14201
14202            icon_href = "favicon.ico";
14203            icon_type = "image/x-icon";
14204          } else if ($truthy((icon_ext = $$('Helpers').$extname(icon_href, nil)))) {
14205            icon_type = ($eqeq(icon_ext, ".ico") ? ("image/x-icon") : ("image/" + (icon_ext.$slice(1, icon_ext.$length()))))
14206          } else {
14207            icon_type = "image/x-icon"
14208          };
14209          result['$<<']("<link rel=\"icon\" type=\"" + (icon_type) + "\" href=\"" + (icon_href) + "\"" + (slash) + ">");
14210        };
14211        result['$<<']("<title>" + (node.$doctitle($hash2(["sanitize", "use_fallback"], {"sanitize": true, "use_fallback": true}))) + "</title>");
14212        if ($truthy($$('DEFAULT_STYLESHEET_KEYS')['$include?'](node.$attr("stylesheet")))) {
14213
14214          if ($truthy((webfonts = node.$attr("webfonts")))) {
14215            result['$<<']("<link rel=\"stylesheet\" href=\"" + (asset_uri_scheme) + "//fonts.googleapis.com/css?family=" + (($truthy(webfonts['$empty?']()) ? ("Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700") : (webfonts))) + "\"" + (slash) + ">")
14216          };
14217          if ($truthy(linkcss)) {
14218            result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path($$('DEFAULT_STYLESHEET_NAME'), node.$attr("stylesdir", ""), false)) + "\"" + (slash) + ">")
14219          } else {
14220            result['$<<']("<style>\n" + ($$('Stylesheets').$instance().$primary_stylesheet_data()) + "\n" + "</style>")
14221          };
14222        } else if ($truthy(node['$attr?']("stylesheet"))) {
14223          if ($truthy(linkcss)) {
14224            result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path(node.$attr("stylesheet"), node.$attr("stylesdir", ""))) + "\"" + (slash) + ">")
14225          } else {
14226            result['$<<']("<style>\n" + (node.$read_contents(node.$attr("stylesheet"), $hash2(["start", "warn_on_failure", "label"], {"start": node.$attr("stylesdir"), "warn_on_failure": true, "label": "stylesheet"}))) + "\n" + "</style>")
14227          }
14228        };
14229        if ($truthy(node['$attr?']("icons", "font"))) {
14230          if ($truthy(node['$attr?']("iconfont-remote"))) {
14231            result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$attr("iconfont-cdn", "" + (cdn_base_url) + "/font-awesome/" + ($$('FONT_AWESOME_VERSION')) + "/css/font-awesome.min.css")) + "\"" + (slash) + ">")
14232          } else {
14233
14234            iconfont_stylesheet = "" + (node.$attr("iconfont-name", "font-awesome")) + ".css";
14235            result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path(iconfont_stylesheet, node.$attr("stylesdir", ""), false)) + "\"" + (slash) + ">");
14236          }
14237        };
14238        if ($truthy((syntax_hl = node.$syntax_highlighter()))) {
14239          result['$<<']((syntax_hl_docinfo_head_idx = result.$size()))
14240        };
14241        if (!$truthy((docinfo_content = node.$docinfo())['$empty?']())) {
14242          result['$<<'](docinfo_content)
14243        };
14244        result['$<<']("</head>");
14245        id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14246        if (((($truthy((sectioned = node['$sections?']())) && ($truthy(node['$attr?']("toc-class")))) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) {
14247          classes = [node.$doctype(), node.$attr("toc-class"), "toc-" + (node.$attr("toc-position", "header"))]
14248        } else {
14249          classes = [node.$doctype()]
14250        };
14251        if ($truthy(node['$role?']())) {
14252          classes['$<<'](node.$role())
14253        };
14254        result['$<<']("<body" + (id_attr) + " class=\"" + (classes.$join(" ")) + "\">");
14255        if (!$truthy((docinfo_content = node.$docinfo("header"))['$empty?']())) {
14256          result['$<<'](docinfo_content)
14257        };
14258        if (!$truthy(node.$noheader())) {
14259
14260          result['$<<']("<div id=\"header\"" + (max_width_attr) + ">");
14261          if ($eqeq(node.$doctype(), "manpage")) {
14262
14263            result['$<<']("<h1>" + (node.$doctitle()) + " Manual Page</h1>");
14264            if ((($truthy(sectioned) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) {
14265              result['$<<']("<div id=\"toc\" class=\"" + (node.$attr("toc-class", "toc")) + "\">\n" + "<div id=\"toctitle\">" + (node.$attr("toc-title")) + "</div>\n" + (node.$converter().$convert(node, "outline")) + "\n" + "</div>")
14266            };
14267            if ($truthy(node['$attr?']("manpurpose"))) {
14268              result['$<<'](self.$generate_manname_section(node))
14269            };
14270          } else {
14271
14272            if ($truthy(node['$header?']())) {
14273
14274              if (!$truthy(node.$notitle())) {
14275                result['$<<']("<h1>" + (node.$header().$title()) + "</h1>")
14276              };
14277              details = [];
14278              idx = 1;
14279              $send(node.$authors(), 'each', [], function $$1(author){
14280
14281                if (author == null) author = nil;
14282                details['$<<']("<span id=\"author" + (($truthy($rb_gt(idx, 1)) ? (idx) : (""))) + "\" class=\"author\">" + (node.$sub_replacements(author.$name())) + "</span>" + (br));
14283                if ($truthy(author.$email())) {
14284                  details['$<<']("<span id=\"email" + (($truthy($rb_gt(idx, 1)) ? (idx) : (""))) + "\" class=\"email\">" + (node.$sub_macros(author.$email())) + "</span>" + (br))
14285                };
14286                return (idx = $rb_plus(idx, 1));});
14287              if ($truthy(node['$attr?']("revnumber"))) {
14288                details['$<<']("<span id=\"revnumber\">" + (($truthy(($ret_or_1 = node.$attr("version-label"))) ? ($ret_or_1) : ("")).$downcase()) + " " + (node.$attr("revnumber")) + (($truthy(node['$attr?']("revdate")) ? (",") : (""))) + "</span>")
14289              };
14290              if ($truthy(node['$attr?']("revdate"))) {
14291                details['$<<']("<span id=\"revdate\">" + (node.$attr("revdate")) + "</span>")
14292              };
14293              if ($truthy(node['$attr?']("revremark"))) {
14294                details['$<<']("" + (br) + "<span id=\"revremark\">" + (node.$attr("revremark")) + "</span>")
14295              };
14296              if (!$truthy(details['$empty?']())) {
14297
14298                result['$<<']("<div class=\"details\">");
14299                result.$concat(details);
14300                result['$<<']("</div>");
14301              };
14302            };
14303            if ((($truthy(sectioned) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) {
14304              result['$<<']("<div id=\"toc\" class=\"" + (node.$attr("toc-class", "toc")) + "\">\n" + "<div id=\"toctitle\">" + (node.$attr("toc-title")) + "</div>\n" + (node.$converter().$convert(node, "outline")) + "\n" + "</div>")
14305            };
14306          };
14307          result['$<<']("</div>");
14308        };
14309        result['$<<']("<div id=\"content\"" + (max_width_attr) + ">\n" + (node.$content()) + "\n" + "</div>");
14310        if (($truthy(node['$footnotes?']()) && ($not(node['$attr?']("nofootnotes"))))) {
14311
14312          result['$<<']("<div id=\"footnotes\"" + (max_width_attr) + ">\n" + "<hr" + (slash) + ">");
14313          $send(node.$footnotes(), 'each', [], function $$2(footnote){
14314
14315            if (footnote == null) footnote = nil;
14316            return result['$<<']("<div class=\"footnote\" id=\"_footnotedef_" + (footnote.$index()) + "\">\n" + "<a href=\"#_footnoteref_" + (footnote.$index()) + "\">" + (footnote.$index()) + "</a>. " + (footnote.$text()) + "\n" + "</div>");});
14317          result['$<<']("</div>");
14318        };
14319        if (!$truthy(node.$nofooter())) {
14320
14321          result['$<<']("<div id=\"footer\"" + (max_width_attr) + ">");
14322          result['$<<']("<div id=\"footer-text\">");
14323          if ($truthy(node['$attr?']("revnumber"))) {
14324            result['$<<']("" + (node.$attr("version-label")) + " " + (node.$attr("revnumber")) + (br))
14325          };
14326          if (($truthy(node['$attr?']("last-update-label")) && ($not(node['$attr?']("reproducible"))))) {
14327            result['$<<']("" + (node.$attr("last-update-label")) + " " + (node.$attr("docdatetime")))
14328          };
14329          result['$<<']("</div>");
14330          result['$<<']("</div>");
14331        };
14332        if ($truthy(syntax_hl)) {
14333
14334          if ($truthy(syntax_hl['$docinfo?']("head"))) {
14335            result['$[]='](syntax_hl_docinfo_head_idx, syntax_hl.$docinfo("head", node, $hash2(["cdn_base_url", "linkcss", "self_closing_tag_slash"], {"cdn_base_url": cdn_base_url, "linkcss": linkcss, "self_closing_tag_slash": slash})))
14336          } else {
14337            result.$delete_at(syntax_hl_docinfo_head_idx)
14338          };
14339          if ($truthy(syntax_hl['$docinfo?']("footer"))) {
14340            result['$<<'](syntax_hl.$docinfo("footer", node, $hash2(["cdn_base_url", "linkcss", "self_closing_tag_slash"], {"cdn_base_url": cdn_base_url, "linkcss": linkcss, "self_closing_tag_slash": slash})))
14341          };
14342        };
14343        if ($truthy(node['$attr?']("stem"))) {
14344
14345          eqnums_val = node.$attr("eqnums", "none");
14346          if ($truthy(eqnums_val['$empty?']())) {
14347            eqnums_val = "AMS"
14348          };
14349          eqnums_opt = " equationNumbers: { autoNumber: \"" + (eqnums_val) + "\" } ";
14350          result['$<<']("<script type=\"text/x-mathjax-config\">\n" + "MathJax.Hub.Config({\n" + "  messageStyle: \"none\",\n" + "  tex2jax: {\n" + "    inlineMath: [" + ($$('INLINE_MATH_DELIMITERS')['$[]']("latexmath").$inspect()) + "],\n" + "    displayMath: [" + ($$('BLOCK_MATH_DELIMITERS')['$[]']("latexmath").$inspect()) + "],\n" + "    ignoreClass: \"nostem|nolatexmath\"\n" + "  },\n" + "  asciimath2jax: {\n" + "    delimiters: [" + ($$('BLOCK_MATH_DELIMITERS')['$[]']("asciimath").$inspect()) + "],\n" + "    ignoreClass: \"nostem|noasciimath\"\n" + "  },\n" + "  TeX: {" + (eqnums_opt) + "}\n" + "})\n" + "MathJax.Hub.Register.StartupHook(\"AsciiMath Jax Ready\", function () {\n" + "  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {\n" + "    if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains(\"stemblock\")) {\n" + "      data.math.root.display = \"block\"\n" + "    }\n" + "    return data\n" + "  })\n" + "})\n" + "</script>\n" + "<script src=\"" + (cdn_base_url) + "/mathjax/" + ($$('MATHJAX_VERSION')) + "/MathJax.js?config=TeX-MML-AM_HTMLorMML\"></script>");
14351        };
14352        if (!$truthy((docinfo_content = node.$docinfo("footer"))['$empty?']())) {
14353          result['$<<'](docinfo_content)
14354        };
14355        result['$<<']("</body>");
14356        result['$<<']("</html>");
14357        return result.$join($$('LF'));
14358      });
14359
14360      $def(self, '$convert_embedded', function $$convert_embedded(node) {
14361        var self = this, result = nil, id_attr = nil, toc_p = nil;
14362
14363
14364        result = [];
14365        if ($eqeq(node.$doctype(), "manpage")) {
14366
14367          if (!$truthy(node.$notitle())) {
14368
14369            id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14370            result['$<<']("<h1" + (id_attr) + ">" + (node.$doctitle()) + " Manual Page</h1>");
14371          };
14372          if ($truthy(node['$attr?']("manpurpose"))) {
14373            result['$<<'](self.$generate_manname_section(node))
14374          };
14375        } else if (($truthy(node['$header?']()) && ($not(node.$notitle())))) {
14376
14377          id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14378          result['$<<']("<h1" + (id_attr) + ">" + (node.$header().$title()) + "</h1>");
14379        };
14380        if (((($truthy(node['$sections?']()) && ($truthy(node['$attr?']("toc")))) && ($neqeq((toc_p = node.$attr("toc-placement")), "macro"))) && ($neqeq(toc_p, "preamble")))) {
14381          result['$<<']("<div id=\"toc\" class=\"toc\">\n" + "<div id=\"toctitle\">" + (node.$attr("toc-title")) + "</div>\n" + (node.$converter().$convert(node, "outline")) + "\n" + "</div>")
14382        };
14383        result['$<<'](node.$content());
14384        if (($truthy(node['$footnotes?']()) && ($not(node['$attr?']("nofootnotes"))))) {
14385
14386          result['$<<']("<div id=\"footnotes\">\n" + "<hr" + (self.void_element_slash) + ">");
14387          $send(node.$footnotes(), 'each', [], function $$3(footnote){
14388
14389            if (footnote == null) footnote = nil;
14390            return result['$<<']("<div class=\"footnote\" id=\"_footnotedef_" + (footnote.$index()) + "\">\n" + "<a href=\"#_footnoteref_" + (footnote.$index()) + "\">" + (footnote.$index()) + "</a>. " + (footnote.$text()) + "\n" + "</div>");});
14391          result['$<<']("</div>");
14392        };
14393        return result.$join($$('LF'));
14394      });
14395
14396      $def(self, '$convert_outline', function $$convert_outline(node, opts) {
14397        var self = this, sectnumlevels = nil, $ret_or_1 = nil, $ret_or_2 = nil, toclevels = nil, sections = nil, result = nil;
14398
14399
14400        if (opts == null) opts = $hash2([], {});
14401        if (!$truthy(node['$sections?']())) {
14402          return nil
14403        };
14404        sectnumlevels = ($truthy(($ret_or_1 = opts['$[]']("sectnumlevels"))) ? ($ret_or_1) : (($truthy(($ret_or_2 = node.$document().$attributes()['$[]']("sectnumlevels"))) ? ($ret_or_2) : (3)).$to_i()));
14405        toclevels = ($truthy(($ret_or_1 = opts['$[]']("toclevels"))) ? ($ret_or_1) : (($truthy(($ret_or_2 = node.$document().$attributes()['$[]']("toclevels"))) ? ($ret_or_2) : (2)).$to_i()));
14406        sections = node.$sections();
14407        result = ["<ul class=\"sectlevel" + (sections['$[]'](0).$level()) + "\">"];
14408        $send(sections, 'each', [], function $$4(section){var self = $$4.$$s == null ? this : $$4.$$s, slevel = nil, stitle = nil, signifier = nil, child_toc_level = nil;
14409
14410
14411          if (section == null) section = nil;
14412          slevel = section.$level();
14413          if ($truthy(section.$caption())) {
14414            stitle = section.$captioned_title()
14415          } else if (($truthy(section.$numbered()) && ($truthy($rb_le(slevel, sectnumlevels))))) {
14416            if (($truthy($rb_lt(slevel, 2)) && ($eqeq(node.$document().$doctype(), "book")))) {
14417
14418              switch (section.$sectname()) {
14419                case "chapter":
14420                  stitle = "" + (($truthy((signifier = node.$document().$attributes()['$[]']("chapter-signifier"))) ? ("" + (signifier) + " ") : (""))) + (section.$sectnum()) + " " + (section.$title())
14421                  break;
14422                case "part":
14423                  stitle = "" + (($truthy((signifier = node.$document().$attributes()['$[]']("part-signifier"))) ? ("" + (signifier) + " ") : (""))) + (section.$sectnum(nil, ":")) + " " + (section.$title())
14424                  break;
14425                default:
14426                  stitle = "" + (section.$sectnum()) + " " + (section.$title())
14427              }
14428            } else {
14429              stitle = "" + (section.$sectnum()) + " " + (section.$title())
14430            }
14431          } else {
14432            stitle = section.$title()
14433          };
14434          if ($truthy(stitle['$include?']("<a"))) {
14435            stitle = stitle.$gsub($$('DropAnchorRx'), "")
14436          };
14437          if (($truthy($rb_lt(slevel, toclevels)) && ($truthy((child_toc_level = self.$convert_outline(section, $hash2(["toclevels", "sectnumlevels"], {"toclevels": toclevels, "sectnumlevels": sectnumlevels}))))))) {
14438
14439            result['$<<']("<li><a href=\"#" + (section.$id()) + "\">" + (stitle) + "</a>");
14440            result['$<<'](child_toc_level);
14441            return result['$<<']("</li>");
14442          } else {
14443            return result['$<<']("<li><a href=\"#" + (section.$id()) + "\">" + (stitle) + "</a></li>")
14444          };}, {$$s: self});
14445        result['$<<']("</ul>");
14446        return result.$join($$('LF'));
14447      }, -2);
14448
14449      $def(self, '$convert_section', function $$convert_section(node) {
14450        var doc_attrs = nil, level = nil, title = nil, $ret_or_1 = nil, signifier = nil, id_attr = nil, id = nil, role = nil;
14451
14452
14453        doc_attrs = node.$document().$attributes();
14454        level = node.$level();
14455        if ($truthy(node.$caption())) {
14456          title = node.$captioned_title()
14457        } else if (($truthy(node.$numbered()) && ($truthy($rb_le(level, ($truthy(($ret_or_1 = doc_attrs['$[]']("sectnumlevels"))) ? ($ret_or_1) : (3)).$to_i()))))) {
14458          if (($truthy($rb_lt(level, 2)) && ($eqeq(node.$document().$doctype(), "book")))) {
14459
14460            switch (node.$sectname()) {
14461              case "chapter":
14462                title = "" + (($truthy((signifier = doc_attrs['$[]']("chapter-signifier"))) ? ("" + (signifier) + " ") : (""))) + (node.$sectnum()) + " " + (node.$title())
14463                break;
14464              case "part":
14465                title = "" + (($truthy((signifier = doc_attrs['$[]']("part-signifier"))) ? ("" + (signifier) + " ") : (""))) + (node.$sectnum(nil, ":")) + " " + (node.$title())
14466                break;
14467              default:
14468                title = "" + (node.$sectnum()) + " " + (node.$title())
14469            }
14470          } else {
14471            title = "" + (node.$sectnum()) + " " + (node.$title())
14472          }
14473        } else {
14474          title = node.$title()
14475        };
14476        if ($truthy(node.$id())) {
14477
14478          id_attr = " id=\"" + ((id = node.$id())) + "\"";
14479          if ($truthy(doc_attrs['$[]']("sectlinks"))) {
14480            title = "<a class=\"link\" href=\"#" + (id) + "\">" + (title) + "</a>"
14481          };
14482          if ($truthy(doc_attrs['$[]']("sectanchors"))) {
14483            if ($eqeq(doc_attrs['$[]']("sectanchors"), "after")) {
14484              title = "" + (title) + "<a class=\"anchor\" href=\"#" + (id) + "\"></a>"
14485            } else {
14486              title = "<a class=\"anchor\" href=\"#" + (id) + "\"></a>" + (title)
14487            }
14488          };
14489        } else {
14490          id_attr = ""
14491        };
14492        if ($eqeq(level, 0)) {
14493          return "<h1" + (id_attr) + " class=\"sect0" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">" + (title) + "</h1>\n" + (node.$content())
14494        } else {
14495          return "<div class=\"sect" + (level) + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + "<h" + ($rb_plus(level, 1)) + (id_attr) + ">" + (title) + "</h" + ($rb_plus(level, 1)) + ">\n" + (($eqeq(level, 1) ? ("<div class=\"sectionbody\">\n" + (node.$content()) + "\n" + "</div>") : (node.$content()))) + "\n" + "</div>"
14496        };
14497      });
14498
14499      $def(self, '$convert_admonition', function $$convert_admonition(node) {
14500        var self = this, id_attr = nil, name = nil, title_element = nil, label = nil, role = nil;
14501
14502
14503        id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14504        name = node.$attr("name");
14505        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14506        if ($truthy(node.$document()['$attr?']("icons"))) {
14507          if (($truthy(node.$document()['$attr?']("icons", "font")) && ($not(node['$attr?']("icon"))))) {
14508            label = "<i class=\"fa icon-" + (name) + "\" title=\"" + (node.$attr("textlabel")) + "\"></i>"
14509          } else {
14510            label = "<img src=\"" + (node.$icon_uri(name)) + "\" alt=\"" + (node.$attr("textlabel")) + "\"" + (self.void_element_slash) + ">"
14511          }
14512        } else {
14513          label = "<div class=\"title\">" + (node.$attr("textlabel")) + "</div>"
14514        };
14515        return "<div" + (id_attr) + " class=\"admonitionblock " + (name) + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + "<table>\n" + "<tr>\n" + "<td class=\"icon\">\n" + (label) + "\n" + "</td>\n" + "<td class=\"content\">\n" + (title_element) + (node.$content()) + "\n" + "</td>\n" + "</tr>\n" + "</table>\n" + "</div>";
14516      });
14517
14518      $def(self, '$convert_audio', function $$convert_audio(node) {
14519        var self = this, xml = nil, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil, start_t = nil, end_t = nil, time_anchor = nil, $ret_or_1 = nil;
14520
14521
14522        xml = self.xml_mode;
14523        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14524        classes = ["audioblock", node.$role()].$compact();
14525        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
14526        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14527        start_t = node.$attr("start");
14528        end_t = node.$attr("end");
14529        time_anchor = (($truthy(start_t) || ($truthy(end_t))) ? ("#t=" + (($truthy(($ret_or_1 = start_t)) ? ($ret_or_1) : (""))) + (($truthy(end_t) ? ("," + (end_t)) : ("")))) : (""));
14530        return "<div" + (id_attribute) + (class_attribute) + ">\n" + (title_element) + "<div class=\"content\">\n" + "<audio src=\"" + (node.$media_uri(node.$attr("target"))) + (time_anchor) + "\"" + (($truthy(node['$option?']("autoplay")) ? (self.$append_boolean_attribute("autoplay", xml)) : (""))) + (($truthy(node['$option?']("nocontrols")) ? ("") : (self.$append_boolean_attribute("controls", xml)))) + (($truthy(node['$option?']("loop")) ? (self.$append_boolean_attribute("loop", xml)) : (""))) + ">\n" + "Your browser does not support the audio tag.\n" + "</audio>\n" + "</div>\n" + "</div>";
14531      });
14532
14533      $def(self, '$convert_colist', function $$convert_colist(node) {
14534        var $a, self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, font_icons = nil, num = nil;
14535
14536
14537        result = [];
14538        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14539        classes = ["colist", node.$style(), node.$role()].$compact();
14540        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
14541        result['$<<']("<div" + (id_attribute) + (class_attribute) + ">");
14542        if ($truthy(node['$title?']())) {
14543          result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>")
14544        };
14545        if ($truthy(node.$document()['$attr?']("icons"))) {
14546
14547          result['$<<']("<table>");
14548          $a = [node.$document()['$attr?']("icons", "font"), 0], (font_icons = $a[0]), (num = $a[1]), $a;
14549          $send(node.$items(), 'each', [], function $$5(item){var self = $$5.$$s == null ? this : $$5.$$s, num_label = nil;
14550            if (self.void_element_slash == null) self.void_element_slash = nil;
14551
14552
14553            if (item == null) item = nil;
14554            num = $rb_plus(num, 1);
14555            if ($truthy(font_icons)) {
14556              num_label = "<i class=\"conum\" data-value=\"" + (num) + "\"></i><b>" + (num) + "</b>"
14557            } else {
14558              num_label = "<img src=\"" + (node.$icon_uri("callouts/" + (num))) + "\" alt=\"" + (num) + "\"" + (self.void_element_slash) + ">"
14559            };
14560            return result['$<<']("<tr>\n" + "<td>" + (num_label) + "</td>\n" + "<td>" + (item.$text()) + (($truthy(item['$blocks?']()) ? ($rb_plus($$('LF'), item.$content())) : (""))) + "</td>\n" + "</tr>");}, {$$s: self});
14561          result['$<<']("</table>");
14562        } else {
14563
14564          result['$<<']("<ol>");
14565          $send(node.$items(), 'each', [], function $$6(item){
14566
14567            if (item == null) item = nil;
14568            return result['$<<']("<li>\n" + "<p>" + (item.$text()) + "</p>" + (($truthy(item['$blocks?']()) ? ($rb_plus($$('LF'), item.$content())) : (""))) + "\n" + "</li>");});
14569          result['$<<']("</ol>");
14570        };
14571        result['$<<']("</div>");
14572        return result.$join($$('LF'));
14573      });
14574
14575      $def(self, '$convert_dlist', function $$convert_dlist(node) {
14576        var self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, slash = nil, col_style_attribute = nil, dt_style_attribute = nil;
14577
14578
14579        result = [];
14580        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14581
14582        switch (node.$style()) {
14583          case "qanda":
14584            classes = ["qlist", "qanda", node.$role()]
14585            break;
14586          case "horizontal":
14587            classes = ["hdlist", node.$role()]
14588            break;
14589          default:
14590            classes = ["dlist", node.$style(), node.$role()]
14591        };
14592        class_attribute = " class=\"" + (classes.$compact().$join(" ")) + "\"";
14593        result['$<<']("<div" + (id_attribute) + (class_attribute) + ">");
14594        if ($truthy(node['$title?']())) {
14595          result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>")
14596        };
14597
14598        switch (node.$style()) {
14599          case "qanda":
14600
14601            result['$<<']("<ol>");
14602            $send(node.$items(), 'each', [], function $$7(terms, dd){
14603
14604              if (terms == null) terms = nil;
14605              if (dd == null) dd = nil;
14606              result['$<<']("<li>");
14607              $send(terms, 'each', [], function $$8(dt){
14608
14609                if (dt == null) dt = nil;
14610                return result['$<<']("<p><em>" + (dt.$text()) + "</em></p>");});
14611              if ($truthy(dd)) {
14612
14613                if ($truthy(dd['$text?']())) {
14614                  result['$<<']("<p>" + (dd.$text()) + "</p>")
14615                };
14616                if ($truthy(dd['$blocks?']())) {
14617                  result['$<<'](dd.$content())
14618                };
14619              };
14620              return result['$<<']("</li>");});
14621            result['$<<']("</ol>");
14622            break;
14623          case "horizontal":
14624
14625            slash = self.void_element_slash;
14626            result['$<<']("<table>");
14627            if (($truthy(node['$attr?']("labelwidth")) || ($truthy(node['$attr?']("itemwidth"))))) {
14628
14629              result['$<<']("<colgroup>");
14630              col_style_attribute = ($truthy(node['$attr?']("labelwidth")) ? (" style=\"width: " + (node.$attr("labelwidth").$chomp("%")) + "%;\"") : (""));
14631              result['$<<']("<col" + (col_style_attribute) + (slash) + ">");
14632              col_style_attribute = ($truthy(node['$attr?']("itemwidth")) ? (" style=\"width: " + (node.$attr("itemwidth").$chomp("%")) + "%;\"") : (""));
14633              result['$<<']("<col" + (col_style_attribute) + (slash) + ">");
14634              result['$<<']("</colgroup>");
14635            };
14636            $send(node.$items(), 'each', [], function $$9(terms, dd){var first_term = nil;
14637
14638
14639              if (terms == null) terms = nil;
14640              if (dd == null) dd = nil;
14641              result['$<<']("<tr>");
14642              result['$<<']("<td class=\"hdlist1" + (($truthy(node['$option?']("strong")) ? (" strong") : (""))) + "\">");
14643              first_term = true;
14644              $send(terms, 'each', [], function $$10(dt){
14645
14646                if (dt == null) dt = nil;
14647                if (!$truthy(first_term)) {
14648                  result['$<<']("<br" + (slash) + ">")
14649                };
14650                result['$<<'](dt.$text());
14651                return (first_term = nil);});
14652              result['$<<']("</td>");
14653              result['$<<']("<td class=\"hdlist2\">");
14654              if ($truthy(dd)) {
14655
14656                if ($truthy(dd['$text?']())) {
14657                  result['$<<']("<p>" + (dd.$text()) + "</p>")
14658                };
14659                if ($truthy(dd['$blocks?']())) {
14660                  result['$<<'](dd.$content())
14661                };
14662              };
14663              result['$<<']("</td>");
14664              return result['$<<']("</tr>");});
14665            result['$<<']("</table>");
14666            break;
14667          default:
14668
14669            result['$<<']("<dl>");
14670            dt_style_attribute = ($truthy(node.$style()) ? ("") : (" class=\"hdlist1\""));
14671            $send(node.$items(), 'each', [], function $$11(terms, dd){
14672
14673              if (terms == null) terms = nil;
14674              if (dd == null) dd = nil;
14675              $send(terms, 'each', [], function $$12(dt){
14676
14677                if (dt == null) dt = nil;
14678                return result['$<<']("<dt" + (dt_style_attribute) + ">" + (dt.$text()) + "</dt>");});
14679              if (!$truthy(dd)) {
14680                return nil
14681              };
14682              result['$<<']("<dd>");
14683              if ($truthy(dd['$text?']())) {
14684                result['$<<']("<p>" + (dd.$text()) + "</p>")
14685              };
14686              if ($truthy(dd['$blocks?']())) {
14687                result['$<<'](dd.$content())
14688              };
14689              return result['$<<']("</dd>");});
14690            result['$<<']("</dl>");
14691        };
14692        result['$<<']("</div>");
14693        return result.$join($$('LF'));
14694      });
14695
14696      $def(self, '$convert_example', function $$convert_example(node) {
14697        var id_attribute = nil, class_attribute = nil, summary_element = nil, title_element = nil, role = nil;
14698
14699
14700        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14701        if ($truthy(node['$option?']("collapsible"))) {
14702
14703          class_attribute = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : (""));
14704          summary_element = ($truthy(node['$title?']()) ? ("<summary class=\"title\">" + (node.$title()) + "</summary>") : ("<summary class=\"title\">Details</summary>"));
14705          return "<details" + (id_attribute) + (class_attribute) + (($truthy(node['$option?']("open")) ? (" open") : (""))) + ">\n" + (summary_element) + "\n" + "<div class=\"content\">\n" + (node.$content()) + "\n" + "</div>\n" + "</details>";
14706        } else {
14707
14708          title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$captioned_title()) + "</div>\n") : (""));
14709          return "<div" + (id_attribute) + " class=\"exampleblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + (node.$content()) + "\n" + "</div>\n" + "</div>";
14710        };
14711      });
14712
14713      $def(self, '$convert_floating_title', function $$convert_floating_title(node) {
14714        var tag_name = nil, id_attribute = nil, classes = nil;
14715
14716
14717        tag_name = "h" + ($rb_plus(node.$level(), 1));
14718        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14719        classes = [node.$style(), node.$role()].$compact();
14720        return "<" + (tag_name) + (id_attribute) + " class=\"" + (classes.$join(" ")) + "\">" + (node.$title()) + "</" + (tag_name) + ">";
14721      });
14722
14723      $def(self, '$convert_image', function $$convert_image(node) {
14724        var self = this, target = nil, width_attr = nil, height_attr = nil, img = nil, $ret_or_1 = nil, fallback = nil, id_attr = nil, classes = nil, class_attr = nil, title_el = nil;
14725
14726
14727        target = node.$attr("target");
14728        width_attr = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : (""));
14729        height_attr = ($truthy(node['$attr?']("height")) ? (" height=\"" + (node.$attr("height")) + "\"") : (""));
14730        if ((($truthy(node['$attr?']("format", "svg")) || ($truthy(target['$include?'](".svg")))) && ($truthy($rb_lt(node.$document().$safe(), $$$($$('SafeMode'), 'SECURE')))))) {
14731          if ($truthy(node['$option?']("inline"))) {
14732            img = ($truthy(($ret_or_1 = self.$read_svg_contents(node, target))) ? ($ret_or_1) : ("<span class=\"alt\">" + (node.$alt()) + "</span>"))
14733          } else if ($truthy(node['$option?']("interactive"))) {
14734
14735            fallback = ($truthy(node['$attr?']("fallback")) ? ("<img src=\"" + (node.$image_uri(node.$attr("fallback"))) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (width_attr) + (height_attr) + (self.void_element_slash) + ">") : ("<span class=\"alt\">" + (node.$alt()) + "</span>"));
14736            img = "<object type=\"image/svg+xml\" data=\"" + (node.$image_uri(target)) + "\"" + (width_attr) + (height_attr) + ">" + (fallback) + "</object>";
14737          } else {
14738            img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (width_attr) + (height_attr) + (self.void_element_slash) + ">"
14739          }
14740        } else {
14741          img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (width_attr) + (height_attr) + (self.void_element_slash) + ">"
14742        };
14743        if ($truthy(node['$attr?']("link"))) {
14744          img = "<a class=\"image\" href=\"" + (node.$attr("link")) + "\"" + (self.$append_link_constraint_attrs(node).$join()) + ">" + (img) + "</a>"
14745        };
14746        id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14747        classes = ["imageblock"];
14748        if ($truthy(node['$attr?']("float"))) {
14749          classes['$<<'](node.$attr("float"))
14750        };
14751        if ($truthy(node['$attr?']("align"))) {
14752          classes['$<<']("text-" + (node.$attr("align")))
14753        };
14754        if ($truthy(node.$role())) {
14755          classes['$<<'](node.$role())
14756        };
14757        class_attr = " class=\"" + (classes.$join(" ")) + "\"";
14758        title_el = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$captioned_title()) + "</div>") : (""));
14759        return "<div" + (id_attr) + (class_attr) + ">\n" + "<div class=\"content\">\n" + (img) + "\n" + "</div>" + (title_el) + "\n" + "</div>";
14760      });
14761
14762      $def(self, '$convert_listing', function $$convert_listing(node) {
14763        var nowrap = nil, $ret_or_1 = nil, lang = nil, syntax_hl = nil, opts = nil, doc_attrs = nil, pre_open = nil, pre_close = nil, id_attribute = nil, title_element = nil, role = nil;
14764
14765
14766        nowrap = ($truthy(($ret_or_1 = node['$option?']("nowrap"))) ? ($ret_or_1) : (node.$document()['$attr?']("prewrap")['$!']()));
14767        if ($eqeq(node.$style(), "source")) {
14768
14769          lang = node.$attr("language");
14770          if ($truthy((syntax_hl = node.$document().$syntax_highlighter()))) {
14771
14772            opts = ($truthy(syntax_hl['$highlight?']()) ? ($hash2(["css_mode", "style"], {"css_mode": ($truthy(($ret_or_1 = (doc_attrs = node.$document().$attributes())['$[]']("" + (syntax_hl.$name()) + "-css"))) ? ($ret_or_1) : ("class")).$to_sym(), "style": doc_attrs['$[]']("" + (syntax_hl.$name()) + "-style")})) : ($hash2([], {})));
14773            opts['$[]=']("nowrap", nowrap);
14774          } else {
14775
14776            pre_open = "<pre class=\"highlight" + (($truthy(nowrap) ? (" nowrap") : (""))) + "\"><code" + (($truthy(lang) ? (" class=\"language-" + (lang) + "\" data-lang=\"" + (lang) + "\"") : (""))) + ">";
14777            pre_close = "</code></pre>";
14778          };
14779        } else {
14780
14781          pre_open = "<pre" + (($truthy(nowrap) ? (" class=\"nowrap\"") : (""))) + ">";
14782          pre_close = "</pre>";
14783        };
14784        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14785        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$captioned_title()) + "</div>\n") : (""));
14786        return "<div" + (id_attribute) + " class=\"listingblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + (($truthy(syntax_hl) ? (syntax_hl.$format(node, lang, opts)) : ($rb_plus($rb_plus(pre_open, node.$content()), pre_close)))) + "\n" + "</div>\n" + "</div>";
14787      });
14788
14789      $def(self, '$convert_literal', function $$convert_literal(node) {
14790        var id_attribute = nil, title_element = nil, nowrap = nil, $ret_or_1 = nil, role = nil;
14791
14792
14793        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14794        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14795        nowrap = ($truthy(($ret_or_1 = node.$document()['$attr?']("prewrap")['$!']())) ? ($ret_or_1) : (node['$option?']("nowrap")));
14796        return "<div" + (id_attribute) + " class=\"literalblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + "<pre" + (($truthy(nowrap) ? (" class=\"nowrap\"") : (""))) + ">" + (node.$content()) + "</pre>\n" + "</div>\n" + "</div>";
14797      });
14798
14799      $def(self, '$convert_stem', function $$convert_stem(node) {
14800        var $a, $b, self = this, id_attribute = nil, title_element = nil, style = nil, open = nil, close = nil, equation = nil, br = nil, role = nil;
14801
14802
14803        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14804        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14805        $b = $$('BLOCK_MATH_DELIMITERS')['$[]']((style = node.$style().$to_sym())), $a = $to_ary($b), (open = ($a[0] == null ? nil : $a[0])), (close = ($a[1] == null ? nil : $a[1])), $b;
14806        if ($truthy((equation = node.$content()))) {
14807
14808          if (($eqeq(style, "asciimath") && ($truthy(equation['$include?']($$('LF')))))) {
14809
14810            br = "" + ($$('LF')) + "<br" + (self.void_element_slash) + ">";
14811            equation = $send(equation, 'gsub', [$$('StemBreakRx')], function $$13(){var $c;
14812
14813              return "" + (close) + ($rb_times(br, $rb_minus((($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$count($$('LF')), 1))) + ($$('LF')) + (open)});
14814          };
14815          if (!($truthy(equation['$start_with?'](open)) && ($truthy(equation['$end_with?'](close))))) {
14816            equation = "" + (open) + (equation) + (close)
14817          };
14818        } else {
14819          equation = ""
14820        };
14821        return "<div" + (id_attribute) + " class=\"stemblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + (equation) + "\n" + "</div>\n" + "</div>";
14822      });
14823
14824      $def(self, '$convert_olist', function $$convert_olist(node) {
14825        var self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, type_attribute = nil, keyword = nil, start_attribute = nil, reversed_attribute = nil;
14826
14827
14828        result = [];
14829        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14830        classes = ["olist", node.$style(), node.$role()].$compact();
14831        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
14832        result['$<<']("<div" + (id_attribute) + (class_attribute) + ">");
14833        if ($truthy(node['$title?']())) {
14834          result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>")
14835        };
14836        type_attribute = ($truthy((keyword = node.$list_marker_keyword())) ? (" type=\"" + (keyword) + "\"") : (""));
14837        start_attribute = ($truthy(node['$attr?']("start")) ? (" start=\"" + (node.$attr("start")) + "\"") : (""));
14838        reversed_attribute = ($truthy(node['$option?']("reversed")) ? (self.$append_boolean_attribute("reversed", self.xml_mode)) : (""));
14839        result['$<<']("<ol class=\"" + (node.$style()) + "\"" + (type_attribute) + (start_attribute) + (reversed_attribute) + ">");
14840        $send(node.$items(), 'each', [], function $$14(item){
14841
14842          if (item == null) item = nil;
14843          if ($truthy(item.$id())) {
14844            result['$<<']("<li id=\"" + (item.$id()) + "\"" + (($truthy(item.$role()) ? (" class=\"" + (item.$role()) + "\"") : (""))) + ">")
14845          } else if ($truthy(item.$role())) {
14846            result['$<<']("<li class=\"" + (item.$role()) + "\">")
14847          } else {
14848            result['$<<']("<li>")
14849          };
14850          result['$<<']("<p>" + (item.$text()) + "</p>");
14851          if ($truthy(item['$blocks?']())) {
14852            result['$<<'](item.$content())
14853          };
14854          return result['$<<']("</li>");});
14855        result['$<<']("</ol>");
14856        result['$<<']("</div>");
14857        return result.$join($$('LF'));
14858      });
14859
14860      $def(self, '$convert_open', function $$convert_open(node) {
14861        var self = this, style = nil, id_attr = nil, title_el = nil, role = nil;
14862
14863        if ($eqeq((style = node.$style()), "abstract")) {
14864          if (($eqeq(node.$parent(), node.$document()) && ($eqeq(node.$document().$doctype(), "book")))) {
14865
14866            self.$logger().$warn("abstract block cannot be used in a document without a title when doctype is book. Excluding block content.");
14867            return "";
14868          } else {
14869
14870            id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14871            title_el = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14872            return "<div" + (id_attr) + " class=\"quoteblock abstract" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_el) + "<blockquote>\n" + (node.$content()) + "\n" + "</blockquote>\n" + "</div>";
14873          }
14874        } else if (($eqeq(style, "partintro") && ((($truthy($rb_gt(node.$level(), 0)) || ($neqeq(node.$parent().$context(), "section"))) || ($neqeq(node.$document().$doctype(), "book")))))) {
14875
14876          self.$logger().$error("partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.");
14877          return "";
14878        } else {
14879
14880          id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14881          title_el = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14882          return "<div" + (id_attr) + " class=\"openblock" + ((($truthy(style) && ($neqeq(style, "open"))) ? (" " + (style)) : (""))) + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_el) + "<div class=\"content\">\n" + (node.$content()) + "\n" + "</div>\n" + "</div>";
14883        }
14884      });
14885
14886      $def(self, '$convert_page_break', $return_val("<div style=\"page-break-after: always;\"></div>"));
14887
14888      $def(self, '$convert_paragraph', function $$convert_paragraph(node) {
14889        var attributes = nil;
14890
14891
14892        if ($truthy(node.$role())) {
14893          attributes = "" + (($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""))) + " class=\"paragraph " + (node.$role()) + "\""
14894        } else if ($truthy(node.$id())) {
14895          attributes = " id=\"" + (node.$id()) + "\" class=\"paragraph\""
14896        } else {
14897          attributes = " class=\"paragraph\""
14898        };
14899        if ($truthy(node['$title?']())) {
14900          return "<div" + (attributes) + ">\n" + "<div class=\"title\">" + (node.$title()) + "</div>\n" + "<p>" + (node.$content()) + "</p>\n" + "</div>"
14901        } else {
14902          return "<div" + (attributes) + ">\n" + "<p>" + (node.$content()) + "</p>\n" + "</div>"
14903        };
14904      });
14905      $alias(self, "convert_pass", "content_only");
14906
14907      $def(self, '$convert_preamble', function $$convert_preamble(node) {
14908        var doc = nil, toc = nil;
14909
14910
14911        if ((($truthy((doc = node.$document())['$attr?']("toc-placement", "preamble")) && ($truthy(doc['$sections?']()))) && ($truthy(doc['$attr?']("toc"))))) {
14912          toc = "\n" + "<div id=\"toc\" class=\"" + (doc.$attr("toc-class", "toc")) + "\">\n" + "<div id=\"toctitle\">" + (doc.$attr("toc-title")) + "</div>\n" + (doc.$converter().$convert(doc, "outline")) + "\n" + "</div>"
14913        } else {
14914          toc = ""
14915        };
14916        return "<div id=\"preamble\">\n" + "<div class=\"sectionbody\">\n" + (node.$content()) + "\n" + "</div>" + (toc) + "\n" + "</div>";
14917      });
14918
14919      $def(self, '$convert_quote', function $$convert_quote(node) {
14920        var self = this, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil, attribution = nil, citetitle = nil, cite_element = nil, attribution_text = nil, attribution_element = nil;
14921
14922
14923        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14924        classes = ["quoteblock", node.$role()].$compact();
14925        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
14926        title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : (""));
14927        attribution = ($truthy(node['$attr?']("attribution")) ? (node.$attr("attribution")) : (nil));
14928        citetitle = ($truthy(node['$attr?']("citetitle")) ? (node.$attr("citetitle")) : (nil));
14929        if (($truthy(attribution) || ($truthy(citetitle)))) {
14930
14931          cite_element = ($truthy(citetitle) ? ("<cite>" + (citetitle) + "</cite>") : (""));
14932          attribution_text = ($truthy(attribution) ? ("&#8212; " + (attribution) + (($truthy(citetitle) ? ("<br" + (self.void_element_slash) + ">\n") : ("")))) : (""));
14933          attribution_element = "\n<div class=\"attribution\">\n" + (attribution_text) + (cite_element) + "\n</div>";
14934        } else {
14935          attribution_element = ""
14936        };
14937        return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<blockquote>\n" + (node.$content()) + "\n" + "</blockquote>" + (attribution_element) + "\n" + "</div>";
14938      });
14939
14940      $def(self, '$convert_thematic_break', function $$convert_thematic_break(node) {
14941        var self = this;
14942
14943        return "<hr" + (self.void_element_slash) + ">"
14944      });
14945
14946      $def(self, '$convert_sidebar', function $$convert_sidebar(node) {
14947        var id_attribute = nil, title_element = nil, role = nil;
14948
14949
14950        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14951        title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : (""));
14952        return "<div" + (id_attribute) + " class=\"sidebarblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + "<div class=\"content\">\n" + (title_element) + (node.$content()) + "\n" + "</div>\n" + "</div>";
14953      });
14954
14955      $def(self, '$convert_table', function $$convert_table(node) {
14956        var self = this, result = nil, id_attribute = nil, frame = nil, classes = nil, stripes = nil, style_attribute = nil, autowidth = nil, tablewidth = nil, role = nil, class_attribute = nil, slash = nil;
14957
14958
14959        result = [];
14960        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
14961        if ($eqeq((frame = node.$attr("frame", "all", "table-frame")), "topbot")) {
14962          frame = "ends"
14963        };
14964        classes = ["tableblock", "frame-" + (frame), "grid-" + (node.$attr("grid", "all", "table-grid"))];
14965        if ($truthy((stripes = node.$attr("stripes", nil, "table-stripes")))) {
14966          classes['$<<']("stripes-" + (stripes))
14967        };
14968        style_attribute = "";
14969        if (($truthy((autowidth = node['$option?']("autowidth"))) && ($not(node['$attr?']("width"))))) {
14970          classes['$<<']("fit-content")
14971        } else if ($eqeq((tablewidth = node.$attr("tablepcwidth")), 100)) {
14972          classes['$<<']("stretch")
14973        } else {
14974          style_attribute = " style=\"width: " + (tablewidth) + "%;\""
14975        };
14976        if ($truthy(node['$attr?']("float"))) {
14977          classes['$<<'](node.$attr("float"))
14978        };
14979        if ($truthy((role = node.$role()))) {
14980          classes['$<<'](role)
14981        };
14982        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
14983        result['$<<']("<table" + (id_attribute) + (class_attribute) + (style_attribute) + ">");
14984        if ($truthy(node['$title?']())) {
14985          result['$<<']("<caption class=\"title\">" + (node.$captioned_title()) + "</caption>")
14986        };
14987        if ($truthy($rb_gt(node.$attr("rowcount"), 0))) {
14988
14989          slash = self.void_element_slash;
14990          result['$<<']("<colgroup>");
14991          if ($truthy(autowidth)) {
14992            result = $rb_plus(result, $$('Array').$new(node.$columns().$size(), "<col" + (slash) + ">"))
14993          } else {
14994            $send(node.$columns(), 'each', [], function $$15(col){
14995
14996              if (col == null) col = nil;
14997              return result['$<<'](($truthy(col['$option?']("autowidth")) ? ("<col" + (slash) + ">") : ("<col style=\"width: " + (col.$attr("colpcwidth")) + "%;\"" + (slash) + ">")));})
14998          };
14999          result['$<<']("</colgroup>");
15000          $send(node.$rows().$to_h(), 'each', [], function $$16(tsec, rows){
15001
15002            if (tsec == null) tsec = nil;
15003            if (rows == null) rows = nil;
15004            if ($truthy(rows['$empty?']())) {
15005              return nil
15006            };
15007            result['$<<']("<t" + (tsec) + ">");
15008            $send(rows, 'each', [], function $$17(row){
15009
15010              if (row == null) row = nil;
15011              result['$<<']("<tr>");
15012              $send(row, 'each', [], function $$18(cell){var cell_content = nil, cell_tag_name = nil, cell_class_attribute = nil, cell_colspan_attribute = nil, cell_rowspan_attribute = nil, cell_style_attribute = nil;
15013
15014
15015                if (cell == null) cell = nil;
15016                if ($eqeq(tsec, "head")) {
15017                  cell_content = cell.$text()
15018                } else
15019                switch (cell.$style()) {
15020                  case "asciidoc":
15021                    cell_content = "<div class=\"content\">" + (cell.$content()) + "</div>"
15022                    break;
15023                  case "literal":
15024                    cell_content = "<div class=\"literal\"><pre>" + (cell.$text()) + "</pre></div>"
15025                    break;
15026                  default:
15027                    cell_content = ($truthy((cell_content = cell.$content())['$empty?']()) ? ("") : ("<p class=\"tableblock\">" + (cell_content.$join("</p>\n" + "<p class=\"tableblock\">")) + "</p>"))
15028                };
15029                cell_tag_name = (($eqeq(tsec, "head") || ($eqeq(cell.$style(), "header"))) ? ("th") : ("td"));
15030                cell_class_attribute = " class=\"tableblock halign-" + (cell.$attr("halign")) + " valign-" + (cell.$attr("valign")) + "\"";
15031                cell_colspan_attribute = ($truthy(cell.$colspan()) ? (" colspan=\"" + (cell.$colspan()) + "\"") : (""));
15032                cell_rowspan_attribute = ($truthy(cell.$rowspan()) ? (" rowspan=\"" + (cell.$rowspan()) + "\"") : (""));
15033                cell_style_attribute = ($truthy(node.$document()['$attr?']("cellbgcolor")) ? (" style=\"background-color: " + (node.$document().$attr("cellbgcolor")) + ";\"") : (""));
15034                return result['$<<']("<" + (cell_tag_name) + (cell_class_attribute) + (cell_colspan_attribute) + (cell_rowspan_attribute) + (cell_style_attribute) + ">" + (cell_content) + "</" + (cell_tag_name) + ">");});
15035              return result['$<<']("</tr>");});
15036            return result['$<<']("</t" + (tsec) + ">");});
15037        };
15038        result['$<<']("</table>");
15039        return result.$join($$('LF'));
15040      });
15041
15042      $def(self, '$convert_toc', function $$convert_toc(node) {
15043        var doc = nil, id_attr = nil, title_id_attr = nil, title = nil, levels = nil, role = nil;
15044
15045
15046        if (!(($truthy((doc = node.$document())['$attr?']("toc-placement", "macro")) && ($truthy(doc['$sections?']()))) && ($truthy(doc['$attr?']("toc"))))) {
15047          return "<!-- toc disabled -->"
15048        };
15049        if ($truthy(node.$id())) {
15050
15051          id_attr = " id=\"" + (node.$id()) + "\"";
15052          title_id_attr = " id=\"" + (node.$id()) + "title\"";
15053        } else {
15054
15055          id_attr = " id=\"toc\"";
15056          title_id_attr = " id=\"toctitle\"";
15057        };
15058        title = ($truthy(node['$title?']()) ? (node.$title()) : (doc.$attr("toc-title")));
15059        levels = ($truthy(node['$attr?']("levels")) ? (node.$attr("levels").$to_i()) : (nil));
15060        role = ($truthy(node['$role?']()) ? (node.$role()) : (doc.$attr("toc-class", "toc")));
15061        return "<div" + (id_attr) + " class=\"" + (role) + "\">\n" + "<div" + (title_id_attr) + " class=\"title\">" + (title) + "</div>\n" + (doc.$converter().$convert(doc, "outline", $hash2(["toclevels"], {"toclevels": levels}))) + "\n" + "</div>";
15062      });
15063
15064      $def(self, '$convert_ulist', function $$convert_ulist(node) {
15065        var self = this, result = nil, id_attribute = nil, div_classes = nil, marker_checked = nil, marker_unchecked = nil, checklist = nil, ul_class_attribute = nil;
15066
15067
15068        result = [];
15069        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
15070        div_classes = ["ulist", node.$style(), node.$role()].$compact();
15071        marker_checked = (marker_unchecked = "");
15072        if ($truthy((checklist = node['$option?']("checklist")))) {
15073
15074          div_classes.$unshift(div_classes.$shift(), "checklist");
15075          ul_class_attribute = " class=\"checklist\"";
15076          if ($truthy(node['$option?']("interactive"))) {
15077            if ($truthy(self.xml_mode)) {
15078
15079              marker_checked = "<input type=\"checkbox\" data-item-complete=\"1\" checked=\"checked\"/> ";
15080              marker_unchecked = "<input type=\"checkbox\" data-item-complete=\"0\"/> ";
15081            } else {
15082
15083              marker_checked = "<input type=\"checkbox\" data-item-complete=\"1\" checked> ";
15084              marker_unchecked = "<input type=\"checkbox\" data-item-complete=\"0\"> ";
15085            }
15086          } else if ($truthy(node.$document()['$attr?']("icons", "font"))) {
15087
15088            marker_checked = "<i class=\"fa fa-check-square-o\"></i> ";
15089            marker_unchecked = "<i class=\"fa fa-square-o\"></i> ";
15090          } else {
15091
15092            marker_checked = "&#10003; ";
15093            marker_unchecked = "&#10063; ";
15094          };
15095        } else {
15096          ul_class_attribute = ($truthy(node.$style()) ? (" class=\"" + (node.$style()) + "\"") : (""))
15097        };
15098        result['$<<']("<div" + (id_attribute) + " class=\"" + (div_classes.$join(" ")) + "\">");
15099        if ($truthy(node['$title?']())) {
15100          result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>")
15101        };
15102        result['$<<']("<ul" + (ul_class_attribute) + ">");
15103        $send(node.$items(), 'each', [], function $$19(item){
15104
15105          if (item == null) item = nil;
15106          if ($truthy(item.$id())) {
15107            result['$<<']("<li id=\"" + (item.$id()) + "\"" + (($truthy(item.$role()) ? (" class=\"" + (item.$role()) + "\"") : (""))) + ">")
15108          } else if ($truthy(item.$role())) {
15109            result['$<<']("<li class=\"" + (item.$role()) + "\">")
15110          } else {
15111            result['$<<']("<li>")
15112          };
15113          if (($truthy(checklist) && ($truthy(item['$attr?']("checkbox"))))) {
15114            result['$<<']("<p>" + (($truthy(item['$attr?']("checked")) ? (marker_checked) : (marker_unchecked))) + (item.$text()) + "</p>")
15115          } else {
15116            result['$<<']("<p>" + (item.$text()) + "</p>")
15117          };
15118          if ($truthy(item['$blocks?']())) {
15119            result['$<<'](item.$content())
15120          };
15121          return result['$<<']("</li>");});
15122        result['$<<']("</ul>");
15123        result['$<<']("</div>");
15124        return result.$join($$('LF'));
15125      });
15126
15127      $def(self, '$convert_verse', function $$convert_verse(node) {
15128        var self = this, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil, attribution = nil, citetitle = nil, cite_element = nil, attribution_text = nil, attribution_element = nil;
15129
15130
15131        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
15132        classes = ["verseblock", node.$role()].$compact();
15133        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
15134        title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : (""));
15135        attribution = ($truthy(node['$attr?']("attribution")) ? (node.$attr("attribution")) : (nil));
15136        citetitle = ($truthy(node['$attr?']("citetitle")) ? (node.$attr("citetitle")) : (nil));
15137        if (($truthy(attribution) || ($truthy(citetitle)))) {
15138
15139          cite_element = ($truthy(citetitle) ? ("<cite>" + (citetitle) + "</cite>") : (""));
15140          attribution_text = ($truthy(attribution) ? ("&#8212; " + (attribution) + (($truthy(citetitle) ? ("<br" + (self.void_element_slash) + ">\n") : ("")))) : (""));
15141          attribution_element = "\n<div class=\"attribution\">\n" + (attribution_text) + (cite_element) + "\n</div>";
15142        } else {
15143          attribution_element = ""
15144        };
15145        return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<pre class=\"content\">" + (node.$content()) + "</pre>" + (attribution_element) + "\n" + "</div>";
15146      });
15147
15148      $def(self, '$convert_video', function $$convert_video(node) {
15149        var $a, $b, self = this, xml = nil, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil, width_attribute = nil, height_attribute = nil, asset_uri_scheme = nil, start_anchor = nil, delimiter = nil, target = nil, hash = nil, hash_param = nil, $ret_or_2 = nil, autoplay_param = nil, loop_param = nil, muted_param = nil, rel_param_val = nil, start_param = nil, end_param = nil, has_loop_param = nil, mute_param = nil, controls_param = nil, fs_param = nil, fs_attribute = nil, modest_param = nil, theme_param = nil, hl_param = nil, list = nil, list_param = nil, playlist = nil, poster_attribute = nil, val = nil, preload_attribute = nil, start_t = nil, end_t = nil, time_anchor = nil;
15150
15151
15152        xml = self.xml_mode;
15153        id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""));
15154        classes = ["videoblock"];
15155        if ($truthy(node['$attr?']("float"))) {
15156          classes['$<<'](node.$attr("float"))
15157        };
15158        if ($truthy(node['$attr?']("align"))) {
15159          classes['$<<']("text-" + (node.$attr("align")))
15160        };
15161        if ($truthy(node.$role())) {
15162          classes['$<<'](node.$role())
15163        };
15164        class_attribute = " class=\"" + (classes.$join(" ")) + "\"";
15165        title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : (""));
15166        width_attribute = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : (""));
15167        height_attribute = ($truthy(node['$attr?']("height")) ? (" height=\"" + (node.$attr("height")) + "\"") : (""));
15168
15169        switch (node.$attr("poster")) {
15170          case "vimeo":
15171
15172            if (!$truthy((asset_uri_scheme = node.$document().$attr("asset-uri-scheme", "https"))['$empty?']())) {
15173              asset_uri_scheme = "" + (asset_uri_scheme) + ":"
15174            };
15175            start_anchor = ($truthy(node['$attr?']("start")) ? ("#at=" + (node.$attr("start"))) : (""));
15176            delimiter = ["?"];
15177            $b = node.$attr("target").$split("/", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (hash = ($a[1] == null ? nil : $a[1])), $b;
15178            hash_param = ($truthy((hash = ($truthy(($ret_or_2 = hash)) ? ($ret_or_2) : (node.$attr("hash"))))) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&amp;"))) + "h=" + (hash)) : (""));
15179            autoplay_param = ($truthy(node['$option?']("autoplay")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&amp;"))) + "autoplay=1") : (""));
15180            loop_param = ($truthy(node['$option?']("loop")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&amp;"))) + "loop=1") : (""));
15181            muted_param = ($truthy(node['$option?']("muted")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&amp;"))) + "muted=1") : (""));
15182            return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<div class=\"content\">\n" + "<iframe" + (width_attribute) + (height_attribute) + " src=\"" + (asset_uri_scheme) + "//player.vimeo.com/video/" + (target) + (hash_param) + (autoplay_param) + (loop_param) + (muted_param) + (start_anchor) + "\" frameborder=\"0\"" + (($truthy(node['$option?']("nofullscreen")) ? ("") : (self.$append_boolean_attribute("allowfullscreen", xml)))) + "></iframe>\n" + "</div>\n" + "</div>";
15183          case "youtube":
15184
15185            if (!$truthy((asset_uri_scheme = node.$document().$attr("asset-uri-scheme", "https"))['$empty?']())) {
15186              asset_uri_scheme = "" + (asset_uri_scheme) + ":"
15187            };
15188            rel_param_val = ($truthy(node['$option?']("related")) ? (1) : (0));
15189            start_param = ($truthy(node['$attr?']("start")) ? ("&amp;start=" + (node.$attr("start"))) : (""));
15190            end_param = ($truthy(node['$attr?']("end")) ? ("&amp;end=" + (node.$attr("end"))) : (""));
15191            autoplay_param = ($truthy(node['$option?']("autoplay")) ? ("&amp;autoplay=1") : (""));
15192            loop_param = ($truthy((has_loop_param = node['$option?']("loop"))) ? ("&amp;loop=1") : (""));
15193            mute_param = ($truthy(node['$option?']("muted")) ? ("&amp;mute=1") : (""));
15194            controls_param = ($truthy(node['$option?']("nocontrols")) ? ("&amp;controls=0") : (""));
15195            if ($truthy(node['$option?']("nofullscreen"))) {
15196
15197              fs_param = "&amp;fs=0";
15198              fs_attribute = "";
15199            } else {
15200
15201              fs_param = "";
15202              fs_attribute = self.$append_boolean_attribute("allowfullscreen", xml);
15203            };
15204            modest_param = ($truthy(node['$option?']("modest")) ? ("&amp;modestbranding=1") : (""));
15205            theme_param = ($truthy(node['$attr?']("theme")) ? ("&amp;theme=" + (node.$attr("theme"))) : (""));
15206            hl_param = ($truthy(node['$attr?']("lang")) ? ("&amp;hl=" + (node.$attr("lang"))) : (""));
15207            $b = node.$attr("target").$split("/", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (list = ($a[1] == null ? nil : $a[1])), $b;
15208            if ($truthy((list = ($truthy(($ret_or_2 = list)) ? ($ret_or_2) : (node.$attr("list")))))) {
15209              list_param = "&amp;list=" + (list)
15210            } else {
15211
15212              $b = target.$split(",", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (playlist = ($a[1] == null ? nil : $a[1])), $b;
15213              if ($truthy((playlist = ($truthy(($ret_or_2 = playlist)) ? ($ret_or_2) : (node.$attr("playlist")))))) {
15214                list_param = "&amp;playlist=" + (target) + "," + (playlist)
15215              } else {
15216                list_param = ($truthy(has_loop_param) ? ("&amp;playlist=" + (target)) : (""))
15217              };
15218            };
15219            return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<div class=\"content\">\n" + "<iframe" + (width_attribute) + (height_attribute) + " src=\"" + (asset_uri_scheme) + "//www.youtube.com/embed/" + (target) + "?rel=" + (rel_param_val) + (start_param) + (end_param) + (autoplay_param) + (loop_param) + (mute_param) + (controls_param) + (list_param) + (fs_param) + (modest_param) + (theme_param) + (hl_param) + "\" frameborder=\"0\"" + (fs_attribute) + "></iframe>\n" + "</div>\n" + "</div>";
15220          default:
15221
15222            poster_attribute = ($truthy((val = node.$attr("poster"))['$nil_or_empty?']()) ? ("") : (" poster=\"" + (node.$media_uri(val)) + "\""));
15223            preload_attribute = ($truthy((val = node.$attr("preload"))['$nil_or_empty?']()) ? ("") : (" preload=\"" + (val) + "\""));
15224            start_t = node.$attr("start");
15225            end_t = node.$attr("end");
15226            time_anchor = (($truthy(start_t) || ($truthy(end_t))) ? ("#t=" + (($truthy(($ret_or_2 = start_t)) ? ($ret_or_2) : (""))) + (($truthy(end_t) ? ("," + (end_t)) : ("")))) : (""));
15227            return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<div class=\"content\">\n" + "<video src=\"" + (node.$media_uri(node.$attr("target"))) + (time_anchor) + "\"" + (width_attribute) + (height_attribute) + (poster_attribute) + (($truthy(node['$option?']("autoplay")) ? (self.$append_boolean_attribute("autoplay", xml)) : (""))) + (($truthy(node['$option?']("muted")) ? (self.$append_boolean_attribute("muted", xml)) : (""))) + (($truthy(node['$option?']("nocontrols")) ? ("") : (self.$append_boolean_attribute("controls", xml)))) + (($truthy(node['$option?']("loop")) ? (self.$append_boolean_attribute("loop", xml)) : (""))) + (preload_attribute) + ">\n" + "Your browser does not support the video tag.\n" + "</video>\n" + "</div>\n" + "</div>";
15228        };
15229      });
15230
15231      $def(self, '$convert_inline_anchor', function $$convert_inline_anchor(node) {
15232        var self = this, path = nil, attrs = nil, text = nil, $ret_or_2 = nil, ref = nil, $ret_or_3 = nil, refid = nil, top = nil, outer = nil;
15233
15234
15235        switch (node.$type()) {
15236          case "xref":
15237
15238            if ($truthy((path = node.$attributes()['$[]']("path")))) {
15239
15240              attrs = self.$append_link_constraint_attrs(node, ($truthy(node.$role()) ? ([" class=\"" + (node.$role()) + "\""]) : ([]))).$join();
15241              text = ($truthy(($ret_or_2 = node.$text())) ? ($ret_or_2) : (path));
15242            } else {
15243
15244              attrs = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : (""));
15245              if (!$truthy((text = node.$text()))) {
15246                if ($eqeqeq($$('AbstractNode'), (ref = ($truthy(($ret_or_2 = (self.refs = ($truthy(($ret_or_3 = self.refs)) ? ($ret_or_3) : (node.$document().$catalog()['$[]']("refs"))))['$[]']((refid = node.$attributes()['$[]']("refid"))))) ? ($ret_or_2) : (($truthy(refid['$nil_or_empty?']()) ? ((top = self.$get_root_document(node))) : (nil))))))) {
15247                  if (($truthy((self.resolving_xref = ($truthy(($ret_or_2 = self.resolving_xref)) ? ($ret_or_2) : ((outer = true))))) && ($truthy(outer)))) {
15248
15249                    if ($truthy((text = ref.$xreftext(node.$attr("xrefstyle", nil, true))))) {
15250                      if ($truthy(text['$include?']("<a"))) {
15251                        text = text.$gsub($$('DropAnchorRx'), "")
15252                      }
15253                    } else {
15254                      text = ($truthy(top) ? ("[^top]") : ("[" + (refid) + "]"))
15255                    };
15256                    self.resolving_xref = nil;
15257                  } else {
15258                    text = ($truthy(top) ? ("[^top]") : ("[" + (refid) + "]"))
15259                  }
15260                } else {
15261                  text = "[" + (refid) + "]"
15262                }
15263              };
15264            };
15265            return "<a href=\"" + (node.$target()) + "\"" + (attrs) + ">" + (text) + "</a>";
15266          case "ref":
15267            return "<a id=\"" + (node.$id()) + "\"></a>"
15268          case "link":
15269
15270            attrs = ($truthy(node.$id()) ? ([" id=\"" + (node.$id()) + "\""]) : ([]));
15271            if ($truthy(node.$role())) {
15272              attrs['$<<'](" class=\"" + (node.$role()) + "\"")
15273            };
15274            if ($truthy(node['$attr?']("title"))) {
15275              attrs['$<<'](" title=\"" + (node.$attr("title")) + "\"")
15276            };
15277            return "<a href=\"" + (node.$target()) + "\"" + (self.$append_link_constraint_attrs(node, attrs).$join()) + ">" + (node.$text()) + "</a>";
15278          case "bibref":
15279            return "<a id=\"" + (node.$id()) + "\"></a>[" + (($truthy(($ret_or_2 = node.$reftext())) ? ($ret_or_2) : (node.$id()))) + "]"
15280          default:
15281
15282            self.$logger().$warn("unknown anchor type: " + (node.$type().$inspect()));
15283            return nil;
15284        }
15285      });
15286
15287      $def(self, '$convert_inline_break', function $$convert_inline_break(node) {
15288        var self = this;
15289
15290        return "" + (node.$text()) + "<br" + (self.void_element_slash) + ">"
15291      });
15292
15293      $def(self, '$convert_inline_button', function $$convert_inline_button(node) {
15294
15295        return "<b class=\"button\">" + (node.$text()) + "</b>"
15296      });
15297
15298      $def(self, '$convert_inline_callout', function $$convert_inline_callout(node) {
15299        var self = this, src = nil, guard = nil;
15300
15301        if ($truthy(node.$document()['$attr?']("icons", "font"))) {
15302          return "<i class=\"conum\" data-value=\"" + (node.$text()) + "\"></i><b>(" + (node.$text()) + ")</b>"
15303        } else if ($truthy(node.$document()['$attr?']("icons"))) {
15304
15305          src = node.$icon_uri("callouts/" + (node.$text()));
15306          return "<img src=\"" + (src) + "\" alt=\"" + (node.$text()) + "\"" + (self.void_element_slash) + ">";
15307        } else if ($eqeqeq($$$('Array'), (guard = node.$attributes()['$[]']("guard")))) {
15308          return "&lt;!--<b class=\"conum\">(" + (node.$text()) + ")</b>--&gt;"
15309        } else {
15310          return "" + (guard) + "<b class=\"conum\">(" + (node.$text()) + ")</b>"
15311        }
15312      });
15313
15314      $def(self, '$convert_inline_footnote', function $$convert_inline_footnote(node) {
15315        var index = nil, id_attr = nil;
15316
15317        if ($truthy((index = node.$attr("index")))) {
15318          if ($eqeq(node.$type(), "xref")) {
15319            return "<sup class=\"footnoteref\">[<a class=\"footnote\" href=\"#_footnotedef_" + (index) + "\" title=\"View footnote.\">" + (index) + "</a>]</sup>"
15320          } else {
15321
15322            id_attr = ($truthy(node.$id()) ? (" id=\"_footnote_" + (node.$id()) + "\"") : (""));
15323            return "<sup class=\"footnote\"" + (id_attr) + ">[<a id=\"_footnoteref_" + (index) + "\" class=\"footnote\" href=\"#_footnotedef_" + (index) + "\" title=\"View footnote.\">" + (index) + "</a>]</sup>";
15324          }
15325        } else if ($eqeq(node.$type(), "xref")) {
15326          return "<sup class=\"footnoteref red\" title=\"Unresolved footnote reference.\">[" + (node.$text()) + "]</sup>"
15327        } else {
15328          return nil
15329        }
15330      });
15331
15332      $def(self, '$convert_inline_image', function $$convert_inline_image(node) {
15333        var self = this, target = nil, type = nil, $ret_or_1 = nil, icons = nil, i_class_attr_val = nil, attrs = nil, img = nil, fallback = nil, class_attr_val = nil, role = nil;
15334
15335
15336        target = node.$target();
15337        if ($eqeq((type = ($truthy(($ret_or_1 = node.$type())) ? ($ret_or_1) : ("image"))), "icon")) {
15338          if ($eqeq((icons = node.$document().$attr("icons")), "font")) {
15339
15340            i_class_attr_val = "fa fa-" + (target);
15341            if ($truthy(node['$attr?']("size"))) {
15342              i_class_attr_val = "" + (i_class_attr_val) + " fa-" + (node.$attr("size"))
15343            };
15344            if ($truthy(node['$attr?']("flip"))) {
15345              i_class_attr_val = "" + (i_class_attr_val) + " fa-flip-" + (node.$attr("flip"))
15346            } else if ($truthy(node['$attr?']("rotate"))) {
15347              i_class_attr_val = "" + (i_class_attr_val) + " fa-rotate-" + (node.$attr("rotate"))
15348            };
15349            attrs = ($truthy(node['$attr?']("title")) ? (" title=\"" + (node.$attr("title")) + "\"") : (""));
15350            img = "<i class=\"" + (i_class_attr_val) + "\"" + (attrs) + "></i>";
15351          } else if ($truthy(icons)) {
15352
15353            attrs = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : (""));
15354            if ($truthy(node['$attr?']("height"))) {
15355              attrs = "" + (attrs) + " height=\"" + (node.$attr("height")) + "\""
15356            };
15357            if ($truthy(node['$attr?']("title"))) {
15358              attrs = "" + (attrs) + " title=\"" + (node.$attr("title")) + "\""
15359            };
15360            img = "<img src=\"" + (node.$icon_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">";
15361          } else {
15362            img = "[" + (node.$alt()) + "&#93;"
15363          }
15364        } else {
15365
15366          attrs = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : (""));
15367          if ($truthy(node['$attr?']("height"))) {
15368            attrs = "" + (attrs) + " height=\"" + (node.$attr("height")) + "\""
15369          };
15370          if ($truthy(node['$attr?']("title"))) {
15371            attrs = "" + (attrs) + " title=\"" + (node.$attr("title")) + "\""
15372          };
15373          if ((($truthy(node['$attr?']("format", "svg")) || ($truthy(target['$include?'](".svg")))) && ($truthy($rb_lt(node.$document().$safe(), $$$($$('SafeMode'), 'SECURE')))))) {
15374            if ($truthy(node['$option?']("inline"))) {
15375              img = ($truthy(($ret_or_1 = self.$read_svg_contents(node, target))) ? ($ret_or_1) : ("<span class=\"alt\">" + (node.$alt()) + "</span>"))
15376            } else if ($truthy(node['$option?']("interactive"))) {
15377
15378              fallback = ($truthy(node['$attr?']("fallback")) ? ("<img src=\"" + (node.$image_uri(node.$attr("fallback"))) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">") : ("<span class=\"alt\">" + (node.$alt()) + "</span>"));
15379              img = "<object type=\"image/svg+xml\" data=\"" + (node.$image_uri(target)) + "\"" + (attrs) + ">" + (fallback) + "</object>";
15380            } else {
15381              img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">"
15382            }
15383          } else {
15384            img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">"
15385          };
15386        };
15387        if ($truthy(node['$attr?']("link"))) {
15388          img = "<a class=\"image\" href=\"" + (node.$attr("link")) + "\"" + (self.$append_link_constraint_attrs(node).$join()) + ">" + (img) + "</a>"
15389        };
15390        class_attr_val = type;
15391        if ($truthy((role = node.$role()))) {
15392          class_attr_val = ($truthy(node['$attr?']("float")) ? ("" + (class_attr_val) + " " + (node.$attr("float")) + " " + (role)) : ("" + (class_attr_val) + " " + (role)))
15393        } else if ($truthy(node['$attr?']("float"))) {
15394          class_attr_val = "" + (class_attr_val) + " " + (node.$attr("float"))
15395        };
15396        return "<span class=\"" + (class_attr_val) + "\">" + (img) + "</span>";
15397      });
15398
15399      $def(self, '$convert_inline_indexterm', function $$convert_inline_indexterm(node) {
15400
15401        if ($eqeq(node.$type(), "visible")) {
15402          return node.$text()
15403        } else {
15404          return ""
15405        }
15406      });
15407
15408      $def(self, '$convert_inline_kbd', function $$convert_inline_kbd(node) {
15409        var keys = nil;
15410
15411        if ($eqeq((keys = node.$attr("keys")).$size(), 1)) {
15412          return "<kbd>" + (keys['$[]'](0)) + "</kbd>"
15413        } else {
15414          return "<span class=\"keyseq\"><kbd>" + (keys.$join("</kbd>+<kbd>")) + "</kbd></span>"
15415        }
15416      });
15417
15418      $def(self, '$convert_inline_menu', function $$convert_inline_menu(node) {
15419        var caret = nil, submenu_joiner = nil, menu = nil, submenus = nil, menuitem = nil;
15420
15421
15422        caret = ($truthy(node.$document()['$attr?']("icons", "font")) ? ("&#160;<i class=\"fa fa-angle-right caret\"></i> ") : ("&#160;<b class=\"caret\">&#8250;</b> "));
15423        submenu_joiner = "</b>" + (caret) + "<b class=\"submenu\">";
15424        menu = node.$attr("menu");
15425        if ($truthy((submenus = node.$attr("submenus"))['$empty?']())) {
15426          if ($truthy((menuitem = node.$attr("menuitem")))) {
15427            return "<span class=\"menuseq\"><b class=\"menu\">" + (menu) + "</b>" + (caret) + "<b class=\"menuitem\">" + (menuitem) + "</b></span>"
15428          } else {
15429            return "<b class=\"menuref\">" + (menu) + "</b>"
15430          }
15431        } else {
15432          return "<span class=\"menuseq\"><b class=\"menu\">" + (menu) + "</b>" + (caret) + "<b class=\"submenu\">" + (submenus.$join(submenu_joiner)) + "</b>" + (caret) + "<b class=\"menuitem\">" + (node.$attr("menuitem")) + "</b></span>"
15433        };
15434      });
15435
15436      $def(self, '$convert_inline_quoted', function $$convert_inline_quoted(node) {
15437        var $a, $b, open = nil, close = nil, tag = nil, class_attr = nil;
15438
15439
15440        $b = $$('QUOTE_TAGS')['$[]'](node.$type()), $a = $to_ary($b), (open = ($a[0] == null ? nil : $a[0])), (close = ($a[1] == null ? nil : $a[1])), (tag = ($a[2] == null ? nil : $a[2])), $b;
15441        if ($truthy(node.$id())) {
15442
15443          class_attr = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : (""));
15444          if ($truthy(tag)) {
15445            return "" + (open.$chop()) + " id=\"" + (node.$id()) + "\"" + (class_attr) + ">" + (node.$text()) + (close)
15446          } else {
15447            return "<span id=\"" + (node.$id()) + "\"" + (class_attr) + ">" + (open) + (node.$text()) + (close) + "</span>"
15448          };
15449        } else if ($truthy(node.$role())) {
15450          if ($truthy(tag)) {
15451            return "" + (open.$chop()) + " class=\"" + (node.$role()) + "\">" + (node.$text()) + (close)
15452          } else {
15453            return "<span class=\"" + (node.$role()) + "\">" + (open) + (node.$text()) + (close) + "</span>"
15454          }
15455        } else {
15456          return "" + (open) + (node.$text()) + (close)
15457        };
15458      });
15459
15460      $def(self, '$read_svg_contents', function $$read_svg_contents(node, target) {
15461        var svg = nil, old_start_tag = nil, new_start_tag = nil, start_tag_match = nil;
15462
15463
15464        if ($truthy((svg = node.$read_contents(target, $hash2(["start", "normalize", "label", "warn_if_empty"], {"start": node.$document().$attr("imagesdir"), "normalize": true, "label": "SVG", "warn_if_empty": true}))))) {
15465
15466          if ($truthy(svg['$empty?']())) {
15467            return nil
15468          };
15469          if (!$truthy(svg['$start_with?']("<svg"))) {
15470            svg = svg.$sub($$('SvgPreambleRx'), "")
15471          };
15472          old_start_tag = (new_start_tag = (start_tag_match = nil));
15473          $send(["width", "height"], 'each', [], function $$20(dim){var $ret_or_1 = nil, $ret_or_2 = nil;
15474
15475
15476            if (dim == null) dim = nil;
15477            if (!$truthy(node['$attr?'](dim))) {
15478              return nil
15479            };
15480            if (!$truthy(new_start_tag)) {
15481
15482              if ($eqeq((start_tag_match = ($truthy(($ret_or_1 = start_tag_match)) ? ($ret_or_1) : ($truthy(($ret_or_2 = svg.$match($$('SvgStartTagRx')))) ? ($ret_or_2) : ("no_match")))), "no_match")) {
15483                return nil
15484              };
15485              new_start_tag = (old_start_tag = start_tag_match['$[]'](0)).$gsub($$('DimensionAttributeRx'), "");
15486            };
15487            return (new_start_tag = "" + (new_start_tag.$chop()) + " " + (dim) + "=\"" + (node.$attr(dim)) + "\">");});
15488          if ($truthy(new_start_tag)) {
15489            svg = "" + (new_start_tag) + (svg['$[]'](Opal.Range.$new(old_start_tag.$length(), -1, false)))
15490          };
15491        };
15492        return svg;
15493      });
15494      self.$private();
15495
15496      $def(self, '$append_boolean_attribute', function $$append_boolean_attribute(name, xml) {
15497
15498        if ($truthy(xml)) {
15499          return " " + (name) + "=\"" + (name) + "\""
15500        } else {
15501          return " " + (name)
15502        }
15503      });
15504
15505      $def(self, '$append_link_constraint_attrs', function $$append_link_constraint_attrs(node, attrs) {
15506        var rel = nil, window = nil;
15507
15508
15509        if (attrs == null) attrs = [];
15510        if ($truthy(node['$option?']("nofollow"))) {
15511          rel = "nofollow"
15512        };
15513        if ($truthy((window = node.$attributes()['$[]']("window")))) {
15514
15515          attrs['$<<'](" target=\"" + (window) + "\"");
15516          if (($eqeq(window, "_blank") || ($truthy(node['$option?']("noopener"))))) {
15517            attrs['$<<'](($truthy(rel) ? (" rel=\"" + (rel) + " noopener\"") : (" rel=\"noopener\"")))
15518          };
15519        } else if ($truthy(rel)) {
15520          attrs['$<<'](" rel=\"" + (rel) + "\"")
15521        };
15522        return attrs;
15523      }, -2);
15524
15525      $def(self, '$encode_attribute_value', function $$encode_attribute_value(val) {
15526
15527        if ($truthy(val['$include?']("\""))) {
15528
15529          return val.$gsub("\"", "&quot;");
15530        } else {
15531          return val
15532        }
15533      });
15534
15535      $def(self, '$generate_manname_section', function $$generate_manname_section(node) {
15536        var manname_title = nil, next_section_title = nil, next_section = nil, manname_id_attr = nil, manname_id = nil;
15537
15538
15539        manname_title = node.$attr("manname-title", "Name");
15540        if (($truthy((next_section = node.$sections()['$[]'](0))) && ($eqeq((next_section_title = next_section.$title()), next_section_title.$upcase())))) {
15541          manname_title = manname_title.$upcase()
15542        };
15543        manname_id_attr = ($truthy((manname_id = node.$attr("manname-id"))) ? (" id=\"" + (manname_id) + "\"") : (""));
15544        return "<h2" + (manname_id_attr) + ">" + (manname_title) + "</h2>\n" + "<div class=\"sectionbody\">\n" + "<p>" + (node.$attr("mannames").$join(", ")) + " - " + (node.$attr("manpurpose")) + "</p>\n" + "</div>";
15545      });
15546
15547      $def(self, '$get_root_document', function $$get_root_document(node) {
15548
15549
15550        while ($truthy((node = node.$document())['$nested?']())) {
15551        node = node.$parent_document()
15552        };
15553        return node;
15554      });
15555
15556      $def(self, '$method_missing', function $$method_missing(id, $a) {
15557        var $post_args, args, $yield = $$method_missing.$$p || nil, self = this, name = nil;
15558
15559        $$method_missing.$$p = null;
15560
15561        $post_args = $slice(arguments, 1);
15562        args = $post_args;
15563        if (($not((name = id.$to_s())['$start_with?']("convert_")) && ($truthy(self['$handles?'](name))))) {
15564
15565          return $send(self, 'send', ["convert_" + (name)].concat($to_a(args)));
15566        } else {
15567          return $send2(self, $find_super(self, 'method_missing', $$method_missing, false, true), 'method_missing', [id].concat($to_a(args)), $yield)
15568        };
15569      }, -2);
15570      return $def(self, '$respond_to_missing?', function $Html5Converter_respond_to_missing$ques$21(id, $a) {
15571        var $post_args, options, self = this, $ret_or_1 = nil, name = nil;
15572
15573
15574        $post_args = $slice(arguments, 1);
15575        options = $post_args;
15576        if ($truthy(($ret_or_1 = (name = id.$to_s())['$start_with?']("convert_")['$!']()))) {
15577
15578          return self['$handles?'](name);
15579        } else {
15580          return $ret_or_1
15581        };
15582      }, -2);
15583    })($$('Converter'), $$$($$('Converter'), 'Base'), $nesting)
15584  })($nesting[0], $nesting)
15585};
15586
15587Opal.modules["asciidoctor/extensions"] = function(Opal) {/* Generated by Opal 1.7.3 */
15588  "use strict";
15589  var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $def = Opal.def, $send = Opal.send, $alias = Opal.alias, $slice = Opal.slice, $rb_plus = Opal.rb_plus, $eqeq = Opal.eqeq, $rb_gt = Opal.rb_gt, $not = Opal.not, $eqeqeq = Opal.eqeqeq, $to_a = Opal.to_a, $to_ary = Opal.to_ary, $const_set = Opal.const_set, $return_val = Opal.return_val, $send2 = Opal.send2, $find_super = Opal.find_super, $NilClass = Opal.NilClass, $class_variable_set = Opal.class_variable_set, $class_variable_get = Opal.class_variable_get, $regexp = Opal.regexp, $Class = Opal.Class, $return_ivar = Opal.return_ivar, $rb_lt = Opal.rb_lt, $rb_minus = Opal.rb_minus, $hash = Opal.hash, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
15590
15591  Opal.add_stubs('[]=,config,const_defined?,singleton_class?,include,const_get,extend,enable_dsl,attr_reader,merge,class,update,raise,document,==,doctype,[],+,level,delete,>,casecmp,new,title=,sectname=,special=,fetch,numbered=,attr?,!,key?,special,numbered,id=,generate_id,title,update_attributes,tr,basename,create_block,assign_caption,===,parse_blocks,empty?,include?,sub_attributes,parse,each,define_method,unshift,shift,send,size,receiver,binding,define_singleton_method,instance_exec,to_proc,call,option,content_model,flatten,positional_attributes,default_attributes,respond_to?,to_s,partition,to_i,<<,compact,inspect,resolve_attributes,attr_accessor,to_set,contexts,match?,resolve_regexp,format,method,register,reset,values,groups,arity,activate,add_document_processor,tree_processor,tree_processors?,tree_processors,any?,select,add_syntax_processor,to_sym,instance_variable_get,kind,private,join,map,split,capitalize,instance_variable_set,resolve_args,singleton_class,process_block_given?,source_location,freeze,resolve_class,<,update_config,as_symbol,name,name=,pop,-,-@,next_auto_id,generate_name,each_with_object');
15592
15593  nil;
15594  return (function($base, $parent_nesting) {
15595    var self = $module($base, 'Asciidoctor');
15596
15597    var $nesting = [self].concat($parent_nesting);
15598
15599    return (function($base, $parent_nesting) {
15600      var self = $module($base, 'Extensions');
15601
15602      var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
15603
15604
15605      (function($base, $super, $parent_nesting) {
15606        var self = $klass($base, $super, 'Processor');
15607
15608        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
15609
15610        $proto.config = nil;
15611
15612        (function(self, $parent_nesting) {
15613
15614
15615
15616          $def(self, '$config', function $$config() {
15617            var self = this, $ret_or_1 = nil;
15618            if (self.config == null) self.config = nil;
15619
15620            return (self.config = ($truthy(($ret_or_1 = self.config)) ? ($ret_or_1) : ($hash2([], {}))))
15621          });
15622
15623          $def(self, '$option', function $$option(key, default_value) {
15624            var $a, self = this;
15625
15626            return ($a = [key, default_value], $send(self.$config(), '[]=', $a), $a[$a.length - 1])
15627          });
15628
15629          $def(self, '$enable_dsl', function $$enable_dsl() {
15630            var self = this;
15631
15632            if ($truthy(self['$const_defined?']("DSL"))) {
15633              if ($truthy(self['$singleton_class?']())) {
15634                return self.$include(self.$const_get("DSL"))
15635              } else {
15636                return self.$extend(self.$const_get("DSL"))
15637              }
15638            } else {
15639              return nil
15640            }
15641          });
15642          return $alias(self, "use_dsl", "enable_dsl");
15643        })(Opal.get_singleton_class(self), $nesting);
15644        self.$attr_reader("config");
15645
15646        $def(self, '$initialize', function $$initialize(config) {
15647          var self = this;
15648
15649
15650          if (config == null) config = $hash2([], {});
15651          return (self.config = self.$class().$config().$merge(config));
15652        }, -1);
15653
15654        $def(self, '$update_config', function $$update_config(config) {
15655          var self = this;
15656
15657          return self.config.$update(config)
15658        });
15659
15660        $def(self, '$process', function $$process($a) {
15661          var $post_args, args, self = this;
15662
15663
15664          $post_args = $slice(arguments);
15665          args = $post_args;
15666          return self.$raise($$$('NotImplementedError'), "" + ($$('Processor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method");
15667        }, -1);
15668
15669        $def(self, '$create_section', function $$create_section(parent, title, attrs, opts) {
15670          var $a, $b, doc = nil, book = nil, doctype = nil, level = nil, $ret_or_1 = nil, style = nil, sectname = nil, special = nil, sect = nil, id = nil;
15671
15672
15673          if (opts == null) opts = $hash2([], {});
15674          doc = parent.$document();
15675          book = (doctype = doc.$doctype())['$==']("book");
15676          level = ($truthy(($ret_or_1 = opts['$[]']("level"))) ? ($ret_or_1) : ($rb_plus(parent.$level(), 1)));
15677          if ($truthy((style = attrs.$delete("style")))) {
15678            if (($truthy(book) && ($eqeq(style, "abstract")))) {
15679              $a = ["chapter", 1], (sectname = $a[0]), (level = $a[1]), $a
15680            } else {
15681
15682              $a = [style, true], (sectname = $a[0]), (special = $a[1]), $a;
15683              if ($eqeq(level, 0)) {
15684                level = 1
15685              };
15686            }
15687          } else if ($truthy(book)) {
15688            sectname = ($eqeq(level, 0) ? ("part") : (($truthy($rb_gt(level, 1)) ? ("section") : ("chapter"))))
15689          } else if (($eqeq(doctype, "manpage") && ($eqeq(title.$casecmp("synopsis"), 0)))) {
15690            $a = ["synopsis", true], (sectname = $a[0]), (special = $a[1]), $a
15691          } else {
15692            sectname = "section"
15693          };
15694          sect = $$('Section').$new(parent, level);
15695          $a = [title, sectname], ($b = [$a[0]], $send(sect, 'title=', $b), $b[$b.length - 1]), ($b = [$a[1]], $send(sect, 'sectname=', $b), $b[$b.length - 1]), $a;
15696          if ($truthy(special)) {
15697
15698            sect['$special='](true);
15699            if ($truthy(opts.$fetch("numbered", style['$==']("appendix")))) {
15700              sect['$numbered='](true)
15701            } else if (($not(opts['$key?']("numbered")) && ($truthy(doc['$attr?']("sectnums", "all"))))) {
15702              sect['$numbered=']((($truthy(book) && ($eqeq(level, 1))) ? ("chapter") : (true)))
15703            };
15704          } else if ($truthy($rb_gt(level, 0))) {
15705            if ($truthy(opts.$fetch("numbered", doc['$attr?']("sectnums")))) {
15706              sect['$numbered='](($truthy(sect.$special()) ? (($truthy(($ret_or_1 = parent.$numbered())) || ($ret_or_1))) : (true)))
15707            }
15708          } else if ($truthy(opts.$fetch("numbered", ($truthy(($ret_or_1 = book)) ? (doc['$attr?']("partnums")) : ($ret_or_1))))) {
15709            sect['$numbered='](true)
15710          };
15711          if ($eqeq((id = attrs['$[]']("id")), false)) {
15712            attrs.$delete("id")
15713          } else {
15714            sect['$id='](($a = ["id", ($truthy(($ret_or_1 = id)) ? ($ret_or_1) : (($truthy(doc['$attr?']("sectids")) ? ($$('Section').$generate_id(sect.$title(), doc)) : (nil))))], $send(attrs, '[]=', $a), $a[$a.length - 1]))
15715          };
15716          sect.$update_attributes(attrs);
15717          return sect;
15718        }, -4);
15719
15720        $def(self, '$create_block', function $$create_block(parent, context, source, attrs, opts) {
15721
15722
15723          if (opts == null) opts = $hash2([], {});
15724          return $$('Block').$new(parent, context, $hash2(["source", "attributes"], {"source": source, "attributes": attrs}).$merge(opts));
15725        }, -5);
15726
15727        $def(self, '$create_list', function $$create_list(parent, context, attrs) {
15728          var list = nil;
15729
15730
15731          if (attrs == null) attrs = nil;
15732          list = $$('List').$new(parent, context);
15733          if ($truthy(attrs)) {
15734            list.$update_attributes(attrs)
15735          };
15736          return list;
15737        }, -3);
15738
15739        $def(self, '$create_list_item', function $$create_list_item(parent, text) {
15740
15741
15742          if (text == null) text = nil;
15743          return $$('ListItem').$new(parent, text);
15744        }, -2);
15745
15746        $def(self, '$create_image_block', function $$create_image_block(parent, attrs, opts) {
15747          var $a, self = this, target = nil, $ret_or_1 = nil, title = nil, block = nil;
15748
15749
15750          if (opts == null) opts = $hash2([], {});
15751          if (!$truthy((target = attrs['$[]']("target")))) {
15752            self.$raise($$$('ArgumentError'), "Unable to create an image block, target attribute is required")
15753          };
15754          if ($truthy(($ret_or_1 = attrs['$[]']("alt")))) {
15755            $ret_or_1
15756          } else {
15757            attrs['$[]=']("alt", ($a = ["default-alt", $$('Helpers').$basename(target, true).$tr("_-", " ")], $send(attrs, '[]=', $a), $a[$a.length - 1]))
15758          };
15759          title = ($truthy(attrs['$key?']("title")) ? (attrs.$delete("title")) : (nil));
15760          block = self.$create_block(parent, "image", nil, attrs, opts);
15761          if ($truthy(title)) {
15762
15763            block['$title='](title);
15764            block.$assign_caption(attrs.$delete("caption"), "figure");
15765          };
15766          return block;
15767        }, -3);
15768
15769        $def(self, '$create_inline', function $$create_inline(parent, context, text, opts) {
15770
15771
15772          if (opts == null) opts = $hash2([], {});
15773          return $$('Inline').$new(parent, context, text, ($eqeq(context, "quoted") ? ($hash2(["type"], {"type": "unquoted"}).$merge(opts)) : (opts)));
15774        }, -4);
15775
15776        $def(self, '$parse_content', function $$parse_content(parent, content, attributes) {
15777          var reader = nil;
15778
15779
15780          if (attributes == null) attributes = nil;
15781          reader = ($eqeqeq($$('Reader'), content) ? (content) : ($$('Reader').$new(content)));
15782          $$('Parser').$parse_blocks(reader, parent, attributes);
15783          return parent;
15784        }, -3);
15785
15786        $def(self, '$parse_attributes', function $$parse_attributes(block, attrlist, opts) {
15787          var $ret_or_1 = nil;
15788
15789
15790          if (opts == null) opts = $hash2([], {});
15791          if ($truthy(($truthy(attrlist) ? (attrlist['$empty?']()) : (true)))) {
15792            return $hash2([], {})
15793          };
15794          if (($truthy(opts['$[]']("sub_attributes")) && ($truthy(attrlist['$include?']($$('ATTR_REF_HEAD')))))) {
15795            attrlist = block.$sub_attributes(attrlist)
15796          };
15797          return $$('AttributeList').$new(attrlist).$parse(($truthy(($ret_or_1 = opts['$[]']("positional_attributes"))) ? ($ret_or_1) : ([])));
15798        }, -3);
15799        return $send([["create_paragraph", "create_block", "paragraph"], ["create_open_block", "create_block", "open"], ["create_example_block", "create_block", "example"], ["create_pass_block", "create_block", "pass"], ["create_listing_block", "create_block", "listing"], ["create_literal_block", "create_block", "literal"], ["create_anchor", "create_inline", "anchor"], ["create_inline_pass", "create_inline", "quoted"]], 'each', [], function $Processor$1(method_name, delegate_method_name, context){var self = $Processor$1.$$s == null ? this : $Processor$1.$$s;
15800
15801
15802          if (method_name == null) method_name = nil;
15803          if (delegate_method_name == null) delegate_method_name = nil;
15804          if (context == null) context = nil;
15805          return $send(self, 'define_method', [method_name], function $$2($a){var $post_args, args, self = $$2.$$s == null ? this : $$2.$$s;
15806
15807
15808            $post_args = $slice(arguments);
15809            args = $post_args;
15810            args.$unshift(args.$shift(), context);
15811            return $send(self, 'send', [delegate_method_name].concat($to_a(args)));}, {$$arity: -1, $$s: self});}, {$$s: self});
15812      })($nesting[0], null, $nesting);
15813      (function($base) {
15814        var self = $module($base, 'ProcessorDsl');
15815
15816
15817
15818
15819        $def(self, '$option', function $$option(key, value) {
15820          var $a, self = this;
15821
15822          return ($a = [key, value], $send(self.$config(), '[]=', $a), $a[$a.length - 1])
15823        });
15824
15825        $def(self, '$process', function $$process($a) {
15826          var block = $$process.$$p || nil, $post_args, args, $b, self = this, context = nil;
15827          if (self.process_block == null) self.process_block = nil;
15828
15829          $$process.$$p = null;
15830
15831          ;
15832          $post_args = $slice(arguments);
15833          args = $post_args;
15834          if ((block !== nil)) {
15835
15836            if (!$truthy(args['$empty?']())) {
15837              self.$raise($$$('ArgumentError'), "wrong number of arguments (given " + (args.$size()) + ", expected 0)")
15838            };
15839            if (!($truthy(block.$binding()) && ($eqeq(self, block.$binding().$receiver())))) {
15840
15841              context = self;
15842              $send(block, 'define_singleton_method', ["call"], function $$3($b){var $post_args, m_args;
15843
15844
15845                $post_args = $slice(arguments);
15846                m_args = $post_args;
15847                return $send(context, 'instance_exec', $to_a(m_args), block.$to_proc());}, -1);
15848            };
15849            return (self.process_block = block);
15850          } else if ($truthy((($b = self['process_block'], $b != null && $b !== nil) ? 'instance-variable' : nil))) {
15851            return $send(self.process_block, 'call', $to_a(args))
15852          } else {
15853            return self.$raise($$$('NotImplementedError'), "" + (self.$class()) + " #" + ("process") + " method called before being registered")
15854          };
15855        }, -1);
15856        return $def(self, '$process_block_given?', function $ProcessorDsl_process_block_given$ques$4() {
15857          var $a, self = this;
15858
15859          return (($a = self['process_block'], $a != null && $a !== nil) ? 'instance-variable' : nil)
15860        });
15861      })($nesting[0]);
15862      (function($base, $parent_nesting) {
15863        var self = $module($base, 'DocumentProcessorDsl');
15864
15865        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
15866
15867
15868        self.$include($$('ProcessorDsl'));
15869        return $def(self, '$prefer', function $$prefer() {
15870          var self = this;
15871
15872          return self.$option("position", ">>")
15873        });
15874      })($nesting[0], $nesting);
15875      (function($base, $parent_nesting) {
15876        var self = $module($base, 'SyntaxProcessorDsl');
15877
15878        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
15879
15880
15881        self.$include($$('ProcessorDsl'));
15882
15883        $def(self, '$named', function $$named(value) {
15884          var self = this;
15885
15886          if ($eqeqeq($$('Processor'), self)) {
15887            return (self.name = value)
15888          } else {
15889            return self.$option("name", value)
15890          }
15891        });
15892
15893        $def(self, '$content_model', function $$content_model(value) {
15894          var self = this;
15895
15896          return self.$option("content_model", value)
15897        });
15898        $alias(self, "parse_content_as", "content_model");
15899
15900        $def(self, '$positional_attributes', function $$positional_attributes($a) {
15901          var $post_args, value, self = this;
15902
15903
15904          $post_args = $slice(arguments);
15905          value = $post_args;
15906          return self.$option("positional_attrs", value.$flatten());
15907        }, -1);
15908        $alias(self, "name_positional_attributes", "positional_attributes");
15909        $alias(self, "positional_attrs", "positional_attributes");
15910
15911        $def(self, '$default_attributes', function $$default_attributes(value) {
15912          var self = this;
15913
15914          return self.$option("default_attrs", value)
15915        });
15916        $alias(self, "default_attrs", "default_attributes");
15917
15918        $def(self, '$resolve_attributes', function $$resolve_attributes($a) {
15919          var $post_args, args, $b, self = this, $ret_or_1 = nil, names = nil, defaults = nil;
15920
15921
15922          $post_args = $slice(arguments);
15923          args = $post_args;
15924          if (!$truthy($rb_gt(args.$size(), 1))) {
15925            if ($truthy((args = args.$fetch(0, true))['$respond_to?']("to_sym"))) {
15926              args = [args]
15927            }
15928          };
15929          if ($eqeqeq(true, ($ret_or_1 = args))) {
15930
15931            self.$option("positional_attrs", []);
15932            return self.$option("default_attrs", $hash2([], {}));
15933          } else if ($eqeqeq($$$('Array'), $ret_or_1)) {
15934
15935            $b = [[], $hash2([], {})], (names = $b[0]), (defaults = $b[1]), $b;
15936            $send(args, 'each', [], function $$5(arg){var $c, $d, name = nil, _ = nil, value = nil, idx = nil;
15937
15938
15939              if (arg == null) arg = nil;
15940              if ($truthy((arg = arg.$to_s())['$include?']("="))) {
15941
15942                $d = arg.$partition("="), $c = $to_ary($d), (name = ($c[0] == null ? nil : $c[0])), (_ = ($c[1] == null ? nil : $c[1])), (value = ($c[2] == null ? nil : $c[2])), $d;
15943                if ($truthy(name['$include?'](":"))) {
15944
15945                  $d = name.$partition(":"), $c = $to_ary($d), (idx = ($c[0] == null ? nil : $c[0])), (_ = ($c[1] == null ? nil : $c[1])), (name = ($c[2] == null ? nil : $c[2])), $d;
15946                  idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i()));
15947                  names['$[]='](idx, name);
15948                };
15949                return ($c = [name, value], $send(defaults, '[]=', $c), $c[$c.length - 1]);
15950              } else if ($truthy(arg['$include?'](":"))) {
15951
15952                $d = arg.$partition(":"), $c = $to_ary($d), (idx = ($c[0] == null ? nil : $c[0])), (_ = ($c[1] == null ? nil : $c[1])), (name = ($c[2] == null ? nil : $c[2])), $d;
15953                idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i()));
15954                return ($c = [idx, name], $send(names, '[]=', $c), $c[$c.length - 1]);
15955              } else {
15956                return names['$<<'](arg)
15957              };});
15958            self.$option("positional_attrs", names.$compact());
15959            return self.$option("default_attrs", defaults);
15960          } else if ($eqeqeq($$$('Hash'), $ret_or_1)) {
15961
15962            $b = [[], $hash2([], {})], (names = $b[0]), (defaults = $b[1]), $b;
15963            $send(args, 'each', [], function $$6(key, val){var $c, $d, name = nil, idx = nil, _ = nil;
15964
15965
15966              if (key == null) key = nil;
15967              if (val == null) val = nil;
15968              if ($truthy((name = key.$to_s())['$include?'](":"))) {
15969
15970                $d = name.$partition(":"), $c = $to_ary($d), (idx = ($c[0] == null ? nil : $c[0])), (_ = ($c[1] == null ? nil : $c[1])), (name = ($c[2] == null ? nil : $c[2])), $d;
15971                idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i()));
15972                names['$[]='](idx, name);
15973              };
15974              if ($truthy(val)) {
15975                return ($c = [name, val], $send(defaults, '[]=', $c), $c[$c.length - 1])
15976              } else {
15977                return nil
15978              };});
15979            self.$option("positional_attrs", names.$compact());
15980            return self.$option("default_attrs", defaults);
15981          } else {
15982            return self.$raise($$$('ArgumentError'), "unsupported attributes specification for macro: " + (args.$inspect()))
15983          };
15984        }, -1);
15985        return $alias(self, "resolves_attributes", "resolve_attributes");
15986      })($nesting[0], $nesting);
15987      (function($base, $super, $parent_nesting) {
15988        var self = $klass($base, $super, 'Preprocessor');
15989
15990        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
15991
15992        return $def(self, '$process', function $$process(document, reader) {
15993          var self = this;
15994
15995          return self.$raise($$$('NotImplementedError'), "" + ($$('Preprocessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
15996        })
15997      })($nesting[0], $$('Processor'), $nesting);
15998      $const_set($$('Preprocessor'), 'DSL', $$('DocumentProcessorDsl'));
15999      (function($base, $super, $parent_nesting) {
16000        var self = $klass($base, $super, 'TreeProcessor');
16001
16002        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16003
16004        return $def(self, '$process', function $$process(document) {
16005          var self = this;
16006
16007          return self.$raise($$$('NotImplementedError'), "" + ($$('TreeProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16008        })
16009      })($nesting[0], $$('Processor'), $nesting);
16010      $const_set($$('TreeProcessor'), 'DSL', $$('DocumentProcessorDsl'));
16011      $const_set($nesting[0], 'Treeprocessor', $$('TreeProcessor'));
16012      (function($base, $super, $parent_nesting) {
16013        var self = $klass($base, $super, 'Postprocessor');
16014
16015        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16016
16017        return $def(self, '$process', function $$process(document, output) {
16018          var self = this;
16019
16020          return self.$raise($$$('NotImplementedError'), "" + ($$('Postprocessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16021        })
16022      })($nesting[0], $$('Processor'), $nesting);
16023      $const_set($$('Postprocessor'), 'DSL', $$('DocumentProcessorDsl'));
16024      (function($base, $super, $parent_nesting) {
16025        var self = $klass($base, $super, 'IncludeProcessor');
16026
16027        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16028
16029
16030
16031        $def(self, '$process', function $$process(document, reader, target, attributes) {
16032          var self = this;
16033
16034          return self.$raise($$$('NotImplementedError'), "" + ($$('IncludeProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16035        });
16036        return $def(self, '$handles?', $return_val(true));
16037      })($nesting[0], $$('Processor'), $nesting);
16038      (function($base, $parent_nesting) {
16039        var self = $module($base, 'IncludeProcessorDsl');
16040
16041        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16042
16043
16044        self.$include($$('DocumentProcessorDsl'));
16045        return $def(self, '$handles?', function $IncludeProcessorDsl_handles$ques$7($a) {
16046          var block = $IncludeProcessorDsl_handles$ques$7.$$p || nil, $post_args, args, $b, self = this;
16047          if (self.handles_block == null) self.handles_block = nil;
16048
16049          $IncludeProcessorDsl_handles$ques$7.$$p = null;
16050
16051          ;
16052          $post_args = $slice(arguments);
16053          args = $post_args;
16054          if ((block !== nil)) {
16055
16056            if (!$truthy(args['$empty?']())) {
16057              self.$raise($$$('ArgumentError'), "wrong number of arguments (given " + (args.$size()) + ", expected 0)")
16058            };
16059            return (self.handles_block = block);
16060          } else if ($truthy((($b = self['handles_block'], $b != null && $b !== nil) ? 'instance-variable' : nil))) {
16061            return self.handles_block.$call(args['$[]'](0))
16062          } else {
16063            return true
16064          };
16065        }, -1);
16066      })($nesting[0], $nesting);
16067      $const_set($$('IncludeProcessor'), 'DSL', $$('IncludeProcessorDsl'));
16068      (function($base, $super, $parent_nesting) {
16069        var self = $klass($base, $super, 'DocinfoProcessor');
16070
16071        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16072
16073        $proto.config = nil;
16074
16075
16076        $def(self, '$initialize', function $$initialize(config) {
16077          var $a, $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil;
16078
16079          $$initialize.$$p = null;
16080
16081          if (config == null) config = $hash2([], {});
16082          $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null);
16083          if ($truthy(($ret_or_1 = self.config['$[]']("location")))) {
16084            return $ret_or_1
16085          } else {
16086            return ($a = ["location", "head"], $send(self.config, '[]=', $a), $a[$a.length - 1])
16087          };
16088        }, -1);
16089        return $def(self, '$process', function $$process(document) {
16090          var self = this;
16091
16092          return self.$raise($$$('NotImplementedError'), "" + ($$('DocinfoProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16093        });
16094      })($nesting[0], $$('Processor'), $nesting);
16095      (function($base, $parent_nesting) {
16096        var self = $module($base, 'DocinfoProcessorDsl');
16097
16098        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16099
16100
16101        self.$include($$('DocumentProcessorDsl'));
16102        return $def(self, '$at_location', function $$at_location(value) {
16103          var self = this;
16104
16105          return self.$option("location", value)
16106        });
16107      })($nesting[0], $nesting);
16108      $const_set($$('DocinfoProcessor'), 'DSL', $$('DocinfoProcessorDsl'));
16109      (function($base, $super, $parent_nesting) {
16110        var self = $klass($base, $super, 'BlockProcessor');
16111
16112        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16113
16114        $proto.config = nil;
16115
16116        self.$attr_accessor("name");
16117
16118        $def(self, '$initialize', function $$initialize(name, config) {
16119          var $a, $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil, $ret_or_2 = nil;
16120
16121          $$initialize.$$p = null;
16122
16123          if (name == null) name = nil;
16124          if (config == null) config = $hash2([], {});
16125          $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null);
16126          self.name = ($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.config['$[]']("name")));
16127          if ($eqeqeq($NilClass, ($ret_or_1 = self.config['$[]']("contexts")))) {
16128            if ($truthy(($ret_or_2 = self.config['$[]']("contexts")))) {
16129              $ret_or_2
16130            } else {
16131              self.config['$[]=']("contexts", ["open", "paragraph"].$to_set())
16132            }
16133          } else if ($eqeqeq($$$('Symbol'), $ret_or_1)) {
16134            self.config['$[]=']("contexts", [self.config['$[]']("contexts")].$to_set())
16135          } else {
16136            self.config['$[]=']("contexts", self.config['$[]']("contexts").$to_set())
16137          };
16138          if ($truthy(($ret_or_1 = self.config['$[]']("content_model")))) {
16139            return $ret_or_1
16140          } else {
16141            return ($a = ["content_model", "compound"], $send(self.config, '[]=', $a), $a[$a.length - 1])
16142          };
16143        }, -1);
16144        return $def(self, '$process', function $$process(parent, reader, attributes) {
16145          var self = this;
16146
16147          return self.$raise($$$('NotImplementedError'), "" + ($$('BlockProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16148        });
16149      })($nesting[0], $$('Processor'), $nesting);
16150      (function($base, $parent_nesting) {
16151        var self = $module($base, 'BlockProcessorDsl');
16152
16153        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16154
16155
16156        self.$include($$('SyntaxProcessorDsl'));
16157
16158        $def(self, '$contexts', function $$contexts($a) {
16159          var $post_args, value, self = this;
16160
16161
16162          $post_args = $slice(arguments);
16163          value = $post_args;
16164          return self.$option("contexts", value.$flatten().$to_set());
16165        }, -1);
16166        $alias(self, "on_contexts", "contexts");
16167        $alias(self, "on_context", "contexts");
16168        return $alias(self, "bind_to", "contexts");
16169      })($nesting[0], $nesting);
16170      $const_set($$('BlockProcessor'), 'DSL', $$('BlockProcessorDsl'));
16171      (function($base, $super, $parent_nesting) {
16172        var self = $klass($base, $super, 'MacroProcessor');
16173
16174        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16175
16176        $proto.config = nil;
16177
16178        self.$attr_accessor("name");
16179
16180        $def(self, '$initialize', function $$initialize(name, config) {
16181          var $a, $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil;
16182
16183          $$initialize.$$p = null;
16184
16185          if (name == null) name = nil;
16186          if (config == null) config = $hash2([], {});
16187          $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null);
16188          self.name = ($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.config['$[]']("name")));
16189          if ($truthy(($ret_or_1 = self.config['$[]']("content_model")))) {
16190            return $ret_or_1
16191          } else {
16192            return ($a = ["content_model", "attributes"], $send(self.config, '[]=', $a), $a[$a.length - 1])
16193          };
16194        }, -1);
16195        return $def(self, '$process', function $$process(parent, target, attributes) {
16196          var self = this;
16197
16198          return self.$raise($$$('NotImplementedError'), "" + ($$('MacroProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method")
16199        });
16200      })($nesting[0], $$('Processor'), $nesting);
16201      (function($base, $parent_nesting) {
16202        var self = $module($base, 'MacroProcessorDsl');
16203
16204        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16205
16206
16207        self.$include($$('SyntaxProcessorDsl'));
16208
16209        $def(self, '$resolve_attributes', function $$resolve_attributes($a) {
16210          var $post_args, args, $yield = $$resolve_attributes.$$p || nil, self = this;
16211
16212          $$resolve_attributes.$$p = null;
16213
16214          $post_args = $slice(arguments);
16215          args = $post_args;
16216          if (($eqeq(args.$size(), 1) && ($not(args['$[]'](0))))) {
16217            return self.$option("content_model", "text")
16218          } else {
16219
16220            $send2(self, $find_super(self, 'resolve_attributes', $$resolve_attributes, false, true), 'resolve_attributes', $to_a(args), $yield);
16221            return self.$option("content_model", "attributes");
16222          };
16223        }, -1);
16224        return $alias(self, "resolves_attributes", "resolve_attributes");
16225      })($nesting[0], $nesting);
16226      (function($base, $super, $parent_nesting) {
16227        var self = $klass($base, $super, 'BlockMacroProcessor');
16228
16229        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16230
16231        $proto.name = nil;
16232        return $def(self, '$name', function $$name() {
16233          var self = this;
16234
16235
16236          if (!$truthy($$('MacroNameRx')['$match?'](self.name.$to_s()))) {
16237            self.$raise($$$('ArgumentError'), "invalid name for block macro: " + (self.name))
16238          };
16239          return self.name;
16240        })
16241      })($nesting[0], $$('MacroProcessor'), $nesting);
16242      $const_set($$('BlockMacroProcessor'), 'DSL', $$('MacroProcessorDsl'));
16243      (function($base, $super, $parent_nesting) {
16244        var self = $klass($base, $super, 'InlineMacroProcessor');
16245
16246        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16247
16248        $proto.config = $proto.name = nil;
16249
16250        $class_variable_set($nesting[0], '@@rx_cache', $hash2([], {}));
16251
16252        $def(self, '$regexp', function $$regexp() {
16253          var $a, self = this, $ret_or_1 = nil;
16254
16255          if ($truthy(($ret_or_1 = self.config['$[]']("regexp")))) {
16256            return $ret_or_1
16257          } else {
16258            return ($a = ["regexp", self.$resolve_regexp(self.name.$to_s(), self.config['$[]']("format"))], $send(self.config, '[]=', $a), $a[$a.length - 1])
16259          }
16260        });
16261        return $def(self, '$resolve_regexp', function $$resolve_regexp(name, format) {
16262          var $a, self = this, $ret_or_1 = nil;
16263
16264
16265          if (!$truthy($$('MacroNameRx')['$match?'](name))) {
16266            self.$raise($$$('ArgumentError'), "invalid name for inline macro: " + (name))
16267          };
16268          if ($truthy(($ret_or_1 = $class_variable_get($nesting[0], '@@rx_cache', false)['$[]']([name, format])))) {
16269            return $ret_or_1
16270          } else {
16271            return ($a = [[name, format], $regexp(["\\\\?", name, ":", ($eqeq(format, "short") ? ("(){0}") : ("(\\S+?)")), "\\[(|", $$('CC_ANY'), "*?[^\\\\])\\]"])], $send($class_variable_get($nesting[0], '@@rx_cache', false), '[]=', $a), $a[$a.length - 1])
16272          };
16273        });
16274      })($nesting[0], $$('MacroProcessor'), $nesting);
16275      (function($base, $parent_nesting) {
16276        var self = $module($base, 'InlineMacroProcessorDsl');
16277
16278        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16279
16280
16281        self.$include($$('MacroProcessorDsl'));
16282
16283        $def(self, '$format', function $$format(value) {
16284          var self = this;
16285
16286          return self.$option("format", value)
16287        });
16288        $alias(self, "match_format", "format");
16289        $alias(self, "using_format", "format");
16290        return $def(self, '$match', function $$match(value) {
16291          var self = this;
16292
16293          return self.$option("regexp", value)
16294        });
16295      })($nesting[0], $nesting);
16296      $const_set($$('InlineMacroProcessor'), 'DSL', $$('InlineMacroProcessorDsl'));
16297      (function($base, $super) {
16298        var self = $klass($base, $super, 'Extension');
16299
16300
16301
16302        self.$attr_reader("kind");
16303        self.$attr_reader("config");
16304        self.$attr_reader("instance");
16305        return $def(self, '$initialize', function $$initialize(kind, instance, config) {
16306          var self = this;
16307
16308
16309          self.kind = kind;
16310          self.instance = instance;
16311          return (self.config = config);
16312        });
16313      })($nesting[0], null);
16314      (function($base, $super) {
16315        var self = $klass($base, $super, 'ProcessorExtension');
16316
16317
16318
16319        self.$attr_reader("process_method");
16320        return $def(self, '$initialize', function $$initialize(kind, instance, process_method) {
16321          var $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil;
16322
16323          $$initialize.$$p = null;
16324
16325          if (process_method == null) process_method = nil;
16326          $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [kind, instance, instance.$config()], null);
16327          return (self.process_method = ($truthy(($ret_or_1 = process_method)) ? ($ret_or_1) : (instance.$method("process"))));
16328        }, -3);
16329      })($nesting[0], $$('Extension'));
16330      (function($base, $super, $parent_nesting) {
16331        var self = $klass($base, $super, 'Group');
16332
16333        var $nesting = [self].concat($parent_nesting);
16334
16335
16336        (function(self, $parent_nesting) {
16337          var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16338
16339          return $def(self, '$register', function $$register(name) {
16340            var self = this;
16341
16342
16343            if (name == null) name = nil;
16344            return $$('Extensions').$register(name, self);
16345          }, -1)
16346        })(Opal.get_singleton_class(self), $nesting);
16347        return $def(self, '$activate', function $$activate(registry) {
16348          var self = this;
16349
16350          return self.$raise($$$('NotImplementedError'))
16351        });
16352      })($nesting[0], null, $nesting);
16353      (function($base, $super, $parent_nesting) {
16354        var self = $klass($base, $super, 'Registry');
16355
16356        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
16357
16358        $proto.document = $proto.groups = $proto.preprocessor_extensions = $proto.tree_processor_extensions = $proto.postprocessor_extensions = $proto.include_processor_extensions = $proto.docinfo_processor_extensions = $proto.block_extensions = $proto.block_macro_extensions = $proto.inline_macro_extensions = nil;
16359
16360        self.$attr_reader("document");
16361        self.$attr_reader("groups");
16362
16363        $def(self, '$initialize', function $$initialize(groups) {
16364          var self = this;
16365
16366
16367          if (groups == null) groups = $hash2([], {});
16368          self.groups = groups;
16369          self.$reset();
16370          self.preprocessor_extensions = (self.tree_processor_extensions = (self.postprocessor_extensions = (self.include_processor_extensions = (self.docinfo_processor_extensions = (self.block_extensions = (self.block_macro_extensions = (self.inline_macro_extensions = nil)))))));
16371          return (self.document = nil);
16372        }, -1);
16373
16374        $def(self, '$activate', function $$activate(document) {
16375          var self = this, ext_groups = nil;
16376
16377
16378          if ($truthy(self.document)) {
16379            self.$reset()
16380          };
16381          self.document = document;
16382          if (!$truthy((ext_groups = $rb_plus($$('Extensions').$groups().$values(), self.groups.$values()))['$empty?']())) {
16383            $send(ext_groups, 'each', [], function $$8(group){var self = $$8.$$s == null ? this : $$8.$$s, $ret_or_1 = nil;
16384
16385
16386              if (group == null) group = nil;
16387              if ($eqeqeq($$$('Proc'), ($ret_or_1 = group))) {
16388
16389                switch (group.$arity()) {
16390                  case 0:
16391                  case -1:
16392                    return $send(self, 'instance_exec', [], group.$to_proc())
16393                  case 1:
16394                    return group.$call(self)
16395                  default:
16396                    return nil
16397                }
16398              } else if ($eqeqeq($Class, $ret_or_1)) {
16399                return group.$new().$activate(self)
16400              } else {
16401                return group.$activate(self)
16402              };}, {$$s: self})
16403          };
16404          return self;
16405        });
16406
16407        $def(self, '$preprocessor', function $$preprocessor($a) {
16408          var block = $$preprocessor.$$p || nil, $post_args, args, self = this;
16409
16410          $$preprocessor.$$p = null;
16411
16412          ;
16413          $post_args = $slice(arguments);
16414          args = $post_args;
16415          return $send(self, 'add_document_processor', ["preprocessor", args], block.$to_proc());
16416        }, -1);
16417
16418        $def(self, '$preprocessors?', function $Registry_preprocessors$ques$9() {
16419          var self = this;
16420
16421          return self.preprocessor_extensions['$!']()['$!']()
16422        });
16423
16424        $def(self, '$preprocessors', $return_ivar("preprocessor_extensions"));
16425
16426        $def(self, '$tree_processor', function $$tree_processor($a) {
16427          var block = $$tree_processor.$$p || nil, $post_args, args, self = this;
16428
16429          $$tree_processor.$$p = null;
16430
16431          ;
16432          $post_args = $slice(arguments);
16433          args = $post_args;
16434          return $send(self, 'add_document_processor', ["tree_processor", args], block.$to_proc());
16435        }, -1);
16436
16437        $def(self, '$tree_processors?', function $Registry_tree_processors$ques$10() {
16438          var self = this;
16439
16440          return self.tree_processor_extensions['$!']()['$!']()
16441        });
16442
16443        $def(self, '$tree_processors', $return_ivar("tree_processor_extensions"));
16444        $alias(self, "treeprocessor", "tree_processor");
16445        $alias(self, "treeprocessors?", "tree_processors?");
16446        $alias(self, "treeprocessors", "tree_processors");
16447
16448        $def(self, '$postprocessor', function $$postprocessor($a) {
16449          var block = $$postprocessor.$$p || nil, $post_args, args, self = this;
16450
16451          $$postprocessor.$$p = null;
16452
16453          ;
16454          $post_args = $slice(arguments);
16455          args = $post_args;
16456          return $send(self, 'add_document_processor', ["postprocessor", args], block.$to_proc());
16457        }, -1);
16458
16459        $def(self, '$postprocessors?', function $Registry_postprocessors$ques$11() {
16460          var self = this;
16461
16462          return self.postprocessor_extensions['$!']()['$!']()
16463        });
16464
16465        $def(self, '$postprocessors', $return_ivar("postprocessor_extensions"));
16466
16467        $def(self, '$include_processor', function $$include_processor($a) {
16468          var block = $$include_processor.$$p || nil, $post_args, args, self = this;
16469
16470          $$include_processor.$$p = null;
16471
16472          ;
16473          $post_args = $slice(arguments);
16474          args = $post_args;
16475          return $send(self, 'add_document_processor', ["include_processor", args], block.$to_proc());
16476        }, -1);
16477
16478        $def(self, '$include_processors?', function $Registry_include_processors$ques$12() {
16479          var self = this;
16480
16481          return self.include_processor_extensions['$!']()['$!']()
16482        });
16483
16484        $def(self, '$include_processors', $return_ivar("include_processor_extensions"));
16485
16486        $def(self, '$docinfo_processor', function $$docinfo_processor($a) {
16487          var block = $$docinfo_processor.$$p || nil, $post_args, args, self = this;
16488
16489          $$docinfo_processor.$$p = null;
16490
16491          ;
16492          $post_args = $slice(arguments);
16493          args = $post_args;
16494          return $send(self, 'add_document_processor', ["docinfo_processor", args], block.$to_proc());
16495        }, -1);
16496
16497        $def(self, '$docinfo_processors?', function $Registry_docinfo_processors$ques$13(location) {
16498          var self = this;
16499
16500
16501          if (location == null) location = nil;
16502          if ($truthy(self.docinfo_processor_extensions)) {
16503            if ($truthy(location)) {
16504              return $send(self.docinfo_processor_extensions, 'any?', [], function $$14(ext){
16505
16506                if (ext == null) ext = nil;
16507                return ext.$config()['$[]']("location")['$=='](location);})
16508            } else {
16509              return true
16510            }
16511          } else {
16512            return false
16513          };
16514        }, -1);
16515
16516        $def(self, '$docinfo_processors', function $$docinfo_processors(location) {
16517          var self = this;
16518
16519
16520          if (location == null) location = nil;
16521          if ($truthy(self.docinfo_processor_extensions)) {
16522            if ($truthy(location)) {
16523              return $send(self.docinfo_processor_extensions, 'select', [], function $$15(ext){
16524
16525                if (ext == null) ext = nil;
16526                return ext.$config()['$[]']("location")['$=='](location);})
16527            } else {
16528              return self.docinfo_processor_extensions
16529            }
16530          } else {
16531            return nil
16532          };
16533        }, -1);
16534
16535        $def(self, '$block', function $$block($a) {
16536          var block = $$block.$$p || nil, $post_args, args, self = this;
16537
16538          $$block.$$p = null;
16539
16540          ;
16541          $post_args = $slice(arguments);
16542          args = $post_args;
16543          return $send(self, 'add_syntax_processor', ["block", args], block.$to_proc());
16544        }, -1);
16545
16546        $def(self, '$blocks?', function $Registry_blocks$ques$16() {
16547          var self = this;
16548
16549          return self.block_extensions['$!']()['$!']()
16550        });
16551
16552        $def(self, '$registered_for_block?', function $Registry_registered_for_block$ques$17(name, context) {
16553          var self = this, ext = nil;
16554
16555          if ($truthy((ext = self.block_extensions['$[]'](name.$to_sym())))) {
16556            if ($truthy(ext.$config()['$[]']("contexts")['$include?'](context))) {
16557              return ext
16558            } else {
16559              return false
16560            }
16561          } else {
16562            return false
16563          }
16564        });
16565
16566        $def(self, '$find_block_extension', function $$find_block_extension(name) {
16567          var self = this;
16568
16569          return self.block_extensions['$[]'](name.$to_sym())
16570        });
16571
16572        $def(self, '$block_macro', function $$block_macro($a) {
16573          var block = $$block_macro.$$p || nil, $post_args, args, self = this;
16574
16575          $$block_macro.$$p = null;
16576
16577          ;
16578          $post_args = $slice(arguments);
16579          args = $post_args;
16580          return $send(self, 'add_syntax_processor', ["block_macro", args], block.$to_proc());
16581        }, -1);
16582
16583        $def(self, '$block_macros?', function $Registry_block_macros$ques$18() {
16584          var self = this;
16585
16586          return self.block_macro_extensions['$!']()['$!']()
16587        });
16588
16589        $def(self, '$registered_for_block_macro?', function $Registry_registered_for_block_macro$ques$19(name) {
16590          var self = this, ext = nil;
16591
16592          if ($truthy((ext = self.block_macro_extensions['$[]'](name.$to_sym())))) {
16593            return ext
16594          } else {
16595            return false
16596          }
16597        });
16598
16599        $def(self, '$find_block_macro_extension', function $$find_block_macro_extension(name) {
16600          var self = this;
16601
16602          return self.block_macro_extensions['$[]'](name.$to_sym())
16603        });
16604
16605        $def(self, '$inline_macro', function $$inline_macro($a) {
16606          var block = $$inline_macro.$$p || nil, $post_args, args, self = this;
16607
16608          $$inline_macro.$$p = null;
16609
16610          ;
16611          $post_args = $slice(arguments);
16612          args = $post_args;
16613          return $send(self, 'add_syntax_processor', ["inline_macro", args], block.$to_proc());
16614        }, -1);
16615
16616        $def(self, '$inline_macros?', function $Registry_inline_macros$ques$20() {
16617          var self = this;
16618
16619          return self.inline_macro_extensions['$!']()['$!']()
16620        });
16621
16622        $def(self, '$registered_for_inline_macro?', function $Registry_registered_for_inline_macro$ques$21(name) {
16623          var self = this, ext = nil;
16624
16625          if ($truthy((ext = self.inline_macro_extensions['$[]'](name.$to_sym())))) {
16626            return ext
16627          } else {
16628            return false
16629          }
16630        });
16631
16632        $def(self, '$find_inline_macro_extension', function $$find_inline_macro_extension(name) {
16633          var self = this;
16634
16635          return self.inline_macro_extensions['$[]'](name.$to_sym())
16636        });
16637
16638        $def(self, '$inline_macros', function $$inline_macros() {
16639          var self = this;
16640
16641          return self.inline_macro_extensions.$values()
16642        });
16643
16644        $def(self, '$prefer', function $$prefer($a) {
16645          var block = $$prefer.$$p || nil, $post_args, args, self = this, extension = nil, arg0 = nil, extensions_store = nil;
16646
16647          $$prefer.$$p = null;
16648
16649          ;
16650          $post_args = $slice(arguments);
16651          args = $post_args;
16652          extension = ($eqeqeq($$('ProcessorExtension'), (arg0 = args.$shift())) ? (arg0) : ($send(self, 'send', [arg0].concat($to_a(args)), block.$to_proc())));
16653          extensions_store = self.$instance_variable_get(((("@") + (extension.$kind())) + "_extensions").$to_sym());
16654          extensions_store.$unshift(extensions_store.$delete(extension));
16655          return extension;
16656        }, -1);
16657        self.$private();
16658
16659        $def(self, '$add_document_processor', function $$add_document_processor(kind, args) {
16660          var block = $$add_document_processor.$$p || nil, $a, $b, $c, self = this, kind_name = nil, kind_class_symbol = nil, kind_class = nil, kind_java_class = nil, kind_store = nil, $ret_or_1 = nil, config = nil, processor = nil, extension = nil, processor_class = nil, processor_instance = nil;
16661
16662          $$add_document_processor.$$p = null;
16663
16664          ;
16665          kind_name = kind.$to_s().$tr("_", " ");
16666          kind_class_symbol = $send(kind_name.$split(), 'map', [], function $$22(it){
16667
16668            if (it == null) it = nil;
16669            return it.$capitalize();}).$join().$to_sym();
16670          kind_class = $$('Extensions').$const_get(kind_class_symbol, false);
16671          kind_java_class = ($truthy((($a = $$$('::', 'AsciidoctorJ', 'skip_raise')) ? 'constant' : nil)) ? ($$$($$$('AsciidoctorJ'), 'Extensions').$const_get(kind_class_symbol, false)) : (nil));
16672          kind_store = ($truthy(($ret_or_1 = self.$instance_variable_get(((("@") + (kind)) + "_extensions").$to_sym()))) ? ($ret_or_1) : (self.$instance_variable_set(((("@") + (kind)) + "_extensions").$to_sym(), [])));
16673          if ((block !== nil)) {
16674
16675            config = self.$resolve_args(args, 1);
16676            (processor = kind_class.$new(config)).$singleton_class().$enable_dsl();
16677            if ($eqeq(block.$arity(), 0)) {
16678              $send(processor, 'instance_exec', [], block.$to_proc())
16679            } else {
16680              Opal.yield1(block, processor)
16681            };
16682            if (!$truthy(processor['$process_block_given?']())) {
16683              self.$raise($$$('NoMethodError'), "No block specified to process " + (kind_name) + " extension at " + (block.$source_location().$join(":")))
16684            };
16685            processor.$freeze();
16686            extension = $$('ProcessorExtension').$new(kind, processor);
16687          } else {
16688
16689            $c = self.$resolve_args(args, 2), $b = $to_ary($c), (processor = ($b[0] == null ? nil : $b[0])), (config = ($b[1] == null ? nil : $b[1])), $c;
16690            if ($truthy((processor_class = $$('Helpers').$resolve_class(processor)))) {
16691
16692              if (!($truthy($rb_lt(processor_class, kind_class)) || (($truthy(kind_java_class) && ($truthy($rb_lt(processor_class, kind_java_class))))))) {
16693                self.$raise($$$('ArgumentError'), "Invalid type for " + (kind_name) + " extension: " + (processor))
16694              };
16695              processor_instance = processor_class.$new(config);
16696              processor_instance.$freeze();
16697              extension = $$('ProcessorExtension').$new(kind, processor_instance);
16698            } else if (($eqeqeq(kind_class, processor) || (($truthy(kind_java_class) && ($eqeqeq(kind_java_class, processor)))))) {
16699
16700              processor.$update_config(config);
16701              processor.$freeze();
16702              extension = $$('ProcessorExtension').$new(kind, processor);
16703            } else {
16704              self.$raise($$$('ArgumentError'), "Invalid arguments specified for registering " + (kind_name) + " extension: " + (args))
16705            };
16706          };
16707          if ($eqeq(extension.$config()['$[]']("position"), ">>")) {
16708
16709            kind_store.$unshift(extension);
16710          } else {
16711
16712            kind_store['$<<'](extension);
16713          };
16714          return extension;
16715        });
16716
16717        $def(self, '$add_syntax_processor', function $$add_syntax_processor(kind, args) {
16718          var block = $$add_syntax_processor.$$p || nil, $a, $b, $c, self = this, kind_name = nil, kind_class_symbol = nil, kind_class = nil, kind_java_class = nil, kind_store = nil, $ret_or_1 = nil, name = nil, config = nil, processor = nil, processor_class = nil, processor_instance = nil;
16719
16720          $$add_syntax_processor.$$p = null;
16721
16722          ;
16723          kind_name = kind.$to_s().$tr("_", " ");
16724          kind_class_symbol = $send(kind_name.$split(), 'map', [], function $$23(it){
16725
16726            if (it == null) it = nil;
16727            return it.$capitalize();})['$<<']("Processor").$join().$to_sym();
16728          kind_class = $$('Extensions').$const_get(kind_class_symbol, false);
16729          kind_java_class = ($truthy((($a = $$$('::', 'AsciidoctorJ', 'skip_raise')) ? 'constant' : nil)) ? ($$$($$$('AsciidoctorJ'), 'Extensions').$const_get(kind_class_symbol, false)) : (nil));
16730          kind_store = ($truthy(($ret_or_1 = self.$instance_variable_get(((("@") + (kind)) + "_extensions").$to_sym()))) ? ($ret_or_1) : (self.$instance_variable_set(((("@") + (kind)) + "_extensions").$to_sym(), $hash2([], {}))));
16731          if ((block !== nil)) {
16732
16733            $c = self.$resolve_args(args, 2), $b = $to_ary($c), (name = ($b[0] == null ? nil : $b[0])), (config = ($b[1] == null ? nil : $b[1])), $c;
16734            (processor = kind_class.$new(self.$as_symbol(name), config)).$singleton_class().$enable_dsl();
16735            if ($eqeq(block.$arity(), 0)) {
16736              $send(processor, 'instance_exec', [], block.$to_proc())
16737            } else {
16738              Opal.yield1(block, processor)
16739            };
16740            if (!$truthy((name = self.$as_symbol(processor.$name())))) {
16741              self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension at " + (block.$source_location().$join(":")))
16742            };
16743            if (!$truthy(processor['$process_block_given?']())) {
16744              self.$raise($$$('NoMethodError'), "No block specified to process " + (kind_name) + " extension at " + (block.$source_location().$join(":")))
16745            };
16746            processor.$freeze();
16747            return ($b = [name, $$('ProcessorExtension').$new(kind, processor)], $send(kind_store, '[]=', $b), $b[$b.length - 1]);
16748          } else {
16749
16750            $c = self.$resolve_args(args, 3), $b = $to_ary($c), (processor = ($b[0] == null ? nil : $b[0])), (name = ($b[1] == null ? nil : $b[1])), (config = ($b[2] == null ? nil : $b[2])), $c;
16751            if ($truthy((processor_class = $$('Helpers').$resolve_class(processor)))) {
16752
16753              if (!($truthy($rb_lt(processor_class, kind_class)) || (($truthy(kind_java_class) && ($truthy($rb_lt(processor_class, kind_java_class))))))) {
16754                self.$raise($$$('ArgumentError'), "Class specified for " + (kind_name) + " extension does not inherit from " + (kind_class) + ": " + (processor))
16755              };
16756              processor_instance = processor_class.$new(self.$as_symbol(name), config);
16757              if (!$truthy((name = self.$as_symbol(processor_instance.$name())))) {
16758                self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension: " + (processor))
16759              };
16760              processor_instance.$freeze();
16761              return ($b = [name, $$('ProcessorExtension').$new(kind, processor_instance)], $send(kind_store, '[]=', $b), $b[$b.length - 1]);
16762            } else if (($eqeqeq(kind_class, processor) || (($truthy(kind_java_class) && ($eqeqeq(kind_java_class, processor)))))) {
16763
16764              processor.$update_config(config);
16765              if (!$truthy((name = ($truthy(name) ? (($b = [self.$as_symbol(name)], $send(processor, 'name=', $b), $b[$b.length - 1])) : (self.$as_symbol(processor.$name())))))) {
16766                self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension: " + (processor))
16767              };
16768              processor.$freeze();
16769              return ($b = [name, $$('ProcessorExtension').$new(kind, processor)], $send(kind_store, '[]=', $b), $b[$b.length - 1]);
16770            } else {
16771              return self.$raise($$$('ArgumentError'), "Invalid arguments specified for registering " + (kind_name) + " extension: " + (args))
16772            };
16773          };
16774        });
16775
16776        $def(self, '$reset', function $$reset() {
16777          var self = this;
16778
16779
16780          self.preprocessor_extensions = (self.tree_processor_extensions = (self.postprocessor_extensions = (self.include_processor_extensions = (self.docinfo_processor_extensions = (self.block_extensions = (self.block_macro_extensions = (self.inline_macro_extensions = nil)))))));
16781          return (self.document = nil);
16782        });
16783
16784        $def(self, '$resolve_args', function $$resolve_args(args, expect) {
16785          var opts = nil, missing = nil;
16786
16787
16788          opts = ($eqeqeq($$$('Hash'), args['$[]'](-1)) ? (args.$pop()) : ($hash2([], {})));
16789          if ($eqeq(expect, 1)) {
16790            return opts
16791          };
16792          if ($truthy($rb_gt((missing = $rb_minus($rb_minus(expect, 1), args.$size())), 0))) {
16793            args = $rb_plus(args, $$$('Array').$new(missing))
16794          } else if ($truthy($rb_lt(missing, 0))) {
16795            args.$pop(missing['$-@']())
16796          };
16797          args['$<<'](opts);
16798          return args;
16799        });
16800        return $def(self, '$as_symbol', function $$as_symbol(name) {
16801
16802          if ($truthy(name)) {
16803            return name.$to_sym()
16804          } else {
16805            return nil
16806          }
16807        });
16808      })($nesting[0], null, $nesting);
16809      return (function(self, $parent_nesting) {
16810        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16811
16812
16813
16814        $def(self, '$generate_name', function $$generate_name() {
16815          var self = this;
16816
16817          return "extgrp" + (self.$next_auto_id())
16818        });
16819
16820        $def(self, '$next_auto_id', function $$next_auto_id() {
16821          var self = this, $ret_or_1 = nil;
16822          if (self.auto_id == null) self.auto_id = nil;
16823
16824
16825          self.auto_id = ($truthy(($ret_or_1 = self.auto_id)) ? ($ret_or_1) : (-1));
16826          return (self.auto_id = $rb_plus(self.auto_id, 1));
16827        });
16828
16829        $def(self, '$groups', function $$groups() {
16830          var self = this, $ret_or_1 = nil;
16831          if (self.groups == null) self.groups = nil;
16832
16833          return (self.groups = ($truthy(($ret_or_1 = self.groups)) ? ($ret_or_1) : ($hash2([], {}))))
16834        });
16835
16836        $def(self, '$create', function $$create(name) {
16837          var block = $$create.$$p || nil, self = this, $ret_or_1 = nil;
16838
16839          $$create.$$p = null;
16840
16841          ;
16842          if (name == null) name = nil;
16843          if ((block !== nil)) {
16844            return $$('Registry').$new($hash(($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.$generate_name())), block))
16845          } else {
16846            return $$('Registry').$new()
16847          };
16848        }, -1);
16849
16850        $def(self, '$register', function $$register($a) {
16851          var block = $$register.$$p || nil, $post_args, args, $b, self = this, argc = nil, resolved_group = nil, group = nil, $ret_or_1 = nil, name = nil;
16852
16853          $$register.$$p = null;
16854
16855          ;
16856          $post_args = $slice(arguments);
16857          args = $post_args;
16858          argc = args.$size();
16859          if ((block !== nil)) {
16860            resolved_group = block
16861          } else if ($truthy((group = args.$pop()))) {
16862            resolved_group = ($truthy(($ret_or_1 = $$('Helpers').$resolve_class(group))) ? ($ret_or_1) : (group))
16863          } else {
16864            self.$raise($$$('ArgumentError'), "Extension group to register not specified")
16865          };
16866          name = ($truthy(($ret_or_1 = args.$pop())) ? ($ret_or_1) : (self.$generate_name()));
16867          if (!$truthy(args['$empty?']())) {
16868            self.$raise($$$('ArgumentError'), "Wrong number of arguments (" + (argc) + " for 1..2)")
16869          };
16870          return ($b = [name.$to_sym(), resolved_group], $send(self.$groups(), '[]=', $b), $b[$b.length - 1]);
16871        }, -1);
16872
16873        $def(self, '$unregister_all', function $$unregister_all() {
16874          var self = this;
16875
16876
16877          self.groups = $hash2([], {});
16878          return nil;
16879        });
16880        return $def(self, '$unregister', function $$unregister($a) {
16881          var $post_args, names, self = this;
16882
16883
16884          $post_args = $slice(arguments);
16885          names = $post_args;
16886          $send(names, 'each_with_object', [self.$groups()], function $$24(group, catalog){
16887
16888            if (group == null) group = nil;
16889            if (catalog == null) catalog = nil;
16890            return catalog.$delete(group.$to_sym());});
16891          return nil;
16892        }, -1);
16893      })(Opal.get_singleton_class(self), $nesting);
16894    })($nesting[0], $nesting)
16895  })($nesting[0], $nesting);
16896};
16897
16898Opal.modules["asciidoctor/js/asciidoctor_ext/stylesheet"] = function(Opal) {/* Generated by Opal 1.7.3 */
16899  "use strict";
16900  var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
16901
16902  Opal.add_stubs('rstrip,read,join');
16903  return (function($base, $parent_nesting) {
16904    var self = $module($base, 'Asciidoctor');
16905
16906    var $nesting = [self].concat($parent_nesting);
16907
16908    return (function($base, $super) {
16909      var self = $klass($base, $super, 'Stylesheets');
16910
16911      var $proto = self.$$prototype;
16912
16913      $proto.primary_stylesheet_data = nil;
16914      return $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() {
16915        var self = this, $ret_or_1 = nil;
16916
16917        return (self.primary_stylesheet_data = ($truthy(($ret_or_1 = self.primary_stylesheet_data)) ? ($ret_or_1) : ($$$('IO').$read($$$('File').$join("css", "asciidoctor.css")).$rstrip())))
16918      })
16919    })($nesting[0], null)
16920  })($nesting[0], $nesting)
16921};
16922
16923Opal.modules["asciidoctor/js/asciidoctor_ext/document"] = function(Opal) {/* Generated by Opal 1.7.3 */
16924  "use strict";
16925  var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $nesting = [], nil = Opal.nil;
16926
16927  return (function($base, $parent_nesting) {
16928    var self = $module($base, 'Asciidoctor');
16929
16930    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
16931
16932    return (function($base, $super) {
16933      var self = $klass($base, $super, 'Document');
16934
16935
16936      return $def(self, '$fill_datetime_attributes', function $$fill_datetime_attributes(attrs, input_mtime) {
16937
16938
16939      var $truthy = Opal.truthy
16940      var $falsy = Opal.falsy
16941      var nil = Opal.nil
16942      var utc_offset
16943      var source_date_epoch
16944      var localdate
16945      var localyear
16946      var localtime
16947      var localdatetime
16948      var docdate
16949      var doctime
16950
16951      var getYear = function (time, utc_offset) {
16952        return utc_offset === 0 ? time.getUTCFullYear() : time.getFullYear()
16953      }
16954      var getMonth = function (time, utc_offset) {
16955        return utc_offset === 0 ? time.getUTCMonth() : time.getMonth()
16956      }
16957      var getDay = function (time, utc_offset) {
16958        return utc_offset === 0 ? time.getUTCDate() : time.getDate()
16959      }
16960      var getHours = function (time, utc_offset) {
16961        return utc_offset === 0 ? time.getUTCHours() : time.getHours()
16962      }
16963
16964      var now = new Date()
16965      // See https://reproducible-builds.org/specs/source-date-epoch/
16966      if (Opal.const_get_qualified('::', 'ENV')['$key?']('SOURCE_DATE_EPOCH')) {
16967        now.setTime(parseInt(Opal.const_get_qualified('::', 'ENV')['$[]']('SOURCE_DATE_EPOCH')) * 1000)
16968        source_date_epoch = now
16969        utc_offset = 0  // utc
16970      } else {
16971        utc_offset = -now.getTimezoneOffset() / 60 // local date
16972      }
16973      // localdate and localyear
16974      if ($truthy((localdate = attrs['$[]']('localdate')))) {
16975        if ($falsy(localyear = attrs['$[]']('localyear'))) {
16976          localyear = localdate.indexOf('-') === 4 ? localdate.substring(0, 4) : nil
16977          attrs['$[]=']('localyear', localyear)
16978        }
16979      } else {
16980        var now_year = getYear(now, utc_offset).toString()
16981        var now_month = ('0' + (getMonth(now, utc_offset) + 1)).slice(-2)
16982        var now_day = ('0' + getDay(now, utc_offset)).slice(-2)
16983        localdate = now_year + '-' + now_month + '-' + now_day
16984        attrs['$[]=']('localdate', localdate)
16985        localyear = now_year
16986        attrs['$[]=']('localyear', now_year)
16987      }
16988      // localtime
16989      if ($falsy((localtime = attrs['$[]']('localtime')))) {
16990        var hours = ('0' + (getHours(now, utc_offset))).slice(-2)
16991        var minutes = ('0' + (now.getMinutes())).slice(-2)
16992        var seconds = ('0' + (now.getSeconds())).slice(-2)
16993        var utc_offset_format
16994        if (utc_offset === 0) {
16995          utc_offset_format = 'UTC'
16996        } else if (utc_offset > 0) {
16997          utc_offset_format = ('+0' + (utc_offset * 100)).slice(-5)
16998        } else {
16999          utc_offset_format = ('-0' + (-utc_offset * 100)).slice(-5)
17000        }
17001        localtime = hours + ':' + minutes + ':' + seconds + ' ' + utc_offset_format
17002        attrs['$[]=']('localtime', localtime)
17003      }
17004      // localdatetime
17005      if ($falsy((localdatetime = attrs['$[]']('localdatetime')))) {
17006        localdatetime = localdate + ' ' + localtime
17007        attrs['$[]=']('localdatetime', localdatetime)
17008      }
17009
17010      // docdate, doctime and docdatetime should default to localdate, localtime and localdatetime if not otherwise set
17011      if ($truthy(source_date_epoch)) {
17012        input_mtime = source_date_epoch
17013      } else if ($truthy(input_mtime)) {
17014        utc_offset = -input_mtime.getTimezoneOffset() / 60
17015      } else {
17016        input_mtime = now
17017      }
17018
17019      // docdate and docyear
17020      if ($truthy(docdate = attrs['$[]']('docdate'))) {
17021        attrs['$[]=']('docyear', docdate.indexOf('-') === 4 ? docdate.substring(0, 4) : nil)
17022      } else {
17023        var mtime_year = getYear(input_mtime, utc_offset).toString()
17024        var mtime_month = ('0' + (getMonth(input_mtime, utc_offset) + 1)).slice(-2)
17025        var mtime_day = ('0' + (getDay(input_mtime, utc_offset))).slice(-2)
17026        docdate = mtime_year + '-' + mtime_month + '-' + mtime_day
17027        attrs['$[]=']('docdate', docdate)
17028        if ($falsy(attrs['$[]']('docyear'))) {
17029          attrs['$[]=']('docyear', mtime_year)
17030        }
17031      }
17032      // doctime
17033      if ($falsy(doctime = attrs['$[]']('doctime'))) {
17034        var mtime_hours = ('0' + (getHours(input_mtime, utc_offset))).slice(-2)
17035        var mtime_minutes = ('0' + (input_mtime.getMinutes())).slice(-2)
17036        var mtime_seconds = ('0' + (input_mtime.getSeconds())).slice(-2)
17037        var utc_offset_format
17038        if (utc_offset === 0) {
17039          utc_offset_format = 'UTC'
17040        } else if (utc_offset > 0) {
17041          utc_offset_format = ('+0' + (utc_offset * 100)).slice(-5)
17042        } else {
17043          utc_offset_format = ('-0' + (-utc_offset * 100)).slice(-5)
17044        }
17045        doctime = mtime_hours + ':' + mtime_minutes + ':' + mtime_seconds + ' ' + utc_offset_format
17046        attrs['$[]=']('doctime', doctime)
17047      }
17048      // docdatetime
17049      if ($falsy(attrs['$[]']('docdatetime'))) {
17050        attrs['$[]=']('docdatetime', docdate + ' ' + doctime)
17051      }
17052      return nil
17053
17054      })
17055    })($nesting[0], $$('AbstractBlock'))
17056  })($nesting[0], $nesting)
17057};
17058
17059Opal.modules["asciidoctor/js/asciidoctor_ext/substitutors"] = function(Opal) {/* Generated by Opal 1.7.3 */
17060  "use strict";
17061  var $module = Opal.module, $def = Opal.def, $nesting = [], nil = Opal.nil;
17062
17063  return (function($base, $parent_nesting) {
17064    var self = $module($base, 'Asciidoctor');
17065
17066    var $nesting = [self].concat($parent_nesting);
17067
17068    return (function($base) {
17069      var self = $module($base, 'Substitutors');
17070
17071
17072      return $def(self, '$sub_placeholder', function $$sub_placeholder(format_string, replacement) {
17073
17074        return format_string.replace('%s', replacement);
17075      })
17076    })($nesting[0])
17077  })($nesting[0], $nesting)
17078};
17079
17080Opal.modules["asciidoctor/js/asciidoctor_ext/parser"] = function(Opal) {/* Generated by Opal 1.7.3 */
17081  "use strict";
17082  var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $defs = Opal.defs, $nesting = [], nil = Opal.nil;
17083
17084  return (function($base, $parent_nesting) {
17085    var self = $module($base, 'Asciidoctor');
17086
17087    var $nesting = [self].concat($parent_nesting);
17088
17089    return (function($base, $super) {
17090      var self = $klass($base, $super, 'Parser');
17091
17092
17093      if ($truthy(String.prototype.repeat)) {
17094        return $defs(self, '$uniform?', function $Parser_uniform$ques$1(str, chr, len) {
17095
17096          return chr.repeat(len) === str;
17097        })
17098      } else {
17099        return $defs(self, '$uniform?', function $Parser_uniform$ques$2(str, chr, len) {
17100
17101          return Array.apply(null, { length: len }).map(function () { return chr }).join('') === str;
17102        })
17103      }
17104    })($nesting[0], null)
17105  })($nesting[0], $nesting)
17106};
17107
17108Opal.modules["asciidoctor/js/asciidoctor_ext/syntax_highlighter"] = function(Opal) {/* Generated by Opal 1.7.3 */
17109  "use strict";
17110  var $module = Opal.module, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil;
17111
17112  Opal.add_stubs('key?,registry,[],include?,include,empty?,debug,logger,join,keys');
17113  return (function($base, $parent_nesting) {
17114    var self = $module($base, 'Asciidoctor');
17115
17116    var $nesting = [self].concat($parent_nesting);
17117
17118    return (function($base, $parent_nesting) {
17119      var self = $module($base, 'SyntaxHighlighter');
17120
17121      var $nesting = [self].concat($parent_nesting);
17122
17123      return (function($base, $parent_nesting) {
17124        var self = $module($base, 'Factory');
17125
17126        var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting);
17127
17128        return $def(self, '$for', function $Factory_for$1(name) {
17129          var self = this;
17130
17131          if ($truthy(self.$registry()['$key?'](name))) {
17132            return self.$registry()['$[]'](name)
17133          } else {
17134
17135            if (!$truthy(self['$include?']($$('Logging')))) {
17136              self.$include($$('Logging'))
17137            };
17138            if ($truthy(self.$registry()['$empty?']())) {
17139              self.$logger().$debug("no syntax highlighter available, functionality disabled.")
17140            } else {
17141              self.$logger().$debug("syntax highlighter named '" + (name) + "' is not available, must be one of: '" + (self.$registry().$keys().$join("', '")) + "'.")
17142            };
17143            return nil;
17144          }
17145        })
17146      })($nesting[0], $nesting)
17147    })($nesting[0], $nesting)
17148  })($nesting[0], $nesting)
17149};
17150
17151Opal.modules["asciidoctor/js/asciidoctor_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */
17152  "use strict";
17153  var self = Opal.top, nil = Opal.nil;
17154
17155  Opal.add_stubs('require');
17156
17157  self.$require("asciidoctor/js/asciidoctor_ext/stylesheet");
17158  self.$require("asciidoctor/js/asciidoctor_ext/document");
17159  self.$require("asciidoctor/js/asciidoctor_ext/substitutors");
17160  self.$require("asciidoctor/js/asciidoctor_ext/parser");
17161  self.$require("asciidoctor/js/asciidoctor_ext/syntax_highlighter");
17162
17163// Load specific runtime
17164self.$require("asciidoctor/js/asciidoctor_ext/node");
17165;
17166};
17167
17168Opal.modules["asciidoctor/js/opal_ext/logger"] = function(Opal) {/* Generated by Opal 1.7.3 */
17169  "use strict";
17170  var $klass = Opal.klass, $def = Opal.def, $truthy = Opal.truthy, $rb_lt = Opal.rb_lt, $nesting = [], nil = Opal.nil;
17171
17172  Opal.add_stubs('chr,rjust,message_as_string,<,write,call,[]');
17173  return (function($base, $super, $parent_nesting) {
17174    var self = $klass($base, $super, 'Logger');
17175
17176    var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype;
17177
17178    $proto.level = $proto.progname = $proto.pipe = $proto.formatter = nil;
17179
17180    (function($base, $super) {
17181      var self = $klass($base, $super, 'Formatter');
17182
17183
17184      return $def(self, '$call', function $$call(severity, time, progname, msg) {
17185        var self = this, time_format = nil;
17186
17187
17188        time_format = time.getFullYear() + '-' + ('0'+(time.getMonth()+1)).slice(-2) + '-' + ('0'+time.getDate()).slice(-2) + 'T' + ('0'+time.getHours()).slice(-2) + ':' + ('0'+time.getMinutes()).slice(-2) + ':' + ('0'+time.getSeconds()).slice(-2) + '.' + ('00' + new Date().getMilliseconds() * 1000).slice(-6);
17189        return "" + (severity.$chr()) + ", [" + (time_format) + "] " + (severity.$rjust(5)) + " -- " + (progname) + ": " + (self.$message_as_string(msg));
17190      })
17191    })($nesting[0], null);
17192    return $def(self, '$add', function $$add(severity, message, progname) {
17193      var block = $$add.$$p || nil, self = this, $ret_or_1 = nil;
17194
17195      $$add.$$p = null;
17196
17197      ;
17198      if (message == null) message = nil;
17199      if (progname == null) progname = nil;
17200      if ($truthy($rb_lt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), self.level))) {
17201        return true
17202      };
17203      progname = ($truthy(($ret_or_1 = progname)) ? ($ret_or_1) : (self.progname));
17204      if (!$truthy(message)) {
17205        if ((block !== nil)) {
17206          message = Opal.yieldX(block, [])
17207        } else {
17208
17209          message = progname;
17210          progname = self.progname;
17211        }
17212      };
17213      self.pipe.$write(self.formatter.$call(($truthy(($ret_or_1 = $$('SEVERITY_LABELS')['$[]'](severity))) ? ($ret_or_1) : ("ANY")), new Date(), progname, message));
17214      return true;
17215    }, -2);
17216  })($nesting[0], null, $nesting)
17217};
17218
17219Opal.modules["asciidoctor/js/postscript"] = function(Opal) {/* Generated by Opal 1.7.3 */
17220  "use strict";
17221  var self = Opal.top, nil = Opal.nil;
17222
17223  Opal.add_stubs('require');
17224
17225  self.$require("asciidoctor/converter/composite");
17226  self.$require("asciidoctor/converter/html5");
17227  self.$require("asciidoctor/extensions");
17228  self.$require("asciidoctor/js/asciidoctor_ext");
17229  return self.$require("asciidoctor/js/opal_ext/logger");
17230};
17231
17232Opal.queue(function(Opal) {/* Generated by Opal 1.7.3 */
17233  "use strict";
17234  var $module = Opal.module, $const_set = Opal.const_set, $send = Opal.send, $to_ary = Opal.to_ary, $defs = Opal.defs, $def = Opal.def, $truthy = Opal.truthy, $hash2 = Opal.hash2, $eqeq = Opal.eqeq, $rb_minus = Opal.rb_minus, $regexp = Opal.regexp, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$;
17235
17236  Opal.add_stubs('require,==,to_h,sort,map,constants,const_get,downcase,to_s,<=>,upcase,[],values,new,attr_reader,instance_variable_set,send,singleton_class,<<,define,dirname,absolute_path,join,home,pwd,to_set,tap,each,chr,each_key,[]=,slice,length,-,merge,default=,drop,insert');
17237
17238  self.$require("set");
17239  self.$require("asciidoctor/js");
17240  (function($base, $parent_nesting) {
17241    var self = $module($base, 'Asciidoctor');
17242
17243    var $a, $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $ret_or_1 = nil;
17244
17245
17246    $const_set($nesting[0], 'RUBY_ENGINE_OPAL', $const_set($nesting[0], 'RUBY_ENGINE', $$$('RUBY_ENGINE'))['$==']("opal"));
17247    (function($base, $parent_nesting) {
17248      var self = $module($base, 'SafeMode');
17249
17250      var $nesting = [self].concat($parent_nesting);
17251
17252
17253      $const_set($nesting[0], 'UNSAFE', 0);
17254      $const_set($nesting[0], 'SAFE', 1);
17255      $const_set($nesting[0], 'SERVER', 10);
17256      $const_set($nesting[0], 'SECURE', 20);
17257      self.names_by_value = $send($send(self.$constants(false), 'map', [], function $SafeMode$1(sym){var self = $SafeMode$1.$$s == null ? this : $SafeMode$1.$$s;
17258
17259
17260        if (sym == null) sym = nil;
17261        return [self.$const_get(sym), sym.$to_s().$downcase()];}, {$$s: self}), 'sort', [], function $SafeMode$2($mlhs_tmp1, $mlhs_tmp2){var $a, $b, a = nil, b = nil;
17262
17263
17264        if ($mlhs_tmp1 == null) $mlhs_tmp1 = nil;
17265        if ($mlhs_tmp2 == null) $mlhs_tmp2 = nil;
17266        $b = $mlhs_tmp1, $a = $to_ary($b), (a = ($a[0] == null ? nil : $a[0])), $b;
17267        $b = $mlhs_tmp2, $a = $to_ary($b), (b = ($a[0] == null ? nil : $a[0])), $b;
17268        return a['$<=>'](b);}, {$$has_top_level_mlhs_arg: true}).$to_h();
17269      $defs(self, '$value_for_name', function $$value_for_name(name) {
17270        var self = this;
17271
17272        return self.$const_get(name.$upcase(), false)
17273      });
17274      $defs(self, '$name_for_value', function $$name_for_value(value) {
17275        var self = this;
17276        if (self.names_by_value == null) self.names_by_value = nil;
17277
17278        return self.names_by_value['$[]'](value)
17279      });
17280      return $defs(self, '$names', function $$names() {
17281        var self = this;
17282        if (self.names_by_value == null) self.names_by_value = nil;
17283
17284        return self.names_by_value.$values()
17285      });
17286    })($nesting[0], $nesting);
17287    (function($base, $parent_nesting) {
17288      var self = $module($base, 'Compliance');
17289
17290      var $nesting = [self].concat($parent_nesting);
17291
17292
17293      self.keys = $$$('Set').$new();
17294      (function(self, $parent_nesting) {
17295
17296
17297        self.$attr_reader("keys");
17298        return $def(self, '$define', function $$define(key, value) {
17299          var self = this;
17300          if (self.keys == null) self.keys = nil;
17301
17302
17303          self.$instance_variable_set("@" + (key), value);
17304          self.$singleton_class().$send("attr_accessor", key);
17305          self.keys['$<<'](key);
17306          return nil;
17307        });
17308      })(Opal.get_singleton_class(self), $nesting);
17309      self.$define("block_terminates_paragraph", true);
17310      self.$define("strict_verbatim_paragraphs", true);
17311      self.$define("underline_style_section_titles", true);
17312      self.$define("unwrap_standalone_preamble", true);
17313      self.$define("attribute_missing", "skip");
17314      self.$define("attribute_undefined", "drop-line");
17315      self.$define("shorthand_property_syntax", true);
17316      self.$define("natural_xrefs", true);
17317      self.$define("unique_id_start_index", 2);
17318      return self.$define("markdown_syntax", true);
17319    })($nesting[0], $nesting);
17320    if (!$truthy((($a = $$('ROOT_DIR', 'skip_raise')) ? 'constant' : nil))) {
17321      $const_set($nesting[0], 'ROOT_DIR', $$$('File').$dirname($$$('File').$absolute_path(".")))
17322    };
17323    $const_set($nesting[0], 'LIB_DIR', $$$('File').$join($$('ROOT_DIR'), "lib"));
17324    $const_set($nesting[0], 'DATA_DIR', $$$('File').$join($$('ROOT_DIR'), "data"));
17325    $const_set($nesting[0], 'USER_HOME', (function() { try {
17326      return $$$('Dir').$home()
17327    } catch ($err) {
17328      if (Opal.rescue($err, [$$('StandardError')])) {
17329        try {
17330
17331          if ($truthy(($ret_or_1 = $$$('ENV')['$[]']("HOME")))) {
17332            return $ret_or_1
17333          } else {
17334            return $$$('Dir').$pwd()
17335          };
17336        } finally { Opal.pop_exception(); }
17337      } else { throw $err; }
17338    }})());
17339    $const_set($nesting[0], 'LF', "\n");
17340    $const_set($nesting[0], 'NULL', "\x00");
17341    $const_set($nesting[0], 'TAB', "\t");
17342    $const_set($nesting[0], 'MAX_INT', 9007199254740991);
17343    $const_set($nesting[0], 'UTF_8', $$$($$$('Encoding'), 'UTF_8'));
17344    $const_set($nesting[0], 'BOM_BYTES_UTF_8', [239, 187, 191]);
17345    $const_set($nesting[0], 'BOM_BYTES_UTF_16LE', [255, 254]);
17346    $const_set($nesting[0], 'BOM_BYTES_UTF_16BE', [254, 255]);
17347    $const_set($nesting[0], 'FILE_READ_MODE', ($truthy($$('RUBY_ENGINE_OPAL')) ? ("r") : ("rb:utf-8:utf-8")));
17348    $const_set($nesting[0], 'URI_READ_MODE', $$('FILE_READ_MODE'));
17349    $const_set($nesting[0], 'FILE_WRITE_MODE', ($truthy($$('RUBY_ENGINE_OPAL')) ? ("w") : ("w:utf-8")));
17350    $const_set($nesting[0], 'DEFAULT_DOCTYPE', "article");
17351    $const_set($nesting[0], 'DEFAULT_BACKEND', "html5");
17352    $const_set($nesting[0], 'DEFAULT_STYLESHEET_KEYS', ["", "DEFAULT"].$to_set());
17353    $const_set($nesting[0], 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css");
17354    $const_set($nesting[0], 'BACKEND_ALIASES', $hash2(["html", "docbook"], {"html": "html5", "docbook": "docbook5"}));
17355    $const_set($nesting[0], 'DEFAULT_PAGE_WIDTHS', $hash2(["docbook"], {"docbook": 425}));
17356    $const_set($nesting[0], 'DEFAULT_EXTENSIONS', $hash2(["html", "docbook", "pdf", "epub", "manpage", "asciidoc"], {"html": ".html", "docbook": ".xml", "pdf": ".pdf", "epub": ".epub", "manpage": ".man", "asciidoc": ".adoc"}));
17357    $const_set($nesting[0], 'ASCIIDOC_EXTENSIONS', $hash2([".adoc", ".asciidoc", ".asc", ".ad", ".txt"], {".adoc": true, ".asciidoc": true, ".asc": true, ".ad": true, ".txt": true}));
17358    $const_set($nesting[0], 'SETEXT_SECTION_LEVELS', $hash2(["=", "-", "~", "^", "+"], {"=": 0, "-": 1, "~": 2, "^": 3, "+": 4}));
17359    $const_set($nesting[0], 'ADMONITION_STYLES', ["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"].$to_set());
17360    $const_set($nesting[0], 'ADMONITION_STYLE_HEADS', $send($$$('Set').$new(), 'tap', [], function $Asciidoctor$3(accum){
17361
17362      if (accum == null) accum = nil;
17363      return $send($$('ADMONITION_STYLES'), 'each', [], function $$4(s){
17364
17365        if (s == null) s = nil;
17366        return accum['$<<'](s.$chr());});}));
17367    $const_set($nesting[0], 'PARAGRAPH_STYLES', ["comment", "example", "literal", "listing", "normal", "open", "pass", "quote", "sidebar", "source", "verse", "abstract", "partintro"].$to_set());
17368    $const_set($nesting[0], 'VERBATIM_STYLES', ["literal", "listing", "source", "verse"].$to_set());
17369    $const_set($nesting[0], 'DELIMITED_BLOCKS', $hash2(["--", "----", "....", "====", "****", "____", "++++", "|===", ",===", ":===", "!===", "////", "```"], {"--": ["open", ["comment", "example", "literal", "listing", "pass", "quote", "sidebar", "source", "verse", "admonition", "abstract", "partintro"].$to_set()], "----": ["listing", ["literal", "source"].$to_set()], "....": ["literal", ["listing", "source"].$to_set()], "====": ["example", ["admonition"].$to_set()], "****": ["sidebar", $$$('Set').$new()], "____": ["quote", ["verse"].$to_set()], "++++": ["pass", ["stem", "latexmath", "asciimath"].$to_set()], "|===": ["table", $$$('Set').$new()], ",===": ["table", $$$('Set').$new()], ":===": ["table", $$$('Set').$new()], "!===": ["table", $$$('Set').$new()], "////": ["comment", $$$('Set').$new()], "```": ["fenced_code", $$$('Set').$new()]}));
17370    $const_set($nesting[0], 'DELIMITED_BLOCK_HEADS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$5(accum){
17371
17372      if (accum == null) accum = nil;
17373      return $send($$('DELIMITED_BLOCKS'), 'each_key', [], function $$6(k){var $b;
17374
17375
17376        if (k == null) k = nil;
17377        return ($b = [k.$slice(0, 2), true], $send(accum, '[]=', $b), $b[$b.length - 1]);});}));
17378    $const_set($nesting[0], 'DELIMITED_BLOCK_TAILS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$7(accum){
17379
17380      if (accum == null) accum = nil;
17381      return $send($$('DELIMITED_BLOCKS'), 'each_key', [], function $$8(k){var $b;
17382
17383
17384        if (k == null) k = nil;
17385        if ($eqeq(k.$length(), 4)) {
17386          return ($b = [k, k['$[]']($rb_minus(k.$length(), 1))], $send(accum, '[]=', $b), $b[$b.length - 1])
17387        } else {
17388          return nil
17389        };});}));
17390    $const_set($nesting[0], 'CAPTION_ATTRIBUTE_NAMES', $hash2(["example", "figure", "listing", "table"], {"example": "example-caption", "figure": "figure-caption", "listing": "listing-caption", "table": "table-caption"}));
17391    $const_set($nesting[0], 'LAYOUT_BREAK_CHARS', $hash2(["'", "<"], {"'": "thematic_break", "<": "page_break"}));
17392    $const_set($nesting[0], 'MARKDOWN_THEMATIC_BREAK_CHARS', $hash2(["-", "*", "_"], {"-": "thematic_break", "*": "thematic_break", "_": "thematic_break"}));
17393    $const_set($nesting[0], 'HYBRID_LAYOUT_BREAK_CHARS', $$('LAYOUT_BREAK_CHARS').$merge($$('MARKDOWN_THEMATIC_BREAK_CHARS')));
17394    $const_set($nesting[0], 'NESTABLE_LIST_CONTEXTS', ["ulist", "olist", "dlist"]);
17395    $const_set($nesting[0], 'ORDERED_LIST_STYLES', ["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"]);
17396    $const_set($nesting[0], 'ORDERED_LIST_KEYWORDS', $hash2(["loweralpha", "lowerroman", "upperalpha", "upperroman"], {"loweralpha": "a", "lowerroman": "i", "upperalpha": "A", "upperroman": "I"}));
17397    $const_set($nesting[0], 'ATTR_REF_HEAD', "{");
17398    $const_set($nesting[0], 'LIST_CONTINUATION', "+");
17399    $const_set($nesting[0], 'HARD_LINE_BREAK', " +");
17400    $const_set($nesting[0], 'LINE_CONTINUATION', " \\");
17401    $const_set($nesting[0], 'LINE_CONTINUATION_LEGACY', " +");
17402    $const_set($nesting[0], 'BLOCK_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\[", "\\]"]}));
17403    $const_set($nesting[0], 'INLINE_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\(", "\\)"]}));
17404    $const_set($nesting[0], 'STEM_TYPE_ALIASES', $hash2(["latexmath", "latex", "tex"], {"latexmath": "latexmath", "latex": "latexmath", "tex": "latexmath"}))['$default=']("asciimath");
17405    $const_set($nesting[0], 'FONT_AWESOME_VERSION', "4.7.0");
17406    $const_set($nesting[0], 'HIGHLIGHT_JS_VERSION', "9.18.3");
17407    $const_set($nesting[0], 'MATHJAX_VERSION', "2.7.9");
17408    $const_set($nesting[0], 'DEFAULT_ATTRIBUTES', $hash2(["appendix-caption", "appendix-refsig", "caution-caption", "chapter-refsig", "example-caption", "figure-caption", "important-caption", "last-update-label", "note-caption", "part-refsig", "prewrap", "sectids", "section-refsig", "table-caption", "tip-caption", "toc-placement", "toc-title", "untitled-label", "version-label", "warning-caption"], {"appendix-caption": "Appendix", "appendix-refsig": "Appendix", "caution-caption": "Caution", "chapter-refsig": "Chapter", "example-caption": "Example", "figure-caption": "Figure", "important-caption": "Important", "last-update-label": "Last updated", "note-caption": "Note", "part-refsig": "Part", "prewrap": "", "sectids": "", "section-refsig": "Section", "table-caption": "Table", "tip-caption": "Tip", "toc-placement": "auto", "toc-title": "Table of Contents", "untitled-label": "Untitled", "version-label": "Version", "warning-caption": "Warning"}));
17409    $const_set($nesting[0], 'FLEXIBLE_ATTRIBUTES', ["sectnums"]);
17410    $const_set($nesting[0], 'INTRINSIC_ATTRIBUTES', $hash2(["startsb", "endsb", "vbar", "caret", "asterisk", "tilde", "plus", "backslash", "backtick", "blank", "empty", "sp", "two-colons", "two-semicolons", "nbsp", "deg", "zwsp", "quot", "apos", "lsquo", "rsquo", "ldquo", "rdquo", "wj", "brvbar", "pp", "cpp", "amp", "lt", "gt"], {"startsb": "[", "endsb": "]", "vbar": "|", "caret": "^", "asterisk": "*", "tilde": "~", "plus": "&#43;", "backslash": "\\", "backtick": "`", "blank": "", "empty": "", "sp": " ", "two-colons": "::", "two-semicolons": ";;", "nbsp": "&#160;", "deg": "&#176;", "zwsp": "&#8203;", "quot": "&#34;", "apos": "&#39;", "lsquo": "&#8216;", "rsquo": "&#8217;", "ldquo": "&#8220;", "rdquo": "&#8221;", "wj": "&#8288;", "brvbar": "&#166;", "pp": "&#43;&#43;", "cpp": "C&#43;&#43;", "amp": "&", "lt": "<", "gt": ">"}));
17411    nil;
17412    $const_set($nesting[0], 'QUOTE_SUBS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$9(accum){var normal = nil, compat = nil;
17413
17414
17415      if (accum == null) accum = nil;
17416      accum['$[]='](false, (normal = [["strong", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?\\*\\*(", $$('CC_ALL'), "+?)\\*\\*"], 'm')], ["strong", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?\\*(\\S|\\S", $$('CC_ALL'), "*?\\S)\\*(?!", $$('CG_WORD'), ")"], 'm')], ["double", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?\"`(\\S|\\S", $$('CC_ALL'), "*?\\S)`\"(?!", $$('CG_WORD'), ")"], 'm')], ["single", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:`}])(?:\\[([^\\]]+)\\])?'`(\\S|\\S", $$('CC_ALL'), "*?\\S)`'(?!", $$('CG_WORD'), ")"], 'm')], ["monospaced", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?``(", $$('CC_ALL'), "+?)``"], 'm')], ["monospaced", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:\"'`}])(?:\\[([^\\]]+)\\])?`(\\S|\\S", $$('CC_ALL'), "*?\\S)`(?![", $$('CC_WORD'), "\"'`])"], 'm')], ["emphasis", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?__(", $$('CC_ALL'), "+?)__"], 'm')], ["emphasis", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?_(\\S|\\S", $$('CC_ALL'), "*?\\S)_(?!", $$('CG_WORD'), ")"], 'm')], ["mark", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?##(", $$('CC_ALL'), "+?)##"], 'm')], ["mark", "constrained", $regexp(["(^|[^", $$('CC_WORD'), "&;:}])(?:\\[([^\\]]+)\\])?#(\\S|\\S", $$('CC_ALL'), "*?\\S)#(?!", $$('CG_WORD'), ")"], 'm')], ["superscript", "unconstrained", /\\?(?:\[([^\]]+)\])?\^(\S+?)\^/], ["subscript", "unconstrained", /\\?(?:\[([^\]]+)\])?~(\S+?)~/]]));
17417      accum['$[]='](true, (compat = normal.$drop(0)));
17418      compat['$[]='](2, ["double", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?``(\\S|\\S", $$('CC_ALL'), "*?\\S)''(?!", $$('CG_WORD'), ")"], 'm')]);
17419      compat['$[]='](3, ["single", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?`(\\S|\\S", $$('CC_ALL'), "*?\\S)'(?!", $$('CG_WORD'), ")"], 'm')]);
17420      compat['$[]='](4, ["monospaced", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?\\+\\+(", $$('CC_ALL'), "+?)\\+\\+"], 'm')]);
17421      compat['$[]='](5, ["monospaced", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?\\+(\\S|\\S", $$('CC_ALL'), "*?\\S)\\+(?!", $$('CG_WORD'), ")"], 'm')]);
17422      return compat.$insert(3, ["emphasis", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?'(\\S|\\S", $$('CC_ALL'), "*?\\S)'(?!", $$('CG_WORD'), ")"], 'm')]);}));
17423    $const_set($nesting[0], 'REPLACEMENTS', [[/\\?\(C\)/, "&#169;", "none"], [/\\?\(R\)/, "&#174;", "none"], [/\\?\(TM\)/, "&#8482;", "none"], [/(?: |\n|^|\\)--(?: |\n|$)/, "&#8201;&#8212;&#8201;", "none"], [$regexp(["(", $$('CG_WORD'), ")\\\\?--(?=", $$('CG_WORD'), ")"]), "&#8212;&#8203;", "leading"], [/\\?\.\.\./, "&#8230;&#8203;", "none"], [/\\?`'/, "&#8217;", "none"], [$regexp(["(", $$('CG_ALNUM'), ")\\\\?'(?=", $$('CG_ALPHA'), ")"]), "&#8217;", "leading"], [/\\?-&gt;/, "&#8594;", "none"], [/\\?=&gt;/, "&#8658;", "none"], [/\\?&lt;-/, "&#8592;", "none"], [/\\?&lt;=/, "&#8656;", "none"], [/\\?(&)amp;((?:[a-zA-Z][a-zA-Z]+\d{0,2}|#\d\d\d{0,4}|#x[\da-fA-F][\da-fA-F][\da-fA-F]{0,3});)/, "", "bounding"]]);
17424    nil;
17425    return nil;
17426  })($nesting[0], $nesting);
17427  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/core_ext");
17428  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/helpers");
17429  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/logging");
17430  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/rx");
17431  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/substitutors");
17432  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/version");
17433  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/abstract_node");
17434  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/abstract_block");
17435  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/attribute_list");
17436  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/block");
17437  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/callouts");
17438  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/converter");
17439  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/document");
17440  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/inline");
17441  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/list");
17442  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/parser");
17443  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/path_resolver");
17444  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/reader");
17445  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/section");
17446  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/stylesheets");
17447  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/table");
17448  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/writer");
17449  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/load");
17450  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/convert");
17451
17452  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/syntax_highlighter");
17453  self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/timings");
17454  return self.$require("asciidoctor/js/postscript");;
17455});
17456
17457
17458/* global Opal */
17459
17460/**
17461 * Convert a JSON to an (Opal) Hash.
17462 * @private
17463 */
17464const toHash = function (object) {
17465  return object && !object.$$is_hash ? Opal.hash2(Object.keys(object), object) : object
17466}
17467
17468/**
17469 * Convert an (Opal) Hash to JSON.
17470 * @private
17471 */
17472const fromHash = function (hash) {
17473  const object = {}
17474  if (hash) {
17475    const stringMap = hash.$$smap
17476    for (const key in stringMap) {
17477      const value = stringMap[key]
17478      object[key] = value === Opal.nil ? undefined : value
17479    }
17480    const numericMap = hash.$$map
17481    if (numericMap) {
17482      const positional = []
17483      for (const key in numericMap) {
17484        const entry = numericMap[key]
17485        const value = entry.value
17486        const index = entry.key - 1
17487        positional[index] = value === Opal.nil ? undefined : value
17488      }
17489      if (positional.length > 0) {
17490        object.$positional = positional
17491      }
17492    }
17493  }
17494  return object
17495}
17496
17497const fromHashKeys = function (hash) {
17498  const object = {}
17499  if (hash) {
17500    const data = hash.$$keys
17501    for (const key in data) {
17502      const value = data[key].value
17503      object[key.toString()] = value === Opal.nil ? undefined : value
17504    }
17505  }
17506  return object
17507}
17508
17509/**
17510 * @private
17511 */
17512const prepareOptions = function (options) {
17513  options = toHash(options)
17514  if (options) {
17515    const converter = options['$[]']('converter')
17516    if (converter && converter !== Opal.nil) {
17517      options['$[]=']('converter', bridgeConverter(converter))
17518    }
17519    const attrs = options['$[]']('attributes')
17520    if (attrs && typeof attrs === 'object' && attrs.constructor.name === 'Object') {
17521      options = options.$dup()
17522      options['$[]=']('attributes', toHash(attrs))
17523    }
17524  }
17525  return options
17526}
17527
17528const bridgeConverter = function (converter) {
17529  const buildBackendTraitsFromObject = function (obj) {
17530    return Object.assign({},
17531      obj.basebackend ? { basebackend: obj.basebackend } : {},
17532      obj.outfilesuffix ? { outfilesuffix: obj.outfilesuffix } : {},
17533      obj.filetype ? { filetype: obj.filetype } : {},
17534      obj.htmlsyntax ? { htmlsyntax: obj.htmlsyntax } : {},
17535      obj.supports_templates ? { supports_templates: obj.supports_templates } : {}
17536    )
17537  }
17538  const assignBackendTraitsToInstance = function (obj, instance) {
17539    if (obj.backend_traits) {
17540      instance.backend_traits = toHash(obj.backend_traits)
17541    } else if (obj.backendTraits) {
17542      instance.backend_traits = toHash(obj.backendTraits)
17543    } else if (obj.basebackend || obj.outfilesuffix || obj.filetype || obj.htmlsyntax || obj.supports_templates) {
17544      instance.backend_traits = toHash(buildBackendTraitsFromObject(obj))
17545    }
17546  }
17547  const bridgeHandlesMethodToInstance = function (obj, instance) {
17548    bridgeMethodToInstance(obj, instance, '$handles?', 'handles', function () {
17549      return true
17550    })
17551  }
17552  const bridgeComposedMethodToInstance = function (obj, instance) {
17553    bridgeMethodToInstance(obj, instance, '$composed', 'composed')
17554  }
17555  const bridgeEqEqMethodToInstance = function (obj, instance) {
17556    bridgeMethodToInstance(obj, instance, '$==', '==', function (other) {
17557      return instance === other
17558    })
17559  }
17560  const bridgeSendMethodToInstance = function (obj, instance) {
17561    bridgeMethodToInstance(obj, instance, '$send', 'send', function (symbol) {
17562      const [, ...args] = Array.from(arguments)
17563      const func = instance['$' + symbol]
17564      if (func) {
17565        return func.apply(instance, args)
17566      }
17567      throw new Error(`undefined method \`${symbol}\` for \`${instance.toString()}\``)
17568    })
17569  }
17570  const bridgeMethodToInstance = function (obj, instance, methodName, functionName, defaultImplementation) {
17571    if (typeof obj[methodName] === 'undefined') {
17572      if (typeof obj[functionName] === 'function') {
17573        instance[methodName] = obj[functionName]
17574      } else if (defaultImplementation) {
17575        instance[methodName] = defaultImplementation
17576      }
17577    }
17578  }
17579  const addRespondToMethod = function (instance) {
17580    if (typeof instance['$respond_to?'] !== 'function') {
17581      instance['$respond_to?'] = function (name) {
17582        return typeof this[name] === 'function'
17583      }
17584    }
17585  }
17586  if (typeof converter === 'function') {
17587    // Class
17588    const object = initializeClass(ConverterBase, converter.constructor.name, {
17589      initialize: function (backend, opts) {
17590        const self = this
17591        const result = new converter(backend, opts) // eslint-disable-line
17592        Object.assign(this, result)
17593        assignBackendTraitsToInstance(result, self)
17594        const propertyNames = Object.getOwnPropertyNames(converter.prototype)
17595        for (let i = 0; i < propertyNames.length; i++) {
17596          const propertyName = propertyNames[i]
17597          if (propertyName !== 'constructor') {
17598            self[propertyName] = result[propertyName]
17599          }
17600        }
17601        if (typeof result.$convert === 'undefined' && typeof result.convert === 'function') {
17602          self.$convert = result.convert
17603        }
17604        bridgeHandlesMethodToInstance(result, self)
17605        bridgeComposedMethodToInstance(result, self)
17606        addRespondToMethod(self)
17607        self.super(backend, opts)
17608      }
17609    })
17610    object.$extend(ConverterBackendTraits)
17611    return object
17612  }
17613  if (typeof converter === 'object') {
17614    // Instance
17615    if (typeof converter.$convert === 'undefined' && typeof converter.convert === 'function') {
17616      converter.$convert = converter.convert
17617    }
17618    assignBackendTraitsToInstance(converter, converter)
17619    if (converter.backend_traits) {
17620      // "extends" ConverterBackendTraits
17621      const converterBackendTraitsFunctionNames = [
17622        'basebackend',
17623        'filetype',
17624        'htmlsyntax',
17625        'outfilesuffix',
17626        'supports_templates',
17627        'supports_templates?',
17628        'init_backend_traits',
17629        'backend_traits'
17630      ]
17631      for (const functionName of converterBackendTraitsFunctionNames) {
17632        converter['$' + functionName] = ConverterBackendTraits.prototype['$' + functionName]
17633      }
17634      converter.$$meta = ConverterBackendTraits
17635    }
17636    bridgeHandlesMethodToInstance(converter, converter)
17637    bridgeComposedMethodToInstance(converter, converter)
17638    bridgeEqEqMethodToInstance(converter, converter)
17639    bridgeSendMethodToInstance(converter, converter)
17640    addRespondToMethod(converter)
17641    return converter
17642  }
17643  return converter
17644}
17645
17646function initializeClass (superClass, className, functions, defaultFunctions, argProxyFunctions) {
17647  const scope = Opal.klass(Opal.Object, superClass, className, function () { })
17648  let postConstructFunction
17649  let initializeFunction
17650  let constructorFunction
17651  const defaultFunctionsOverridden = {}
17652  for (const functionName in functions) {
17653    if (Object.prototype.hasOwnProperty.call(functions, functionName)) {
17654      (function (functionName) {
17655        const userFunction = functions[functionName]
17656        if (functionName === 'postConstruct') {
17657          postConstructFunction = userFunction
17658        } else if (functionName === 'initialize') {
17659          initializeFunction = userFunction
17660        } else if (functionName === 'constructor') {
17661          constructorFunction = userFunction
17662        } else {
17663          if (defaultFunctions && Object.prototype.hasOwnProperty.call(defaultFunctions, functionName)) {
17664            defaultFunctionsOverridden[functionName] = true
17665          }
17666          let $function
17667          Opal.def(scope, '$' + functionName, ($function = function () {
17668            let args
17669            if (argProxyFunctions && Object.prototype.hasOwnProperty.call(argProxyFunctions, functionName)) {
17670              args = argProxyFunctions[functionName](arguments)
17671            } else {
17672              args = arguments
17673            }
17674            // append Ruby block as the final argument
17675            const $block = $function.$$p
17676            if ($block) {
17677              args[args.length] = function () { return Opal.yield1($block) }
17678              args.length += 1
17679              $function.$$p = null
17680            }
17681            return userFunction.apply(this, args)
17682          }))
17683        }
17684      }(functionName))
17685    }
17686  }
17687  let initialize
17688  if (typeof constructorFunction === 'function') {
17689    initialize = function () {
17690      const args = Array.from(arguments)
17691      for (let i = 0; i < args.length; i++) {
17692        // convert all (Opal) Hash arguments to JSON.
17693        if (typeof args[i] === 'object' && '$$smap' in args[i]) {
17694          args[i] = fromHash(args[i])
17695        }
17696      }
17697      args.unshift(null)
17698      const result = new (Function.prototype.bind.apply(constructorFunction, args)) // eslint-disable-line
17699      Object.assign(this, result)
17700      if (typeof postConstructFunction === 'function') {
17701        postConstructFunction.bind(this)()
17702      }
17703    }
17704  } else if (typeof initializeFunction === 'function') {
17705    initialize = function () {
17706      const args = Array.from(arguments)
17707      for (let i = 0; i < args.length; i++) {
17708        // convert all (Opal) Hash arguments to JSON.
17709        if (typeof args[i] === 'object' && '$$smap' in args[i]) {
17710          args[i] = fromHash(args[i])
17711        }
17712      }
17713      initializeFunction.apply(this, args)
17714      if (typeof postConstructFunction === 'function') {
17715        postConstructFunction.bind(this)()
17716      }
17717    }
17718  } else {
17719    initialize = function () {
17720      Opal.send(this, Opal.find_super_dispatcher(this, 'initialize', initialize))
17721      if (typeof postConstructFunction === 'function') {
17722        postConstructFunction.bind(this)()
17723      }
17724    }
17725  }
17726  Opal.def(scope, '$initialize', initialize)
17727  let $superFunction
17728  Opal.def(scope, 'super', ($superFunction = function (func) {
17729    if (typeof func === 'function') {
17730      Opal.send(this, Opal.find_super_dispatcher(this, func.name, func))
17731    } else {
17732      // Bind the initialize function to super();
17733      const argumentsList = Array.from(arguments)
17734      for (let i = 0; i < argumentsList.length; i++) {
17735        // convert all (Opal) Hash arguments to JSON.
17736        if (typeof argumentsList[i] === 'object') {
17737          argumentsList[i] = toHash(argumentsList[i])
17738        }
17739      }
17740      Opal.send(this, Opal.find_super_dispatcher(this, 'initialize', initialize), argumentsList)
17741    }
17742  }))
17743  for (const functionName in functions) {
17744    $superFunction[functionName] = function () {
17745      const argumentsList = Array.from(arguments)
17746      for (let i = 0; i < argumentsList.length; i++) {
17747        // convert all (Opal) Hash arguments to JSON.
17748        if (typeof argumentsList[i] === 'object' && typeof argumentsList[i].constructor === 'function' && argumentsList[i].constructor.name === 'Object') {
17749          argumentsList[i] = toHash(argumentsList[i])
17750        }
17751      }
17752      const self = scope.$$prototype
17753      return Opal.send(self, Opal.find_super_dispatcher(self, functionName, self[`$${functionName}`]), argumentsList)
17754    }
17755  }
17756  if (defaultFunctions) {
17757    for (const defaultFunctionName in defaultFunctions) {
17758      if (Object.prototype.hasOwnProperty.call(defaultFunctions, defaultFunctionName) && !Object.prototype.hasOwnProperty.call(defaultFunctionsOverridden, defaultFunctionName)) {
17759        (function (defaultFunctionName) {
17760          const defaultFunction = defaultFunctions[defaultFunctionName]
17761          Opal.def(scope, '$' + defaultFunctionName, function () {
17762            return defaultFunction.apply(this, arguments)
17763          })
17764        }(defaultFunctionName))
17765      }
17766    }
17767  }
17768  return scope
17769}
17770
17771// Asciidoctor API
17772
17773/**
17774 * @namespace
17775 * @description
17776 * The main application interface (API) for Asciidoctor.
17777 * This API provides methods to parse AsciiDoc content and convert it to various output formats using built-in or third-party converters.
17778 *
17779 * An AsciiDoc document can be as simple as a single line of content,
17780 * though it more commonly starts with a document header that declares the document title and document attribute definitions.
17781 * The document header is then followed by zero or more section titles, optionally nested, to organize the paragraphs, blocks, lists, etc. of the document.
17782 *
17783 * By default, the processor converts the AsciiDoc document to HTML 5 using a built-in converter.
17784 * However, this behavior can be changed by specifying a different backend (e.g., +docbook+).
17785 * A backend is a keyword for an output format (e.g., DocBook).
17786 * That keyword, in turn, is used to select a converter, which carries out the request to convert the document to that format.
17787 *
17788 * @example
17789 * asciidoctor.convertFile('document.adoc', { 'safe': 'safe' }) // Convert an AsciiDoc file
17790 *
17791 * asciidoctor.convert("I'm using *Asciidoctor* version {asciidoctor-version}.", { 'safe': 'safe' }) // Convert an AsciiDoc string
17792 *
17793 * const doc = asciidoctor.loadFile('document.adoc', { 'safe': 'safe' }) // Parse an AsciiDoc file into a document object
17794 *
17795 * const doc = asciidoctor.load("= Document Title\n\nfirst paragraph\n\nsecond paragraph", { 'safe': 'safe' }) // Parse an AsciiDoc string into a document object
17796 */
17797const Asciidoctor = Opal.Asciidoctor.$$class
17798
17799/**
17800 * Get Asciidoctor core version number.
17801 *
17802 * @returns {string} - the version number of Asciidoctor core.
17803 * @memberof Asciidoctor
17804 */
17805Asciidoctor.prototype.getCoreVersion = function () {
17806  return this.$$const.VERSION
17807}
17808
17809/**
17810 * Get Asciidoctor.js runtime environment information.
17811 *
17812 * @returns {Object} - the runtime environment including the ioModule, the platform, the engine and the framework.
17813 * @memberof Asciidoctor
17814 */
17815Asciidoctor.prototype.getRuntime = function () {
17816  return {
17817    ioModule: Opal.const_get_qualified('::', 'JAVASCRIPT_IO_MODULE'),
17818    platform: Opal.const_get_qualified('::', 'JAVASCRIPT_PLATFORM'),
17819    engine: Opal.const_get_qualified('::', 'JAVASCRIPT_ENGINE'),
17820    framework: Opal.const_get_qualified('::', 'JAVASCRIPT_FRAMEWORK')
17821  }
17822}
17823
17824/**
17825 * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format.
17826 *
17827 * Accepts input as a Buffer or String.
17828 *
17829 * @param {string|Buffer} input - AsciiDoc input as String or Buffer
17830 * @param {Object} options - a JSON of options to control processing (default: {})
17831 * @returns {string|Document} - the {@link Document} object if the converted String is written to a file,
17832 * otherwise the converted String
17833 * @example
17834 * const input = `= Hello, AsciiDoc!
17835 * Guillaume Grossetie <ggrossetie@example.com>
17836 *
17837 * An introduction to http://asciidoc.org[AsciiDoc].
17838 *
17839 * == First Section
17840 *
17841 * * item 1
17842 * * item 2`
17843 *
17844 * const html = asciidoctor.convert(input)
17845 * @memberof Asciidoctor
17846 */
17847Asciidoctor.prototype.convert = function (input, options) {
17848  if (typeof input === 'object' && input.constructor.name === 'Buffer') {
17849    input = input.toString('utf8')
17850  }
17851  const toFile = options && options.to_file
17852  if (typeof toFile === 'object' && toFile.constructor.name === 'Writable' && typeof toFile.write === 'function') {
17853    toFile['$respond_to?'] = (name) => name === 'write'
17854    toFile.$object_id = () => ''
17855    toFile.$write = function (data) {
17856      this.write(data)
17857    }
17858  }
17859  const opts = prepareOptions(options)
17860  const result = this.$convert(input, opts)
17861  if (typeof toFile === 'object' && toFile.constructor.name === 'Writable' && typeof toFile.end === 'function') {
17862    toFile.end()
17863  }
17864  return result === Opal.nil ? '' : result
17865}
17866
17867/**
17868 * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format.
17869 *
17870 * @param {string} filename - source filename
17871 * @param {Object} options - a JSON of options to control processing (default: {})
17872 * @returns {string|Document} - the {@link Document} object if the converted String is written to a file,
17873 * otherwise the converted String
17874 * @example
17875 * const html = asciidoctor.convertFile('./document.adoc')
17876 * @memberof Asciidoctor
17877 */
17878Asciidoctor.prototype.convertFile = function (filename, options) {
17879  return this.$convert_file(filename, prepareOptions(options))
17880}
17881
17882/**
17883 * Parse the AsciiDoc source input into an {@link Document}
17884 *
17885 * Accepts input as a Buffer or String.
17886 *
17887 * @param {string|Buffer} input - AsciiDoc input as String or Buffer
17888 * @param {Object} options - a JSON of options to control processing (default: {})
17889 * @returns {Document} - the {@link Document} object
17890 * @memberof Asciidoctor
17891 */
17892Asciidoctor.prototype.load = function (input, options) {
17893  if (typeof input === 'object' && input.constructor.name === 'Buffer') {
17894    input = input.toString('utf8')
17895  }
17896  return this.$load(input, prepareOptions(options))
17897}
17898
17899/**
17900 * Parse the contents of the AsciiDoc source file into an {@link Document}
17901 *
17902 * @param {string} filename - source filename
17903 * @param {Object} options - a JSON of options to control processing (default: {})
17904 * @returns {Document} - the {@link Document} object
17905 * @memberof Asciidoctor
17906 */
17907Asciidoctor.prototype.loadFile = function (filename, options) {
17908  return this.$load_file(filename, prepareOptions(options))
17909}
17910
17911// AbstractBlock API
17912
17913/**
17914 * @namespace
17915 * @extends AbstractNode
17916 */
17917const AbstractBlock = Opal.Asciidoctor.AbstractBlock
17918
17919/**
17920 *  Describes the type of content this block accepts and how it should be converted.
17921 * @returns {string} - the type of content this block accepts.
17922 * @memberof AbstractBlock
17923 */
17924AbstractBlock.prototype.getContentModel = function () {
17925  const contentModel = this.content_model
17926  return contentModel === Opal.nil ? undefined : contentModel
17927}
17928
17929/**
17930 *  Set the type of content this block accepts. Acceptable values are:
17931 *  - compound - this block contains other blocks
17932 *  - simple - this block holds a paragraph of prose that receives normal substitutions
17933 *  - verbatim - this block holds verbatim text (displayed "as is") that receives verbatim substitutions
17934 *  - raw - this block holds unprocessed content passed directly to the output with no substitutions applied
17935 *  - empty - this block has no content
17936 * @param {string} contentModel - type of content, one of: compound, simple, verbatim, raw or empty.
17937 * @memberof AbstractBlock
17938 */
17939AbstractBlock.prototype.setContentModel = function (contentModel) {
17940  this.content_model = contentModel
17941}
17942
17943/**
17944 * Append a block to this block's list of child blocks.
17945 * @param {AbstractBlock} block - the block to append
17946 * @returns {AbstractBlock} - the parent block to which this block was appended.
17947 * @memberof AbstractBlock
17948 */
17949AbstractBlock.prototype.append = function (block) {
17950  this.$append(block)
17951  return this
17952}
17953
17954/**
17955 * Get the String title of this Block with title substitutions applied
17956 *
17957 * The following substitutions are applied to block and section titles:
17958 *
17959 * <code>specialcharacters</code>, <code>quotes</code>, <code>replacements</code>, <code>macros</code>, <code>attributes</code> and <code>post_replacements</code>
17960 *
17961 * @returns {string} - the converted String title for this Block, or undefined if the title is not set.
17962 * @example
17963 * block.title // "Foo 3^ # {two-colons} Bar(1)"
17964 * block.getTitle(); // "Foo 3^ # :: Bar(1)"
17965 * @memberof AbstractBlock
17966 */
17967AbstractBlock.prototype.getTitle = function () {
17968  const title = this.$title()
17969  return title === Opal.nil ? undefined : title
17970}
17971
17972/**
17973 * Set the String block title.
17974 *
17975 * @param {string} title - The block title
17976 * @returns {string} - the new String title assigned to this Block.
17977 * @memberof AbstractBlock
17978 */
17979AbstractBlock.prototype.setTitle = function (title) {
17980  title = typeof title === 'undefined' ? Opal.nil : title
17981  return this['$title='](title)
17982}
17983
17984/**
17985 * Generate and assign caption to block if not already assigned.
17986 *
17987 * If the block has a title and a caption prefix is available for this block,
17988 * then build a caption from this information, assign it a number and store it
17989 * to the caption attribute on the block.
17990 *
17991 * If a caption has already been assigned to this block, do nothing.
17992 *
17993 * The parts of a complete caption are: `<prefix> <number>. <title>`
17994 * This partial caption represents the part the precedes the title.
17995 *
17996 * @param {string} value - the String caption to assign to this block or nil to use document attribute.
17997 * @param {string} captionContext - the String context to use when resolving caption-related attributes.
17998 * If not provided, the name of the context for this block is used. Only certain contexts allow the caption to be looked up.
17999 *
18000 * @memberof AbstractBlock
18001 */
18002AbstractBlock.prototype.assignCaption = function (value, captionContext) {
18003  value = typeof value === 'undefined' ? Opal.nil : value
18004  captionContext = typeof captionContext === 'undefined' ? null : captionContext
18005  this.$assign_caption(value, captionContext)
18006}
18007
18008/**
18009 * Convenience method that returns the interpreted title of the Block
18010 * with the caption prepended.
18011 * Concatenates the value of this Block's caption instance variable and the
18012 * return value of this Block's title method. No space is added between the
18013 * two values. If the Block does not have a caption, the interpreted title is
18014 * returned.
18015 *
18016 * @returns {string} - the converted String title prefixed with the caption, or just the converted String title if no caption is set
18017 * @memberof AbstractBlock
18018 */
18019AbstractBlock.prototype.getCaptionedTitle = function () {
18020  return this.$captioned_title()
18021}
18022
18023/**
18024 * Get the style (block type qualifier) for this block.
18025 *
18026 * @returns {string} - the style for this block
18027 * @memberof AbstractBlock
18028 */
18029AbstractBlock.prototype.getStyle = function () {
18030  const style = this.style
18031  return style === Opal.nil ? undefined : style
18032}
18033
18034/**
18035 * Set the style for this block.
18036 *
18037 * @param {string} style - Style
18038 * @memberof AbstractBlock
18039 */
18040AbstractBlock.prototype.setStyle = function (style) {
18041  this.style = style
18042}
18043
18044/**
18045 * Get the location in the AsciiDoc source where this block begins.
18046 *
18047 * @returns {Cursor} - the location in the AsciiDoc source where this block begins
18048 * @memberof AbstractBlock
18049 */
18050AbstractBlock.prototype.getSourceLocation = function () {
18051  const sourceLocation = this.source_location
18052  if (sourceLocation === Opal.nil) {
18053    return undefined
18054  }
18055  sourceLocation.getFile = function () {
18056    const file = this.file
18057    return file === Opal.nil ? undefined : file
18058  }
18059  sourceLocation.getDirectory = function () {
18060    const dir = this.dir
18061    return dir === Opal.nil ? undefined : dir
18062  }
18063  sourceLocation.getPath = function () {
18064    const path = this.path
18065    return path === Opal.nil ? undefined : path
18066  }
18067  sourceLocation.getLineNumber = function () {
18068    const lineno = this.lineno
18069    return lineno === Opal.nil ? undefined : lineno
18070  }
18071  return sourceLocation
18072}
18073
18074/**
18075 * Get the caption for this block.
18076 *
18077 * @returns {string} - the caption for this block
18078 * @memberof AbstractBlock
18079 */
18080AbstractBlock.prototype.getCaption = function () {
18081  const caption = this.$caption()
18082  return caption === Opal.nil ? undefined : caption
18083}
18084
18085/**
18086 * Set the caption for this block.
18087 *
18088 * @param {string} caption - Caption
18089 * @memberof AbstractBlock
18090 */
18091AbstractBlock.prototype.setCaption = function (caption) {
18092  this.caption = typeof caption === 'undefined' ? Opal.nil : caption
18093}
18094
18095/**
18096 * Get the level of this section or the section level in which this block resides.
18097 *
18098 * @returns {number} - the level (Integer) of this section
18099 * @memberof AbstractBlock
18100 */
18101AbstractBlock.prototype.getLevel = function () {
18102  const level = this.level
18103  return level === Opal.nil ? undefined : level
18104}
18105
18106/**
18107 * Get the substitution keywords to be applied to the contents of this block.
18108 *
18109 * @returns {Array<string>} - the list of {string} substitution keywords associated with this block.
18110 * @memberof AbstractBlock
18111 */
18112AbstractBlock.prototype.getSubstitutions = function () {
18113  return this.subs
18114}
18115
18116/**
18117 * Check whether a given substitution keyword is present in the substitutions for this block.
18118 *
18119 * @returns {boolean} - whether the substitution is present on this block.
18120 * @memberof AbstractBlock
18121 */
18122AbstractBlock.prototype.hasSubstitution = function (substitution) {
18123  return this['$sub?'](substitution)
18124}
18125
18126/**
18127 * Remove the specified substitution keyword from the list of substitutions for this block.
18128 *
18129 * @memberof AbstractBlock
18130 */
18131AbstractBlock.prototype.removeSubstitution = function (substitution) {
18132  this.$remove_sub(substitution)
18133}
18134
18135/**
18136 * Checks if the {@link AbstractBlock} contains any child blocks.
18137 *
18138 * @returns {boolean} - whether the {@link AbstractBlock} has child blocks.
18139 * @memberof AbstractBlock
18140 */
18141AbstractBlock.prototype.hasBlocks = function () {
18142  return this.blocks.length > 0
18143}
18144
18145/**
18146 * Get the list of {@link AbstractBlock} sub-blocks for this block.
18147 *
18148 * @returns {Array<AbstractBlock>} - a list of {@link AbstractBlock} sub-blocks
18149 * @memberof AbstractBlock
18150 */
18151AbstractBlock.prototype.getBlocks = function () {
18152  return this.blocks
18153}
18154
18155/**
18156 * Get the converted result of the child blocks by converting the children appropriate to content model that this block supports.
18157 *
18158 * @returns {string} - the converted result of the child blocks
18159 * @memberof AbstractBlock
18160 */
18161AbstractBlock.prototype.getContent = function () {
18162  const content = this.$content()
18163  return content === Opal.nil ? undefined : content
18164}
18165
18166/**
18167 * Get the converted content for this block.
18168 * If the block has child blocks, the content method should cause them to be converted
18169 * and returned as content that can be included in the parent block's template.
18170 *
18171 * @returns {string} - the converted String content for this block
18172 * @memberof AbstractBlock
18173 */
18174AbstractBlock.prototype.convert = function () {
18175  return this.$convert()
18176}
18177
18178/**
18179 * Query for all descendant block-level nodes in the document tree
18180 * that match the specified selector (context, style, id, and/or role).
18181 * If a function block is given, it's used as an additional filter.
18182 * If no selector or function block is supplied, all block-level nodes in the tree are returned.
18183 * @param {Object} [selector]
18184 * @param {function} [block]
18185 * @example
18186 * doc.findBy({'context': 'section'});
18187 * // => { level: 0, title: "Hello, AsciiDoc!", blocks: 0 }
18188 * // => { level: 1, title: "First Section", blocks: 1 }
18189 *
18190 * doc.findBy({'context': 'section'}, function (section) { return section.getLevel() === 1; });
18191 * // => { level: 1, title: "First Section", blocks: 1 }
18192 *
18193 * doc.findBy({'context': 'listing', 'style': 'source'});
18194 * // => { context: :listing, content_model: :verbatim, style: "source", lines: 1 }
18195 *
18196 * @returns {Array<AbstractBlock>} - a list of block-level nodes that match the filter or an empty list if no matches are found
18197 * @memberof AbstractBlock
18198 */
18199AbstractBlock.prototype.findBy = function (selector, block) {
18200  if (typeof block === 'undefined' && typeof selector === 'function') {
18201    return Opal.send(this, 'find_by', null, selector)
18202  } else if (typeof block === 'function') {
18203    return Opal.send(this, 'find_by', [toHash(selector)], block)
18204  } else {
18205    return this.$find_by(toHash(selector))
18206  }
18207}
18208
18209/**
18210 * Get the source line number where this block started.
18211 * @returns {number} - the source line number where this block started
18212 * @memberof AbstractBlock
18213 */
18214AbstractBlock.prototype.getLineNumber = function () {
18215  const lineno = this.$lineno()
18216  return lineno === Opal.nil ? undefined : lineno
18217}
18218
18219/**
18220 * Check whether this block has any child Section objects.
18221 * Only applies to Document and Section instances.
18222 * @returns {boolean} - true if this block has child Section objects, otherwise false
18223 * @memberof AbstractBlock
18224 */
18225AbstractBlock.prototype.hasSections = function () {
18226  // REMIND: call directly the underlying method "$sections?"
18227  // once https://github.com/asciidoctor/asciidoctor/pull/3591 is merged and a new version is released.
18228  // return this['$sections?']()
18229  return this.next_section_index !== Opal.nil && this.next_section_index > 0
18230}
18231
18232/**
18233 * Get the Array of child Section objects.
18234 * Only applies to Document and Section instances.
18235 * @memberof AbstractBlock
18236 * @returns {Array<Section>} - an {Array} of {@link Section} objects
18237 */
18238AbstractBlock.prototype.getSections = function () {
18239  return this.$sections()
18240}
18241
18242/**
18243 * Get the numeral of this block (if section, relative to parent, otherwise absolute).
18244 * Only assigned to section if automatic section numbering is enabled.
18245 * Only assigned to formal block (block with title) if corresponding caption attribute is present.
18246 * If the section is an appendix, the numeral is a letter (starting with A).
18247 * @returns {string} - the numeral
18248 * @memberof AbstractBlock
18249 */
18250AbstractBlock.prototype.getNumeral = function () {
18251  const numeral = this.$numeral()
18252  return numeral === Opal.nil ? undefined : numeral
18253}
18254
18255/**
18256 * Set the numeral of this block.
18257 * @param {string} value - The numeral value
18258 * @memberof AbstractBlock
18259 */
18260AbstractBlock.prototype.setNumeral = function (value) {
18261  this['$numeral='](value)
18262}
18263
18264/**
18265 * A convenience method that checks whether the title of this block is defined.
18266 *
18267 * @returns {boolean} - a {boolean} indicating whether this block has a title.
18268 * @memberof AbstractBlock
18269 */
18270AbstractBlock.prototype.hasTitle = function () {
18271  return this['$title?']()
18272}
18273
18274/**
18275 * Returns the converted alt text for this block image.
18276 * @returns {string} - the {string} value of the alt attribute with XML special character and replacement substitutions applied.
18277 * @memberof AbstractBlock
18278 */
18279AbstractBlock.prototype.getAlt = function () {
18280  return this.$alt()
18281}
18282
18283// Section API
18284
18285/**
18286 * @description
18287 * Methods for managing sections of AsciiDoc content in a document.
18288 *
18289 * @example
18290 * <pre>
18291 *   section = asciidoctor.Section.create()
18292 *   section.setTitle('Section 1')
18293 *   section.setId('sect1')
18294 *   section.getBlocks().length // 0
18295 *   section.getId() // "sect1"
18296 *   section.append(newBlock)
18297 *   section.getBlocks().length // 1
18298 * </pre>
18299 * @namespace
18300 * @extends AbstractBlock
18301 */
18302const Section = Opal.Asciidoctor.Section
18303
18304/**
18305 * Create a {Section} object.
18306 * @param {AbstractBlock} [parent] - The parent AbstractBlock. If set, must be a Document or Section object (default: undefined)
18307 * @param {number} [level] - The Integer level of this section (default: 1 more than parent level or 1 if parent not defined)
18308 * @param {boolean} [numbered] - A Boolean indicating whether numbering is enabled for this Section (default: false)
18309 * @param {Object} [opts] - An optional JSON of options (default: {})
18310 * @returns {Section} - a new {Section} object
18311 * @memberof Section
18312 */
18313Section.create = function (parent, level, numbered, opts) {
18314  if (opts && opts.attributes) {
18315    opts.attributes = toHash(opts.attributes)
18316  }
18317  return this.$new(parent, level, numbered, toHash(opts))
18318}
18319
18320/**
18321 * Set the level of this section or the section level in which this block resides.
18322 * @param {number} level - Level (Integer)
18323 * @memberof AbstractBlock
18324 */
18325Section.prototype.setLevel = function (level) {
18326  this.level = level
18327}
18328
18329/**
18330 * Get the 0-based index order of this section within the parent block.
18331 * @returns {number}
18332 * @memberof Section
18333 */
18334Section.prototype.getIndex = function () {
18335  return this.index
18336}
18337
18338/**
18339 * Set the 0-based index order of this section within the parent block.
18340 * @param {string} index - The index order of this section
18341 * @memberof Section
18342 */
18343Section.prototype.setIndex = function (index) {
18344  this.index = index
18345}
18346
18347/**
18348 * Get the section name of this section.
18349 * @returns {string|undefined}
18350 * @memberof Section
18351 */
18352Section.prototype.getSectionName = function () {
18353  const sectname = this.sectname
18354  return sectname === Opal.nil ? undefined : sectname
18355}
18356
18357/**
18358 * Set the section name of this section.
18359 * @param {string} value - The section name
18360 * @memberof Section
18361 */
18362Section.prototype.setSectionName = function (value) {
18363  this.sectname = value
18364}
18365
18366/**
18367 * Get the section numeral of this section.
18368 * @returns {string}
18369 * @memberof Section
18370 */
18371Section.prototype.getSectionNumeral = function () {
18372  return this.$sectnum()
18373}
18374
18375Section.prototype.getSectionNumber = Section.prototype.getSectionNumeral
18376
18377/**
18378 * Get the flag to indicate whether this is a special section or a child of one.
18379 * @returns {boolean}
18380 * @memberof Section
18381 */
18382Section.prototype.isSpecial = function () {
18383  return this.special
18384}
18385
18386/**
18387 * Set the flag to indicate whether this is a special section or a child of one.
18388 * @param {boolean} value - A flag to indicated if this is a special section
18389 * @memberof Section
18390 */
18391Section.prototype.setSpecial = function (value) {
18392  this.special = value
18393}
18394
18395/**
18396 * Get the state of the numbered attribute at this section (need to preserve for creating TOC).
18397 * @returns {boolean}
18398 * @memberof Section
18399 */
18400Section.prototype.isNumbered = function () {
18401  return this.numbered
18402}
18403
18404/**
18405 * Get the caption for this section (only relevant for appendices).
18406 * @returns {string}
18407 * @memberof Section
18408 */
18409Section.prototype.getCaption = function () {
18410  const value = this.caption
18411  return value === Opal.nil ? undefined : value
18412}
18413
18414/**
18415 * Get the name of the Section (title)
18416 * @returns {string}
18417 * @see {@link AbstractBlock#getTitle}
18418 * @memberof Section
18419 */
18420Section.prototype.getName = function () {
18421  return this.getTitle()
18422}
18423
18424/**
18425 * @description
18426 * Methods for managing AsciiDoc content blocks.
18427 *
18428 * @example
18429 * block = asciidoctor.Block.create(parent, 'paragraph', {source: '_This_ is a <test>'})
18430 * block.getContent()
18431 * // "<em>This</em> is a &lt;test&gt;"
18432 *
18433 * @namespace
18434 * @extends AbstractBlock
18435 */
18436const Block = Opal.Asciidoctor.Block
18437
18438/**
18439 * Create a {Block} object.
18440 * @param {AbstractBlock} parent - The parent {AbstractBlock} with a compound content model to which this {Block} will be appended.
18441 * @param {string} context - The context name for the type of content (e.g., "paragraph").
18442 * @param {Object} [opts] - a JSON of options to customize block initialization: (default: {})
18443 * @param {string} opts.content_model - indicates whether blocks can be nested in this {Block} ("compound"),
18444 * otherwise how the lines should be processed ("simple", "verbatim", "raw", "empty"). (default: "simple")
18445 * @param {Object} opts.attributes - a JSON of attributes (key/value pairs) to assign to this {Block}. (default: {})
18446 * @param {string|Array<string>} opts.source - a String or {Array} of raw source for this {Block}. (default: undefined)
18447 *
18448 * IMPORTANT: If you don't specify the `subs` option, you must explicitly call the `commit_subs` method to resolve and assign the substitutions
18449 * to this block (which are resolved from the `subs` attribute, if specified, or the default substitutions based on this block's context).
18450 * If you want to use the default subs for a block, pass the option `subs: "default"`.
18451 * You can override the default subs using the `default_subs` option.
18452 *
18453 * @returns {Block} - a new {Block} object
18454 * @memberof Block
18455 */
18456Block.create = function (parent, context, opts) {
18457  if (opts && opts.attributes) {
18458    opts.attributes = toHash(opts.attributes)
18459  }
18460  return this.$new(parent, context, toHash(opts))
18461}
18462
18463/**
18464 * Get the source of this block.
18465 * @returns {string} - the String source of this block.
18466 * @memberof Block
18467 */
18468Block.prototype.getSource = function () {
18469  return this.$source()
18470}
18471
18472/**
18473 * Get the source lines of this block.
18474 * @returns {Array<string>} - the String {Array} of source lines for this block.
18475 * @memberof Block
18476 */
18477Block.prototype.getSourceLines = function () {
18478  return this.lines
18479}
18480
18481// AbstractNode API
18482
18483/**
18484 * @namespace
18485 * @description
18486 * An abstract base class that provides state and methods for managing a node of AsciiDoc content.
18487 * The state and methods on this class are common to all content segments in an AsciiDoc document.
18488 */
18489const AbstractNode = Opal.Asciidoctor.AbstractNode
18490
18491/**
18492 * Apply the specified substitutions to the text.
18493 * If no substitutions are specified, the following substitutions are applied:
18494 * <code>specialcharacters</code>, <code>quotes</code>, <code>attributes</code>, <code>replacements</code>, <code>macros</code>, and <code>post_replacements</code>.
18495 *
18496 * @param {string|Array<string>} text - The String or String Array of text to process; must not be undefined.
18497 * @param {Array<string>} [subs] - The substitutions to perform; must be an Array or undefined.
18498 * @returns {string|Array<string>} - a String or String Array to match the type of the text argument with substitutions applied.
18499 * @memberof AbstractNode
18500 */
18501AbstractNode.prototype.applySubstitutions = function (text, subs) {
18502  return this.$apply_subs(text, subs)
18503}
18504
18505/**
18506 * Resolve the list of comma-delimited subs against the possible options.
18507 *
18508 * @param {string} subs - The comma-delimited String of substitution names or aliases.
18509 * @param {string} [type] - A String representing the context for which the subs are being resolved (default: 'block').
18510 * @param {Array<string>} [defaults] - An Array of substitutions to start with when computing incremental substitutions (default: undefined).
18511 * @param {string} [subject] - The String to use in log messages to communicate the subject for which subs are being resolved (default: undefined)
18512 *
18513 * @returns {Array<string>} - An Array of Strings representing the substitution operation or nothing if no subs are found.
18514 * @memberof AbstractNode
18515 */
18516AbstractNode.prototype.resolveSubstitutions = function (subs, type, defaults, subject) {
18517  if (typeof type === 'undefined') {
18518    type = 'block'
18519  }
18520  if (typeof defaults === 'undefined') {
18521    defaults = Opal.nil
18522  }
18523  if (typeof subject === 'undefined') {
18524    subject = Opal.nil
18525  }
18526  const value = this.$resolve_subs(subs, type, defaults, subject)
18527  return value === Opal.nil ? undefined : value
18528}
18529
18530/**
18531 * Call {@link AbstractNode#resolveSubstitutions} for the 'block' type.
18532 *
18533 * @see {@link AbstractNode#resolveSubstitutions}
18534 */
18535AbstractNode.prototype.resolveBlockSubstitutions = function (subs, defaults, subject) {
18536  return this.resolveSubstitutions(subs, 'block', defaults, subject)
18537}
18538
18539/**
18540 * Call {@link AbstractNode#resolveSubstitutions} for the 'inline' type with the subject set as passthrough macro.
18541 *
18542 * @see {@link AbstractNode#resolveSubstitutions}
18543 */
18544AbstractNode.prototype.resolvePassSubstitutions = function (subs) {
18545  return this.resolveSubstitutions(subs, 'inline', undefined, 'passthrough macro')
18546}
18547
18548/**
18549 * @returns {string} - the String name of this node
18550 * @memberof AbstractNode
18551 */
18552AbstractNode.prototype.getNodeName = function () {
18553  return this.node_name
18554}
18555
18556/**
18557 * @returns {Object} - the JSON of attributes for this node
18558 * @memberof AbstractNode
18559 */
18560AbstractNode.prototype.getAttributes = function () {
18561  return fromHash(this.attributes)
18562}
18563
18564/**
18565 * Get the value of the specified attribute.
18566 * If the attribute is not found on this node, fallback_name is set, and this node is not the Document node, get the value of the specified attribute from the Document node.
18567 *
18568 * Look for the specified attribute in the attributes on this node and return the value of the attribute, if found.
18569 * Otherwise, if fallback_name is set (default: same as name) and this node is not the Document node, look for that attribute on the Document node and return its value, if found.
18570 * Otherwise, return the default value (default: undefined).
18571 *
18572 * @param {string} name - The String of the attribute to resolve.
18573 * @param {*} [defaultValue] - The {Object} value to return if the attribute is not found (default: undefined).
18574 * @param {string} [fallbackName] - The String of the attribute to resolve on the Document if the attribute is not found on this node (default: same as name).
18575 *
18576 * @returns {*} - the {Object} value (typically a String) of the attribute or defaultValue if the attribute is not found.
18577 * @memberof AbstractNode
18578 */
18579AbstractNode.prototype.getAttribute = function (name, defaultValue, fallbackName) {
18580  const value = this.$attr(name, defaultValue, fallbackName)
18581  return value === Opal.nil ? undefined : value
18582}
18583
18584/**
18585 * Check whether the specified attribute is present on this node.
18586 *
18587 * @param {string} name - The String of the attribute to resolve.
18588 * @returns {boolean} - true if the attribute is present, otherwise false
18589 * @memberof AbstractNode
18590 */
18591AbstractNode.prototype.hasAttribute = function (name) {
18592  return name in this.attributes.$$smap
18593}
18594
18595/**
18596 * Check if the specified attribute is defined using the same logic as {AbstractNode#getAttribute}, optionally performing acomparison with the expected value if specified.
18597 *
18598 * Look for the specified attribute in the attributes on this node.
18599 * If not found, fallback_name is specified (default: same as name), and this node is not the Document node, look for that attribute on the Document node.
18600 * In either case, if the attribute is found, and the comparison value is truthy, return whether the two values match.
18601 * Otherwise, return whether the attribute was found.
18602 *
18603 * @param {string} name - The String name of the attribute to resolve.
18604 * @param {*} [expectedValue] - The expected Object value of the attribute (default: undefined).
18605 * @param {string} fallbackName - The String of the attribute to resolve on the Document if the attribute is not found on this node (default: same as name).
18606 *
18607 * @returns {boolean} - a Boolean indicating whether the attribute exists and, if a truthy comparison value is specified, whether the value of the attribute matches the comparison value.
18608 * @memberof AbstractNode
18609 */
18610AbstractNode.prototype.isAttribute = function (name, expectedValue, fallbackName) {
18611  return this['$attr?'](name, expectedValue, fallbackName)
18612}
18613
18614/**
18615 * Assign the value to the attribute name for the current node.
18616 *
18617 * @param {string} name - The String attribute name to assign
18618 * @param {*} value - The Object value to assign to the attribute (default: '')
18619 * @param {boolean} overwrite - A Boolean indicating whether to assign the attribute if currently present in the attributes JSON (default: true)
18620 *
18621 * @returns {boolean} - a Boolean indicating whether the assignment was performed
18622 * @memberof AbstractNode
18623 */
18624AbstractNode.prototype.setAttribute = function (name, value, overwrite) {
18625  if (typeof overwrite === 'undefined') overwrite = true
18626  return this.$set_attr(name, value, overwrite)
18627}
18628
18629/**
18630 * Remove the attribute from the current node.
18631 * @param {string} name - The String attribute name to remove
18632 * @returns {string} - the previous {string} value, or undefined if the attribute was not present.
18633 * @memberof AbstractNode
18634 */
18635AbstractNode.prototype.removeAttribute = function (name) {
18636  const value = this.$remove_attr(name)
18637  return value === Opal.nil ? undefined : value
18638}
18639
18640/**
18641 * Get the {@link Document} to which this node belongs.
18642 *
18643 * @returns {Document} - the {@link Document} object to which this node belongs.
18644 * @memberof AbstractNode
18645 */
18646AbstractNode.prototype.getDocument = function () {
18647  return this.document
18648}
18649
18650/**
18651 * Get the {@link AbstractNode} to which this node is attached.
18652 *
18653 * @memberof AbstractNode
18654 * @returns {AbstractNode} - the {@link AbstractNode} object to which this node is attached,
18655 * or undefined if this node has no parent.
18656 */
18657AbstractNode.prototype.getParent = function () {
18658  const parent = this.parent
18659  return parent === Opal.nil ? undefined : parent
18660}
18661
18662/**
18663 * @returns {boolean} - true if this {AbstractNode} is an instance of {Inline}
18664 * @memberof AbstractNode
18665 */
18666AbstractNode.prototype.isInline = function () {
18667  return this['$inline?']()
18668}
18669
18670/**
18671 * @returns {boolean} - true if this {AbstractNode} is an instance of {Block}
18672 * @memberof AbstractNode
18673 */
18674AbstractNode.prototype.isBlock = function () {
18675  return this['$block?']()
18676}
18677
18678/**
18679 * Checks if the role attribute is set on this node and, if an expected value is given, whether the space-separated role matches that value.
18680 *
18681 * @param {string} expectedValue - The expected String value of the role (optional, default: undefined)
18682 *
18683 * @returns {boolean} - a Boolean indicating whether the role attribute is set on this node and, if an expected value is given, whether the space-separated role matches that value.
18684 * @memberof AbstractNode
18685 */
18686AbstractNode.prototype.isRole = function (expectedValue) {
18687  return this['$role?'](expectedValue)
18688}
18689
18690/**
18691 * Retrieves the space-separated String role for this node.
18692 *
18693 * @returns {string} - the role as a space-separated String.
18694 * @memberof AbstractNode
18695 */
18696AbstractNode.prototype.getRole = function () {
18697  const role = this.$role()
18698  return role === Opal.nil ? undefined : role
18699}
18700
18701/**
18702 * Sets the value of the role attribute on this node.
18703 *
18704 * @param {...string|Array<string>} names - A single role name, a space-separated String of role names, an Array of role names or a list of role names
18705 *
18706 * @returns {string} - the value of the role attribute
18707 * @memberof AbstractNode
18708 */
18709AbstractNode.prototype.setRole = function (names) {
18710  if (Array.isArray(names) || (typeof names === 'string' && arguments.length === 1)) {
18711    return this['$role='](names)
18712  }
18713  return this['$role='](Array.from(arguments))
18714}
18715
18716/**
18717 * Checks if the specified role is present in the list of roles for this node.
18718 *
18719 * @param {string} name - The String name of the role to find.
18720 *
18721 * @returns {boolean} - a Boolean indicating whether this node has the specified role.
18722 * @memberof AbstractNode
18723 */
18724AbstractNode.prototype.hasRole = function (name) {
18725  return this['$has_role?'](name)
18726}
18727
18728/**
18729 * Retrieves the String role names for this node as an Array.
18730 *
18731 * @returns {Array<string>} - the role names as a String {Array}, which is empty if the role attribute is absent on this node.
18732 * @memberof AbstractNode
18733 */
18734AbstractNode.prototype.getRoles = function () {
18735  return this.$roles()
18736}
18737
18738/**
18739 * Adds the given role directly to this node.
18740 *
18741 * @param {string} name - The name of the role to add
18742 *
18743 * @returns {boolean} - a Boolean indicating whether the role was added.
18744 * @memberof AbstractNode
18745 */
18746AbstractNode.prototype.addRole = function (name) {
18747  return this.$add_role(name)
18748}
18749
18750/**
18751 * Public: Removes the given role directly from this node.
18752 *
18753 * @param {string} name - The name of the role to remove
18754 *
18755 * @returns {boolean} - a Boolean indicating whether the role was removed.
18756 * @memberof AbstractNode
18757 */
18758AbstractNode.prototype.removeRole = function (name) {
18759  return this.$remove_role(name)
18760}
18761
18762/**
18763 * A convenience method that checks if the reftext attribute is defined.
18764 * @returns {boolean} - A Boolean indicating whether the reftext attribute is defined
18765 * @memberof AbstractNode
18766 */
18767AbstractNode.prototype.isReftext = function () {
18768  return this['$reftext?']()
18769}
18770
18771/**
18772 * A convenience method that returns the value of the reftext attribute with substitutions applied.
18773 * @returns {string|undefined} - the value of the reftext attribute with substitutions applied.
18774 * @memberof AbstractNode
18775 */
18776AbstractNode.prototype.getReftext = function () {
18777  const reftext = this.$reftext()
18778  return reftext === Opal.nil ? undefined : reftext
18779}
18780
18781/**
18782 * @returns {string} - Get the context name for this node
18783 * @memberof AbstractNode
18784 */
18785AbstractNode.prototype.getContext = function () {
18786  const context = this.context
18787  // Automatically convert Opal pseudo-symbol to String
18788  return typeof context === 'string' ? context : context.toString()
18789}
18790
18791/**
18792 * @returns {string} - the String id of this node
18793 * @memberof AbstractNode
18794 */
18795AbstractNode.prototype.getId = function () {
18796  const id = this.id
18797  return id === Opal.nil ? undefined : id
18798}
18799
18800/**
18801 * @param {string} id - the String id of this node
18802 * @memberof AbstractNode
18803 */
18804AbstractNode.prototype.setId = function (id) {
18805  this.id = id
18806}
18807
18808/**
18809 * A convenience method to check if the specified option attribute is enabled on the current node.
18810 * Check if the option is enabled. This method simply checks to see if the <name>-option attribute is defined on the current node.
18811 *
18812 * @param {string} name - the String name of the option
18813 *
18814 * @return {boolean} - a Boolean indicating whether the option has been specified
18815 * @memberof AbstractNode
18816 */
18817AbstractNode.prototype.isOption = function (name) {
18818  return this['$option?'](name)
18819}
18820
18821/**
18822 * Set the specified option on this node.
18823 * This method sets the specified option on this node by setting the <name>-option attribute.
18824 *
18825 * @param {string} name - the String name of the option
18826 *
18827 * @memberof AbstractNode
18828 */
18829AbstractNode.prototype.setOption = function (name) {
18830  return this.$set_option(name)
18831}
18832
18833/**
18834 * @memberof AbstractNode
18835 */
18836AbstractNode.prototype.getIconUri = function (name) {
18837  return this.$icon_uri(name)
18838}
18839
18840/**
18841 * @memberof AbstractNode
18842 */
18843AbstractNode.prototype.getMediaUri = function (target, assetDirKey) {
18844  return this.$media_uri(target, assetDirKey)
18845}
18846
18847/**
18848 * @memberof AbstractNode
18849 */
18850AbstractNode.prototype.getImageUri = function (targetImage, assetDirKey) {
18851  return this.$image_uri(targetImage, assetDirKey)
18852}
18853
18854/**
18855 * Get the {Converter} instance being used to convert the current {Document}.
18856 * @returns {Object}
18857 * @memberof AbstractNode
18858 */
18859AbstractNode.prototype.getConverter = function () {
18860  return this.$converter()
18861}
18862
18863/**
18864 * @memberof AbstractNode
18865 */
18866AbstractNode.prototype.readContents = function (target, options) {
18867  return this.$read_contents(target, toHash(options))
18868}
18869
18870/**
18871 * Read the contents of the file at the specified path.
18872 * This method assumes that the path is safe to read.
18873 * It checks that the file is readable before attempting to read it.
18874 *
18875 * @param path - the {string} path from which to read the contents
18876 * @param {Object} options - a JSON {Object} of options to control processing (default: {})
18877 * @param {boolean} options.warn_on_failure - a {boolean} that controls whether a warning is issued if the file cannot be read (default: false)
18878 * @param {boolean} options.normalize - a {boolean} that controls whether the lines are normalized and coerced to UTF-8 (default: false)
18879 *
18880 * @returns {string} - the String content of the file at the specified path, or undefined if the file does not exist.
18881 * @memberof AbstractNode
18882 */
18883AbstractNode.prototype.readAsset = function (path, options) {
18884  const result = this.$read_asset(path, toHash(options))
18885  return result === Opal.nil ? undefined : result
18886}
18887
18888/**
18889 * @memberof AbstractNode
18890 */
18891AbstractNode.prototype.normalizeWebPath = function (target, start, preserveTargetUri) {
18892  return this.$normalize_web_path(target, start, preserveTargetUri)
18893}
18894
18895/**
18896 * @memberof AbstractNode
18897 */
18898AbstractNode.prototype.normalizeSystemPath = function (target, start, jail, options) {
18899  return this.$normalize_system_path(target, start, jail, toHash(options))
18900}
18901
18902/**
18903 * @memberof AbstractNode
18904 */
18905AbstractNode.prototype.normalizeAssetPath = function (assetRef, assetName, autoCorrect) {
18906  return this.$normalize_asset_path(assetRef, assetName, autoCorrect)
18907}
18908
18909// Document API
18910
18911/**
18912 * The {@link Document} class represents a parsed AsciiDoc document.
18913 *
18914 * Document is the root node of a parsed AsciiDoc document.<br/>
18915 * It provides an abstract syntax tree (AST) that represents the structure of the AsciiDoc document
18916 * from which the Document object was parsed.
18917 *
18918 * Although the constructor can be used to create an empty document object,
18919 * more commonly, you'll load the document object from AsciiDoc source
18920 * using the primary API methods on {@link Asciidoctor}.
18921 * When using one of these APIs, you almost always want to set the safe mode to 'safe' (or 'unsafe')
18922 * to enable all of Asciidoctor's features.
18923 *
18924 * <pre>
18925 *   const doc = Asciidoctor.load('= Hello, AsciiDoc!', { 'safe': 'safe' })
18926 *   // => Asciidoctor::Document { doctype: "article", doctitle: "Hello, AsciiDoc!", blocks: 0 }
18927 * </pre>
18928 *
18929 * Instances of this class can be used to extract information from the document or alter its structure.
18930 * As such, the Document object is most often used in extensions and by integrations.
18931 *
18932 * The most basic usage of the Document object is to retrieve the document's title.
18933 *
18934 * <pre>
18935 *  const source = '= Document Title'
18936 *  const doc = asciidoctor.load(source, { 'safe': 'safe' })
18937 *  console.log(doc.getTitle()) // 'Document Title'
18938 * </pre>
18939 *
18940 * You can also use the Document object to access document attributes defined in the header, such as the author and doctype.
18941 * @namespace
18942 * @extends AbstractBlock
18943 */
18944const Document = Opal.Asciidoctor.Document
18945
18946/**
18947 * Append a content Block to this Document.
18948 * If the child block is a Section, assign an index to it.
18949 * @param {AbstractBlock} block - the child Block to append to this parent Block
18950 * @returns {AbstractBlock} - the parent block to which this block was appended.
18951 * @memberof Document
18952 */
18953Document.prototype.append = function (block) {
18954  this['$<<'](block)
18955  return this
18956}
18957
18958/**
18959 * Returns the SyntaxHighlighter associated with this document.
18960 *
18961 * @returns {SyntaxHighlighter} - the SyntaxHighlighter associated with this document.
18962 * @memberof Document
18963 */
18964Document.prototype.getSyntaxHighlighter = function () {
18965  const syntaxHighlighter = this.syntax_highlighter
18966  // eslint-disable-next-line no-proto
18967  const prototype = syntaxHighlighter.__proto__
18968  if (prototype) {
18969    if (typeof prototype['$highlight?'] === 'function') {
18970      prototype.handlesHighlighting = function () {
18971        const value = prototype['$highlight?']()
18972        return value === Opal.nil ? false : value
18973      }
18974    }
18975    if (typeof prototype['$docinfo?'] === 'function') {
18976      prototype.hasDocinfo = prototype['$docinfo?']
18977    }
18978    if (typeof prototype.$format === 'function') {
18979      prototype.format = function (node, lang, opts) {
18980        return this.$format(node, lang, toHash(opts))
18981      }
18982    }
18983    if (typeof prototype.$docinfo === 'function') {
18984      prototype.docinfo = function (location, doc, opts) {
18985        return this.$docinfo(location, doc, toHash(opts))
18986      }
18987    }
18988  }
18989  return syntaxHighlighter
18990}
18991
18992/**
18993 * Returns a JSON {Object} of references captured by the processor.
18994 *
18995 * @returns {Object} - a JSON {Object} of {AbstractNode} in the document.
18996 * @memberof Document
18997 */
18998Document.prototype.getRefs = function () {
18999  return fromHash(this.catalog.$$smap.refs)
19000}
19001
19002/**
19003 * Returns an {Array} of {Document/ImageReference} captured by the processor.
19004 *
19005 * @returns {Array<ImageReference>} - an {Array} of {Document/ImageReference} in the document.
19006 * Will return an empty array if the option "catalog_assets: true" was not defined on the processor.
19007 * @memberof Document
19008 */
19009Document.prototype.getImages = function () {
19010  return this.catalog.$$smap.images
19011}
19012
19013/**
19014 * Returns an {Array} of links captured by the processor.
19015 *
19016 * @returns {Array<string>} - an {Array} of links in the document.
19017 * Will return an empty array if:
19018 * - the function was called before the document was converted
19019 * - the option "catalog_assets: true" was not defined on the processor
19020 * @memberof Document
19021 */
19022Document.prototype.getLinks = function () {
19023  return this.catalog.$$smap.links
19024}
19025
19026/**
19027 * @returns {boolean} - true if the document has footnotes otherwise false
19028 * @memberof Document
19029 */
19030Document.prototype.hasFootnotes = function () {
19031  return this['$footnotes?']()
19032}
19033
19034/**
19035 * Returns an {Array} of {Document/Footnote} captured by the processor.
19036 *
19037 * @returns {Array<Footnote>} - an {Array} of {Document/Footnote} in the document.
19038 * Will return an empty array if the function was called before the document was converted.
19039 * @memberof Document
19040 */
19041Document.prototype.getFootnotes = function () {
19042  return this.$footnotes()
19043}
19044
19045/**
19046 * Returns the level-0 {Section} (i.e. the document title).
19047 * Only stores the title, not the header attributes.
19048 *
19049 * @returns {string} - the level-0 {Section}.
19050 * @memberof Document
19051 */
19052Document.prototype.getHeader = function () {
19053  return this.header
19054}
19055
19056/**
19057 * @memberof Document
19058 */
19059Document.prototype.setAttribute = function (name, value) {
19060  return this.$set_attribute(name, value)
19061}
19062
19063/**
19064
19065 * @memberof Document
19066 */
19067Document.prototype.removeAttribute = function (name) {
19068  this.attributes.$delete(name)
19069  this.attribute_overrides.$delete(name)
19070}
19071
19072/**
19073 * Convert the AsciiDoc document using the templates loaded by the Converter.
19074 * If a "template_dir" is not specified, or a template is missing, the converter will fall back to using the appropriate built-in template.
19075 *
19076 * @param {Object} [options] - a JSON of options to control processing (default: {})
19077 *
19078 * @returns {string}
19079 * @memberof Document
19080 */
19081Document.prototype.convert = function (options) {
19082  const result = this.$convert(toHash(options))
19083  return result === Opal.nil ? '' : result
19084}
19085
19086/**
19087 * Write the output to the specified file.
19088 *
19089 * If the converter responds to "write", delegate the work of writing the file to that method.
19090 * Otherwise, write the output the specified file.
19091 *
19092 * @param {string} output
19093 * @param {string} target
19094 *
19095 * @memberof Document
19096 */
19097Document.prototype.write = function (output, target) {
19098  return this.$write(output, target)
19099}
19100
19101/**
19102 * @returns {string} - the full name of the author as a String
19103 * @memberof Document
19104 */
19105Document.prototype.getAuthor = function () {
19106  return this.$author()
19107}
19108
19109/**
19110 * @returns {string}
19111 * @memberof Document
19112 */
19113Document.prototype.getSource = function () {
19114  return this.$source()
19115}
19116
19117/**
19118 * @returns {Array<string>}
19119 * @memberof Document
19120 */
19121Document.prototype.getSourceLines = function () {
19122  return this.$source_lines()
19123}
19124
19125/**
19126 * @returns {boolean}
19127 * @memberof Document
19128 */
19129Document.prototype.isNested = function () {
19130  return this['$nested?']()
19131}
19132
19133/**
19134 * @returns {boolean}
19135 * @memberof Document
19136 */
19137Document.prototype.isEmbedded = function () {
19138  return this['$embedded?']()
19139}
19140
19141/**
19142 * @returns {boolean}
19143 * @memberof Document
19144 */
19145Document.prototype.hasExtensions = function () {
19146  return this['$extensions?']()
19147}
19148
19149/**
19150 * Get the value of the doctype attribute for this document.
19151 * @returns {string}
19152 * @memberof Document
19153 */
19154Document.prototype.getDoctype = function () {
19155  return this.doctype
19156}
19157
19158/**
19159 * Get the value of the backend attribute for this document.
19160 * @returns {string}
19161 * @memberof Document
19162 */
19163Document.prototype.getBackend = function () {
19164  return this.backend
19165}
19166
19167/**
19168 * @returns {boolean}
19169 * @memberof Document
19170 */
19171Document.prototype.isBasebackend = function (base) {
19172  return this['$basebackend?'](base)
19173}
19174
19175/**
19176 * Get the title explicitly defined in the document attributes.
19177 * @returns {string}
19178 * @see {@link AbstractNode#getAttributes}
19179 * @memberof Document
19180 */
19181Document.prototype.getTitle = function () {
19182  const title = this.$title()
19183  return title === Opal.nil ? undefined : title
19184}
19185
19186/**
19187 * Set the title on the document header
19188 *
19189 * Set the title of the document header to the specified value.
19190 * If the header does not exist, it is first created.
19191 *
19192 * @param {string} title - the String title to assign as the title of the document header
19193 *
19194 * @returns {string} - the new String title assigned to the document header
19195 * @memberof Document
19196 */
19197Document.prototype.setTitle = function (title) {
19198  return this['$title='](title)
19199}
19200
19201/**
19202 * @returns {Document/Title} - a {@link Document/Title}
19203 * @memberof Document
19204 */
19205Document.prototype.getDocumentTitle = function (options) {
19206  const doctitle = this.$doctitle(toHash(options))
19207  return doctitle === Opal.nil ? undefined : doctitle
19208}
19209
19210/**
19211 * @see {@link Document#getDocumentTitle}
19212 * @memberof Document
19213 */
19214Document.prototype.getDoctitle = Document.prototype.getDocumentTitle
19215
19216/**
19217 * Get the document catalog JSON object.
19218 * @returns {Object}
19219 * @memberof Document
19220 */
19221Document.prototype.getCatalog = function () {
19222  return fromHash(this.catalog)
19223}
19224
19225/**
19226 *
19227 * @returns {Object}
19228 * @see Document#getCatalog
19229 * @memberof Document
19230 */
19231Document.prototype.getReferences = Document.prototype.getCatalog
19232
19233/**
19234 * Get the document revision date from document header (document attribute <code>revdate</code>).
19235 * @returns {string}
19236 * @memberof Document
19237 */
19238Document.prototype.getRevisionDate = function () {
19239  return this.getAttribute('revdate')
19240}
19241
19242/**
19243 * @see Document#getRevisionDate
19244 * @returns {string}
19245 * @memberof Document
19246 */
19247Document.prototype.getRevdate = function () {
19248  return this.getRevisionDate()
19249}
19250
19251/**
19252 * Get the document revision number from document header (document attribute <code>revnumber</code>).
19253 * @returns {string}
19254 * @memberof Document
19255 */
19256Document.prototype.getRevisionNumber = function () {
19257  return this.getAttribute('revnumber')
19258}
19259
19260/**
19261 * Get the document revision remark from document header (document attribute <code>revremark</code>).
19262 * @returns {string}
19263 * @memberof Document
19264 */
19265Document.prototype.getRevisionRemark = function () {
19266  return this.getAttribute('revremark')
19267}
19268
19269/**
19270 *  Assign a value to the specified attribute in the document header.
19271 *
19272 *  The assignment will be visible when the header attributes are restored,
19273 *  typically between processor phases (e.g., between parse and convert).
19274 *
19275 * @param {string} name - The {string} attribute name to assign
19276 * @param {Object} value - The {Object} value to assign to the attribute (default: '')
19277 * @param {boolean} overwrite - A {boolean} indicating whether to assign the attribute
19278 * if already present in the attributes Hash (default: true)
19279 *
19280 * @returns {boolean} - true if the assignment was performed otherwise false
19281 * @memberof Document
19282 */
19283Document.prototype.setHeaderAttribute = function (name, value, overwrite) {
19284  if (typeof overwrite === 'undefined') overwrite = true
19285  if (typeof value === 'undefined') value = ''
19286  return this.$set_header_attribute(name, value, overwrite)
19287}
19288
19289/**
19290 * Convenience method to retrieve the authors of this document as an {Array} of {Document/Author} objects.
19291 *
19292 * This method is backed by the author-related attributes on the document.
19293 *
19294 * @returns {Array<Author>} - an {Array} of {Document/Author} objects.
19295 * @memberof Document
19296 */
19297Document.prototype.getAuthors = function () {
19298  return this.$authors()
19299}
19300
19301// Document.Footnote API
19302
19303/**
19304 * @namespace
19305 * @module Document/Footnote
19306 */
19307const Footnote = Document.Footnote
19308
19309/**
19310 * @returns {number} - the footnote's index
19311 * @memberof Document/Footnote
19312 */
19313Footnote.prototype.getIndex = function () {
19314  const index = this.$$data.index
19315  return index === Opal.nil ? undefined : index
19316}
19317
19318/**
19319 * @returns {number} - the footnote's id
19320 * @memberof Document/Footnote
19321 */
19322Footnote.prototype.getId = function () {
19323  const id = this.$$data.id
19324  return id === Opal.nil ? undefined : id
19325}
19326
19327/**
19328 * @returns {string} - the footnote's text
19329 * @memberof Document/Footnote
19330 */
19331Footnote.prototype.getText = function () {
19332  const text = this.$$data.text
19333  return text === Opal.nil ? undefined : text
19334}
19335
19336// Document.ImageReference API
19337
19338/**
19339 * @class
19340 * @module Document/ImageReference
19341 */
19342const ImageReference = Document.ImageReference
19343
19344/**
19345 * @returns {string} - the image's target
19346 * @memberof Document/ImageReference
19347 */
19348ImageReference.prototype.getTarget = function () {
19349  return this.$$data.target
19350}
19351
19352/**
19353 * @returns {string} - the image's directory (imagesdir attribute)
19354 * @memberof Document/ImageReference
19355 */
19356ImageReference.prototype.getImagesDirectory = function () {
19357  const value = this.$$data.imagesdir
19358  return value === Opal.nil ? undefined : value
19359}
19360
19361// Document.Author API
19362
19363/**
19364 * The Author class represents information about an author extracted from document attributes.
19365 * @namespace
19366 * @module Document/Author
19367 */
19368const Author = Document.Author
19369
19370/**
19371 * @returns {string} - the author's full name
19372 * @memberof Document/Author
19373 */
19374Author.prototype.getName = function () {
19375  const name = this.$$data.name
19376  return name === Opal.nil ? undefined : name
19377}
19378
19379/**
19380 * @returns {string} - the author's first name
19381 * @memberof Document/Author
19382 */
19383Author.prototype.getFirstName = function () {
19384  const firstName = this.$$data.firstname
19385  return firstName === Opal.nil ? undefined : firstName
19386}
19387
19388/**
19389 * @returns {string} - the author's middle name (or undefined if the author has no middle name)
19390 * @memberof Document/Author
19391 */
19392Author.prototype.getMiddleName = function () {
19393  const middleName = this.$$data.middlename
19394  return middleName === Opal.nil ? undefined : middleName
19395}
19396
19397/**
19398 * @returns {string} - the author's last name
19399 * @memberof Document/Author
19400 */
19401Author.prototype.getLastName = function () {
19402  const lastName = this.$$data.lastname
19403  return lastName === Opal.nil ? undefined : lastName
19404}
19405
19406/**
19407 * @returns {string} - the author's initials (by default based on the author's name)
19408 * @memberof Document/Author
19409 */
19410Author.prototype.getInitials = function () {
19411  const initials = this.$$data.initials
19412  return initials === Opal.nil ? undefined : initials
19413}
19414
19415/**
19416 * @returns {string} - the author's email
19417 * @memberof Document/Author
19418 */
19419Author.prototype.getEmail = function () {
19420  const email = this.$$data.email
19421  return email === Opal.nil ? undefined : email
19422}
19423
19424// private constructor
19425Document.RevisionInfo = function (date, number, remark) {
19426  this.date = date
19427  this.number = number
19428  this.remark = remark
19429}
19430
19431/**
19432 * @class
19433 * @namespace
19434 * @module Document/RevisionInfo
19435 */
19436const RevisionInfo = Document.RevisionInfo
19437
19438/**
19439 * Get the document revision date from document header (document attribute <code>revdate</code>).
19440 * @returns {string}
19441 * @memberof Document/RevisionInfo
19442 */
19443RevisionInfo.prototype.getDate = function () {
19444  return this.date
19445}
19446
19447/**
19448 * Get the document revision number from document header (document attribute <code>revnumber</code>).
19449 * @returns {string}
19450 * @memberof Document/RevisionInfo
19451 */
19452RevisionInfo.prototype.getNumber = function () {
19453  return this.number
19454}
19455
19456/**
19457 * Get the document revision remark from document header (document attribute <code>revremark</code>).
19458 * A short summary of changes in this document revision.
19459 * @returns {string}
19460 * @memberof Document/RevisionInfo
19461 */
19462RevisionInfo.prototype.getRemark = function () {
19463  return this.remark
19464}
19465
19466/**
19467 * @returns {boolean} - true if the revision info is empty (ie. not defined), otherwise false
19468 * @memberof Document/RevisionInfo
19469 */
19470RevisionInfo.prototype.isEmpty = function () {
19471  return this.date === undefined && this.number === undefined && this.remark === undefined
19472}
19473
19474// SafeMode API
19475
19476/**
19477 * @namespace
19478 */
19479const SafeMode = Opal.Asciidoctor.SafeMode
19480
19481/**
19482 * @param {string} name - the name of the security level
19483 * @returns {number} - the integer value of the corresponding security level
19484 */
19485SafeMode.getValueForName = function (name) {
19486  return this.$value_for_name(name)
19487}
19488
19489/**
19490 * @param {number} value - the integer value of the security level
19491 * @returns {string} - the name of the corresponding security level
19492 */
19493SafeMode.getNameForValue = function (value) {
19494  const name = this.$name_for_value(value)
19495  return name === Opal.nil ? undefined : name
19496}
19497
19498/**
19499 * @returns {Array<string>} - the String {Array} of security levels
19500 */
19501SafeMode.getNames = function () {
19502  return this.$names()
19503}
19504
19505// Callouts API
19506
19507/**
19508 * Maintains a catalog of callouts and their associations.
19509 * @namespace
19510 */
19511const Callouts = Opal.Asciidoctor.Callouts
19512
19513/**
19514 * Create a new Callouts.
19515 * @returns {Callouts} - a new Callouts
19516 * @memberof Callouts
19517 */
19518Callouts.create = function () {
19519  return this.$new()
19520}
19521
19522/**
19523 * Register a new callout for the given list item ordinal.
19524 * Generates a unique id for this callout based on the index of the next callout list in the document and the index of this callout since the end of the last callout list.
19525 *
19526 * @param {number} ordinal - the Integer ordinal (1-based) of the list item to which this callout is to be associated
19527 * @returns {string} - The unique String id of this callout
19528 * @example
19529 *  callouts = asciidoctor.Callouts.create()
19530 *  callouts.register(1)
19531 *  // => "CO1-1"
19532 *  callouts.nextList()
19533 *  callouts.register(2)
19534 *  // => "CO2-1"
19535 * @memberof Callouts
19536 */
19537
19538Callouts.prototype.register = function (ordinal) {
19539  return this.$register(ordinal)
19540}
19541/**
19542 * Get the next callout index in the document.
19543 *
19544 * Reads the next callout index in the document and advances the pointer.
19545 * This method is used during conversion to retrieve the unique id of the callout that was generated during parsing.
19546 *
19547 * @returns {string} - The unique String id of the next callout in the document
19548 * @memberof Callouts
19549 */
19550Callouts.prototype.readNextId = function () {
19551  return this.$read_next_id()
19552}
19553
19554/**
19555 * et a space-separated list of callout ids for the specified list item.
19556 * @param {number} ordinal - the Integer ordinal (1-based) of the list item for which to retrieve the callouts
19557 * @returns {string} - a space-separated String of callout ids associated with the specified list item
19558 * @memberof Callouts
19559 */
19560Callouts.prototype.getCalloutIds = function (ordinal) {
19561  return this.$callout_ids(ordinal)
19562}
19563
19564/**
19565 * @memberof Callouts
19566 */
19567Callouts.prototype.getLists = function () {
19568  const lists = this.lists
19569  if (lists && lists.length > 0) {
19570    for (let i = 0; i < lists.length; i++) {
19571      const list = lists[i]
19572      if (list && list.length > 0) {
19573        for (let j = 0; j < list.length; j++) {
19574          if (typeof list[j] === 'object' && '$$smap' in list[j]) {
19575            list[j] = fromHash(list[j])
19576          }
19577        }
19578      }
19579    }
19580  }
19581  return lists
19582}
19583
19584/**
19585 * @memberof Callouts
19586 */
19587Callouts.prototype.getListIndex = function () {
19588  return this.list_index
19589}
19590
19591/**
19592 * The current list for which callouts are being collected.
19593 * @returns {Array} - The Array of callouts at the position of the list index pointer
19594 * @memberof Callouts
19595 */
19596Callouts.prototype.getCurrentList = function () {
19597  const currentList = this.$current_list()
19598  if (currentList && currentList.length > 0) {
19599    for (let i = 0; i < currentList.length; i++) {
19600      if (typeof currentList[i] === 'object' && '$$smap' in currentList[i]) {
19601        currentList[i] = fromHash(currentList[i])
19602      }
19603    }
19604  }
19605  return currentList
19606}
19607
19608/**
19609 * Advance to the next callout list in the document.
19610 * @memberof Callouts
19611 */
19612Callouts.prototype.nextList = function () {
19613  return this.$nextList()
19614}
19615
19616/**
19617 * Rewind the list index pointer, intended to be used when switching from the parsing to conversion phase.
19618 * @memberof Callouts
19619 */
19620Callouts.prototype.rewind = function () {
19621  return this.$rewind()
19622}
19623
19624/**
19625 * @returns {Document/RevisionInfo} - a {@link Document/RevisionInfo}
19626 * @memberof Document
19627 */
19628Document.prototype.getRevisionInfo = function () {
19629  return new Document.RevisionInfo(this.getRevisionDate(), this.getRevisionNumber(), this.getRevisionRemark())
19630}
19631
19632/**
19633 * @returns {boolean} - true if the document contains revision info, otherwise false
19634 * @memberof Document
19635 */
19636Document.prototype.hasRevisionInfo = function () {
19637  const revisionInfo = this.getRevisionInfo()
19638  return !revisionInfo.isEmpty()
19639}
19640
19641/**
19642 * @returns {boolean}
19643 * @memberof Document
19644 */
19645Document.prototype.getNotitle = function () {
19646  return this.$notitle()
19647}
19648
19649/**
19650 * @returns {boolean}
19651 * @memberof Document
19652 */
19653Document.prototype.getNoheader = function () {
19654  return this.$noheader()
19655}
19656
19657/**
19658 * @returns {boolean}
19659 * @memberof Document
19660 */
19661Document.prototype.getNofooter = function () {
19662  return this.$nofooter()
19663}
19664
19665/**
19666 * @returns {boolean}
19667 * @memberof Document
19668 */
19669Document.prototype.hasHeader = function () {
19670  return this['$header?']()
19671}
19672
19673/**
19674 * Replay attribute assignments at the block level.
19675 *
19676 * <i>This method belongs to an internal API that deals with how attributes are managed by the processor.</i>
19677 * If you understand why this group of methods are necessary, and what they do, feel free to use them.
19678 * <strong>However, keep in mind they are subject to change at any time.</strong>
19679 *
19680 * @param {Object} blockAttributes - A JSON of attributes
19681 * @memberof Document
19682 */
19683Document.prototype.playbackAttributes = function (blockAttributes) {
19684  blockAttributes = toHash(blockAttributes)
19685  if (blockAttributes) {
19686    const attrEntries = blockAttributes['$[]']('attribute_entries')
19687    if (attrEntries && Array.isArray(attrEntries)) {
19688      const result = []
19689      for (let i = 0; i < attrEntries.length; i++) {
19690        const attrEntryObject = attrEntries[i]
19691        if (attrEntryObject && typeof attrEntryObject === 'object' && attrEntryObject.constructor.name === 'Object') {
19692          attrEntryObject.$name = function () {
19693            return this.name
19694          }
19695          attrEntryObject.$value = function () {
19696            return this.value
19697          }
19698          attrEntryObject.$negate = function () {
19699            return this.negate
19700          }
19701        }
19702        result.push(attrEntryObject)
19703      }
19704      blockAttributes['$[]=']('attribute_entries', result)
19705    }
19706  }
19707  this.$playback_attributes(blockAttributes)
19708}
19709
19710/**
19711 * Delete the specified attribute from the document if the name is not locked.
19712 * If the attribute is locked, false is returned.
19713 * Otherwise, the attribute is deleted.
19714 *
19715 * @param {string} name - the String attribute name
19716 *
19717 * @returns {boolean} - true if the attribute was deleted, false if it was not because it's locked
19718 * @memberof Document
19719 */
19720Document.prototype.deleteAttribute = function (name) {
19721  return this.$delete_attribute(name)
19722}
19723
19724/**
19725 * Determine if the attribute has been locked by being assigned in document options.
19726 *
19727 * @param {string} key - The attribute key to check
19728 *
19729 * @returns {boolean} - true if the attribute is locked, false otherwise
19730 * @memberof Document
19731 */
19732Document.prototype.isAttributeLocked = function (key) {
19733  return this['$attribute_locked?'](key)
19734}
19735
19736/**
19737 * Restore the attributes to the previously saved state (attributes in header).
19738 *
19739 * @memberof Document
19740 */
19741Document.prototype.restoreAttributes = function () {
19742  return this.$restore_attributes()
19743}
19744
19745/**
19746 * Parse the AsciiDoc source stored in the {Reader} into an abstract syntax tree.
19747 *
19748 * If the data parameter is not nil, create a new {PreprocessorReader} and assigned it to the reader property of this object.
19749 * Otherwise, continue with the reader that was created when the {Document} was instantiated.
19750 * Pass the reader to {Parser.parse} to parse the source data into an abstract syntax tree.
19751 *
19752 * If parsing has already been performed, this method returns without performing any processing.
19753 *
19754 * @param {string|Array<string>} [data] - The optional replacement AsciiDoc source data as a String or String Array. (default: undefined)
19755 *
19756 * @returns {Document} - this {Document}
19757 * @memberof Document
19758 */
19759Document.prototype.parse = function (data) {
19760  return this.$parse(data)
19761}
19762
19763/**
19764 * Read the docinfo file(s) for inclusion in the document template
19765 *
19766 * If the docinfo1 attribute is set, read the docinfo.ext file.
19767 * If the docinfo attribute is set, read the doc-name.docinfo.ext file.
19768 * If the docinfo2 attribute is set, read both files in that order.
19769 *
19770 * @param {string} docinfoLocation - The Symbol location of the docinfo (e.g., head, footer, etc). (default: head)
19771 * @param {string|undefined} suffix - The suffix of the docinfo file(s).
19772 * If not set, the extension will be set to the outfilesuffix. (default: undefined)
19773 *
19774 * @returns {string} - the contents of the docinfo file(s) or empty string if no files are found or the safe mode is secure or greater.
19775 * @memberof Document
19776 */
19777Document.prototype.getDocinfo = function (docinfoLocation, suffix) {
19778  return this.$docinfo(docinfoLocation, suffix)
19779}
19780
19781/**
19782 * @param {string} [docinfoLocation] - A {string} for checking docinfo extensions at a given location (head or footer) (default: head)
19783 * @returns {boolean}
19784 * @memberof Document
19785 */
19786Document.prototype.hasDocinfoProcessors = function (docinfoLocation) {
19787  return this['$docinfo_processors?'](docinfoLocation)
19788}
19789
19790/**
19791 * Increment the specified counter and store it in the block's attributes.
19792 *
19793 * @param {string} counterName - the String name of the counter attribute
19794 * @param {Block} block - the {Block} on which to save the counter
19795 *
19796 * @returns {number} - the next number in the sequence for the specified counter
19797 * @memberof Document
19798 */
19799Document.prototype.incrementAndStoreCounter = function (counterName, block) {
19800  return this.$increment_and_store_counter(counterName, block)
19801}
19802
19803/**
19804 * @deprecated Please use {Document#incrementAndStoreCounter} method.
19805 * @memberof Document
19806 */
19807Document.prototype.counterIncrement = Document.prototype.incrementAndStoreCounter
19808
19809/**
19810 * Get the named counter and take the next number in the sequence.
19811 *
19812 * @param {string} name - the String name of the counter
19813 * @param {string|number} seed - the initial value as a String or Integer
19814 *
19815 * @returns {number} the next number in the sequence for the specified counter
19816 * @memberof Document
19817 */
19818Document.prototype.counter = function (name, seed) {
19819  return this.$counter(name, seed)
19820}
19821
19822/**
19823 * A read-only integer value indicating the level of security that should be enforced while processing this document.
19824 * The value must be set in the Document constructor using the "safe" option.
19825 *
19826 * A value of 0 (UNSAFE) disables any of the security features enforced by Asciidoctor.
19827 *
19828 * A value of 1 (SAFE) closely parallels safe mode in AsciiDoc.
19829 * In particular, it prevents access to files which reside outside of the parent directory of the source file and disables any macro other than the include directive.
19830 *
19831 * A value of 10 (SERVER) disallows the document from setting attributes that would affect the conversion of the document,
19832 * in addition to all the security features of SafeMode.SAFE.
19833 * For instance, this level forbids changing the backend or source-highlighter using an attribute defined in the source document header.
19834 * This is the most fundamental level of security for server deployments (hence the name).
19835 *
19836 * A value of 20 (SECURE) disallows the document from attempting to read files from the file system and including the contents of them into the document,
19837 * in addition to all the security features of SafeMode.SECURE.
19838 * In particular, it disallows use of the include::[] directive and the embedding of binary content (data uri), stylesheets and JavaScripts referenced by the document.
19839 * (Asciidoctor and trusted extensions may still be allowed to embed trusted content into the document).
19840 *
19841 * Since Asciidoctor is aiming for wide adoption, 20 (SECURE) is the default value and is recommended for server deployments.
19842 *
19843 * A value of 100 (PARANOID) is planned to disallow the use of passthrough macros and prevents the document from setting any known attributes,
19844 * in addition to all the security features of SafeMode.SECURE.
19845 * Please note that this level is not currently implemented (and therefore not enforced)!
19846 *
19847 * @returns {number} - An integer value indicating the level of security
19848 * @memberof Document
19849 */
19850Document.prototype.getSafe = function () {
19851  return this.safe
19852}
19853
19854/**
19855 * Get the Boolean AsciiDoc compatibility mode.
19856 * Enabling this attribute activates the following syntax changes:
19857 *
19858 *   * single quotes as constrained emphasis formatting marks
19859 *   * single backticks parsed as inline literal, formatted as monospace
19860 *   * single plus parsed as constrained, monospaced inline formatting
19861 *   * double plus parsed as constrained, monospaced inline formatting
19862 *
19863 * @returns {boolean}
19864 * @memberof Document
19865 */
19866Document.prototype.getCompatMode = function () {
19867  return this.compat_mode
19868}
19869
19870/**
19871 * Get the Boolean flag that indicates whether source map information should be tracked by the parser.
19872 * @returns {boolean}
19873 * @memberof Document
19874 */
19875Document.prototype.getSourcemap = function () {
19876  const sourcemap = this.sourcemap
19877  return sourcemap === Opal.nil ? false : sourcemap
19878}
19879
19880/**
19881 * Set the Boolean flag that indicates whether source map information should be tracked by the parser.
19882 * @param {boolean} value
19883 * @memberof Document
19884 */
19885Document.prototype.setSourcemap = function (value) {
19886  this.sourcemap = value
19887}
19888
19889/**
19890 * Get the JSON of document counters.
19891 * @returns {Object}
19892 * @memberof Document
19893 */
19894Document.prototype.getCounters = function () {
19895  return fromHash(this.counters)
19896}
19897
19898/**
19899 * @returns {Object}
19900 * @memberof Document
19901 */
19902Document.prototype.getCallouts = function () {
19903  return this.$callouts()
19904}
19905
19906/**
19907 * Get the String base directory for converting this document.
19908 *
19909 * Defaults to directory of the source file.
19910 * If the source is a string, defaults to the current directory.
19911 * @returns {string}
19912 * @memberof Document
19913 */
19914Document.prototype.getBaseDir = function () {
19915  return this.base_dir
19916}
19917
19918/**
19919 * Get the JSON of resolved options used to initialize this {Document}.
19920 * @returns {Object}
19921 * @memberof Document
19922 */
19923Document.prototype.getOptions = function () {
19924  return fromHash(this.options)
19925}
19926
19927/**
19928 * Get the outfilesuffix defined at the end of the header.
19929 * @returns {string}
19930 * @memberof Document
19931 */
19932Document.prototype.getOutfilesuffix = function () {
19933  return this.outfilesuffix
19934}
19935
19936/**
19937 * Get a reference to the parent Document of this nested document.
19938 * @returns {Document|undefined}
19939 * @memberof Document
19940 */
19941Document.prototype.getParentDocument = function () {
19942  const parentDocument = this.parent_document
19943  return parentDocument === Opal.nil ? undefined : parentDocument
19944}
19945
19946/**
19947 * Get the {Reader} associated with this document.
19948 * @returns {Object}
19949 * @memberof Document
19950 */
19951Document.prototype.getReader = function () {
19952  return this.reader
19953}
19954
19955/**
19956 * Get the {Converter} instance being used to convert the current {Document}.
19957 * @returns {Object}
19958 * @memberof Document
19959 */
19960Document.prototype.getConverter = function () {
19961  return this.converter
19962}
19963
19964/**
19965 * Get the activated {Extensions.Registry} associated with this document.
19966 * @returns {Extensions/Registry}
19967 * @memberof Document
19968 */
19969Document.prototype.getExtensions = function () {
19970  const extensions = this.extensions
19971  return extensions === Opal.nil ? undefined : extensions
19972}
19973
19974// Document.Title API
19975
19976/**
19977 * A partitioned title (i.e., title & subtitle).
19978 * @namespace
19979 * @module Document/Title
19980 */
19981const Title = Document.Title
19982
19983/**
19984 * @returns {string}
19985 * @memberof Document/Title
19986 */
19987Title.prototype.getMain = function () {
19988  return this.main
19989}
19990
19991/**
19992 * @returns {string}
19993 * @memberof Document/Title
19994 */
19995Title.prototype.getCombined = function () {
19996  return this.combined
19997}
19998
19999/**
20000 * @returns {string}
20001 * @memberof Document/Title
20002 */
20003Title.prototype.getSubtitle = function () {
20004  const subtitle = this.subtitle
20005  return subtitle === Opal.nil ? undefined : subtitle
20006}
20007
20008/**
20009 * @returns {boolean}
20010 * @memberof Document/Title
20011 */
20012Title.prototype.isSanitized = function () {
20013  const sanitized = this['$sanitized?']()
20014  return sanitized === Opal.nil ? false : sanitized
20015}
20016
20017/**
20018 * @returns {boolean}
20019 * @memberof Document/Title
20020 */
20021Title.prototype.hasSubtitle = function () {
20022  return this['$subtitle?']()
20023}
20024
20025// Inline API
20026
20027/**
20028 * Methods for managing inline elements in AsciiDoc block.
20029 * @namespace
20030 * @extends AbstractNode
20031 */
20032const Inline = Opal.Asciidoctor.Inline
20033
20034/**
20035 * Create a new Inline element.
20036 * @param {AbstractBlock} parent
20037 * @param {string} context
20038 * @param {string|undefined} text
20039 * @param {Object|undefined} opts
20040 * @returns {Inline} - a new Inline element
20041 * @memberof Inline
20042 */
20043Inline.create = function (parent, context, text, opts) {
20044  return this.$new(parent, context, text, prepareOptions(opts))
20045}
20046
20047/**
20048 * Get the converted content for this inline node.
20049 *
20050 * @returns {string} - the converted String content for this inline node
20051 * @memberof Inline
20052 */
20053Inline.prototype.convert = function () {
20054  return this.$convert()
20055}
20056
20057/**
20058 * Get the converted String text of this Inline node, if applicable.
20059 *
20060 * @returns {string|undefined} - the converted String text for this Inline node, or undefined if not applicable for this node.
20061 * @memberof Inline
20062 */
20063Inline.prototype.getText = function () {
20064  const text = this.$text()
20065  return text === Opal.nil ? undefined : text
20066}
20067
20068/**
20069 * Get the String sub-type (aka qualifier) of this Inline node.
20070 *
20071 * This value is used to distinguish different variations of the same node
20072 * category, such as different types of anchors.
20073 *
20074 * @returns {string} - the string sub-type of this Inline node.
20075 * @memberof Inline
20076 */
20077Inline.prototype.getType = function () {
20078  return this.$type()
20079}
20080
20081/**
20082 * Get the primary String target of this Inline node.
20083 *
20084 * @returns {string|undefined} - the string target of this Inline node.
20085 * @memberof Inline
20086 */
20087Inline.prototype.getTarget = function () {
20088  const target = this.$target()
20089  return target === Opal.nil ? undefined : target
20090}
20091
20092/**
20093 * Returns the converted alt text for this inline image.
20094 *
20095 * @returns {string} - the String value of the alt attribute.
20096 * @memberof Inline
20097 */
20098Inline.prototype.getAlt = function () {
20099  return this.$alt()
20100}
20101
20102// List API
20103
20104/**
20105 * Methods for managing AsciiDoc lists (ordered, unordered and description lists).
20106 * @namespace
20107 * @extends AbstractBlock
20108 */
20109const List = Opal.Asciidoctor.List
20110
20111/**
20112 * Checks if the {@link List} contains any child {@link ListItem}.
20113 *
20114 * @memberof List
20115 * @returns {boolean} - whether the {@link List} has child {@link ListItem}.
20116 */
20117List.prototype.hasItems = function () {
20118  return this['$items?']()
20119}
20120
20121/**
20122 * Get the Array of {@link ListItem} nodes for this {@link List}.
20123 *
20124 * @returns {Array<ListItem>} - an Array of {@link ListItem} nodes.
20125 * @memberof List
20126 */
20127List.prototype.getItems = function () {
20128  return this.blocks
20129}
20130
20131// ListItem API
20132
20133/**
20134 * Methods for managing items for AsciiDoc olists, ulist, and dlists.
20135 *
20136 * In a description list (dlist), each item is a tuple that consists of a 2-item Array of ListItem terms and a ListItem description (i.e., [[term, term, ...], desc].
20137 * If a description is not set, then the second entry in the tuple is nil.
20138 * @namespace
20139 * @extends AbstractBlock
20140 */
20141const ListItem = Opal.Asciidoctor.ListItem
20142
20143/**
20144 * Get the converted String text of this {@link ListItem} node.
20145 *
20146 * @returns {string} - the converted String text for this {@link ListItem} node.
20147 * @memberof ListItem
20148 */
20149ListItem.prototype.getText = function () {
20150  return this.$text()
20151}
20152
20153/**
20154 * Set the String source text of this {@link ListItem} node.
20155 *
20156 * @returns {string} - the new String text assigned to this {@link ListItem}
20157 * @memberof ListItem
20158 */
20159ListItem.prototype.setText = function (text) {
20160  return this['$text='](text)
20161}
20162
20163/**
20164 * A convenience method that checks whether the text of this {@link ListItem} is not blank (i.e. not undefined or empty string).
20165 *
20166 * @returns {boolean} - whether the text is not blank
20167 * @memberof ListItem
20168 */
20169ListItem.prototype.hasText = function () {
20170  return this['$text?']()
20171}
20172
20173/**
20174 * Get the {string} used to mark this {@link ListItem}.
20175 *
20176 * @returns {string}
20177 * @memberof ListItem
20178 */
20179ListItem.prototype.getMarker = function () {
20180  return this.marker
20181}
20182
20183/**
20184 * Set the {string} used to mark this {@link ListItem}.
20185 *
20186 * @param {string} marker - the {string} used to mark this {@link ListItem}
20187 * @memberof ListItem
20188 */
20189ListItem.prototype.setMarker = function (marker) {
20190  this.marker = marker
20191}
20192
20193/**
20194 * Get the {@link List} to which this {@link ListItem} is attached.
20195 *
20196 * @returns {List} - the {@link List} object to which this {@link ListItem} is attached,
20197 * or undefined if this node has no parent.
20198 * @memberof ListItem
20199 */
20200ListItem.prototype.getList = function () {
20201  return this.$list()
20202}
20203
20204/**
20205 * @see {@link ListItem#getList}
20206 * @memberof ListItem
20207 */
20208ListItem.prototype.getParent = ListItem.prototype.getList
20209
20210// Reader API
20211
20212/** @namespace */
20213const Reader = Opal.Asciidoctor.Reader
20214
20215/**
20216 * Push source onto the front of the reader and switch the context based on the file, document-relative path and line information given.
20217 *
20218 * This method is typically used in an IncludeProcessor to add source read from the target specified.
20219 *
20220 * @param {string} data
20221 * @param {string|undefined} file
20222 * @param {string|undefined} path
20223 * @param {number} lineno - The line number
20224 * @param {Object} attributes - a JSON of attributes
20225 * @returns {Reader} - this {Reader} object.
20226 * @memberof Reader
20227 */
20228Reader.prototype.pushInclude = function (data, file, path, lineno, attributes) {
20229  return this.$push_include(data, file, path, lineno, toHash(attributes))
20230}
20231
20232/**
20233 * Get the current location of the reader's cursor, which encapsulates the file, dir, path, and lineno of the file being read.
20234 *
20235 * @returns {Cursor}
20236 * @memberof Reader
20237 */
20238Reader.prototype.getCursor = function () {
20239  return this.$cursor()
20240}
20241
20242/**
20243 * Get the remaining unprocessed lines, without consuming them, as an {Array} of {string}.
20244 *
20245 * Lines will not be consumed from the Reader (ie. you will be able to read these lines again).
20246 *
20247 * @returns {Array<string>} - the remaining unprocessed lines as an {Array} of {string}.
20248 * @memberof Reader
20249 */
20250Reader.prototype.getLines = function () {
20251  return this.$lines()
20252}
20253
20254/**
20255 * Get the remaining unprocessed lines, without consuming them, as a {string}.
20256 *
20257 * Lines will not be consumed from the Reader (ie. you will be able to read these lines again).
20258 *
20259 * @returns {string} - the remaining unprocessed lines as a {string} (joined by linefeed characters).
20260 * @memberof Reader
20261 */
20262Reader.prototype.getString = function () {
20263  return this.$string()
20264}
20265
20266/**
20267 * Check whether there are any lines left to read.
20268 * If a previous call to this method resulted in a value of false, immediately returned the cached value.
20269 * Otherwise, delegate to peekLine to determine if there is a next line available.
20270 *
20271 * @returns {boolean} - true if there are more lines, false if there are not.
20272 * @memberof Reader
20273 */
20274Reader.prototype.hasMoreLines = function () {
20275  return this['$has_more_lines?']()
20276}
20277
20278/**
20279 * Check whether this reader is empty (contains no lines).
20280 *
20281 * @returns {boolean} - true if there are no more lines to peek, otherwise false.
20282 * @memberof Reader
20283 */
20284Reader.prototype.isEmpty = function () {
20285  return this['$empty?']()
20286}
20287
20288/**
20289 * Peek at the next line.
20290 * Processes the line if not already marked as processed, but does not consume it (ie. you will be able to read this line again).
20291 *
20292 * This method will probe the reader for more lines.
20293 * If there is a next line that has not previously been visited, the line is passed to the Reader#processLine method to be initialized.
20294 * This call gives sub-classes the opportunity to do preprocessing.
20295 * If the return value of the Reader#processLine is undefined, the data is assumed to be changed and Reader#peekLine is invoked again to perform further processing.
20296 *
20297 * If hasMoreLines is called immediately before peekLine, the direct flag is implicitly true (since the line is flagged as visited).
20298 *
20299 * @param {boolean} direct - A {boolean} flag to bypasses the check for more lines and immediately returns the first element of the internal lines {Array}. (default: false)
20300 * @returns {string} - the next line as a {string} if there are lines remaining.
20301 * @memberof Reader
20302 */
20303Reader.prototype.peekLine = function (direct) {
20304  direct = direct || false
20305  const line = this.$peek_line(direct)
20306  return line === Opal.nil ? undefined : line
20307}
20308
20309/**
20310 * Consume, preprocess, and return the next line.
20311 *
20312 * Line will be consumed from the Reader (ie. you won't be able to read this line again).
20313 *
20314 * @returns {string} - the next line as a {string} if data is present.
20315 * @memberof Reader
20316 */
20317Reader.prototype.readLine = function () {
20318  const line = this.$read_line()
20319  return line === Opal.nil ? undefined : line
20320}
20321
20322/**
20323 * Consume, preprocess, and return the remaining lines.
20324 *
20325 * This method calls Reader#readLine repeatedly until all lines are consumed and returns the lines as an {Array} of {string}.
20326 * This method differs from Reader#getLines in that it processes each line in turn, hence triggering any preprocessors implemented in sub-classes.
20327 *
20328 * Lines will be consumed from the Reader (ie. you won't be able to read these lines again).
20329 *
20330 * @returns {Array<string>} - the lines read as an {Array} of {string}.
20331 * @memberof Reader
20332 */
20333Reader.prototype.readLines = function () {
20334  return this.$read_lines()
20335}
20336
20337/**
20338 * Consume, preprocess, and return the remaining lines joined as a {string}.
20339 *
20340 * Delegates to Reader#readLines, then joins the result.
20341 *
20342 * Lines will be consumed from the Reader (ie. you won't be able to read these lines again).
20343 *
20344 * @returns {string} - the lines read joined as a {string}
20345 * @memberof Reader
20346 */
20347Reader.prototype.read = function () {
20348  return this.$read()
20349}
20350
20351/**
20352 * Advance to the next line by discarding the line at the front of the stack.
20353 *
20354 * @returns {boolean} - a Boolean indicating whether there was a line to discard.
20355 * @memberof Reader
20356 */
20357Reader.prototype.advance = function () {
20358  return this.$advance()
20359}
20360
20361// Cursor API
20362
20363/** @namespace */
20364const Cursor = Opal.Asciidoctor.Reader.Cursor
20365
20366/**
20367 * Get the file associated to the cursor.
20368 * @returns {string|undefined}
20369 * @memberof Cursor
20370 */
20371Cursor.prototype.getFile = function () {
20372  const file = this.file
20373  return file === Opal.nil ? undefined : file
20374}
20375
20376/**
20377 * Get the directory associated to the cursor.
20378 * @returns {string|undefined} - the directory associated to the cursor
20379 * @memberof Cursor
20380 */
20381Cursor.prototype.getDirectory = function () {
20382  const dir = this.dir
20383  return dir === Opal.nil ? undefined : dir
20384}
20385
20386/**
20387 * Get the path associated to the cursor.
20388 * @returns {string|undefined} - the path associated to the cursor (or '<stdin>')
20389 * @memberof Cursor
20390 */
20391Cursor.prototype.getPath = function () {
20392  const path = this.path
20393  return path === Opal.nil ? undefined : path
20394}
20395
20396/**
20397 * Get the line number of the cursor.
20398 * @returns {number|undefined} - the line number of the cursor
20399 * @memberof Cursor
20400 */
20401Cursor.prototype.getLineNumber = function () {
20402  return this.lineno
20403}
20404
20405// Logger API (available in Asciidoctor 1.5.7+)
20406
20407function initializeLoggerFormatterClass (className, functions) {
20408  const superclass = Opal.const_get_qualified(Opal.Logger, 'Formatter')
20409  return initializeClass(superclass, className, functions, {}, {
20410    call: function (args) {
20411      for (let i = 0; i < args.length; i++) {
20412        // convert all (Opal) Hash arguments to JSON.
20413        if (typeof args[i] === 'object' && '$$smap' in args[i]) {
20414          args[i] = fromHash(args[i])
20415        }
20416      }
20417      return args
20418    }
20419  })
20420}
20421
20422function initializeLoggerClass (className, functions) {
20423  const superClass = Opal.const_get_qualified(Opal.Asciidoctor, 'Logger')
20424  return initializeClass(superClass, className, functions, {}, {
20425    add: function (args) {
20426      if (args.length >= 2 && typeof args[2] === 'object' && '$$smap' in args[2]) {
20427        const message = args[2]
20428        const messageObject = fromHash(message)
20429        messageObject.getText = function () {
20430          return this.text
20431        }
20432        messageObject.getSourceLocation = function () {
20433          return this.source_location
20434        }
20435        messageObject.$inspect = function () {
20436          const sourceLocation = this.getSourceLocation()
20437          if (sourceLocation) {
20438            return sourceLocation.getPath() + ': line ' + sourceLocation.getLineNumber() + ': ' + this.getText()
20439          } else {
20440            return this.getText()
20441          }
20442        }
20443        args[2] = messageObject
20444      }
20445      if (args.length >= 1) {
20446        args[1] = args[1] === Opal.nil ? undefined : args[1]
20447      }
20448      return args
20449    }
20450  })
20451}
20452
20453/**
20454 * @namespace
20455 */
20456const LoggerManager = Opal.const_get_qualified(Opal.Asciidoctor, 'LoggerManager', true)
20457
20458// Alias
20459Opal.Asciidoctor.LoggerManager = LoggerManager
20460
20461/**
20462 * @memberof LoggerManager
20463 */
20464LoggerManager.getLogger = function () {
20465  return this.$logger()
20466}
20467
20468/**
20469 * @memberof LoggerManager
20470 */
20471LoggerManager.setLogger = function (logger) {
20472  this['$logger='](logger)
20473}
20474
20475/**
20476 * @memberof LoggerManager
20477 */
20478LoggerManager.newLogger = function (name, functions) {
20479  return initializeLoggerClass(name, functions).$new()
20480}
20481
20482/**
20483 * @memberof LoggerManager
20484 */
20485LoggerManager.newFormatter = function (name, functions) {
20486  return initializeLoggerFormatterClass(name, functions).$new()
20487}
20488
20489/**
20490 * @namespace
20491 */
20492const LoggerSeverity = Opal.const_get_qualified(Opal.Logger, 'Severity', true)
20493
20494// Alias
20495Opal.Asciidoctor.LoggerSeverity = LoggerSeverity
20496
20497/**
20498 * @memberof LoggerSeverity
20499 */
20500LoggerSeverity.get = function (severity) {
20501  return LoggerSeverity.$constants()[severity]
20502}
20503
20504/**
20505 * @namespace
20506 */
20507const LoggerFormatter = Opal.const_get_qualified(Opal.Logger, 'Formatter', true)
20508
20509// Alias
20510Opal.Asciidoctor.LoggerFormatter = LoggerFormatter
20511
20512/**
20513 * @memberof LoggerFormatter
20514 */
20515LoggerFormatter.prototype.call = function (severity, time, programName, message) {
20516  return this.$call(LoggerSeverity.get(severity), time, programName, message)
20517}
20518
20519/**
20520 * @namespace
20521 */
20522const MemoryLogger = Opal.const_get_qualified(Opal.Asciidoctor, 'MemoryLogger', true)
20523
20524// Alias
20525Opal.Asciidoctor.MemoryLogger = MemoryLogger
20526
20527/**
20528 * Create a new MemoryLogger.
20529 * @returns {MemoryLogger} - a MemoryLogger
20530 * @memberof MemoryLogger
20531 */
20532MemoryLogger.create = function () {
20533  return this.$new()
20534}
20535
20536/**
20537 * @returns {Array<Object>} - a list of messages
20538 * @memberof MemoryLogger
20539 */
20540MemoryLogger.prototype.getMessages = function () {
20541  const messages = this.messages
20542  const result = []
20543  for (let i = 0; i < messages.length; i++) {
20544    const message = messages[i]
20545    const messageObject = fromHash(message)
20546    if (typeof messageObject.message === 'string') {
20547      messageObject.getText = function () {
20548        return this.message
20549      }
20550    } else {
20551      // also convert the message attribute
20552      messageObject.message = fromHash(messageObject.message)
20553      messageObject.getText = function () {
20554        return this.message.text
20555      }
20556    }
20557    messageObject.getSeverity = function () {
20558      return this.severity.toString()
20559    }
20560    messageObject.getSourceLocation = function () {
20561      return this.message.source_location
20562    }
20563    result.push(messageObject)
20564  }
20565  return result
20566}
20567
20568const Logging = Opal.const_get_qualified(Opal.Asciidoctor, 'Logging', true)
20569
20570Opal.Asciidoctor.Logging = Logging
20571
20572Logging.getLogger = function () {
20573  return LoggerManager.$logger()
20574}
20575
20576Logging.createLogMessage = function (text, context) {
20577  return Logging.prototype.$message_with_context(text, toHash(context))
20578}
20579
20580// alias
20581
20582/**
20583 * @memberof Reader
20584 */
20585Reader.prototype.getLogger = Logging.getLogger
20586/**
20587 * @memberof Reader
20588 */
20589Reader.prototype.createLogMessage = Logging.createLogMessage
20590
20591/**
20592 * @memberof AbstractNode
20593 */
20594AbstractNode.prototype.getLogger = Logging.getLogger
20595/**
20596 * @memberof AbstractNode
20597 */
20598AbstractNode.prototype.createLogMessage = Logging.createLogMessage
20599
20600/**
20601 * @namespace
20602 */
20603const Logger = Opal.const_get_qualified(Opal.Asciidoctor, 'Logger', true)
20604
20605// Alias
20606Opal.Asciidoctor.Logger = Logger
20607
20608/**
20609 * @returns {number|undefined} - the maximum severity
20610 * @memberof Logger
20611 */
20612Logger.prototype.getMaxSeverity = function () {
20613  const result = this.max_severity
20614  return result === Opal.nil ? undefined : result
20615}
20616/**
20617 * @returns {LoggerFormatter} - the formatter
20618 * @memberof Logger
20619 */
20620Logger.prototype.getFormatter = function () {
20621  return this.formatter
20622}
20623/**
20624 * @param {LoggerFormatter} formatter - the formatter
20625 * @memberof Logger
20626 */
20627Logger.prototype.setFormatter = function (formatter) {
20628  this.formatter = formatter
20629}
20630/**
20631 * @returns {number} - the logging severity threshold
20632 * @memberof Logger
20633 */
20634Logger.prototype.getLevel = function () {
20635  return this.level
20636}
20637/**
20638 * @param {number} level - the logging severity threshold
20639 * @memberof Logger
20640 */
20641Logger.prototype.setLevel = function (level) {
20642  this.level = level
20643}
20644/**
20645 * @returns {string} - the program name
20646 * @memberof Logger
20647 */
20648Logger.prototype.getProgramName = function () {
20649  return this.progname
20650}
20651/**
20652 * @param {string} programName - the program name
20653 * @memberof Logger
20654 */
20655Logger.prototype.setProgramName = function (programName) {
20656  this.progname = programName
20657}
20658
20659const RubyLogger = Opal.const_get_qualified('::', 'Logger')
20660
20661const log = function (logger, level, message) {
20662  logger['$' + level](message)
20663}
20664RubyLogger.prototype.add = function (severity, message, programName) {
20665  const severityValue = typeof severity === 'string' ? LoggerSeverity[severity.toUpperCase()] : severity
20666  this.$add(severityValue, message, programName)
20667}
20668RubyLogger.prototype.log = RubyLogger.prototype.add
20669RubyLogger.prototype.debug = function (message) {
20670  log(this, 'debug', message)
20671}
20672RubyLogger.prototype.info = function (message) {
20673  log(this, 'info', message)
20674}
20675RubyLogger.prototype.warn = function (message) {
20676  log(this, 'warn', message)
20677}
20678RubyLogger.prototype.error = function (message) {
20679  log(this, 'error', message)
20680}
20681RubyLogger.prototype.fatal = function (message) {
20682  log(this, 'fatal', message)
20683}
20684RubyLogger.prototype.isDebugEnabled = function () {
20685  return this['$debug?']()
20686}
20687RubyLogger.prototype.isInfoEnabled = function () {
20688  return this['$info?']()
20689}
20690RubyLogger.prototype.isWarnEnabled = function () {
20691  return this['$warn?']()
20692}
20693RubyLogger.prototype.isErrorEnabled = function () {
20694  return this['$error?']()
20695}
20696RubyLogger.prototype.isFatalEnabled = function () {
20697  return this['$fatal?']()
20698}
20699
20700/**
20701 * @namespace
20702 */
20703const NullLogger = Opal.const_get_qualified(Opal.Asciidoctor, 'NullLogger', true)
20704
20705// Alias
20706Opal.Asciidoctor.NullLogger = NullLogger
20707
20708/**
20709 * Create a new NullLogger.
20710 * @returns {NullLogger} - a NullLogger
20711 * @memberof NullLogger
20712 */
20713NullLogger.create = function () {
20714  return this.$new()
20715}
20716
20717/**
20718 * @returns {number|undefined} - the maximum severity
20719 * @memberof NullLogger
20720 */
20721NullLogger.prototype.getMaxSeverity = function () {
20722  return this.max_severity
20723}
20724
20725// Alias
20726Opal.Asciidoctor.StopIteration = Opal.StopIteration
20727
20728/**
20729 * @namespace
20730 */
20731const Timings = Opal.const_get_qualified(Opal.Asciidoctor, 'Timings', true)
20732
20733// Alias
20734Opal.Asciidoctor.Timings = Timings
20735
20736/**
20737 * Create a new Timings.
20738 * @returns {Timings} - a Timings
20739 * @memberof Timings
20740 */
20741Timings.create = function () {
20742  return this.$new()
20743}
20744
20745/**
20746 * Print a report to the specified output.
20747 * The report will include:
20748 * - the time to read and parse source
20749 * - the time to convert document
20750 * - the total time (read, parse and convert)
20751 * @param {RubyLogger|console|Object} [to] - an optional output (by default stdout)
20752 * @param {string} [subject] - an optional subject (usually the file name)
20753 * @memberof Timings
20754 */
20755Timings.prototype.printReport = function (to, subject) {
20756  let outputFunction
20757  if (to) {
20758    if (typeof to.$add === 'function') {
20759      outputFunction = function (message) {
20760        to.$add(1, message)
20761      }
20762    } else if (typeof to.log === 'function') {
20763      outputFunction = to.log
20764    } else if (typeof to.write === 'function') {
20765      outputFunction = function (message) {
20766        to.write(message, 'utf-8')
20767      }
20768    } else {
20769      throw new Error('The output should be a Stream (with a write function), an object with a log function or a Ruby Logger (with a add function)')
20770    }
20771  } else {
20772    outputFunction = function (message) {
20773      Opal.gvars.stdout.$write(message)
20774    }
20775  }
20776  if (subject) {
20777    outputFunction('Input file: ' + subject)
20778  }
20779  outputFunction(' Time to read and parse source: ' + this.$read_parse().toFixed(2))
20780  outputFunction(' Time to convert document: ' + this.$convert().toFixed(2))
20781  outputFunction(' Total time (read, parse and convert): ' + this.$read_parse_convert().toFixed(2))
20782}
20783
20784/**
20785 * @namespace
20786 * @description
20787 * This API is experimental and subject to change.
20788 *
20789 * A pluggable adapter for integrating a syntax (aka code) highlighter into AsciiDoc processing.
20790 *
20791 * There are two types of syntax highlighter adapters. The first performs syntax highlighting during the convert phase.
20792 * This adapter type must define a "handlesHighlighting" method that returns true.
20793 * The companion "highlight" method will then be called to handle the "specialcharacters" substitution for source blocks.
20794 *
20795 * The second assumes syntax highlighting is performed on the client (e.g., when the HTML document is loaded).
20796 * This adapter type must define a "hasDocinfo" method that returns true.
20797 * The companion "docinfo" method will then be called to insert markup into the output document.
20798 * The docinfo functionality is available to both adapter types.
20799 *
20800 * Asciidoctor.js provides several a built-in adapter for highlight.js.
20801 * Additional adapters can be registered using SyntaxHighlighter.register.
20802 */
20803const SyntaxHighlighter = Opal.const_get_qualified(Opal.Asciidoctor, 'SyntaxHighlighter', true)
20804
20805// Alias
20806Opal.Asciidoctor.SyntaxHighlighter = SyntaxHighlighter
20807
20808/**
20809 * Associates the syntax highlighter class or object with the specified names.
20810 *
20811 * @description This API is experimental and subject to change.
20812 *
20813 * @param {string|Array} names - A {string} name or an {Array} of {string} names
20814 * @param functions - A list of functions representing a {SyntaxHighlighter} or a {SyntaxHighlighter} class to instantiate
20815 * @memberof SyntaxHighlighter
20816 */
20817SyntaxHighlighter.register = function (names, functions) {
20818  const name = typeof names === 'string' ? names : names[0]
20819  if (typeof functions === 'function') {
20820    const classObject = functions
20821    const prototype = classObject.prototype
20822    const properties = Object.getOwnPropertyNames(prototype)
20823    functions = {}
20824    for (const propertyIdx in properties) {
20825      const propertyName = properties[propertyIdx]
20826      functions[propertyName] = prototype[propertyName]
20827    }
20828  }
20829  const scope = initializeClass(SyntaxHighlighterBase, name, functions, {}, {
20830    format: function (args) {
20831      if (args.length >= 2 && typeof args[2] === 'object' && '$$smap' in args[2]) {
20832        args[2] = fromHash(args[2])
20833      }
20834      if (args.length >= 1) {
20835        args[1] = args[1] === Opal.nil ? undefined : args[1]
20836      }
20837      return args
20838    },
20839    highlight: function (args) {
20840      if (args.length >= 3 && typeof args[3] === 'object' && '$$smap' in args[3]) {
20841        let opts = args[3]
20842        opts = fromHash(opts)
20843        for (const key in opts) {
20844          const value = opts[key]
20845          if (key === 'callouts') {
20846            const callouts = fromHashKeys(value)
20847            for (const idx in callouts) {
20848              const callout = callouts[idx]
20849              for (let i = 0; i < callout.length; i++) {
20850                const items = callout[i]
20851                for (let j = 0; j < items.length; j++) {
20852                  items[j] = items[j] === Opal.nil ? undefined : items[j]
20853                }
20854              }
20855            }
20856            opts[key] = callouts
20857          } else {
20858            opts[key] = value === Opal.nil ? undefined : value
20859          }
20860        }
20861        args[3] = opts
20862      }
20863      if (args.length >= 2) {
20864        args[2] = args[2] === Opal.nil ? undefined : args[2]
20865      }
20866      return args
20867    }
20868  })
20869  for (const functionName in functions) {
20870    if (Object.prototype.hasOwnProperty.call(functions, functionName)) {
20871      (function (functionName) {
20872        const userFunction = functions[functionName]
20873        if (functionName === 'handlesHighlighting') {
20874          Opal.def(scope, '$highlight?', function () {
20875            return userFunction.call()
20876          })
20877        } else if (functionName === 'hasDocinfo') {
20878          Opal.def(scope, '$docinfo?', function (location) {
20879            return userFunction.apply(this, [location])
20880          })
20881        }
20882      }(functionName))
20883    }
20884  }
20885  Opal.def(scope, '$name', function () {
20886    return name
20887  })
20888  SyntaxHighlighter.$register(scope, names)
20889  return scope
20890}
20891
20892/**
20893 * Retrieves the syntax highlighter class or object registered for the specified name.
20894 *
20895 * @description This API is experimental and subject to change.
20896 *
20897 * @param {string} name - The {string} name of the syntax highlighter to retrieve.
20898 * @returns {SyntaxHighlighter} - the {SyntaxHighlighter} registered for this name.
20899 * @memberof SyntaxHighlighter
20900 */
20901SyntaxHighlighter.get = function (name) {
20902  const result = SyntaxHighlighter.$for(name)
20903  return result === Opal.nil ? undefined : result
20904}
20905
20906/**
20907 * @deprecated Please use {SyntaxHighlighter#get} method as "for" is a reserved keyword.
20908 */
20909SyntaxHighlighter.for = SyntaxHighlighter.get
20910
20911/**
20912 * @namespace
20913 */
20914const SyntaxHighlighterBase = Opal.const_get_qualified(SyntaxHighlighter, 'Base', true)
20915
20916// Alias
20917Opal.Asciidoctor.SyntaxHighlighterBase = SyntaxHighlighterBase
20918
20919/**
20920 * Statically register the current class in the registry for the specified names.
20921 *
20922 * @description This API is experimental and subject to change.
20923 *
20924 * @param {string|Array<string>} names - A {string} name or an {Array} of {string} names
20925 * @memberof SyntaxHighlighterBase
20926 */
20927SyntaxHighlighterBase.prototype.registerFor = function (names) {
20928  SyntaxHighlighter.$register(this, names)
20929}
20930
20931// Table API
20932
20933/**
20934 * Methods for managing AsciiDoc tables.
20935 * @namespace
20936 * @extends AbstractBlock
20937 */
20938const Table = Opal.Asciidoctor.Table
20939
20940/**
20941 * Create a new Table element.
20942 * @param {AbstractBlock} parent
20943 * @param {Object|undefined} attributes
20944 * @returns {Table} - a new {Table} object
20945 */
20946Table.create = function (parent, attributes) {
20947  return this.$new(parent, toHash(attributes))
20948}
20949
20950/**
20951 * Get the caption of the table.
20952 * @returns {string}
20953 * @memberof Table
20954 */
20955Table.prototype.getCaption = function () {
20956  return this.caption
20957}
20958
20959/**
20960 * Get the rows of this table.
20961 * @returns {Table.Rows} - an {Table.Rows} object with the members "head", "body" and "foot"
20962 * @memberof Table
20963 */
20964Table.prototype.getRows = function () {
20965  return this.rows
20966}
20967
20968/**
20969 * Get the columns of this table.
20970 * @returns {Array<Column>}
20971 * @memberof Table
20972 */
20973Table.prototype.getColumns = function () {
20974  return this.columns
20975}
20976
20977/**
20978 * Get the head rows of this table.
20979 * @returns {Array<Array<Cell>>} - an Array of Array of Cell
20980 * @memberof Table
20981 */
20982Table.prototype.getHeadRows = function () {
20983  return this.rows.head
20984}
20985
20986/**
20987 * Check if the table has a head rows.
20988 * @returns {boolean}
20989 * @memberof Table
20990 */
20991Table.prototype.hasHeadRows = function () {
20992  return this.rows !== Opal.nil && this.rows.head.length > 0
20993}
20994
20995/**
20996 * Get the body rows of this table.
20997 * @returns {Array<Array<Cell>>} - an Array of Array of Cell
20998 * @memberof Table
20999 */
21000Table.prototype.getBodyRows = function () {
21001  return this.rows.body
21002}
21003
21004/**
21005 * Check if the table has a body rows.
21006 * @returns {boolean}
21007 */
21008Table.prototype.hasBodyRows = function () {
21009  return this.rows !== Opal.nil && this.rows.body.length > 0
21010}
21011
21012/**
21013 * Get the foot rows of this table.
21014 * @returns {Array<Array<Cell>>} - an Array of Array of Cell
21015 * @memberof Table
21016 */
21017Table.prototype.getFootRows = function () {
21018  return this.rows.foot
21019}
21020
21021/**
21022 * Check if the table has a foot rows.
21023 * @returns {boolean}
21024 */
21025Table.prototype.hasFootRows = function () {
21026  return this.rows !== Opal.nil && this.rows.foot.length > 0
21027}
21028
21029/**
21030 * Check if the table has a header option set.
21031 * @returns {boolean}
21032 * @memberof Table
21033 */
21034Table.prototype.hasHeaderOption = function () {
21035  return this.has_header_option
21036}
21037
21038/**
21039 * Check if the table has the footer option set.
21040 * @returns {boolean}
21041 * @memberof Table
21042 */
21043Table.prototype.hasFooterOption = function () {
21044  return this.isOption('footer')
21045}
21046
21047/**
21048 * Check if the table has the autowidth option set.
21049 * @returns {boolean}
21050 * @memberof Table
21051 */
21052Table.prototype.hasAutowidthOption = function () {
21053  return this.isOption('autowidth')
21054}
21055
21056/**
21057 * Get the number of rows in the table.
21058 * Please note that the header and footer rows are also counted.
21059 * @returns {number|undefined}
21060 * @memberof Table
21061 */
21062Table.prototype.getRowCount = function () {
21063  return this.getAttribute('rowcount')
21064}
21065
21066/**
21067 * Set the number of rows in the table.
21068 * Please note that the header and footer rows are also counted.
21069 * @param {number} value - the value
21070 * @memberof Table
21071 */
21072Table.prototype.setRowCount = function (value) {
21073  this.setAttribute('rowcount', value)
21074}
21075
21076/**
21077 * Get the number of columns in the table.
21078 * @returns {number|undefined}
21079 * @memberof Table
21080 */
21081Table.prototype.getColumnCount = function () {
21082  return this.getAttribute('colcount')
21083}
21084
21085/**
21086 * Set the number of columns in the table.
21087 * @param {number} value - the value
21088 * @memberof Table
21089 */
21090Table.prototype.setColumnCount = function (value) {
21091  this.setAttribute('colcount', value)
21092}
21093
21094// Rows
21095
21096/**
21097 * @namespace
21098 */
21099const Rows = Opal.Asciidoctor.Table.Rows
21100
21101/**
21102 * Create a new Rows element.
21103 * @param {array<array<Cell>>} head
21104 * @param {array<array<Cell>>} foot
21105 * @param {array<array<Cell>>} body
21106 * @returns Rows
21107 */
21108Rows.create = function (head, foot, body) {
21109  return this.$new(head, foot, body)
21110}
21111
21112/**
21113 * Get head rows.
21114 * @returns {array<array<Cell>>}
21115 */
21116Rows.prototype.getHead = function () {
21117  return this.head
21118}
21119
21120/**
21121 * Get foot rows.
21122 * @returns {array<array<Cell>>}
21123 */
21124Rows.prototype.getFoot = function () {
21125  return this.foot
21126}
21127
21128/**
21129 * Get body rows.
21130 * @returns {array<array<Cell>>}
21131 */
21132Rows.prototype.getBody = function () {
21133  return this.body
21134}
21135
21136/**
21137 * Retrieve the rows grouped by section as a nested Array.
21138 *
21139 * Creates a 2-dimensional array of two element entries.
21140 * The first element is the section name as a string.
21141 * The second element is the Array of rows in that section.
21142 * The entries are in document order (head, foot, body).
21143 * @returns {[[string, array<array<Cell>>], [string, array<array<Cell>>], [string, array<array<Cell>>]]}
21144 */
21145Rows.prototype.bySection = function () {
21146  return [['head', this.head], ['body', this.body], ['foot', this.foot]]
21147}
21148
21149// Table Column
21150
21151/**
21152 * Methods to manage the columns of an AsciiDoc table.
21153 * In particular, it keeps track of the column specs.
21154 * @namespace
21155 * @extends AbstractNode
21156 */
21157const Column = Opal.Asciidoctor.Table.Column
21158
21159/**
21160 * Create a new Column element.
21161 * @param {Table} table
21162 * @param {number} index
21163 * @param {Object|undefined} attributes
21164 * @returns Column
21165 */
21166Column.create = function (table, index, attributes) {
21167  return this.$new(table, index, toHash(attributes))
21168}
21169
21170/**
21171 * Get the column number of this cell.
21172 * @returns {number|undefined}
21173 * @memberof Column
21174 */
21175Column.prototype.getColumnNumber = function () {
21176  return this.getAttribute('colnumber')
21177}
21178
21179/**
21180 * Get the width of this cell.
21181 * @returns {string|undefined}
21182 * @memberof Column
21183 */
21184Column.prototype.getWidth = function () {
21185  return this.getAttribute('width')
21186}
21187
21188/**
21189 * Get the horizontal align of this cell.
21190 * @returns {string|undefined}
21191 * @memberof Column
21192 */
21193Column.prototype.getHorizontalAlign = function () {
21194  return this.getAttribute('halign')
21195}
21196
21197/**
21198 * Get the vertical align of this cell.
21199 * @returns {string|undefined}
21200 * @memberof Column
21201 */
21202Column.prototype.getVerticalAlign = function () {
21203  return this.getAttribute('valign')
21204}
21205
21206/**
21207 * Get the style of this cell.
21208 * @returns {string}
21209 * @memberof Column
21210 */
21211Column.prototype.getStyle = function () {
21212  const style = this.style
21213  return style === Opal.nil ? undefined : style
21214}
21215
21216// Table Cell
21217
21218/**
21219 * Methods for managing the cells in an AsciiDoc table.
21220 * @namespace
21221 * @extends AbstractBlock
21222 */
21223const Cell = Opal.Asciidoctor.Table.Cell
21224
21225/**
21226 * Create a new Cell element
21227 * @param {Column} column
21228 * @param {string} cellText
21229 * @param {Object|undefined} attributes
21230 * @param {Object|undefined} opts
21231 * @returns {Cell}
21232 */
21233Cell.create = function (column, cellText, attributes, opts) {
21234  return this.$new(column, cellText, toHash(attributes), toHash(opts))
21235}
21236
21237/**
21238 * Get the column span of this {@link Cell} node.
21239 * @returns {number} - An Integer of the number of columns this cell will span (default: undefined)
21240 * @memberof Cell
21241 */
21242Cell.prototype.getColumnSpan = function () {
21243  const colspan = this.colspan
21244  return colspan === Opal.nil ? undefined : colspan
21245}
21246
21247/**
21248 * Set the column span of this {@link Cell} node.
21249 * @param {number} value
21250 * @returns {number} - The new colspan value
21251 * @memberof Cell
21252 */
21253Cell.prototype.setColumnSpan = function (value) {
21254  return this['$colspan='](value)
21255}
21256
21257/**
21258 * Get the row span of this {@link Cell} node
21259 * @returns {number|undefined} - An Integer of the number of rows this cell will span (default: undefined)
21260 * @memberof Cell
21261 */
21262Cell.prototype.getRowSpan = function () {
21263  const rowspan = this.rowspan
21264  return rowspan === Opal.nil ? undefined : rowspan
21265}
21266
21267/**
21268 * Set the row span of this {@link Cell} node
21269 * @param {number} value
21270 * @returns {number} - The new rowspan value
21271 * @memberof Cell
21272 */
21273Cell.prototype.setRowSpan = function (value) {
21274  return this['$rowspan='](value)
21275}
21276
21277/**
21278 * Get the content of the cell.
21279 * This method should not be used for cells in the head row or that have the literal style.
21280 * @returns {string}
21281 * @memberof Cell
21282 */
21283Cell.prototype.getContent = function () {
21284  return this.$content()
21285}
21286
21287/**
21288 * Get the text of the cell.
21289 * @returns {string}
21290 * @memberof Cell
21291 */
21292Cell.prototype.getText = function () {
21293  return this.$text()
21294}
21295
21296/**
21297 * Get the source of the cell.
21298 * @returns {string}
21299 * @memberof Cell
21300 */
21301Cell.prototype.getSource = function () {
21302  return this.$source()
21303}
21304
21305/**
21306 * Get the lines of the cell.
21307 * @returns {Array<string>}
21308 * @memberof Cell
21309 */
21310Cell.prototype.getLines = function () {
21311  return this.$lines()
21312}
21313
21314/**
21315 * Get the line number of the cell.
21316 * @returns {number|undefined}
21317 * @memberof Cell
21318 */
21319Cell.prototype.getLineNumber = function () {
21320  const lineno = this.$lineno()
21321  return lineno === Opal.nil ? undefined : lineno
21322}
21323
21324/**
21325 * Get the source file of the cell.
21326 * @returns {string|undefined}
21327 * @memberof Cell
21328 */
21329Cell.prototype.getFile = function () {
21330  const file = this.$file()
21331  return file === Opal.nil ? undefined : file
21332}
21333
21334/**
21335 * Get the style of the cell.
21336 * @returns {string|undefined}
21337 * @memberof Cell
21338 */
21339Cell.prototype.getStyle = function () {
21340  const style = this.$style()
21341  return style === Opal.nil ? undefined : style
21342}
21343
21344/**
21345 * Get the column of this cell.
21346 * @returns {Column|undefined}
21347 * @memberof Cell
21348 */
21349Cell.prototype.getColumn = function () {
21350  const column = this.$column()
21351  return column === Opal.nil ? undefined : column
21352}
21353
21354/**
21355 * Get the width of this cell.
21356 * @returns {string|undefined}
21357 * @memberof Cell
21358 */
21359Cell.prototype.getWidth = function () {
21360  return this.getAttribute('width')
21361}
21362
21363/**
21364 * Get the column width in percentage of this cell.
21365 * @returns {string|undefined}
21366 * @memberof Cell
21367 */
21368Cell.prototype.getColumnPercentageWidth = function () {
21369  return this.getAttribute('colpcwidth')
21370}
21371
21372/**
21373 * Get the nested {Document} of this cell when style is 'asciidoc'.
21374 * @returns {Document|undefined} - the nested {Document}
21375 * @memberof Cell
21376 */
21377Cell.prototype.getInnerDocument = function () {
21378  const innerDocument = this.inner_document
21379  return innerDocument === Opal.nil ? undefined : innerDocument
21380}
21381
21382// Templates
21383
21384/**
21385 * @description
21386 * This API is experimental and subject to change.
21387 *
21388 * Please note that this API is currently only available in a Node environment.
21389 * We recommend to use a custom converter if you are running in the browser.
21390 *
21391 * @namespace
21392 * @module Converter/TemplateConverter
21393 */
21394const TemplateConverter = Opal.Asciidoctor.Converter.TemplateConverter
21395
21396if (TemplateConverter) {
21397  // Alias
21398  Opal.Asciidoctor.TemplateConverter = TemplateConverter
21399
21400  /**
21401   * Create a new TemplateConverter.
21402   * @param {string} backend - the backend name
21403   * @param templateDirectories - a list of template directories
21404   * @param {Object} opts - a JSON of options
21405   * @param {string} opts.template_engine - the name of the template engine
21406   * @param {Object} [opts.template_cache] - an optional template cache
21407   * @param {Object} [opts.template_cache.scans] - a JSON of template objects keyed by template name keyed by path patterns
21408   * @param {Object} [opts.template_cache.templates] - a JSON of template objects keyed by file paths
21409   * @returns {TemplateConverter}
21410   * @memberof Converter/TemplateConverter
21411   */
21412  TemplateConverter.create = function (backend, templateDirectories, opts) {
21413    if (opts && opts.template_cache) {
21414      opts.template_cache = toHash(opts.template_cache)
21415    }
21416    this.$new(backend, templateDirectories, toHash(opts))
21417  }
21418
21419  /**
21420   * @returns {Object} - The global cache
21421   * @memberof Converter/TemplateConverter
21422   */
21423  TemplateConverter.getCache = function () {
21424    const caches = fromHash(this.caches)
21425    if (caches) {
21426      if (caches.scans) {
21427        caches.scans = fromHash(caches.scans)
21428        for (const key in caches.scans) {
21429          caches.scans[key] = fromHash(caches.scans[key])
21430        }
21431      }
21432      if (caches.templates) {
21433        caches.templates = fromHash(caches.templates)
21434      }
21435    }
21436    return caches
21437  }
21438
21439  /**
21440   * Clear the global cache.
21441   * @memberof Converter/TemplateConverter
21442   */
21443  TemplateConverter.clearCache = function () {
21444    this.$clear_caches()
21445  }
21446
21447  /**
21448   * Convert an {AbstractNode} to the backend format using the named template.
21449   *
21450   * Looks for a template that matches the value of the template name or,
21451   * if the template name is not specified, the value of the {@see AbstractNode.getNodeName} function.
21452   *
21453   * @param {AbstractNode} node - the AbstractNode to convert
21454   * @param {string} templateName - the {string} name of the template to use, or the node name of the node if a template name is not specified. (optional, default: undefined)
21455   * @param {Object} opts - an optional JSON that is passed as local variables to the template. (optional, default: undefined)
21456   * @returns {string} - The {string} result from rendering the template
21457   * @memberof Converter/TemplateConverter
21458   */
21459  TemplateConverter.prototype.convert = function (node, templateName, opts) {
21460    return this.$convert(node, templateName, toHash(opts))
21461  }
21462
21463  /**
21464   * Checks whether there is a template registered with the specified name.
21465   *
21466   * @param {string} name - the {string} template name
21467   * @returns {boolean} - a {boolean} that indicates whether a template is registered for the specified template name.
21468   * @memberof Converter/TemplateConverter
21469   */
21470  TemplateConverter.prototype.handles = function (name) {
21471    return this['$handles?'](name)
21472  }
21473
21474  /**
21475   * Converts the {AbstractNode} using only its converted content.
21476   *
21477   * @param {AbstractNode} node
21478   * @returns {string} - the converted {string} content.
21479   * @memberof Converter/TemplateConverter
21480   */
21481  TemplateConverter.prototype.getContentOnly = function (node) {
21482    return this.$content_only(node)
21483  }
21484
21485  /**
21486   * Skips conversion of the {AbstractNode}.
21487   *
21488   * @param {AbstractNode} node
21489   * @memberof Converter/TemplateConverter
21490   */
21491  TemplateConverter.prototype.skip = function (node) {
21492    this.$skip(node)
21493  }
21494
21495  /**
21496   * Retrieves the templates that this converter manages.
21497   *
21498   * @returns {Object} - a JSON of template objects keyed by template name
21499   * @memberof Converter/TemplateConverter
21500   */
21501  TemplateConverter.prototype.getTemplates = function () {
21502    return fromHash(this.$templates())
21503  }
21504
21505  /**
21506   * Registers a template with this converter.
21507   *
21508   * @param {string} name - the {string} template name
21509   * @param {Object} template - the template object to register
21510   * @returns {Object} - the template object
21511   * @memberof Converter/TemplateConverter
21512   */
21513  TemplateConverter.prototype.register = function (name, template) {
21514    return this.$register(name, template)
21515  }
21516
21517  /**
21518   * @namespace
21519   * @description
21520   * This API is experimental and subject to change.
21521   *
21522   * Please note that this API is currently only available in a Node environment.
21523   * We recommend to use a custom converter if you are running in the browser.
21524   *
21525   * A pluggable adapter for integrating a template engine into the built-in template converter.
21526   */
21527  const TemplateEngine = {}
21528  TemplateEngine.registry = {}
21529
21530  // Alias
21531  Opal.Asciidoctor.TemplateEngine = TemplateEngine
21532
21533  /**
21534   * Register a template engine adapter for the given names.
21535   * @param {string|Array} names - a {string} name or an {Array} of {string} names
21536   * @param {Object} templateEngineAdapter - a template engine adapter instance
21537   * @example
21538   *  const fs = require('fs')
21539   *  class DotTemplateEngineAdapter {
21540   *    constructor () {
21541   *      this.doT = require('dot')
21542   *    }
21543   *    compile (file, _) {
21544   *      const templateFn = this.doT.template(fs.readFileSync(file, 'utf8'))
21545   *      return {
21546   *        render: templateFn
21547   *      }
21548   *    }
21549   *  }
21550   *  asciidoctor.TemplateEngine.register('dot, new DotTemplateEngineAdapter())
21551   * @memberof TemplateEngine
21552   */
21553  TemplateEngine.register = function (names, templateEngineAdapter) {
21554    if (typeof names === 'string') {
21555      this.registry[names] = templateEngineAdapter
21556    } else {
21557      // array
21558      for (let i = 0; i < names.length; i++) {
21559        const name = names[i]
21560        this.registry[name] = templateEngineAdapter
21561      }
21562    }
21563  }
21564}
21565
21566/**
21567 * @namespace
21568 * @module Converter/CompositeConverter
21569 */
21570const CompositeConverter = Opal.Asciidoctor.Converter.CompositeConverter
21571
21572if (CompositeConverter) {
21573  // Alias
21574  Opal.Asciidoctor.CompositeConverter = CompositeConverter
21575
21576  /**
21577   * Delegates to the first converter that identifies itself as the handler for the given transform.
21578   * The optional Hash is passed as the last option to the delegate's convert method.
21579   *
21580   * @param node - the AbstractNode to convert
21581   * @param [transform] - the optional {string} transform, or the name of the node if no transform is specified. (optional, default: undefined)
21582   * @param [opts] - an optional JSON that is passed as local variables to the template. (optional, default: undefined)
21583   * @returns The {string} result from the delegate's convert method
21584   * @memberof Converter/CompositeConverter
21585   */
21586  CompositeConverter.prototype.convert = function (node, transform, opts) {
21587    return this.$convert(node, transform, toHash(opts))
21588  }
21589
21590  /**
21591   * Converts the {AbstractNode} using only its converted content.
21592   *
21593   * @param {AbstractNode} node
21594   * @returns {string} - the converted {string} content.
21595   * @memberof Converter/CompositeConverter
21596   */
21597  CompositeConverter.prototype.getContentOnly = function (node) {
21598    return this.$content_only(node)
21599  }
21600
21601  /**
21602   * Skips conversion of the {AbstractNode}.
21603   *
21604   * @param {AbstractNode} node
21605   * @memberof Converter/CompositeConverter
21606   */
21607  CompositeConverter.prototype.skip = function (node) {
21608    this.$skip(node)
21609  }
21610
21611  /**
21612   * Get the Array of Converter objects in the chain.
21613   * @returns {[Converter]}
21614   * @memberof Converter/CompositeConverter
21615   */
21616  CompositeConverter.prototype.getConverters = function () {
21617    return this.converters
21618  }
21619
21620  /**
21621   * Retrieve the converter for the specified transform.
21622   * @param transform
21623   * @returns {Converter|undefined}
21624   * @memberof Converter/CompositeConverter
21625   */
21626  CompositeConverter.prototype.getConverter = function (transform) {
21627    const converter = this.$converter_for(transform)
21628    return converter === Opal.nil ? undefined : converter
21629  }
21630
21631  /**
21632   * Find the converter for the specified transform.
21633   * Throw an exception if no converter is found.
21634   *
21635   * @param transform
21636   * @returns {Converter} - the matching converter
21637   * @throws Error if no converter is found
21638   * @memberof Converter/CompositeConverter
21639   */
21640  CompositeConverter.prototype.findConverter = function (transform) {
21641    return this.$find_converter(transform)
21642  }
21643}
21644
21645// Converter API
21646
21647/**
21648 * @namespace
21649 * @module Converter
21650 */
21651const Converter = Opal.const_get_qualified(Opal.Asciidoctor, 'Converter')
21652
21653// Alias
21654Opal.Asciidoctor.Converter = Converter
21655
21656/**
21657 * Convert the specified node.
21658 *
21659 * @param {AbstractNode} node - the AbstractNode to convert
21660 * @param {string} transform - an optional String transform that hints at
21661 * which transformation should be applied to this node.
21662 * @param {Object} opts - a JSON of options that provide additional hints about how to convert the node (default: {})
21663 * @returns the {Object} result of the conversion, typically a {string}.
21664 * @memberof Converter
21665 */
21666Converter.prototype.convert = function (node, transform, opts) {
21667  return this.$convert(node, transform, toHash(opts))
21668}
21669
21670/**
21671 * Create an instance of the converter bound to the specified backend.
21672 *
21673 * @param {string} backend - look for a converter bound to this keyword.
21674 * @param {Object} opts - a JSON of options to pass to the converter (default: {})
21675 * @returns {Converter} - a converter instance for converting nodes in an Asciidoctor AST.
21676 * @memberof Converter
21677 */
21678Converter.create = function (backend, opts) {
21679  return this.$create(backend, toHash(opts))
21680}
21681
21682// Converter Factory API
21683
21684/**
21685 * @namespace
21686 * @module Converter/Factory
21687 */
21688const ConverterFactory = Opal.Asciidoctor.Converter.Factory
21689
21690const ConverterBase = Opal.Asciidoctor.Converter.Base
21691
21692// Alias
21693Opal.Asciidoctor.ConverterFactory = ConverterFactory
21694
21695const ConverterBackendTraits = Opal.Asciidoctor.Converter.BackendTraits
21696
21697// Alias
21698Opal.Asciidoctor.ConverterBackendTraits = ConverterBackendTraits
21699
21700/**
21701 * Register a custom converter in the global converter factory to handle conversion to the specified backends.
21702 * If the backend value is an asterisk, the converter is used to handle any backend that does not have an explicit converter.
21703 *
21704 * @param converter - The Converter instance to register
21705 * @param backends {Array} - A {string} {Array} of backend names that this converter should be registered to handle (optional, default: ['*'])
21706 * @return {*} - Returns nothing
21707 * @memberof Converter/Factory
21708 */
21709ConverterFactory.register = function (converter, backends) {
21710  const args = [bridgeConverter(converter)].concat(backends)
21711  return Converter.$register.apply(Converter, args)
21712}
21713
21714/**
21715 * Retrieves the singleton instance of the converter factory.
21716 *
21717 * @param {boolean} initialize - instantiate the singleton if it has not yet
21718 * been instantiated. If this value is false and the singleton has not yet been
21719 * instantiated, this method returns a fresh instance.
21720 * @returns {Converter/Factory} an instance of the converter factory.
21721 * @memberof Converter/Factory
21722 */
21723ConverterFactory.getDefault = function (initialize) {
21724  return this.$default(initialize)
21725}
21726
21727/**
21728 * Create an instance of the converter bound to the specified backend.
21729 *
21730 * @param {string} backend - look for a converter bound to this keyword.
21731 * @param {Object} opts - a JSON of options to pass to the converter (default: {})
21732 * @returns {Converter} - a converter instance for converting nodes in an Asciidoctor AST.
21733 * @memberof Converter/Factory
21734 */
21735ConverterFactory.prototype.create = function (backend, opts) {
21736  return this.$create(backend, toHash(opts))
21737}
21738
21739/**
21740 * Get the converter registry.
21741 * @returns the registry of converter instances or classes keyed by backend name
21742 * @memberof Converter/Factory
21743 */
21744ConverterFactory.getRegistry = function () {
21745  return fromHash(Converter.$registry())
21746}
21747
21748/**
21749 * Lookup the custom converter registered with this factory to handle the specified backend.
21750 *
21751 * @param {string} backend - The {string} backend name.
21752 * @returns the {Converter} class or instance registered to convert the specified backend or undefined if no match is found.
21753 * @memberof Converter/Factory
21754 */
21755ConverterFactory.for = function (backend) {
21756  const converter = Converter.$for(backend)
21757  return converter === Opal.nil ? undefined : converter
21758}
21759
21760/*
21761 * Unregister any custom converter classes that are registered with this factory.
21762 * Intended for testing only!
21763 */
21764ConverterFactory.unregisterAll = function () {
21765  const internalRegistry = Converter.DefaultFactory.$$cvars['@@registry']
21766  Converter.DefaultFactory.$$cvars['@@registry'] = toHash({ html5: internalRegistry['$[]']('html5') })
21767}
21768
21769// Built-in converter
21770
21771/**
21772 * @namespace
21773 * @module Converter/Html5Converter
21774 */
21775const Html5Converter = Opal.Asciidoctor.Converter.Html5Converter
21776
21777// Alias
21778Opal.Asciidoctor.Html5Converter = Html5Converter
21779
21780/**
21781 * Create a new Html5Converter.
21782 * @returns {Html5Converter} - a Html5Converter
21783 * @memberof Converter/Html5Converter
21784 */
21785Html5Converter.create = function () {
21786  return this.$new()
21787}
21788
21789/**
21790 * Converts an {AbstractNode} using the given transform.
21791 * This method must be implemented by a concrete converter class.
21792 *
21793 * @param {AbstractNode} node - The concrete instance of AbstractNode to convert.
21794 * @param {string} [transform] - An optional String transform that hints at which transformation should be applied to this node.
21795 * If a transform is not given, the transform is often derived from the value of the {AbstractNode#getNodeName} property. (optional, default: undefined)
21796 * @param {Object} [opts]- An optional JSON of options hints about how to convert the node. (optional, default: undefined)
21797 *
21798 * @returns {string} - the String result.
21799 * @memberof Converter/Html5Converter
21800 */
21801Html5Converter.prototype.convert = function (node, transform, opts) {
21802  return this.$convert(node, transform, opts)
21803}
21804
21805/* global Opal, fromHash, toHash, initializeClass */
21806// Extensions API
21807
21808/**
21809 * @private
21810 */
21811const toBlock = function (block) {
21812  // arity is a mandatory field
21813  block.$$arity = block.length
21814  return block
21815}
21816
21817const registerExtension = function (registry, type, processor, name) {
21818  if (typeof processor === 'object' || processor.$$is_class) {
21819    // processor is an instance or a class
21820    return registry['$' + type](processor, name)
21821  } else {
21822    // processor is a function/lambda
21823    return Opal.send(registry, type, name && [name], toBlock(processor))
21824  }
21825}
21826
21827/**
21828 * @namespace
21829 * @description
21830 * Extensions provide a way to participate in the parsing and converting
21831 * phases of the AsciiDoc processor or extend the AsciiDoc syntax.
21832 *
21833 * The various extensions participate in AsciiDoc processing as follows:
21834 *
21835 * 1. After the source lines are normalized, {{@link Extensions/Preprocessor}}s modify or replace
21836 *    the source lines before parsing begins. {{@link Extensions/IncludeProcessor}}s are used to
21837 *    process include directives for targets which they claim to handle.
21838 * 2. The Parser parses the block-level content into an abstract syntax tree.
21839 *    Custom blocks and block macros are processed by associated {{@link Extensions/BlockProcessor}}s
21840 *    and {{@link Extensions/BlockMacroProcessor}}s, respectively.
21841 * 3. {{@link Extensions/TreeProcessor}}s are run on the abstract syntax tree.
21842 * 4. Conversion of the document begins, at which point inline markup is processed
21843 *    and converted. Custom inline macros are processed by associated {InlineMacroProcessor}s.
21844 * 5. {{@link Extensions/Postprocessor}}s modify or replace the converted document.
21845 * 6. The output is written to the output stream.
21846 *
21847 * Extensions may be registered globally using the {Extensions.register} method
21848 * or added to a custom {Registry} instance and passed as an option to a single
21849 * Asciidoctor processor.
21850 *
21851 * @example
21852 * asciidoctor.Extensions.register(function () {
21853 *   this.block(function () {
21854 *     const self = this
21855 *     self.named('shout')
21856 *     self.onContext('paragraph')
21857 *     self.process(function (parent, reader) {
21858 *       const lines = reader.getLines().map(function (l) { return l.toUpperCase(); })
21859 *       return self.createBlock(parent, 'paragraph', lines)
21860 *     })
21861 *   })
21862 * })
21863 */
21864const Extensions = Opal.const_get_qualified(Opal.Asciidoctor, 'Extensions')
21865
21866// Alias
21867Opal.Asciidoctor.Extensions = Extensions
21868
21869/**
21870 * Create a new {@link Extensions/Registry}.
21871 * @param {string} name
21872 * @param {function} block
21873 * @memberof Extensions
21874 * @returns {Extensions/Registry} - returns a {@link Extensions/Registry}
21875 */
21876Extensions.create = function (name, block) {
21877  if (typeof name === 'function' && typeof block === 'undefined') {
21878    return Opal.send(this, 'create', null, toBlock(name))
21879  } else if (typeof block === 'function') {
21880    return Opal.send(this, 'create', [name], toBlock(block))
21881  } else {
21882    return this.$create()
21883  }
21884}
21885
21886/**
21887 * @memberof Extensions
21888 */
21889Extensions.register = function (name, block) {
21890  if (typeof name === 'function' && typeof block === 'undefined') {
21891    return Opal.send(this, 'register', null, toBlock(name))
21892  } else {
21893    return Opal.send(this, 'register', [name], toBlock(block))
21894  }
21895}
21896
21897/**
21898 * Get statically-registered extension groups.
21899 * @memberof Extensions
21900 */
21901Extensions.getGroups = function () {
21902  return fromHash(this.$groups())
21903}
21904
21905/**
21906 * Unregister all statically-registered extension groups.
21907 * @memberof Extensions
21908 */
21909Extensions.unregisterAll = function () {
21910  this.$unregister_all()
21911}
21912
21913/**
21914 * Unregister the specified statically-registered extension groups.
21915 *
21916 * NOTE Opal cannot delete an entry from a Hash that is indexed by symbol, so
21917 * we have to resort to using low-level operations in this method.
21918 *
21919 * @memberof Extensions
21920 */
21921Extensions.unregister = function () {
21922  const names = Array.prototype.concat.apply([], arguments)
21923  const groups = this.$groups()
21924  const groupNameIdx = {}
21925  let i = 0
21926  const groupSymbolNames = groups.$$keys
21927  for (; i < groupSymbolNames.length; i++) {
21928    const groupSymbolName = groupSymbolNames[i]
21929    groupNameIdx[groupSymbolName.toString()] = groupSymbolName
21930  }
21931  for (let j = 0; j < names.length; j++) {
21932    const groupStringName = names[j]
21933    if (groupStringName in groupNameIdx) Opal.hash_delete(groups, groupNameIdx[groupStringName])
21934  }
21935}
21936
21937/**
21938 * @namespace
21939 * @module Extensions/Registry
21940 */
21941const Registry = Extensions.Registry
21942
21943/**
21944 * @memberof Extensions/Registry
21945 */
21946Registry.prototype.getGroups = Extensions.getGroups
21947
21948/**
21949 * @memberof Extensions/Registry
21950 */
21951Registry.prototype.unregisterAll = function () {
21952  this.groups = Opal.hash()
21953}
21954
21955/**
21956 * @memberof Extensions/Registry
21957 */
21958Registry.prototype.unregister = Extensions.unregister
21959
21960/**
21961 * @memberof Extensions/Registry
21962 */
21963Registry.prototype.prefer = function (name, processor) {
21964  if (arguments.length === 1) {
21965    processor = name
21966    name = null
21967  }
21968  if (typeof processor === 'object' || processor.$$is_class) {
21969    // processor is an instance or a class
21970    return this.$prefer(name, processor)
21971  } else {
21972    // processor is a function/lambda
21973    return Opal.send(this, 'prefer', name && [name], toBlock(processor))
21974  }
21975}
21976
21977/**
21978 * @memberof Extensions/Registry
21979 */
21980Registry.prototype.block = function (name, processor) {
21981  if (arguments.length === 1) {
21982    processor = name
21983    name = null
21984  }
21985  return registerExtension(this, 'block', processor, name)
21986}
21987
21988/**
21989 * @memberof Extensions/Registry
21990 */
21991Registry.prototype.inlineMacro = function (name, processor) {
21992  if (arguments.length === 1) {
21993    processor = name
21994    name = null
21995  }
21996  return registerExtension(this, 'inline_macro', processor, name)
21997}
21998
21999/**
22000 * @memberof Extensions/Registry
22001 */
22002Registry.prototype.includeProcessor = function (name, processor) {
22003  if (arguments.length === 1) {
22004    processor = name
22005    name = null
22006  }
22007  return registerExtension(this, 'include_processor', processor, name)
22008}
22009
22010/**
22011 * @memberof Extensions/Registry
22012 */
22013Registry.prototype.blockMacro = function (name, processor) {
22014  if (arguments.length === 1) {
22015    processor = name
22016    name = null
22017  }
22018  return registerExtension(this, 'block_macro', processor, name)
22019}
22020
22021/**
22022 * @memberof Extensions/Registry
22023 */
22024Registry.prototype.treeProcessor = function (name, processor) {
22025  if (arguments.length === 1) {
22026    processor = name
22027    name = null
22028  }
22029  return registerExtension(this, 'tree_processor', processor, name)
22030}
22031
22032/**
22033 * @memberof Extensions/Registry
22034 */
22035Registry.prototype.postprocessor = function (name, processor) {
22036  if (arguments.length === 1) {
22037    processor = name
22038    name = null
22039  }
22040  return registerExtension(this, 'postprocessor', processor, name)
22041}
22042
22043/**
22044 * @memberof Extensions/Registry
22045 */
22046Registry.prototype.preprocessor = function (name, processor) {
22047  if (arguments.length === 1) {
22048    processor = name
22049    name = null
22050  }
22051  return registerExtension(this, 'preprocessor', processor, name)
22052}
22053
22054/**
22055 * @memberof Extensions/Registry
22056 */
22057Registry.prototype.docinfoProcessor = function (name, processor) {
22058  if (arguments.length === 1) {
22059    processor = name
22060    name = null
22061  }
22062  return registerExtension(this, 'docinfo_processor', processor, name)
22063}
22064
22065/**
22066 * Checks whether any {{@link Extensions/Preprocessor}} extensions have been registered.
22067 *
22068 * @memberof Extensions/Registry
22069 * @returns a {boolean} indicating whether any {{@link Extensions/Preprocessor}} extensions are registered.
22070 */
22071Registry.prototype.hasPreprocessors = function () {
22072  return this['$preprocessors?']()
22073}
22074
22075/**
22076 * Checks whether any {{@link Extensions/TreeProcessor}} extensions have been registered.
22077 *
22078 * @memberof Extensions/Registry
22079 * @returns a {boolean} indicating whether any {{@link Extensions/TreeProcessor}} extensions are registered.
22080 */
22081Registry.prototype.hasTreeProcessors = function () {
22082  return this['$tree_processors?']()
22083}
22084
22085/**
22086 * Checks whether any {{@link Extensions/IncludeProcessor}} extensions have been registered.
22087 *
22088 * @memberof Extensions/Registry
22089 * @returns a {boolean} indicating whether any {{@link Extensions/IncludeProcessor}} extensions are registered.
22090 */
22091Registry.prototype.hasIncludeProcessors = function () {
22092  return this['$include_processors?']()
22093}
22094
22095/**
22096 * Checks whether any {{@link Extensions/Postprocessor}} extensions have been registered.
22097 *
22098 * @memberof Extensions/Registry
22099 * @returns a {boolean} indicating whether any {{@link Extensions/Postprocessor}} extensions are registered.
22100 */
22101Registry.prototype.hasPostprocessors = function () {
22102  return this['$postprocessors?']()
22103}
22104
22105/**
22106 * Checks whether any {{@link Extensions/DocinfoProcessor}} extensions have been registered.
22107 *
22108 * @memberof Extensions/Registry
22109 * @param location - A {string} for selecting docinfo extensions at a given location (head or footer) (default: undefined)
22110 * @returns a {boolean} indicating whether any {{@link Extensions/DocinfoProcessor}} extensions are registered.
22111 */
22112Registry.prototype.hasDocinfoProcessors = function (location) {
22113  return this['$docinfo_processors?'](location)
22114}
22115
22116/**
22117 * Checks whether any {{@link Extensions/BlockProcessor}} extensions have been registered.
22118 *
22119 * @memberof Extensions/Registry
22120 * @returns a {boolean} indicating whether any {{@link Extensions/BlockProcessor}} extensions are registered.
22121 */
22122Registry.prototype.hasBlocks = function () {
22123  return this['$blocks?']()
22124}
22125
22126/**
22127 * Checks whether any {{@link Extensions/BlockMacroProcessor}} extensions have been registered.
22128 *
22129 * @memberof Extensions/Registry
22130 * @returns a {boolean} indicating whether any {{@link Extensions/BlockMacroProcessor}} extensions are registered.
22131 */
22132Registry.prototype.hasBlockMacros = function () {
22133  return this['$block_macros?']()
22134}
22135
22136/**
22137 * Checks whether any {{@link Extensions/InlineMacroProcessor}} extensions have been registered.
22138 *
22139 * @memberof Extensions/Registry
22140 * @returns a {boolean} indicating whether any {{@link Extensions/InlineMacroProcessor}} extensions are registered.
22141 */
22142Registry.prototype.hasInlineMacros = function () {
22143  return this['$inline_macros?']()
22144}
22145
22146/**
22147 * Retrieves the Extension proxy objects for all the {{@link Extensions/Preprocessor}} instances stored in this registry.
22148 *
22149 * @memberof Extensions/Registry
22150 * @returns an {array} of Extension proxy objects.
22151 */
22152Registry.prototype.getPreprocessors = function () {
22153  return this.$preprocessors()
22154}
22155
22156/**
22157 * Retrieves the Extension proxy objects for all the {{@link Extensions/TreeProcessor}} instances stored in this registry.
22158 *
22159 * @memberof Extensions/Registry
22160 * @returns an {array} of Extension proxy objects.
22161 */
22162Registry.prototype.getTreeProcessors = function () {
22163  return this.$tree_processors()
22164}
22165
22166/**
22167 * Retrieves the Extension proxy objects for all the {{@link Extensions/IncludeProcessor}} instances stored in this registry.
22168 *
22169 * @memberof Extensions/Registry
22170 * @returns an {array} of Extension proxy objects.
22171 */
22172Registry.prototype.getIncludeProcessors = function () {
22173  return this.$include_processors()
22174}
22175
22176/**
22177 * Retrieves the Extension proxy objects for all the {{@link Extensions/Postprocessor}} instances stored in this registry.
22178 *
22179 * @memberof Extensions/Registry
22180 * @returns an {array} of Extension proxy objects.
22181 */
22182Registry.prototype.getPostprocessors = function () {
22183  return this.$postprocessors()
22184}
22185
22186/**
22187 * Retrieves the Extension proxy objects for all the {{@link Extensions/DocinfoProcessor}} instances stored in this registry.
22188 *
22189 * @memberof Extensions/Registry
22190 * @param location - A {string} for selecting docinfo extensions at a given location (head or footer) (default: undefined)
22191 * @returns an {array} of Extension proxy objects.
22192 */
22193Registry.prototype.getDocinfoProcessors = function (location) {
22194  return this.$docinfo_processors(location)
22195}
22196
22197/**
22198 * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockProcessor}} instances stored in this registry.
22199 *
22200 * @memberof Extensions/Registry
22201 * @returns an {array} of Extension proxy objects.
22202 */
22203Registry.prototype.getBlocks = function () {
22204  return this.block_extensions.$values()
22205}
22206
22207/**
22208 * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockMacroProcessor}} instances stored in this registry.
22209 *
22210 * @memberof Extensions/Registry
22211 * @returns an {array} of Extension proxy objects.
22212 */
22213Registry.prototype.getBlockMacros = function () {
22214  return this.block_macro_extensions.$values()
22215}
22216
22217/**
22218 * Retrieves the Extension proxy objects for all the {{@link Extensions/InlineMacroProcessor}} instances stored in this registry.
22219 *
22220 * @memberof Extensions/Registry
22221 * @returns an {array} of Extension proxy objects.
22222 */
22223Registry.prototype.getInlineMacros = function () {
22224  return this.$inline_macros()
22225}
22226
22227/**
22228 * Get any {{@link Extensions/InlineMacroProcessor}} extensions are registered to handle the specified inline macro name.
22229 *
22230 * @param name - the {string} inline macro name
22231 * @memberof Extensions/Registry
22232 * @returns the Extension proxy object for the {{@link Extensions/InlineMacroProcessor}} that matches the inline macro name or undefined if no match is found.
22233 */
22234Registry.prototype.getInlineMacroFor = function (name) {
22235  const result = this['$registered_for_inline_macro?'](name)
22236  return result === false ? undefined : result
22237}
22238
22239/**
22240 * Get any {{@link Extensions/BlockProcessor}} extensions are registered to handle the specified block name appearing on the specified context.
22241 * @param name - the {string} block name
22242 * @param context - the context of the block: paragraph, open... (optional)
22243 * @memberof Extensions/Registry
22244 * @returns the Extension proxy object for the {{@link Extensions/BlockProcessor}} that matches the block name and context or undefined if no match is found.
22245 */
22246Registry.prototype.getBlockFor = function (name, context) {
22247  if (typeof context === 'undefined') {
22248    const ext = this.$find_block_extension(name)
22249    return ext === Opal.nil ? undefined : ext
22250  }
22251  const result = this['$registered_for_block?'](name, context)
22252  return result === false ? undefined : result
22253}
22254
22255/**
22256 * Get any {{@link Extensions/BlockMacroProcessor}} extensions are registered to handle the specified macro name.
22257 *
22258 * @param name - the {string} macro name
22259 * @memberof Extensions/Registry
22260 * @returns the Extension proxy object for the {{@link Extensions/BlockMacroProcessor}} that matches the macro name or undefined if no match is found.
22261 */
22262Registry.prototype.getBlockMacroFor = function (name) {
22263  const result = this['$registered_for_block_macro?'](name)
22264  return result === false ? undefined : result
22265}
22266
22267/**
22268 * @namespace
22269 * @module Extensions/Processor
22270 */
22271const Processor = Extensions.Processor
22272
22273/**
22274 * The extension will be added to the beginning of the list for that extension type. (default is append).
22275 * @memberof Extensions/Processor
22276 * @deprecated Please use the <code>prefer</pre> function on the {@link Extensions/Registry},
22277 * the {@link Extensions/IncludeProcessor},
22278 * the {@link Extensions/TreeProcessor},
22279 * the {@link Extensions/Postprocessor},
22280 * the {@link Extensions/Preprocessor}
22281 * or the {@link Extensions/DocinfoProcessor}
22282 */
22283Processor.prototype.prepend = function () {
22284  this.$option('position', '>>')
22285}
22286
22287/**
22288 * @memberof Extensions/Processor
22289 */
22290Processor.prototype.process = function (block) {
22291  const handler = {
22292    apply: function (target, thisArg, argumentsList) {
22293      for (let i = 0; i < argumentsList.length; i++) {
22294        // convert all (Opal) Hash arguments to JSON.
22295        if (typeof argumentsList[i] === 'object' && '$$smap' in argumentsList[i]) {
22296          argumentsList[i] = fromHash(argumentsList[i])
22297        }
22298      }
22299      return target.apply(thisArg, argumentsList)
22300    }
22301  }
22302  const blockProxy = new Proxy(block, handler)
22303  return Opal.send(this, 'process', null, toBlock(blockProxy))
22304}
22305
22306/**
22307 * @param {string} name
22308 * @memberof Extensions/Processor
22309 */
22310Processor.prototype.named = function (name) {
22311  return this.$named(name)
22312}
22313
22314/**
22315 * Creates a block and links it to the specified parent.
22316 *
22317 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22318 * @param {string} context
22319 * @param {string|Array<string>} source
22320 * @param {Object|undefined} attrs - A JSON of attributes
22321 * @param {Object|undefined} opts - A JSON of options
22322 * @return {Block}
22323 * @memberof Extensions/Processor
22324 */
22325Processor.prototype.createBlock = function (parent, context, source, attrs, opts) {
22326  return this.$create_block(parent, context, source, toHash(attrs), toHash(opts))
22327}
22328
22329/**
22330 * Creates a list block node and links it to the specified parent.
22331 *
22332 * @param parent - The parent Block (Block, Section, or Document) of this new list block.
22333 * @param {string} context - The list context (e.g., ulist, olist, colist, dlist)
22334 * @param {Object} attrs - An object of attributes to set on this list block
22335 * @returns {List}
22336 * @memberof Extensions/Processor
22337 */
22338Processor.prototype.createList = function (parent, context, attrs) {
22339  return this.$create_list(parent, context, toHash(attrs))
22340}
22341
22342/**
22343 * Creates a list item node and links it to the specified parent.
22344 *
22345 * @param {List} parent - The parent {List} of this new list item block.
22346 * @param {string} text - The text of the list item.
22347 * @returns {ListItem}
22348 * @memberof Extensions/Processor
22349 */
22350Processor.prototype.createListItem = function (parent, text) {
22351  return this.$create_list_item(parent, text)
22352}
22353
22354/**
22355 * Creates an image block node and links it to the specified parent.
22356 * @param {Block|Section|Document} parent - The parent Block of this new image block.
22357 * @param {Object} attrs - A JSON of attributes
22358 * @param {string} attrs.target - the target attribute to set the source of the image.
22359 * @param {string} attrs.alt - the alt attribute to specify an alternative text for the image.
22360 * @param {Object} opts - A JSON of options
22361 * @returns {Block}
22362 * @memberof Extensions/Processor
22363 */
22364Processor.prototype.createImageBlock = function (parent, attrs, opts) {
22365  return this.$create_image_block(parent, toHash(attrs), toHash(opts))
22366}
22367
22368/**
22369 * Creates a paragraph block and links it to the specified parent.
22370 *
22371 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22372 * @param {string|Array<string>} source - The source
22373 * @param {Object|undefined} attrs - An object of attributes to set on this block
22374 * @param {Object|undefined} opts - An object of options to set on this block
22375 * @returns {Block} - a paragraph {Block}
22376 * @memberof Extensions/Processor
22377 */
22378Processor.prototype.createParagraph = function (parent, source, attrs, opts) {
22379  return this.$create_paragraph(parent, source, toHash(attrs), toHash(opts))
22380}
22381
22382/**
22383 * Creates an open block and links it to the specified parent.
22384 *
22385 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22386 * @param {string|Array<string>} source - The source
22387 * @param {Object|undefined} attrs - An object of attributes to set on this block
22388 * @param {Object|undefined} opts - An object of options to set on this block
22389 * @returns {Block} - an open {Block}
22390 * @memberof Extensions/Processor
22391 */
22392Processor.prototype.createOpenBlock = function (parent, source, attrs, opts) {
22393  return this.$create_open_block(parent, source, toHash(attrs), toHash(opts))
22394}
22395
22396/**
22397 * Creates an example block and links it to the specified parent.
22398 *
22399 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22400 * @param {string|Array<string>} source - The source
22401 * @param {Object|undefined} attrs - An object of attributes to set on this block
22402 * @param {Object|undefined} opts - An object of options to set on this block
22403 * @returns {Block} - an example {Block}
22404 * @memberof Extensions/Processor
22405 */
22406Processor.prototype.createExampleBlock = function (parent, source, attrs, opts) {
22407  return this.$create_example_block(parent, source, toHash(attrs), toHash(opts))
22408}
22409
22410/**
22411 * Creates a literal block and links it to the specified parent.
22412 *
22413 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22414 * @param {string|Array<string>} source - The source
22415 * @param {Object|undefined} attrs - An object of attributes to set on this block
22416 * @param {Object|undefined} opts - An object of options to set on this block
22417 * @returns {Block} - a literal {Block}
22418 * @memberof Extensions/Processor
22419 */
22420Processor.prototype.createPassBlock = function (parent, source, attrs, opts) {
22421  return this.$create_pass_block(parent, source, toHash(attrs), toHash(opts))
22422}
22423
22424/**
22425 * Creates a listing block and links it to the specified parent.
22426 *
22427 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22428 * @param {string|Array<string>} source - The source
22429 * @param {Object|undefined} attrs - An object of attributes to set on this block
22430 * @param {Object|undefined} opts - An object of options to set on this block
22431 * @returns {Block} - a listing {Block}
22432 * @memberof Extensions/Processor
22433 */
22434Processor.prototype.createListingBlock = function (parent, source, attrs, opts) {
22435  return this.$create_listing_block(parent, source, toHash(attrs), toHash(opts))
22436}
22437
22438/**
22439 * Creates a literal block and links it to the specified parent.
22440 *
22441 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22442 * @param {string|Array<string>} source - The source
22443 * @param {Object|undefined} attrs - An object of attributes to set on this block
22444 * @param {Object|undefined} opts - An object of options to set on this block
22445 * @returns {Block} - a literal {Block}
22446 * @memberof Extensions/Processor
22447 */
22448Processor.prototype.createLiteralBlock = function (parent, source, attrs, opts) {
22449  return this.$create_literal_block(parent, source, toHash(attrs), toHash(opts))
22450}
22451
22452/**
22453 * Creates an inline anchor and links it to the specified parent.
22454 *
22455 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22456 * @param {string} text - The text
22457 * @param {Object|undefined} opts - An object of options to set on this block
22458 * @returns {Inline} - an {Inline} anchor
22459 * @memberof Extensions/Processor
22460 */
22461Processor.prototype.createAnchor = function (parent, text, opts) {
22462  if (opts && opts.attributes) {
22463    opts.attributes = toHash(opts.attributes)
22464  }
22465  return this.$create_anchor(parent, text, toHash(opts))
22466}
22467
22468/**
22469 * Creates an inline pass and links it to the specified parent.
22470 *
22471 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block.
22472 * @param {string} text - The text
22473 * @param {Object|undefined} opts - An object of options to set on this block
22474 * @returns {Inline} - an {Inline} pass
22475 * @memberof Extensions/Processor
22476 */
22477Processor.prototype.createInlinePass = function (parent, text, opts) {
22478  if (opts && opts.attributes) {
22479    opts.attributes = toHash(opts.attributes)
22480  }
22481  return this.$create_inline_pass(parent, text, toHash(opts))
22482}
22483
22484/**
22485 * Creates an inline node and links it to the specified parent.
22486 *
22487 * @param {Block|Section|Document} parent - The parent Block of this new inline node.
22488 * @param {string} context - The context name
22489 * @param {string} text - The text
22490 * @param {Object|undefined} opts - A JSON of options
22491 * @returns {Inline} - an {Inline} node
22492 * @memberof Extensions/Processor
22493 */
22494Processor.prototype.createInline = function (parent, context, text, opts) {
22495  if (opts && opts.attributes) {
22496    opts.attributes = toHash(opts.attributes)
22497  }
22498  return this.$create_inline(parent, context, text, toHash(opts))
22499}
22500
22501/**
22502 * Parses blocks in the content and attaches the block to the parent.
22503 * @param {AbstractBlock} parent - the parent block
22504 * @param {string|Array<string>} content - the content
22505 * @param {Object|undefined} attrs - an object of attributes
22506 * @returns {AbstractNode} - The parent node into which the blocks are parsed.
22507 * @memberof Extensions/Processor
22508 */
22509Processor.prototype.parseContent = function (parent, content, attrs) {
22510  return this.$parse_content(parent, content, toHash(attrs))
22511}
22512
22513/**
22514 *  Parses the attrlist String into a JSON of attributes
22515 * @param {AbstractBlock} block - the current AbstractBlock or the parent AbstractBlock if there is no current block (used for applying subs)
22516 * @param {string} attrlist - the list of attributes as a String
22517 * @param {Object|undefined} opts - an optional JSON of options to control processing:
22518 * - positional_attributes: an Array of attribute names to map positional arguments to (optional, default: [])
22519 * - sub_attributes: enables attribute substitution on the attrlist argument (optional, default: false)
22520 *
22521 * @returns - a JSON of parsed attributes
22522 * @memberof Extensions/Processor
22523 */
22524Processor.prototype.parseAttributes = function (block, attrlist, opts) {
22525  if (opts && opts.attributes) {
22526    opts.attributes = toHash(opts.attributes)
22527  }
22528  return fromHash(this.$parse_attributes(block, attrlist, toHash(opts)))
22529}
22530
22531/**
22532 * @param {string|Array<string>} value - Name of a positional attribute or an Array of positional attribute names
22533 * @memberof Extensions/Processor
22534 */
22535Processor.prototype.positionalAttributes = function (value) {
22536  return this.$positional_attrs(value)
22537}
22538
22539/**
22540 * Specify how to resolve attributes.
22541 *
22542 * @param {string|Array<string>|Object|boolean} [value] - A specification to resolve attributes.
22543 * @memberof Extensions/Processor
22544 */
22545Processor.prototype.resolveAttributes = function (value) {
22546  if (typeof value === 'object' && !Array.isArray(value)) {
22547    return this.$resolves_attributes(toHash(value))
22548  }
22549  if (arguments.length > 1) {
22550    return this.$resolves_attributes(Array.prototype.slice.call(arguments))
22551  }
22552  if (typeof value === 'undefined') {
22553    // Convert to nil otherwise an exception is thrown at:
22554    // https://github.com/asciidoctor/asciidoctor/blob/0bcb4addc17b307f62975aad203fb556a1bcd8a5/lib/asciidoctor/extensions.rb#L583
22555    //
22556    // if args.size == 1 && !args[0]
22557    //
22558    // In the above Ruby code, args[0] is undefined and Opal will try to call the function "!" on an undefined object.
22559    return this.$resolves_attributes(Opal.nil)
22560  }
22561  return this.$resolves_attributes(value)
22562}
22563
22564/**
22565 * @deprecated Please use the <code>resolveAttributes</pre> function on the {@link Extensions/Processor}.
22566 * @memberof Extensions/Processor
22567 * @see {Processor#resolveAttributes}
22568 */
22569Processor.prototype.resolvesAttributes = Processor.prototype.resolveAttributes
22570
22571/**
22572 * Get the configuration JSON for this processor instance.
22573 * @memberof Extensions/Processor
22574 */
22575Processor.prototype.getConfig = function () {
22576  return fromHash(this.config)
22577}
22578
22579/**
22580 * @memberof Extensions/Processor
22581 */
22582Processor.prototype.option = function (key, value) {
22583  this.$option(key, value)
22584}
22585
22586/**
22587 * @namespace
22588 * @module Extensions/BlockProcessor
22589 */
22590const BlockProcessor = Extensions.BlockProcessor
22591
22592/**
22593 * @param {Object} value - a JSON of default values for attributes
22594 * @memberof Extensions/BlockProcessor
22595 */
22596BlockProcessor.prototype.defaultAttributes = function (value) {
22597  this.$default_attributes(toHash(value))
22598}
22599
22600/**
22601 * @param {string} context - A context name
22602 * @memberof Extensions/BlockProcessor
22603 */
22604BlockProcessor.prototype.onContext = function (context) {
22605  return this.$on_context(context)
22606}
22607
22608/**
22609 * @param {...string} contexts - A list of context names
22610 * @memberof Extensions/BlockProcessor
22611 */
22612BlockProcessor.prototype.onContexts = function (contexts) {
22613  return this.$on_contexts(Array.prototype.slice.call(arguments))
22614}
22615
22616/**
22617 * @returns {string}
22618 * @memberof Extensions/BlockProcessor
22619 */
22620BlockProcessor.prototype.getName = function () {
22621  const name = this.name
22622  return name === Opal.nil ? undefined : name
22623}
22624
22625/**
22626 * @param {string} value
22627 * @memberof Extensions/BlockProcessor
22628 */
22629BlockProcessor.prototype.parseContentAs = function (value) {
22630  this.$parse_content_as(value)
22631}
22632
22633/**
22634 * @namespace
22635 * @module Extensions/BlockMacroProcessor
22636 */
22637const BlockMacroProcessor = Extensions.BlockMacroProcessor
22638
22639/**
22640 * @param {Object} value - a JSON of default values for attributes
22641 * @memberof Extensions/BlockMacroProcessor
22642 */
22643BlockMacroProcessor.prototype.defaultAttributes = function (value) {
22644  this.$default_attributes(toHash(value))
22645}
22646
22647/**
22648 * @returns {string} - the block macro name
22649 * @memberof Extensions/BlockMacroProcessor
22650 */
22651BlockMacroProcessor.prototype.getName = function () {
22652  const name = this.name
22653  return name === Opal.nil ? undefined : name
22654}
22655
22656/**
22657 * @param {string} value
22658 * @memberof Extensions/BlockMacroProcessor
22659 */
22660BlockMacroProcessor.prototype.parseContentAs = function (value) {
22661  this.$parse_content_as(value)
22662}
22663
22664/**
22665 * @namespace
22666 * @module Extensions/InlineMacroProcessor
22667 */
22668const InlineMacroProcessor = Extensions.InlineMacroProcessor
22669
22670/**
22671 * @param {Object} value - a JSON of default values for attributes
22672 * @memberof Extensions/InlineMacroProcessor
22673 */
22674InlineMacroProcessor.prototype.defaultAttributes = function (value) {
22675  this.$default_attributes(toHash(value))
22676}
22677
22678/**
22679 * @returns {string} - the inline macro name
22680 * @memberof Extensions/InlineMacroProcessor
22681 */
22682InlineMacroProcessor.prototype.getName = function () {
22683  const name = this.name
22684  return name === Opal.nil ? undefined : name
22685}
22686
22687/**
22688 * @param {string} value
22689 * @memberof Extensions/InlineMacroProcessor
22690 */
22691InlineMacroProcessor.prototype.parseContentAs = function (value) {
22692  this.$parse_content_as(value)
22693}
22694
22695/**
22696 * @param {string} value
22697 * @memberof Extensions/InlineMacroProcessor
22698 */
22699InlineMacroProcessor.prototype.matchFormat = function (value) {
22700  this.$match_format(value)
22701}
22702
22703/**
22704 * @param {RegExp} value
22705 * @memberof Extensions/InlineMacroProcessor
22706 */
22707InlineMacroProcessor.prototype.match = function (value) {
22708  this.$match(value)
22709}
22710
22711/**
22712 * @namespace
22713 * @module Extensions/IncludeProcessor
22714 */
22715const IncludeProcessor = Extensions.IncludeProcessor
22716
22717/**
22718 * @memberof Extensions/IncludeProcessor
22719 */
22720IncludeProcessor.prototype.handles = function (block) {
22721  return Opal.send(this, 'handles?', null, toBlock(block))
22722}
22723
22724/**
22725 * @memberof Extensions/IncludeProcessor
22726 */
22727IncludeProcessor.prototype.prefer = function () {
22728  this.$prefer()
22729}
22730
22731/**
22732 * @namespace
22733 * @module Extensions/TreeProcessor
22734 */
22735const TreeProcessor = Extensions.TreeProcessor
22736
22737/**
22738 * @memberof Extensions/TreeProcessor
22739 */
22740TreeProcessor.prototype.prefer = function () {
22741  this.$prefer()
22742}
22743
22744/**
22745 * @namespace
22746 * @module Extensions/Postprocessor
22747 */
22748const Postprocessor = Extensions.Postprocessor
22749
22750/**
22751 * @memberof Extensions/Postprocessor
22752 */
22753Postprocessor.prototype.prefer = function () {
22754  this.$prefer()
22755}
22756
22757/**
22758 * @namespace
22759 * @module Extensions/Preprocessor
22760 */
22761const Preprocessor = Extensions.Preprocessor
22762
22763/**
22764 * @memberof Extensions/Preprocessor
22765 */
22766Preprocessor.prototype.prefer = function () {
22767  this.$prefer()
22768}
22769
22770/**
22771 * @namespace
22772 * @module Extensions/DocinfoProcessor
22773 */
22774const DocinfoProcessor = Extensions.DocinfoProcessor
22775
22776/**
22777 * @memberof Extensions/DocinfoProcessor
22778 */
22779DocinfoProcessor.prototype.prefer = function () {
22780  this.$prefer()
22781}
22782
22783/**
22784 * @param {string} value - The docinfo location ("head", "header" or "footer")
22785 * @memberof Extensions/DocinfoProcessor
22786 */
22787DocinfoProcessor.prototype.atLocation = function (value) {
22788  this.$at_location(value)
22789}
22790
22791function initializeProcessorClass (superclassName, className, functions) {
22792  const superClass = Opal.const_get_qualified(Extensions, superclassName)
22793  return initializeClass(superClass, className, functions, {
22794    'handles?': function () {
22795      return true
22796    }
22797  })
22798}
22799
22800// Postprocessor
22801
22802/**
22803 * Create a postprocessor
22804 * @description this API is experimental and subject to change
22805 * @memberof Extensions
22806 */
22807Extensions.createPostprocessor = function (name, functions) {
22808  if (arguments.length === 1) {
22809    functions = name
22810    name = null
22811  }
22812  return initializeProcessorClass('Postprocessor', name, functions)
22813}
22814
22815/**
22816 * Create and instantiate a postprocessor
22817 * @description this API is experimental and subject to change
22818 * @memberof Extensions
22819 */
22820Extensions.newPostprocessor = function (name, functions) {
22821  if (arguments.length === 1) {
22822    functions = name
22823    name = null
22824  }
22825  return this.createPostprocessor(name, functions).$new()
22826}
22827
22828// Preprocessor
22829
22830/**
22831 * Create a preprocessor
22832 * @description this API is experimental and subject to change
22833 * @memberof Extensions
22834 */
22835Extensions.createPreprocessor = function (name, functions) {
22836  if (arguments.length === 1) {
22837    functions = name
22838    name = null
22839  }
22840  return initializeProcessorClass('Preprocessor', name, functions)
22841}
22842
22843/**
22844 * Create and instantiate a preprocessor
22845 * @description this API is experimental and subject to change
22846 * @memberof Extensions
22847 */
22848Extensions.newPreprocessor = function (name, functions) {
22849  if (arguments.length === 1) {
22850    functions = name
22851    name = null
22852  }
22853  return this.createPreprocessor(name, functions).$new()
22854}
22855
22856// Tree Processor
22857
22858/**
22859 * Create a tree processor
22860 * @description this API is experimental and subject to change
22861 * @memberof Extensions
22862 */
22863Extensions.createTreeProcessor = function (name, functions) {
22864  if (arguments.length === 1) {
22865    functions = name
22866    name = null
22867  }
22868  return initializeProcessorClass('TreeProcessor', name, functions)
22869}
22870
22871/**
22872 * Create and instantiate a tree processor
22873 * @description this API is experimental and subject to change
22874 * @memberof Extensions
22875 */
22876Extensions.newTreeProcessor = function (name, functions) {
22877  if (arguments.length === 1) {
22878    functions = name
22879    name = null
22880  }
22881  return this.createTreeProcessor(name, functions).$new()
22882}
22883
22884// Include Processor
22885
22886/**
22887 * Create an include processor
22888 * @description this API is experimental and subject to change
22889 * @memberof Extensions
22890 */
22891Extensions.createIncludeProcessor = function (name, functions) {
22892  if (arguments.length === 1) {
22893    functions = name
22894    name = null
22895  }
22896  return initializeProcessorClass('IncludeProcessor', name, functions)
22897}
22898
22899/**
22900 * Create and instantiate an include processor
22901 * @description this API is experimental and subject to change
22902 * @memberof Extensions
22903 */
22904Extensions.newIncludeProcessor = function (name, functions) {
22905  if (arguments.length === 1) {
22906    functions = name
22907    name = null
22908  }
22909  return this.createIncludeProcessor(name, functions).$new()
22910}
22911
22912// Docinfo Processor
22913
22914/**
22915 * Create a Docinfo processor
22916 * @description this API is experimental and subject to change
22917 * @memberof Extensions
22918 */
22919Extensions.createDocinfoProcessor = function (name, functions) {
22920  if (arguments.length === 1) {
22921    functions = name
22922    name = null
22923  }
22924  return initializeProcessorClass('DocinfoProcessor', name, functions)
22925}
22926
22927/**
22928 * Create and instantiate a Docinfo processor
22929 * @description this API is experimental and subject to change
22930 * @memberof Extensions
22931 */
22932Extensions.newDocinfoProcessor = function (name, functions) {
22933  if (arguments.length === 1) {
22934    functions = name
22935    name = null
22936  }
22937  return this.createDocinfoProcessor(name, functions).$new()
22938}
22939
22940// Block Processor
22941
22942/**
22943 * Create a block processor
22944 * @description this API is experimental and subject to change
22945 * @memberof Extensions
22946 */
22947Extensions.createBlockProcessor = function (name, functions) {
22948  if (arguments.length === 1) {
22949    functions = name
22950    name = null
22951  }
22952  return initializeProcessorClass('BlockProcessor', name, functions)
22953}
22954
22955/**
22956 * Create and instantiate a block processor
22957 * @description this API is experimental and subject to change
22958 * @memberof Extensions
22959 */
22960Extensions.newBlockProcessor = function (name, functions) {
22961  if (arguments.length === 1) {
22962    functions = name
22963    name = null
22964  }
22965  return this.createBlockProcessor(name, functions).$new()
22966}
22967
22968// Inline Macro Processor
22969
22970/**
22971 * Create an inline macro processor
22972 * @description this API is experimental and subject to change
22973 * @memberof Extensions
22974 */
22975Extensions.createInlineMacroProcessor = function (name, functions) {
22976  if (arguments.length === 1) {
22977    functions = name
22978    name = null
22979  }
22980  return initializeProcessorClass('InlineMacroProcessor', name, functions)
22981}
22982
22983/**
22984 * Create and instantiate an inline macro processor
22985 * @description this API is experimental and subject to change
22986 * @memberof Extensions
22987 */
22988Extensions.newInlineMacroProcessor = function (name, functions) {
22989  if (arguments.length === 1) {
22990    functions = name
22991    name = null
22992  }
22993  return this.createInlineMacroProcessor(name, functions).$new()
22994}
22995
22996// Block Macro Processor
22997
22998/**
22999 * Create a block macro processor
23000 * @description this API is experimental and subject to change
23001 * @memberof Extensions
23002 */
23003Extensions.createBlockMacroProcessor = function (name, functions) {
23004  if (arguments.length === 1) {
23005    functions = name
23006    name = null
23007  }
23008  return initializeProcessorClass('BlockMacroProcessor', name, functions)
23009}
23010
23011/**
23012 * Create and instantiate a block macro processor
23013 * @description this API is experimental and subject to change
23014 * @memberof Extensions
23015 */
23016Extensions.newBlockMacroProcessor = function (name, functions) {
23017  if (arguments.length === 1) {
23018    functions = name
23019    name = null
23020  }
23021  return this.createBlockMacroProcessor(name, functions).$new()
23022}
23023
23024
23025var ASCIIDOCTOR_JS_VERSION = '3.0.2';
23026
23027  /**
23028   * Get Asciidoctor.js version number.
23029   *
23030   * @memberof Asciidoctor
23031   * @returns {string} - returns the version number of Asciidoctor.js.
23032   */
23033  Asciidoctor.prototype.getVersion = function () {
23034    return ASCIIDOCTOR_JS_VERSION
23035  }
23036  return Opal.Asciidoctor
23037}
23038