1'use strict'; 2 3var module$1 = require('module'); 4var url = require('url'); 5var path = require('path'); 6var fs = require('fs'); 7var Opal = require('@asciidoctor/opal-runtime'); 8var unxhr = require('unxhr'); 9 10/* global Asciidoctor, ASCIIDOCTOR_JS_VERSION */ 11 12const __path__ = path; 13const __XMLHttpRequest__ = unxhr.XMLHttpRequest; 14const __asciidoctorDistDir__ = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('asciidoctor-node.cjs', document.baseURI).href)))); 15const __require__ = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('asciidoctor-node.cjs', document.baseURI).href))); 16 17function asciidoctorNode (moduleConfig) { 18Opal.modules["asciidoctor/js/opal_ext/electron/io"] = function(Opal) {/* Generated by Opal 1.7.3 */ 19 var $gvars = Opal.gvars, $send = Opal.send, $a, nil = Opal.nil; 20 if ($gvars.stdout == null) $gvars.stdout = nil; 21 if ($gvars.stderr == null) $gvars.stderr = nil; 22 23 Opal.add_stubs('write_proc='); 24 25 $gvars.stdout['$write_proc='](function(s){console.log(s);}); 26 return ($a = [function(s){console.error(s);}], $send($gvars.stderr, 'write_proc=', $a), $a[$a.length - 1]); 27}; 28 29Opal.modules["asciidoctor/js/opal_ext/node"] = function(Opal) {/* Generated by Opal 1.7.3 */ 30 var $const_set = Opal.const_set, $eqeq = Opal.eqeq, self = Opal.top, $nesting = [], $$ = Opal.$r($nesting); Opal.nil; 31 32 Opal.add_stubs('==,require'); 33 34 35 var isElectron = typeof navigator === 'object' && typeof navigator.userAgent === 'string' && typeof navigator.userAgent.indexOf('Electron') !== -1, 36 platform, 37 engine, 38 framework, 39 ioModule; 40 41 if (typeof moduleConfig === 'object' && typeof moduleConfig.runtime === 'object') { 42 var runtime = moduleConfig.runtime; 43 platform = runtime.platform; 44 engine = runtime.engine; 45 framework = runtime.framework; 46 ioModule = runtime.ioModule; 47 } 48 49 ioModule = ioModule || 'node'; 50 platform = platform || 'node'; 51 engine = engine || 'v8'; 52 if (isElectron) { 53 framework = framework || 'electron'; 54 } else { 55 framework = framework || ''; 56 } 57 $const_set($nesting[0], 'JAVASCRIPT_IO_MODULE', ioModule); 58 $const_set($nesting[0], 'JAVASCRIPT_PLATFORM', platform); 59 $const_set($nesting[0], 'JAVASCRIPT_ENGINE', engine); 60 $const_set($nesting[0], 'JAVASCRIPT_FRAMEWORK', framework); 61 if ($eqeq($$('JAVASCRIPT_FRAMEWORK'), "electron")) { 62 self.$require("asciidoctor/js/opal_ext/electron/io"); 63 } 64// Load Opal modules 65Opal.load("pathname"); 66Opal.load("nodejs"); 67}; 68 69Opal.modules["asciidoctor/js/asciidoctor_ext/node/abstract_node"] = function(Opal) {/* Generated by Opal 1.7.3 */ 70 var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $nesting = []; Opal.nil; 71 72 return (function($base, $parent_nesting) { 73 var self = $module($base, 'Asciidoctor'); 74 75 var $nesting = [self].concat($parent_nesting); 76 77 return (function($base, $super) { 78 var self = $klass($base, $super, 'AbstractNode'); 79 80 81 return $def(self, '$generate_data_uri_from_uri', function $$generate_data_uri_from_uri(image_uri, cache_uri) { 82 var self = this; 83 84 var contentType = ''; 85 var b64encoded = ''; 86 var status = -1; 87 88 try { 89 var xhr = new __XMLHttpRequest__(); 90 xhr.open('GET', image_uri, false); 91 xhr.responseType = 'arraybuffer'; 92 xhr.addEventListener('load', function() { 93 status = this.status; 94 if (status === 200) { 95 var arrayBuffer = this.response; 96 b64encoded = Buffer.from(arrayBuffer).toString('base64'); 97 contentType = this.getResponseHeader('content-type'); 98 } 99 }); 100 xhr.send(null); 101 } 102 catch (e) { 103 // something bad happened! 104 status = 0; 105 } 106 if (status === 404 || (status === 0 && !b64encoded)) { 107 self.$logger().$warn('could not retrieve image data from URI: ' + image_uri); 108 return image_uri 109 } 110 return 'data:' + contentType + ';base64,' + b64encoded 111 ; 112 }, -2) 113 })($nesting[0], null) 114 })($nesting[0], $nesting) 115}; 116 117Opal.modules["asciidoctor/js/asciidoctor_ext/node/open_uri"] = function(Opal) {/* Generated by Opal 1.7.3 */ 118 var $module = Opal.module, $slice = Opal.slice, $defs = Opal.defs, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; 119 120 Opal.add_stubs('require,new,<<,rewind'); 121 122 self.$require("stringio"); 123 return (function($base, $parent_nesting) { 124 var self = $module($base, 'OpenURI'); 125 126 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 127 128 return $defs($$('OpenURI'), '$open_uri', function $$open_uri(uri, $a) { 129 var $yield = $$open_uri.$$p || nil, io = nil, data = nil; 130 131 $$open_uri.$$p = null; 132 133 $slice(arguments, 1); 134 io = $$$('StringIO').$new(); 135 data = ""; 136 137 var contentType = ''; 138 var status = -1; 139 140 try { 141 var xhr = new __XMLHttpRequest__(); 142 xhr.open('GET', uri, false); 143 xhr.responseType = 'text'; 144 xhr.addEventListener('load', function() { 145 status = this.status; 146 if (status === 200) { 147 data = this.responseText; 148 contentType = this.getResponseHeader('content-type'); 149 } 150 }); 151 xhr.send(null); 152 } 153 catch (e) { 154 // something bad happened! 155 status = 0; 156 } 157 if (status === 404 || (status === 0 && !data)) { 158 throw $$('IOError').$new('No such file or directory: ' + uri) 159 } 160 io['$<<'](data); 161 io.$rewind(); 162 if (($yield !== nil)) { 163 return Opal.yield1($yield, io); 164 } else { 165 return io 166 } }, -2) 167 })($nesting[0], $nesting); 168}; 169 170Opal.modules["asciidoctor/js/asciidoctor_ext/node/stylesheet"] = function(Opal) {/* Generated by Opal 1.7.3 */ 171 var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; 172 173 Opal.add_stubs('rstrip,read,join'); 174 return (function($base, $parent_nesting) { 175 var self = $module($base, 'Asciidoctor'); 176 177 var $nesting = [self].concat($parent_nesting); 178 179 return (function($base, $super) { 180 var self = $klass($base, $super, 'Stylesheets'); 181 182 var $proto = self.$$prototype; 183 184 $proto.primary_stylesheet_data = nil; 185 return $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() { 186 var self = this, stylesheets_dir = nil, $ret_or_1 = nil; 187 188 189 if ($truthy(__path__.basename(__asciidoctorDistDir__) === 'node' && __path__.basename(__path__.dirname(__asciidoctorDistDir__)) === 'dist')) { 190 stylesheets_dir = __path__.join(__path__.dirname(__asciidoctorDistDir__), 'css'); 191 } else { 192 stylesheets_dir = __path__.join(__asciidoctorDistDir__, 'css'); 193 } 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()))); 194 }) 195 })($nesting[0], null) 196 })($nesting[0], $nesting) 197}; 198 199Opal.modules["asciidoctor/js/asciidoctor_ext/node/template"] = function(Opal) {/* Generated by Opal 1.7.3 */ 200 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.$$$; 201 202 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'); 203 return (function($base, $parent_nesting) { 204 var self = $module($base, 'Asciidoctor'); 205 206 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 207 208 return (function($base, $super, $parent_nesting) { 209 var self = $klass($base, $super, 'TemplateConverter'); 210 211 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 212 213 $proto.templates = $proto.caches = $proto.backend = $proto.engine = $proto.template_dirs = nil; 214 215 self.caches = $hash2(["scans", "templates"], {"scans": $hash2([], {}), "templates": $hash2([], {})}); 216 $defs(self, '$caches', $return_ivar("caches")); 217 $defs(self, '$clear_caches', function $$clear_caches() { 218 var self = this; 219 if (self.caches == null) self.caches = nil; 220 221 222 if ($truthy(self.caches['$[]']("scans"))) { 223 self.caches['$[]']("scans").$clear(); 224 } if ($truthy(self.caches['$[]']("templates"))) { 225 return self.caches['$[]']("templates").$clear() 226 } else { 227 return nil 228 } }); 229 230 $def(self, '$initialize', function $$initialize(backend, template_dirs, opts) { 231 var self = this, $ret_or_1 = nil; 232 233 234 if (opts == null) opts = $hash2([], {}); 235 self.backend = backend; 236 self.templates = $hash2([], {}); 237 self.template_dirs = template_dirs; 238 self.engine = opts['$[]']("template_engine"); 239 self.engine_options = ($truthy(($ret_or_1 = opts['$[]']("template_engine_options"))) ? ($ret_or_1) : ($hash2([], {}))); 240 if ($eqeqeq(true, ($ret_or_1 = opts['$[]']("template_cache")))) { 241 self.caches = self.$class().$caches(); 242 } else if ($eqeqeq($$$('Hash'), $ret_or_1)) { 243 self.caches = opts['$[]']("template_cache"); 244 } else { 245 self.caches = $hash2([], {}); 246 } return self.$scan(); 247 }, -3); 248 249 $def(self, '$convert', function $$convert(node, template_name, opts) { 250 var self = this, template = nil, $ret_or_1 = nil, helpers_ctx = nil; 251 252 253 if (template_name == null) template_name = nil; 254 if (opts == null) opts = nil; 255 if (!$truthy((template = self.templates['$[]']((template_name = ($truthy(($ret_or_1 = template_name)) ? ($ret_or_1) : (node.$node_name()))))))) { 256 self.$raise("Could not find a custom template to handle transform: " + (template_name)); 257 } helpers_ctx = ($truthy(($ret_or_1 = self.templates['$[]']("helpers.js"))) ? (self.templates['$[]']("helpers.js").$ctx()) : ($ret_or_1)); 258 if ($eqeq(template_name, "document")) { 259 return (template.render({node: node, opts: fromHash(opts), helpers: helpers_ctx})).$strip() 260 } else { 261 return (template.render({node: node, opts: fromHash(opts), helpers: helpers_ctx})).$rstrip() 262 } }, -2); 263 264 $def(self, '$handles?', function $TemplateConverter_handles$ques$1(name) { 265 var self = this; 266 267 return self.templates['$key?'](name) 268 }); 269 270 $def(self, '$templates', function $$templates() { 271 var self = this; 272 273 return self.templates.$merge() 274 }); 275 276 $def(self, '$register', function $$register(name, template) { 277 var $a, $b, self = this, template_cache = nil, $ret_or_1 = nil; 278 279 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]) 280 }); 281 self.$private(); 282 283 $def(self, '$scan', function $$scan() { 284 var self = this, path_resolver = nil, backend = nil, engine = nil; 285 286 287 path_resolver = $$('PathResolver').$new(); 288 backend = self.backend; 289 engine = self.engine; 290 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; 291 if (self.caches == null) self.caches = nil; 292 if (self.templates == null) self.templates = nil; 293 294 295 if (template_dir == null) template_dir = nil; 296 if (!$truthy($$$('File')['$directory?']((template_dir = path_resolver.$system_path(template_dir))))) { 297 return nil 298 } if ($truthy(engine)) { 299 300 file_pattern = "*." + (engine); 301 if ($truthy($$$('File')['$directory?']((engine_dir = "" + (template_dir) + "/" + (engine))))) { 302 template_dir = engine_dir; 303 } } else { 304 file_pattern = "*"; 305 } if ($truthy($$$('File')['$directory?']((backend_dir = "" + (template_dir) + "/" + (backend))))) { 306 template_dir = backend_dir; 307 } pattern = "" + (template_dir) + "/" + (file_pattern); 308 if ($truthy((scan_cache = self.caches['$[]']("scans")))) { 309 310 template_cache = self.caches['$[]']("templates"); 311 if (!$truthy((templates = scan_cache['$[]'](pattern)))) { 312 templates = ($a = [pattern, self.$scan_dir(template_dir, pattern, template_cache)], $send(scan_cache, '[]=', $a), $a[$a.length - 1]); 313 } $send(templates, 'each', [], function $$3(name, template){var $b, $c, self = $$3.$$s == null ? this : $$3.$$s; 314 if (self.templates == null) self.templates = nil; 315 316 317 if (name == null) name = nil; 318 if (template == null) template = nil; 319 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}); 320 } else { 321 self.templates.$update(self.$scan_dir(template_dir, pattern, self.caches['$[]']("templates"))); 322 } return nil;}, {$$s: self}); 323 }); 324 325 $def(self, '$node_require', function $$node_require(module_name) { 326 327 328 try { 329 return __require__(module_name) 330 } 331 catch (e) { 332 throw $$('IOError').$new("Unable to require the module '" + (module_name) + "', please make sure that the module is installed.") 333 } 334 335 }); 336 return $def(self, '$scan_dir', function $$scan_dir(template_dir, pattern, template_cache) { 337 var $a, self = this, result = nil, helpers = nil; 338 339 340 if (template_cache == null) template_cache = nil; 341 $a = [$hash2([], {}), nil], (result = $a[0]), (helpers = $a[1]); 342 var enginesContext = {}; 343 $send($send($$$('Dir').$glob(pattern), 'select', [], function $$4(match){ 344 345 if (match == null) match = nil; 346 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; 347 348 349 if (file == null) file = nil; 350 if (($eqeq((basename = $$$('File').$basename(file)), "helpers.js") || ($eqeq((basename = $$$('File').$basename(file)), "helpers.cjs")))) { 351 352 helpers = file; 353 return nil; 354 } else if ($truthy($rb_lt((path_segments = basename.$split(".")).$size(), 2))) { 355 return nil 356 } if ($eqeq((name = path_segments['$[]'](0)), "block_ruler")) { 357 name = "thematic_break"; 358 } else if ($truthy(name['$start_with?']("block_"))) { 359 name = name.$slice(6, name.$length()); 360 } if (!($truthy(template_cache) && ($truthy((template = template_cache['$[]'](file)))))) { 361 362 extsym = path_segments['$[]'](-1).$to_sym(); 363 364 switch (extsym) { 365 case "nunjucks": 366 case "njk": 367 368 nunjucks = self.$node_require("nunjucks"); 369 370 var env; 371 if (enginesContext.nunjucks && enginesContext.nunjucks.environment) { 372 env = enginesContext.nunjucks.environment; 373 } else { 374 var opts = self.engine_options['nunjucks'] || {}; 375 delete opts.web; // unsupported option 376 env = nunjucks.configure(template_dir, opts); 377 enginesContext.nunjucks = { environment: env }; 378 } 379 template = Object.assign(nunjucks.compile(fs.readFileSync(file, 'utf8'), env), { '$file': function() { return file } }) 380 ; 381 break; 382 case "handlebars": 383 case "hbs": 384 385 handlebars = self.$node_require("handlebars"); 386 387 var env; 388 var opts = self.engine_options['handlebars'] || {}; 389 if (enginesContext.handlebars && enginesContext.handlebars.environment) { 390 env = enginesContext.handlebars.environment; 391 } else { 392 env = handlebars.create(); 393 enginesContext.handlebars = { environment: env }; 394 } 395 template = { render: env.compile(fs.readFileSync(file, 'utf8'), opts), '$file': function() { return file } } 396 ; 397 break; 398 case "ejs": 399 400 ejs = self.$node_require("ejs"); 401 402 var opts = self.engine_options['ejs'] || {}; 403 opts.filename = file; 404 // unsupported options 405 delete opts.async; 406 delete opts.client; 407 template = { render: ejs.compile(fs.readFileSync(file, 'utf8'), opts), '$file': function() { return file } } 408 ; 409 break; 410 case "pug": 411 412 pug = self.$node_require("pug"); 413 414 var opts = self.engine_options['pug'] || {}; 415 opts.filename = file; 416 template = { render: pug.compileFile(file, opts), '$file': function() { return file } } 417 ; 418 break; 419 case "js": 420 case "cjs": 421 template = { render: __require__(file), '$file': function() { return file } }; 422 break; 423 default: 424 425 var registry = Opal.Asciidoctor.TemplateEngine.registry; 426 var templateEngine = registry[extsym]; 427 if (templateEngine && typeof templateEngine.compile === 'function') { 428 template = Object.assign(templateEngine.compile(file, name), { '$file': function() { return file } }); 429 } else { 430 template = undefined; 431 } 432 433 } } if ($truthy(template)) { 434 return ($b = [name, template], $send(result, '[]=', $b), $b[$b.length - 1]) 435 } else { 436 return nil 437 }}, {$$s: self}); 438 if ((($truthy(helpers) || ($truthy($$$('File')['$file?']((helpers = "" + (template_dir) + "/helpers.js"))))) || ($truthy($$$('File')['$file?']((helpers = "" + (template_dir) + "/helpers.cjs")))))) { 439 440 441 var ctx = __require__(helpers); 442 if (typeof ctx.configure === 'function') { 443 ctx.configure(enginesContext); 444 } 445 result['$[]=']("helpers.js", { '$file': function() { return helpers }, $ctx: function() { return ctx } }); 446 } return result; 447 }, -3); 448 })($$('Converter'), $$$($$('Converter'), 'Base'), $nesting) 449 })($nesting[0], $nesting) 450}; 451 452Opal.modules["asciidoctor/js/asciidoctor_ext/node"] = function(Opal) {/* Generated by Opal 1.7.3 */ 453 var self = Opal.top; Opal.nil; 454 455 Opal.add_stubs('require'); 456 457 self.$require("asciidoctor/js/asciidoctor_ext/node/abstract_node"); 458 self.$require("asciidoctor/js/asciidoctor_ext/node/open_uri"); 459 self.$require("asciidoctor/js/asciidoctor_ext/node/stylesheet"); 460 return self.$require("asciidoctor/js/asciidoctor_ext/node/template"); 461}; 462 463Opal.modules["set"] = Opal.return_val(Opal.nil); /* Generated by Opal 1.7.3 */ 464 465Opal.modules["asciidoctor/js/opal_ext/kernel"] = function(Opal) {/* Generated by Opal 1.7.3 */ 466 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; 467 468 Opal.add_stubs('new'); 469 return (function($base, $parent_nesting) { 470 var self = $module($base, 'Kernel'); 471 472 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 473 474 475 476 $def(self, '$open', function $$open(path, $a) { 477 var $post_args, rest, $yield = $$open.$$p || nil, file = nil; 478 479 $$open.$$p = null; 480 481 $post_args = $slice(arguments, 1); 482 rest = $post_args; 483 file = $send($$('File'), 'new', [path].concat($to_a(rest))); 484 if (($yield !== nil)) { 485 return Opal.yield1($yield, file); 486 } else { 487 return file 488 } }, -2); 489 return $def(self, '$__dir__', $return_val("")); 490 })($nesting[0], $nesting) 491}; 492 493Opal.modules["asciidoctor/js/opal_ext/file"] = function(Opal) {/* Generated by Opal 1.7.3 */ 494 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; 495 496 Opal.add_stubs('attr_reader,delete,gsub,read,size,to_enum,chomp,each_line,readlines,split'); 497 498 (function($base, $super, $parent_nesting) { 499 var self = $klass($base, $super, 'File'); 500 501 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 502 503 $proto.eof = $proto.path = nil; 504 505 self.$attr_reader("eof"); 506 self.$attr_reader("lineno"); 507 self.$attr_reader("path"); 508 509 $def(self, '$initialize', function $$initialize(path, flags) { 510 var self = this, encoding_flag_regexp = nil; 511 512 513 if (flags == null) flags = "r"; 514 self.path = path; 515 self.contents = nil; 516 self.eof = false; 517 self.lineno = 0; 518 flags = flags.$delete("b"); 519 encoding_flag_regexp = /:(.*)/; 520 flags = flags.$gsub(encoding_flag_regexp, ""); 521 return (self.flags = flags); 522 }, -2); 523 524 $def(self, '$read', function $$read() { 525 var self = this, res = nil; 526 527 if ($truthy(self.eof)) { 528 return "" 529 } else { 530 531 res = $$('File').$read(self.path); 532 self.eof = true; 533 self.lineno = res.$size(); 534 return res; 535 } 536 }); 537 538 $def(self, '$each_line', function $$each_line(separator) { 539 var block = $$each_line.$$p || nil, self = this, lines = nil; 540 if ($gvars["/"] == null) $gvars["/"] = nil; 541 542 $$each_line.$$p = null; 543 if (separator == null) separator = $gvars["/"]; 544 if ($truthy(self.eof)) { 545 return ((block !== nil) ? (self) : ([].$to_enum())) 546 } if ((block !== nil)) { 547 548 lines = $$('File').$read(self.path); 549 550 self.eof = false; 551 self.lineno = 0; 552 var chomped = lines.$chomp(), 553 trailing = lines.length != chomped.length, 554 splitted = chomped.split(separator); 555 for (var i = 0, length = splitted.length; i < length; i++) { 556 self.lineno += 1; 557 if (i < length - 1 || trailing) { 558 Opal.yield1(block, splitted[i] + separator); 559 } 560 else { 561 Opal.yield1(block, splitted[i]); 562 } 563 } 564 self.eof = true; 565 return self; 566 } else { 567 return self.$read().$each_line() 568 } }, -1); 569 570 $def(self, '$readlines', function $$readlines() { 571 var self = this; 572 573 return $$('File').$readlines(self.path) 574 }); 575 return (function(self, $parent_nesting) { 576 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 577 578 579 580 $def(self, '$readlines', function $$readlines(path, separator) { 581 var content = nil; 582 if ($gvars["/"] == null) $gvars["/"] = nil; 583 584 585 if (separator == null) separator = $gvars["/"]; 586 content = $$('File').$read(path); 587 return content.$split(separator); 588 }, -2); 589 590 $def(self, '$file?', $return_val(true)); 591 592 $def(self, '$readable?', $return_val(true)); 593 return $def(self, '$read', $return_val("")); 594 })(Opal.get_singleton_class(self), $nesting); 595 })($nesting[0], null, $nesting); 596 return (function($base, $super, $parent_nesting) { 597 var self = $klass($base, $super, 'IO'); 598 599 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 600 601 return $defs(self, '$read', function $$read(path) { 602 603 return $$('File').$read(path) 604 }) 605 })($nesting[0], null, $nesting); 606}; 607 608Opal.modules["asciidoctor/js/opal_ext/match_data"] = function(Opal) {/* Generated by Opal 1.7.3 */ 609 var $klass = Opal.klass, $send = Opal.send, $def = Opal.def, $nesting = [], nil = Opal.nil; 610 611 Opal.add_stubs('[]='); 612 return (function($base, $super) { 613 var self = $klass($base, $super, 'MatchData'); 614 615 var $proto = self.$$prototype; 616 617 $proto.matches = nil; 618 return $def(self, '$[]=', function $MatchData_$$$eq$1(idx, val) { 619 var $a, self = this; 620 621 return ($a = [idx, val], $send(self.matches, '[]=', $a), $a[$a.length - 1]) 622 }) 623 })($nesting[0], null) 624}; 625 626Opal.modules["asciidoctor/js/opal_ext/string"] = function(Opal) {/* Generated by Opal 1.7.3 */ 627 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; 628 629 Opal.add_stubs('method_defined?,<,length,bytes,to_s,byteslice,limit_bytesize,>=,==,-,_original_byteslice,unpack,_original_unpack'); 630 return (function($base, $super) { 631 var self = $klass($base, $super, 'String'); 632 633 634 635 if (!$truthy(self['$method_defined?']("limit_bytesize"))) { 636 637 $def(self, '$limit_bytesize', function $$limit_bytesize(size) { 638 var self = this, result = nil; 639 640 641 if (!$truthy($rb_lt(size, self.$bytes().$length()))) { 642 return self.$to_s() 643 } result = self.$byteslice(0, size); 644 return result.$to_s(); 645 }); 646 } if (!$truthy(self['$method_defined?']("limit"))) { 647 $alias(self, "limit", "limit_bytesize"); 648 } $alias(self, "_original_byteslice", "byteslice"); 649 650 $def(self, '$byteslice', function $$byteslice(index, length) { 651 var self = this; 652 653 654 if (length == null) length = 1; 655 if ((($eqeq(index, 3) && ($truthy($rb_ge(length, index)))) && ($truthy(self.charCodeAt() === 65279)))) { 656 return (self.substr(1)).$byteslice(0, $rb_minus(length, 3)) 657 } else { 658 return self.$_original_byteslice(index, length) 659 } }, -2); 660 $alias(self, "_original_unpack", "unpack"); 661 return $def(self, '$unpack', function $$unpack(format) { 662 var self = this; 663 664 if ($eqeq(format, "C3")) { 665 if ($truthy(self.charCodeAt() === 65279)) { 666 return [239, 187, 191] 667 } else { 668 669 var bytes = []; 670 for (var i=0; i < 3; i++) { 671 if (i < self.length) { 672 bytes.push(self.charCodeAt(i)); 673 } else { 674 bytes.push(nil); 675 } 676 } 677 return bytes 678 679 } 680 } else { 681 return self.$_original_unpack(format) 682 } 683 }); 684 })($nesting[0], null) 685}; 686 687Opal.modules["asciidoctor/js/opal_ext/uri"] = function(Opal) {/* Generated by Opal 1.7.3 */ 688 var $module = Opal.module, $defs = Opal.defs, $return_self = Opal.return_self, $def = Opal.def, $nesting = []; Opal.nil; 689 690 Opal.add_stubs('extend'); 691 return (function($base, $parent_nesting) { 692 var self = $module($base, 'URI'); 693 694 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 695 696 697 $defs(self, '$parse', function $$parse(str) { 698 699 return str.$extend($$('URI')) 700 }); 701 return $def(self, '$path', $return_self); 702 })($nesting[0], $nesting) 703}; 704 705Opal.modules["asciidoctor/js/opal_ext/base64"] = function(Opal) {/* Generated by Opal 1.7.3 */ 706 var $module = Opal.module, $defs = Opal.defs, $ensure_kwargs = Opal.ensure_kwargs, $truthy = Opal.truthy, $nesting = [], nil = Opal.nil; 707 708 Opal.add_stubs('delete'); 709 return (function($base) { 710 var self = $module($base, 'Base64'); 711 712 713 714 715 var encode, decode; 716 encode = Opal.global.btoa || function (input) { 717 var buffer; 718 if (input instanceof Buffer) { 719 buffer = input; 720 } else { 721 buffer = Buffer.from(input.toString(), 'binary'); 722 } 723 return buffer.toString('base64'); 724 }; 725 decode = Opal.global.atob || function (input) { 726 return Buffer.from(input, 'base64').toString('binary'); 727 }; 728 $defs(self, '$decode64', function $$decode64(string) { 729 730 return decode(string.replace(/\r?\n/g, '')); 731 }); 732 $defs(self, '$encode64', function $$encode64(string) { 733 734 return encode(string).replace(/(.{60})/g, "$1\n").replace(/([^\n])$/g, "$1\n"); 735 }); 736 $defs(self, '$strict_decode64', function $$strict_decode64(string) { 737 738 return decode(string); 739 }); 740 $defs(self, '$strict_encode64', function $$strict_encode64(string) { 741 742 return encode(string); 743 }); 744 $defs(self, '$urlsafe_decode64', function $$urlsafe_decode64(string) { 745 746 return decode(string.replace(/\-/g, '+').replace(/_/g, '/')); 747 }); 748 return $defs(self, '$urlsafe_encode64', function $$urlsafe_encode64(string, $kwargs) { 749 var padding, str = nil; 750 751 752 $kwargs = $ensure_kwargs($kwargs); 753 754 padding = $kwargs.$$smap["padding"];if (padding == null) padding = true; 755 str = encode(string).replace(/\+/g, '-').replace(/\//g, '_'); 756 if (!$truthy(padding)) { 757 str = str.$delete("="); 758 } return str; 759 }, -2); 760 })($nesting[0]) 761}; 762 763Opal.modules["asciidoctor/js/opal_ext/number"] = function(Opal) {/* Generated by Opal 1.7.3 */ 764 var $klass = Opal.klass, $truthy = Opal.truthy, $rb_gt = Opal.rb_gt, $def = Opal.def, $nesting = [], $$ = Opal.$r($nesting); Opal.nil; 765 766 Opal.add_stubs('coerce_to!,>'); 767 return (function($base, $super, $parent_nesting) { 768 var self = $klass($base, $super, 'Number'); 769 770 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 771 772 return $def(self, '$round', function $$round(ndigits) { 773 var self = this; 774 ndigits = $$('Opal')['$coerce_to!'](ndigits, $$('Integer'), "to_int"); 775 if ($truthy($rb_gt(ndigits, 0))) { 776 return Number(self.toFixed(ndigits)); 777 } else { 778 return Math.round(self); 779 } }, -1) 780 })($nesting[0], $$('Numeric'), $nesting) 781}; 782 783Opal.modules["asciidoctor/js/opal_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */ 784 var self = Opal.top; Opal.nil; 785 786 Opal.add_stubs('require'); 787 788 self.$require("asciidoctor/js/opal_ext/kernel"); 789 self.$require("asciidoctor/js/opal_ext/file"); 790 self.$require("asciidoctor/js/opal_ext/match_data"); 791 self.$require("asciidoctor/js/opal_ext/string"); 792 self.$require("asciidoctor/js/opal_ext/uri"); 793 self.$require("asciidoctor/js/opal_ext/base64"); 794 self.$require("asciidoctor/js/opal_ext/number"); 795 796// suppress "not supported" warning messages from Opal 797Opal.config.unsupported_features_severity = 'ignore'; 798 799// Load specific runtime 800self.$require("asciidoctor/js/opal_ext/node"); 801}; 802 803Opal.modules["asciidoctor/js/rx"] = function(Opal) {/* Generated by Opal 1.7.3 */ 804 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; 805 806 Opal.add_stubs('gsub,+,unpack_hex_range'); 807 return (function($base, $parent_nesting) { 808 var self = $module($base, 'Asciidoctor'); 809 810 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 811 812 813 $const_set($nesting[0], 'HEX_RANGE_RX', /([A-F0-9]{4})(?:-([A-F0-9]{4}))?/); 814 $defs(self, '$unpack_hex_range', function $$unpack_hex_range(str) { 815 816 return $send(str, 'gsub', [$$('HEX_RANGE_RX')], function $$1(){var $a, $ret_or_1 = nil; 817 818 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)))}) 819 }); 820 $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"))); 821 $const_set($nesting[0], 'P_Nl', self.$unpack_hex_range("16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF")); 822 $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"))); 823 $const_set($nesting[0], 'P_Pc', self.$unpack_hex_range("005F203F20402054FE33FE34FE4D-FE4FFF3F")); 824 $const_set($nesting[0], 'CC_ALPHA', "" + ($$('P_L')) + ($$('P_Nl'))); 825 $const_set($nesting[0], 'CG_ALPHA', "[" + ($$('CC_ALPHA')) + "]"); 826 $const_set($nesting[0], 'CC_ALNUM', "" + ($$('CC_ALPHA')) + ($$('P_Nd'))); 827 $const_set($nesting[0], 'CG_ALNUM', "[" + ($$('CC_ALNUM')) + "]"); 828 $const_set($nesting[0], 'CC_WORD', "" + ($$('CC_ALNUM')) + ($$('P_Pc'))); 829 $const_set($nesting[0], 'CG_WORD', "[" + ($$('CC_WORD')) + "]"); 830 $const_set($nesting[0], 'CG_BLANK', "[ \\t]"); 831 $const_set($nesting[0], 'CC_EOL', "(?=\\n|$)"); 832 $const_set($nesting[0], 'CG_GRAPH', "[^\\s\\x00-\\x1F\\x7F]"); 833 $const_set($nesting[0], 'CC_ALL', "[\\s\\S]"); 834 return $const_set($nesting[0], 'CC_ANY', "[^\\n]"); 835 })($nesting[0], $nesting) 836}; 837 838Opal.modules["strscan"] = function(Opal) {/* Generated by Opal 1.7.3 */ 839 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; 840 841 Opal.add_stubs('attr_reader,anchor,empty?,===,to_s,coerce_to!,scan_until,length,size,rest,pos=,beginning_of_line?,get_byte,private'); 842 return (function($base, $super, $parent_nesting) { 843 var self = $klass($base, $super, 'StringScanner'); 844 845 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 846 847 $proto.pos = $proto.string = $proto.working = $proto.matched = $proto.prev_pos = $proto.match = nil; 848 849 self.$attr_reader("pos", "matched"); 850 851 $def(self, '$initialize', function $$initialize(string) { 852 var self = this; 853 854 855 self.string = string; 856 self.pos = 0; 857 self.matched = nil; 858 self.working = string; 859 return (self.match = []); 860 }); 861 self.$attr_reader("string"); 862 863 $def(self, '$beginning_of_line?', function $StringScanner_beginning_of_line$ques$1() { 864 var self = this; 865 866 return self.pos === 0 || self.string.charAt(self.pos - 1) === "\n" 867 }); 868 869 $def(self, '$scan', function $$scan(pattern) { 870 var self = this; 871 872 873 pattern = self.$anchor(pattern); 874 875 var result = pattern.exec(self.working); 876 877 if (result == null) { 878 return self.matched = nil; 879 } 880 self.prev_pos = self.pos; 881 self.pos += result[0].length; 882 self.working = self.working.substring(result[0].length); 883 self.matched = result[0]; 884 self.match = result; 885 886 return result[0]; 887 }); 888 889 $def(self, '$scan_until', function $$scan_until(pattern) { 890 var self = this; 891 892 893 pattern = self.$anchor(pattern); 894 895 var working = self.working; 896 897 for(var i = 0; working.length != i; ++i) { 898 var result = pattern.exec(working.substr(i)); 899 if (result !== null) { 900 var matched_size = i + result[0].length; 901 var matched = working.substr(0, matched_size); 902 903 self.matched = result[0]; 904 self.match = result; 905 self.prev_pos = self.pos + i; // Position of first character of matched 906 self.pos += matched_size; // Position one after last character of matched 907 self.working = working.substr(matched_size); 908 909 return matched 910 } 911 } 912 return self.matched = nil; 913 }); 914 915 $def(self, '$[]', function $StringScanner_$$$2(idx) { 916 var self = this, $ret_or_1 = nil; 917 918 919 if ($truthy(self.match['$empty?']())) { 920 return nil 921 } if ($eqeqeq($$('Symbol'), ($ret_or_1 = idx))) { 922 idx = idx.$to_s(); 923 } else if (!$eqeqeq($$('String'), $ret_or_1)) { 924 idx = $Opal['$coerce_to!'](idx, $$('Integer'), "to_int"); 925 } 926 var match = self.match; 927 928 if (idx < 0) { 929 idx += match.length; 930 } 931 932 if (idx < 0 || idx >= match.length) { 933 return nil; 934 } 935 936 if (match[idx] == null) { 937 return nil; 938 } 939 940 return match[idx]; 941 }); 942 943 $def(self, '$check', function $$check(pattern) { 944 var self = this; 945 946 947 pattern = self.$anchor(pattern); 948 949 var result = pattern.exec(self.working); 950 951 if (result == null) { 952 return self.matched = nil; 953 } 954 955 return self.matched = result[0]; 956 }); 957 958 $def(self, '$check_until', function $$check_until(pattern) { 959 var self = this; 960 961 962 var old_prev_pos = self.prev_pos; 963 var old_pos = self.pos; 964 var old_working = self.working; 965 966 var result = self.$scan_until(pattern); 967 968 self.prev_pos = old_prev_pos; 969 self.pos = old_pos; 970 self.working = old_working; 971 972 return result; 973 974 }); 975 976 $def(self, '$peek', function $$peek(length) { 977 var self = this; 978 979 return self.working.substring(0, length) 980 }); 981 982 $def(self, '$eos?', function $StringScanner_eos$ques$3() { 983 var self = this; 984 985 return self.working.length === 0 986 }); 987 988 $def(self, '$exist?', function $StringScanner_exist$ques$4(pattern) { 989 var self = this; 990 991 992 var result = pattern.exec(self.working); 993 994 if (result == null) { 995 return nil; 996 } 997 else if (result.index == 0) { 998 return 0; 999 } 1000 else { 1001 return result.index + 1; 1002 } 1003 1004 }); 1005 1006 $def(self, '$skip', function $$skip(pattern) { 1007 var self = this; 1008 1009 1010 pattern = self.$anchor(pattern); 1011 1012 var result = pattern.exec(self.working); 1013 1014 if (result == null) { 1015 self.match = []; 1016 return self.matched = nil; 1017 } 1018 else { 1019 var match_str = result[0]; 1020 var match_len = match_str.length; 1021 1022 self.matched = match_str; 1023 self.match = result; 1024 self.prev_pos = self.pos; 1025 self.pos += match_len; 1026 self.working = self.working.substring(match_len); 1027 1028 return match_len; 1029 } 1030 }); 1031 1032 $def(self, '$skip_until', function $$skip_until(pattern) { 1033 var self = this; 1034 1035 1036 var result = self.$scan_until(pattern); 1037 1038 if (result === nil) { 1039 return nil; 1040 } 1041 else { 1042 self.matched = result.substr(-1); 1043 1044 return result.length; 1045 } 1046 1047 }); 1048 1049 $def(self, '$get_byte', function $$get_byte() { 1050 var self = this; 1051 1052 1053 var result = nil; 1054 1055 if (self.pos < self.string.length) { 1056 self.prev_pos = self.pos; 1057 self.pos += 1; 1058 result = self.matched = self.working.substring(0, 1); 1059 self.working = self.working.substring(1); 1060 } 1061 else { 1062 self.matched = nil; 1063 } 1064 1065 return result; 1066 1067 }); 1068 1069 $def(self, '$match?', function $StringScanner_match$ques$5(pattern) { 1070 var self = this; 1071 1072 1073 pattern = self.$anchor(pattern); 1074 1075 var result = pattern.exec(self.working); 1076 1077 if (result == null) { 1078 return nil; 1079 } 1080 else { 1081 self.prev_pos = self.pos; 1082 1083 return result[0].length; 1084 } 1085 }); 1086 1087 $def(self, '$pos=', function $StringScanner_pos$eq$6(pos) { 1088 var self = this; 1089 1090 1091 1092 if (pos < 0) { 1093 pos += self.string.$length(); 1094 } 1095 self.pos = pos; 1096 return (self.working = self.string.slice(pos)); 1097 }); 1098 1099 $def(self, '$matched_size', function $$matched_size() { 1100 var self = this; 1101 1102 1103 if (self.matched === nil) { 1104 return nil; 1105 } 1106 1107 return self.matched.length 1108 1109 }); 1110 1111 $def(self, '$post_match', function $$post_match() { 1112 var self = this; 1113 1114 1115 if (self.matched === nil) { 1116 return nil; 1117 } 1118 1119 return self.string.substr(self.pos); 1120 1121 }); 1122 1123 $def(self, '$pre_match', function $$pre_match() { 1124 var self = this; 1125 1126 1127 if (self.matched === nil) { 1128 return nil; 1129 } 1130 1131 return self.string.substr(0, self.prev_pos); 1132 1133 }); 1134 1135 $def(self, '$reset', function $$reset() { 1136 var self = this; 1137 1138 1139 self.working = self.string; 1140 self.matched = nil; 1141 return (self.pos = 0); 1142 }); 1143 1144 $def(self, '$rest', $return_ivar("working")); 1145 1146 $def(self, '$rest?', function $StringScanner_rest$ques$7() { 1147 var self = this; 1148 1149 return self.working.length !== 0 1150 }); 1151 1152 $def(self, '$rest_size', function $$rest_size() { 1153 var self = this; 1154 1155 return self.$rest().$size() 1156 }); 1157 1158 $def(self, '$terminate', function $$terminate() { 1159 var $a, self = this; 1160 1161 1162 self.match = nil; 1163 return ($a = [self.string.$length()], $send(self, 'pos=', $a), $a[$a.length - 1]); 1164 }); 1165 1166 $def(self, '$unscan', function $$unscan() { 1167 var self = this; 1168 1169 1170 self.pos = self.prev_pos; 1171 self.prev_pos = nil; 1172 self.match = nil; 1173 return self; 1174 }); 1175 $alias(self, "bol?", "beginning_of_line?"); 1176 $alias(self, "getch", "get_byte"); 1177 self.$private(); 1178 return $def(self, '$anchor', function $$anchor(pattern) { 1179 1180 1181 var flags = pattern.toString().match(/\/([^\/]+)$/); 1182 flags = flags ? flags[1] : undefined; 1183 return new RegExp('^(?:' + pattern.source + ')', flags); 1184 1185 }); 1186 })($nesting[0], null, $nesting) 1187}; 1188 1189Opal.modules["asciidoctor/js"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1190 var self = Opal.top; Opal.nil; 1191 1192 Opal.add_stubs('require'); 1193 1194 self.$require("asciidoctor/js/opal_ext"); 1195 self.$require("asciidoctor/js/rx"); 1196 return self.$require("strscan"); 1197}; 1198 1199Opal.modules["asciidoctor/core_ext/nil_or_empty"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1200 var $klass = Opal.klass, $truthy = Opal.truthy, $alias = Opal.alias, $nesting = [], nil = Opal.nil; 1201 1202 Opal.add_stubs('method_defined?,nil?,empty?'); 1203 1204 (function($base, $super) { 1205 var self = $klass($base, $super, 'NilClass'); 1206 1207 1208 if ($truthy(self['$method_defined?']("nil_or_empty?"))) { 1209 return nil 1210 } else { 1211 return $alias(self, "nil_or_empty?", "nil?") 1212 } 1213 })($nesting[0], null); 1214 (function($base, $super) { 1215 var self = $klass($base, $super, 'String'); 1216 1217 1218 if ($truthy(self['$method_defined?']("nil_or_empty?"))) { 1219 return nil 1220 } else { 1221 return $alias(self, "nil_or_empty?", "empty?") 1222 } 1223 })($nesting[0], null); 1224 (function($base, $super) { 1225 var self = $klass($base, $super, 'Array'); 1226 1227 1228 if ($truthy(self['$method_defined?']("nil_or_empty?"))) { 1229 return nil 1230 } else { 1231 return $alias(self, "nil_or_empty?", "empty?") 1232 } 1233 })($nesting[0], null); 1234 (function($base, $super) { 1235 var self = $klass($base, $super, 'Hash'); 1236 1237 1238 if ($truthy(self['$method_defined?']("nil_or_empty?"))) { 1239 return nil 1240 } else { 1241 return $alias(self, "nil_or_empty?", "empty?") 1242 } 1243 })($nesting[0], null); 1244 return (function($base, $super) { 1245 var self = $klass($base, $super, 'Numeric'); 1246 1247 1248 if ($truthy(self['$method_defined?']("nil_or_empty?"))) { 1249 return nil 1250 } else { 1251 return $alias(self, "nil_or_empty?", "nil?") 1252 } 1253 })($nesting[0], null); 1254}; 1255 1256Opal.modules["asciidoctor/core_ext/hash/merge"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1257 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; 1258 1259 Opal.add_stubs('==,arity,instance_method,send,new,<,length,dup,>,inject,merge,[]'); 1260 if ($eqeq($$('Hash').$instance_method("merge").$arity(), 1)) { 1261 return $$('Hash').$send("prepend", $send($$('Module'), 'new', [], function $$1(){var self = $$1.$$s == null ? this : $$1.$$s; 1262 1263 return $def(self, '$merge', function $$merge($a) { 1264 var $post_args, args; $$merge.$$p || nil; var self = this, len = nil; 1265 1266 $$merge.$$p = null; 1267 1268 $post_args = $slice(arguments); 1269 args = $post_args; 1270 if ($truthy($rb_lt((len = args.$length()), 1))) { 1271 return self.$dup() 1272 } else { 1273 1274 if ($truthy($rb_gt(len, 1))) { 1275 return $send(args, 'inject', [self], function $$2(acc, arg){ 1276 1277 if (acc == null) acc = nil; 1278 if (arg == null) arg = nil; 1279 return acc.$merge(arg);}) 1280 } else { 1281 1282 return $send2(self, $find_super(self, 'merge', $$merge, false, true), 'merge', [args['$[]'](0)], null); 1283 } } }, -1)}, {$$s: self})) 1284 } else { 1285 return nil 1286 } 1287}; 1288 1289Opal.modules["asciidoctor/core_ext/match_data/names"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1290 var $truthy = Opal.truthy, $klass = Opal.klass, $def = Opal.def, $nesting = [], $$ = Opal.$r($nesting), nil = Opal.nil; 1291 1292 Opal.add_stubs('method_defined?'); 1293 if ($truthy($$('MatchData')['$method_defined?']("names"))) { 1294 return nil 1295 } else { 1296 return (function($base, $super) { 1297 var self = $klass($base, $super, 'MatchData'); 1298 1299 1300 return $def(self, '$names', function $$names() { 1301 1302 return [] 1303 }) 1304 })($nesting[0], null) 1305 } 1306}; 1307 1308Opal.modules["asciidoctor/core_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1309 var self = Opal.top; Opal.nil; 1310 1311 1312 self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/nil_or_empty"); 1313 self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/hash/merge"); 1314 return self.$require("asciidoctor/core_ext.rb"+ '/../' + "core_ext/match_data/names"); 1315}; 1316 1317Opal.modules["asciidoctor/helpers"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1318 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.$$$; 1319 1320 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'); 1321 return (function($base, $parent_nesting) { 1322 var self = $module($base, 'Asciidoctor'); 1323 1324 var $nesting = [self].concat($parent_nesting); 1325 1326 return (function($base, $parent_nesting) { 1327 var self = $module($base, 'Helpers'); 1328 1329 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 1330 1331 1332 self.$module_function(); 1333 1334 $def(self, '$require_library', function $$require_library(name, gem_name, on_failure) { 1335 var self = this, details = nil; 1336 if ($gvars["!"] == null) $gvars["!"] = nil; 1337 1338 1339 if (gem_name == null) gem_name = true; 1340 if (on_failure == null) on_failure = "abort"; 1341 try { 1342 return self.$require(name) 1343 } catch ($err) { 1344 if (Opal.rescue($err, [$$$('LoadError')])) { 1345 try { 1346 1347 if (!$truthy(self['$include?']($$('Logging')))) { 1348 self.$include($$('Logging')); 1349 }; 1350 if ($truthy(gem_name)) { 1351 1352 if ($eqeq(gem_name, true)) { 1353 gem_name = name; 1354 }; 1355 1356 switch (on_failure) { 1357 case "abort": 1358 1359 details = ($eqeq($gvars["!"].$path(), gem_name) ? ("") : (" (reason: " + (($truthy($gvars["!"].$path()) ? ("cannot load '" + ($gvars["!"].$path()) + "'") : ($gvars["!"].$message()))) + ")")); 1360 self.$raise($$$('LoadError'), "asciidoctor: FAILED: required gem '" + (gem_name) + "' is not available" + (details) + ". Processing aborted."); 1361 break; 1362 case "warn": 1363 1364 details = ($eqeq($gvars["!"].$path(), gem_name) ? ("") : (" (reason: " + (($truthy($gvars["!"].$path()) ? ("cannot load '" + ($gvars["!"].$path()) + "'") : ($gvars["!"].$message()))) + ")")); 1365 self.$logger().$warn("optional gem '" + (gem_name) + "' is not available" + (details) + ". Functionality disabled."); 1366 break; 1367 default: 1368 nil; 1369 }; 1370 } else 1371 switch (on_failure) { 1372 case "abort": 1373 self.$raise($$$('LoadError'), "asciidoctor: FAILED: " + ($gvars["!"].$message().$chomp(".")) + ". Processing aborted."); 1374 break; 1375 case "warn": 1376 self.$logger().$warn("" + ($gvars["!"].$message().$chomp(".")) + ". Functionality disabled."); 1377 break; 1378 default: 1379 nil; 1380 }; 1381 return nil; 1382 } finally { Opal.pop_exception(); } 1383 } else { throw $err; } 1384 } }, -2); 1385 1386 $def(self, '$prepare_source_array', function $$prepare_source_array(data, trim_end) { 1387 var leading_2_bytes = nil, leading_bytes = nil, first = nil; 1388 1389 1390 if (trim_end == null) trim_end = true; 1391 if ($truthy(data['$empty?']())) { 1392 return [] 1393 } if ($eqeq((leading_2_bytes = (leading_bytes = (first = data['$[]'](0)).$unpack("C3")).$slice(0, 2)), $$('BOM_BYTES_UTF_16LE'))) { 1394 1395 data['$[]='](0, first.$byteslice(2, first.$bytesize())); 1396 return ($truthy(trim_end) ? ($send(data, 'map', [], function $$1(line){ 1397 1398 if (line == null) line = nil; 1399 return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE')).$rstrip();})) : ($send(data, 'map', [], function $$2(line){ 1400 1401 if (line == null) line = nil; 1402 return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE')).$chomp();}))); 1403 } else if ($eqeq(leading_2_bytes, $$('BOM_BYTES_UTF_16BE'))) { 1404 1405 data['$[]='](0, first.$byteslice(2, first.$bytesize())); 1406 return ($truthy(trim_end) ? ($send(data, 'map', [], function $$3(line){ 1407 1408 if (line == null) line = nil; 1409 return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE')).$rstrip();})) : ($send(data, 'map', [], function $$4(line){ 1410 1411 if (line == null) line = nil; 1412 return line.$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE')).$chomp();}))); 1413 } else if ($eqeq(leading_bytes, $$('BOM_BYTES_UTF_8'))) { 1414 data['$[]='](0, first.$byteslice(3, first.$bytesize())); 1415 } if ($eqeq(first.$encoding(), $$('UTF_8'))) { 1416 if ($truthy(trim_end)) { 1417 return $send(data, 'map', [], function $$5(line){ 1418 1419 if (line == null) line = nil; 1420 return line.$rstrip();}) 1421 } else { 1422 return $send(data, 'map', [], function $$6(line){ 1423 1424 if (line == null) line = nil; 1425 return line.$chomp();}) 1426 } 1427 } else if ($truthy(trim_end)) { 1428 return $send(data, 'map', [], function $$7(line){ 1429 1430 if (line == null) line = nil; 1431 return line.$encode($$('UTF_8')).$rstrip();}) 1432 } else { 1433 return $send(data, 'map', [], function $$8(line){ 1434 1435 if (line == null) line = nil; 1436 return line.$encode($$('UTF_8')).$chomp();}) 1437 } }, -2); 1438 1439 $def(self, '$prepare_source_string', function $$prepare_source_string(data, trim_end) { 1440 var leading_2_bytes = nil, leading_bytes = nil; 1441 1442 1443 if (trim_end == null) trim_end = true; 1444 if ($truthy(data['$nil_or_empty?']())) { 1445 return [] 1446 } if ($eqeq((leading_2_bytes = (leading_bytes = data.$unpack("C3")).$slice(0, 2)), $$('BOM_BYTES_UTF_16LE'))) { 1447 data = data.$byteslice(2, data.$bytesize()).$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16LE')); 1448 } else if ($eqeq(leading_2_bytes, $$('BOM_BYTES_UTF_16BE'))) { 1449 data = data.$byteslice(2, data.$bytesize()).$encode($$('UTF_8'), $$$($$$('Encoding'), 'UTF_16BE')); 1450 } else if ($eqeq(leading_bytes, $$('BOM_BYTES_UTF_8'))) { 1451 1452 data = data.$byteslice(3, data.$bytesize()); 1453 if (!$eqeq(data.$encoding(), $$('UTF_8'))) { 1454 data = data.$encode($$('UTF_8')); 1455 } } else if ($neqeq(data.$encoding(), $$('UTF_8'))) { 1456 data = data.$encode($$('UTF_8')); 1457 } if ($truthy(trim_end)) { 1458 return $send([], 'tap', [], function $$9(lines){ 1459 1460 if (lines == null) lines = nil; 1461 return $send(data, 'each_line', [], function $$10(line){ 1462 1463 if (line == null) line = nil; 1464 return lines['$<<'](line.$rstrip());});}) 1465 } else { 1466 return $send([], 'tap', [], function $$11(lines){ 1467 1468 if (lines == null) lines = nil; 1469 return $send(data, 'each_line', [], function $$12(line){ 1470 1471 if (line == null) line = nil; 1472 return lines['$<<'](line.$chomp());});}) 1473 } }, -2); 1474 if ($eqeq($$$('RUBY_ENGINE'), "jruby")) { 1475 1476 $def(self, '$uriish?', function $Helpers_uriish$ques$13(str) { 1477 var $ret_or_1 = nil, $ret_or_2 = nil; 1478 1479 if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = str['$include?'](":"))) ? (str['$start_with?']("uri:classloader:")['$!']()) : ($ret_or_2))))) { 1480 1481 return $$('UriSniffRx')['$match?'](str); 1482 } else { 1483 return $ret_or_1 1484 } 1485 }); 1486 } else { 1487 1488 $def(self, '$uriish?', function $Helpers_uriish$ques$14(str) { 1489 var $ret_or_1 = nil; 1490 1491 if ($truthy(($ret_or_1 = str['$include?'](":")))) { 1492 1493 return $$('UriSniffRx')['$match?'](str); 1494 } else { 1495 return $ret_or_1 1496 } 1497 }); 1498 } 1499 $def(self, '$encode_uri_component', function $$encode_uri_component(str) { 1500 1501 1502 return encodeURIComponent(str).replace(/%20|[!'()*]/g, function (m) { 1503 return m === '%20' ? '+' : '%' + m.charCodeAt(0).toString(16) 1504 }) 1505 1506 }); 1507 1508 $def(self, '$encode_spaces_in_uri', function $$encode_spaces_in_uri(str) { 1509 1510 if ($truthy(str['$include?'](" "))) { 1511 1512 return str.$gsub(" ", "%20"); 1513 } else { 1514 return str 1515 } 1516 }); 1517 1518 $def(self, '$rootname', function $$rootname(filename) { 1519 var last_dot_idx = nil; 1520 1521 if ($truthy((last_dot_idx = filename.$rindex(".")))) { 1522 if ($truthy(filename.$index("/", last_dot_idx))) { 1523 return filename 1524 } else { 1525 1526 return filename.$slice(0, last_dot_idx); 1527 } 1528 } else { 1529 return filename 1530 } 1531 }); 1532 1533 $def(self, '$basename', function $$basename(filename, drop_ext) { 1534 var self = this; 1535 1536 1537 if (drop_ext == null) drop_ext = nil; 1538 if ($truthy(drop_ext)) { 1539 return $$$('File').$basename(filename, ($eqeq(drop_ext, true) ? (self.$extname(filename)) : (drop_ext))) 1540 } else { 1541 return $$$('File').$basename(filename) 1542 } }, -2); 1543 1544 $def(self, '$extname?', function $Helpers_extname$ques$15(path) { 1545 var $ret_or_1 = nil, last_dot_idx = nil; 1546 1547 if ($truthy(($ret_or_1 = (last_dot_idx = path.$rindex("."))))) { 1548 return path.$index("/", last_dot_idx)['$!']() 1549 } else { 1550 return $ret_or_1 1551 } 1552 }); 1553 if ($truthy($$$($$$('File'), 'ALT_SEPARATOR'))) { 1554 1555 $def(self, '$extname', function $$extname(path, fallback) { 1556 var last_dot_idx = nil; 1557 1558 1559 if (fallback == null) fallback = ""; 1560 if ($truthy((last_dot_idx = path.$rindex(".")))) { 1561 if (($truthy(path.$index("/", last_dot_idx)) || ($truthy(path.$index($$$($$$('File'), 'ALT_SEPARATOR'), last_dot_idx))))) { 1562 return fallback 1563 } else { 1564 1565 return path.$slice(last_dot_idx, path.$length()); 1566 } 1567 } else { 1568 return fallback 1569 } }, -2); 1570 } else { 1571 1572 $def(self, '$extname', function $$extname(path, fallback) { 1573 var last_dot_idx = nil; 1574 1575 1576 if (fallback == null) fallback = ""; 1577 if ($truthy((last_dot_idx = path.$rindex(".")))) { 1578 if ($truthy(path.$index("/", last_dot_idx))) { 1579 return fallback 1580 } else { 1581 1582 return path.$slice(last_dot_idx, path.$length()); 1583 } 1584 } else { 1585 return fallback 1586 } }, -2); 1587 } 1588 $def(self, '$mkdir_p', function $$mkdir_p(dir) { 1589 var self = this, parent_dir = nil; 1590 1591 if ($truthy($$$('File')['$directory?'](dir))) { 1592 return nil 1593 } else { 1594 1595 if (!$eqeq((parent_dir = $$$('File').$dirname(dir)), ".")) { 1596 self.$mkdir_p(parent_dir); 1597 } 1598 try { 1599 return $$$('Dir').$mkdir(dir) 1600 } catch ($err) { 1601 if (Opal.rescue($err, [$$$('SystemCallError')])) { 1602 try { 1603 if ($truthy($$$('File')['$directory?'](dir))) { 1604 return nil 1605 } else { 1606 return self.$raise() 1607 } 1608 } finally { Opal.pop_exception(); } 1609 } else { throw $err; } 1610 } } 1611 }); 1612 $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})); 1613 self.$private_constant("ROMAN_NUMERALS"); 1614 1615 $def(self, '$int_to_roman', function $$int_to_roman(val) { 1616 1617 return $send($$('ROMAN_NUMERALS'), 'map', [], function $$16(l, i){var $a, $b, repeat = nil; 1618 1619 1620 if (l == null) l = nil; 1621 if (i == null) i = nil; 1622 $b = val.$divmod(i), $a = $to_ary($b), (repeat = ($a[0] == null ? nil : $a[0])), (val = ($a[1] == null ? nil : $a[1])); 1623 return $rb_times(l, repeat);}).$join() 1624 }); 1625 1626 $def(self, '$nextval', function $$nextval(current) { 1627 var intval = nil; 1628 1629 if ($eqeqeq($$$('Integer'), current)) { 1630 return $rb_plus(current, 1) 1631 } else if ($eqeq((intval = current.$to_i()).$to_s(), current.$to_s())) { 1632 return $rb_plus(intval, 1) 1633 } else { 1634 return current.$succ() 1635 } 1636 }); 1637 1638 $def(self, '$resolve_class', function $$resolve_class(object) { 1639 var self = this; 1640 1641 if ($eqeqeq($Class, object)) { 1642 return object 1643 } else { 1644 1645 if ($eqeqeq($$$('String'), object)) { 1646 1647 return self.$class_for_name(object); 1648 } else { 1649 return nil 1650 } } 1651 }); 1652 return $def(self, '$class_for_name', function $$class_for_name(qualified_name) { 1653 var self = this, resolved = nil; 1654 1655 try { 1656 1657 if (!$eqeqeq($Class, (resolved = $Object.$const_get(qualified_name, false)))) { 1658 self.$raise(); 1659 }; 1660 return resolved; 1661 } catch ($err) { 1662 if (Opal.rescue($err, [$$('StandardError')])) { 1663 try { 1664 return self.$raise($$$('NameError'), "Could not resolve class for name: " + (qualified_name)) 1665 } finally { Opal.pop_exception(); } 1666 } else { throw $err; } 1667 } 1668 }); 1669 })($nesting[0], $nesting) 1670 })($nesting[0], $nesting) 1671}; 1672 1673Opal.modules["logger"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1674 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.$$$; 1675 1676 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'); 1677 return (function($base, $super, $parent_nesting) { 1678 var self = $klass($base, $super, 'Logger'); 1679 1680 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 1681 1682 $proto.level = $proto.progname = $proto.pipe = $proto.formatter = nil; 1683 1684 (function($base, $parent_nesting) { 1685 var self = $module($base, 'Severity'); 1686 1687 var $nesting = [self].concat($parent_nesting); 1688 1689 1690 $const_set($nesting[0], 'DEBUG', 0); 1691 $const_set($nesting[0], 'INFO', 1); 1692 $const_set($nesting[0], 'WARN', 2); 1693 $const_set($nesting[0], 'ERROR', 3); 1694 $const_set($nesting[0], 'FATAL', 4); 1695 return $const_set($nesting[0], 'UNKNOWN', 5); 1696 })($nesting[0], $nesting); 1697 self.$include($$('Severity')); 1698 $const_set($nesting[0], 'SEVERITY_LABELS', $send($$('Severity').$constants(), 'map', [], function $Logger$1(s){ 1699 1700 if (s == null) s = nil; 1701 return [$$('Severity').$const_get(s), s.$to_s()];}).$to_h()); 1702 (function($base, $super, $parent_nesting) { 1703 var self = $klass($base, $super, 'Formatter'); 1704 1705 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 1706 1707 1708 $const_set($nesting[0], 'MESSAGE_FORMAT', "%s, [%s] %5s -- %s: %s\n"); 1709 $const_set($nesting[0], 'DATE_TIME_FORMAT', "%Y-%m-%dT%H:%M:%S.%6N"); 1710 1711 $def(self, '$call', function $$call(severity, time, progname, msg) { 1712 var self = this; 1713 1714 return self.$format($$('MESSAGE_FORMAT'), severity.$chr(), time.$strftime($$('DATE_TIME_FORMAT')), severity, progname, self.$message_as_string(msg)) 1715 }); 1716 return $def(self, '$message_as_string', function $$message_as_string(msg) { 1717 var $ret_or_1 = nil, $ret_or_2 = nil; 1718 1719 if ($eqeqeq($$$('String'), ($ret_or_1 = msg))) { 1720 return msg 1721 } else if ($eqeqeq($$$('Exception'), $ret_or_1)) { 1722 return $rb_plus("" + (msg.$message()) + " (" + (msg.$class()) + ")\n", ($truthy(($ret_or_2 = msg.$backtrace())) ? ($ret_or_2) : ([])).$join("\n")) 1723 } else { 1724 return msg.$inspect() 1725 } 1726 }); 1727 })($nesting[0], null, $nesting); 1728 self.$attr_reader("level"); 1729 self.$attr_accessor("progname"); 1730 self.$attr_accessor("formatter"); 1731 1732 $def(self, '$initialize', function $$initialize(pipe) { 1733 var self = this; 1734 1735 1736 self.pipe = pipe; 1737 self.level = $$('DEBUG'); 1738 return (self.formatter = $$('Formatter').$new()); 1739 }); 1740 1741 $def(self, '$level=', function $Logger_level$eq$2(severity) { 1742 var self = this, level = nil; 1743 1744 if ($eqeqeq($$$('Integer'), severity)) { 1745 return (self.level = severity) 1746 } else if ($truthy((level = $$('SEVERITY_LABELS').$key(severity.$to_s().$upcase())))) { 1747 return (self.level = level) 1748 } else { 1749 return self.$raise($$('ArgumentError'), "invalid log level: " + (severity)) 1750 } 1751 }); 1752 1753 $def(self, '$info', function $$info(progname) { 1754 var block = $$info.$$p || nil, self = this; 1755 1756 $$info.$$p = null; 1757 if (progname == null) progname = nil; 1758 return $send(self, 'add', [$$('INFO'), nil, progname], block.$to_proc()); 1759 }, -1); 1760 1761 $def(self, '$debug', function $$debug(progname) { 1762 var block = $$debug.$$p || nil, self = this; 1763 1764 $$debug.$$p = null; 1765 if (progname == null) progname = nil; 1766 return $send(self, 'add', [$$('DEBUG'), nil, progname], block.$to_proc()); 1767 }, -1); 1768 1769 $def(self, '$warn', function $$warn(progname) { 1770 var block = $$warn.$$p || nil, self = this; 1771 1772 $$warn.$$p = null; 1773 if (progname == null) progname = nil; 1774 return $send(self, 'add', [$$('WARN'), nil, progname], block.$to_proc()); 1775 }, -1); 1776 1777 $def(self, '$error', function $$error(progname) { 1778 var block = $$error.$$p || nil, self = this; 1779 1780 $$error.$$p = null; 1781 if (progname == null) progname = nil; 1782 return $send(self, 'add', [$$('ERROR'), nil, progname], block.$to_proc()); 1783 }, -1); 1784 1785 $def(self, '$fatal', function $$fatal(progname) { 1786 var block = $$fatal.$$p || nil, self = this; 1787 1788 $$fatal.$$p = null; 1789 if (progname == null) progname = nil; 1790 return $send(self, 'add', [$$('FATAL'), nil, progname], block.$to_proc()); 1791 }, -1); 1792 1793 $def(self, '$unknown', function $$unknown(progname) { 1794 var block = $$unknown.$$p || nil, self = this; 1795 1796 $$unknown.$$p = null; 1797 if (progname == null) progname = nil; 1798 return $send(self, 'add', [$$('UNKNOWN'), nil, progname], block.$to_proc()); 1799 }, -1); 1800 1801 $def(self, '$info?', function $Logger_info$ques$3() { 1802 var self = this; 1803 1804 return $rb_le(self.level, $$('INFO')) 1805 }); 1806 1807 $def(self, '$debug?', function $Logger_debug$ques$4() { 1808 var self = this; 1809 1810 return $rb_le(self.level, $$('DEBUG')) 1811 }); 1812 1813 $def(self, '$warn?', function $Logger_warn$ques$5() { 1814 var self = this; 1815 1816 return $rb_le(self.level, $$('WARN')) 1817 }); 1818 1819 $def(self, '$error?', function $Logger_error$ques$6() { 1820 var self = this; 1821 1822 return $rb_le(self.level, $$('ERROR')) 1823 }); 1824 1825 $def(self, '$fatal?', function $Logger_fatal$ques$7() { 1826 var self = this; 1827 1828 return $rb_le(self.level, $$('FATAL')) 1829 }); 1830 return $def(self, '$add', function $$add(severity, message, progname) { 1831 var block = $$add.$$p || nil, self = this, $ret_or_1 = nil; 1832 1833 $$add.$$p = null; 1834 if (message == null) message = nil; 1835 if (progname == null) progname = nil; 1836 if ($truthy($rb_lt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), self.level))) { 1837 return true 1838 } progname = ($truthy(($ret_or_1 = progname)) ? ($ret_or_1) : (self.progname)); 1839 if (!$truthy(message)) { 1840 if ((block !== nil)) { 1841 message = Opal.yieldX(block, []); 1842 } else { 1843 1844 message = progname; 1845 progname = self.progname; 1846 } 1847 } self.pipe.$write(self.formatter.$call(($truthy(($ret_or_1 = $$('SEVERITY_LABELS')['$[]'](severity))) ? ($ret_or_1) : ("ANY")), $$$('Time').$now(), progname, message)); 1848 return true; 1849 }, -2); 1850 })($nesting[0], null, $nesting) 1851}; 1852 1853Opal.modules["asciidoctor/logging"] = function(Opal) {/* Generated by Opal 1.7.3 */ 1854 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.$$$; 1855 1856 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'); 1857 1858 self.$require("logger"); 1859 return (function($base, $parent_nesting) { 1860 var self = $module($base, 'Asciidoctor'); 1861 1862 var $nesting = [self].concat($parent_nesting); 1863 1864 1865 (function($base, $super, $parent_nesting) { 1866 var self = $klass($base, $super, 'Logger'); 1867 1868 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 1869 1870 $proto.max_severity = nil; 1871 1872 self.$attr_reader("max_severity"); 1873 1874 $def(self, '$initialize', function $$initialize($a) { 1875 var $post_args, args, $b, $yield = $$initialize.$$p || nil, self = this; 1876 1877 $$initialize.$$p = null; 1878 1879 $post_args = $slice(arguments); 1880 args = $post_args; 1881 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', $to_a(args), $yield); 1882 self['$progname=']("asciidoctor"); 1883 self['$formatter=']($$('BasicFormatter').$new()); 1884 return ($b = [$$('WARN')], $send(self, 'level=', $b), $b[$b.length - 1]); 1885 }, -1); 1886 1887 $def(self, '$add', function $$add(severity, message, progname) { 1888 var $yield = $$add.$$p || nil, self = this, $ret_or_1 = nil; 1889 1890 $$add.$$p = null; 1891 1892 if (message == null) message = nil; 1893 if (progname == null) progname = nil; 1894 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)))))) { 1895 self.max_severity = severity; 1896 } return $send2(self, $find_super(self, 'add', $$add, false, true), 'add', [severity, message, progname], $yield); 1897 }, -2); 1898 (function($base, $super, $parent_nesting) { 1899 var self = $klass($base, $super, 'BasicFormatter'); 1900 1901 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 1902 1903 1904 $const_set($nesting[0], 'SEVERITY_LABEL_SUBSTITUTES', $hash2(["WARN", "FATAL"], {"WARN": "WARNING", "FATAL": "FAILED"})); 1905 return $def(self, '$call', function $$call(severity, _, progname, msg) { 1906 var $ret_or_1 = nil; 1907 1908 return "" + (progname) + ": " + (($truthy(($ret_or_1 = $$('SEVERITY_LABEL_SUBSTITUTES')['$[]'](severity))) ? ($ret_or_1) : (severity))) + ": " + (($eqeqeq($$$('String'), msg) ? (msg) : (msg.$inspect()))) + ($$('LF')) 1909 }); 1910 })($nesting[0], $$('Formatter'), $nesting); 1911 return (function($base) { 1912 var self = $module($base, 'AutoFormattingMessage'); 1913 1914 1915 return $def(self, '$inspect', function $$inspect() { 1916 var self = this, sloc = nil; 1917 1918 if ($truthy((sloc = self['$[]']("source_location")))) { 1919 return "" + (sloc) + ": " + (self['$[]']("text")) 1920 } else { 1921 return self['$[]']("text") 1922 } 1923 }) 1924 })($nesting[0]); 1925 })($nesting[0], $$$('Logger'), $nesting); 1926 (function($base, $super, $parent_nesting) { 1927 var self = $klass($base, $super, 'MemoryLogger'); 1928 1929 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 1930 1931 $proto.messages = nil; 1932 1933 $const_set($nesting[0], 'SEVERITY_SYMBOL_BY_VALUE', $send($$('Severity').$constants(false), 'map', [], function $MemoryLogger$1(c){ 1934 1935 if (c == null) c = nil; 1936 return [$$('Severity').$const_get(c), c];}).$to_h()); 1937 self.$attr_reader("messages"); 1938 1939 $def(self, '$initialize', function $$initialize() { 1940 var self = this; 1941 1942 1943 self['$level=']($$('WARN')); 1944 return (self.messages = []); 1945 }); 1946 1947 $def(self, '$add', function $$add(severity, message, progname) { 1948 var $yield = $$add.$$p || nil, self = this, $ret_or_1 = nil; 1949 1950 $$add.$$p = null; 1951 1952 if (message == null) message = nil; 1953 if (progname == null) progname = nil; 1954 message = ($truthy(($ret_or_1 = message)) ? ($ret_or_1) : (($yield !== nil) ? (Opal.yieldX($yield, [])) : (progname))); 1955 self.messages['$<<']($hash2(["severity", "message"], {"severity": $$('SEVERITY_SYMBOL_BY_VALUE')['$[]'](($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), "message": message})); 1956 return true; 1957 }, -2); 1958 1959 $def(self, '$clear', function $$clear() { 1960 var self = this; 1961 1962 return self.messages.$clear() 1963 }); 1964 1965 $def(self, '$empty?', function $MemoryLogger_empty$ques$2() { 1966 var self = this; 1967 1968 return self.messages['$empty?']() 1969 }); 1970 return $def(self, '$max_severity', function $$max_severity() { 1971 var self = this; 1972 1973 if ($truthy(self['$empty?']())) { 1974 return nil 1975 } else { 1976 return $send(self.messages, 'map', [], function $$3(m){ 1977 1978 if (m == null) m = nil; 1979 return $$('Severity').$const_get(m['$[]']("severity"));}).$max() 1980 } 1981 }); 1982 })($nesting[0], $$$('Logger'), $nesting); 1983 (function($base, $super, $parent_nesting) { 1984 var self = $klass($base, $super, 'NullLogger'); 1985 1986 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 1987 1988 $proto.max_severity = nil; 1989 1990 self.$attr_reader("max_severity"); 1991 1992 $def(self, '$initialize', function $$initialize() { 1993 var $a, self = this; 1994 1995 return ($a = [$$('WARN')], $send(self, 'level=', $a), $a[$a.length - 1]) 1996 }); 1997 return $def(self, '$add', function $$add(severity, message, progname) { 1998 var self = this, $ret_or_1 = nil; 1999 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)))))) { 2000 self.max_severity = severity; 2001 } return true; 2002 }, -2); 2003 })($nesting[0], $$$('Logger'), $nesting); 2004 (function($base, $parent_nesting) { 2005 var self = $module($base, 'LoggerManager'); 2006 2007 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 2008 2009 2010 self.logger_class = $$('Logger'); 2011 return (function(self, $parent_nesting) { 2012 2013 2014 self.$attr_accessor("logger_class"); 2015 2016 $def(self, '$logger', function $$logger(pipe) { 2017 var self = this, $ret_or_1 = nil; 2018 if (self.logger == null) self.logger = nil; 2019 if (self.logger_class == null) self.logger_class = nil; 2020 if ($gvars.stderr == null) $gvars.stderr = nil; 2021 2022 2023 if (pipe == null) pipe = $gvars.stderr; 2024 self.$memoize_logger(); 2025 return (self.logger = ($truthy(($ret_or_1 = self.logger)) ? ($ret_or_1) : (self.logger_class.$new(pipe)))); 2026 }, -1); 2027 2028 $def(self, '$logger=', function $logger$eq$4(new_logger) { 2029 var self = this, $ret_or_1 = nil; 2030 if (self.logger_class == null) self.logger_class = nil; 2031 if ($gvars.stderr == null) $gvars.stderr = nil; 2032 2033 return (self.logger = ($truthy(($ret_or_1 = new_logger)) ? ($ret_or_1) : (self.logger_class.$new($gvars.stderr)))) 2034 }); 2035 self.$private(); 2036 return $def(self, '$memoize_logger', function $$memoize_logger() { 2037 var self = this; 2038 2039 return (function(self, $parent_nesting) { 2040 2041 2042 $alias(self, "logger", "logger"); 2043 return self.$attr_reader("logger"); 2044 })(Opal.get_singleton_class(self)) 2045 }); 2046 })(Opal.get_singleton_class(self)); 2047 })($nesting[0], $nesting); 2048 return (function($base, $parent_nesting) { 2049 var self = $module($base, 'Logging'); 2050 2051 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 2052 2053 2054 $defs(self, '$included', function $$included(into) { 2055 2056 return into.$extend($$('Logging')) 2057 }); 2058 self.$private_class_method("included"); 2059 2060 $def(self, '$logger', function $$logger() { 2061 2062 return $$('LoggerManager').$logger() 2063 }); 2064 return $def(self, '$message_with_context', function $$message_with_context(text, context) { 2065 2066 2067 if (context == null) context = $hash2([], {}); 2068 return $hash2(["text"], {"text": text}).$merge(context).$extend($$$($$('Logger'), 'AutoFormattingMessage')); 2069 }, -2); 2070 })($nesting[0], $nesting); 2071 })($nesting[0], $nesting); 2072}; 2073 2074Opal.modules["asciidoctor/rx"] = function(Opal) {/* Generated by Opal 1.7.3 */ 2075 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.$$$; 2076 2077 Opal.add_stubs('join,to_a,new,[]=,empty?,escape'); 2078 return (function($base, $parent_nesting) { 2079 var self = $module($base, 'Asciidoctor'); 2080 2081 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 2082 2083 2084 $module($nesting[0], 'Rx'); 2085 $const_set($nesting[0], 'AuthorInfoLineRx', $regexp(["^(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*)(?: +(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*))?(?: +(", $$('CG_WORD'), "[", $$('CC_WORD'), "\\-'.]*))?(?: +<([^>]+)>)?$"])); 2086 $const_set($nesting[0], 'AuthorDelimiterRx', /;(?: |$)/); 2087 $const_set($nesting[0], 'RevisionInfoLineRx', $regexp(["^(?:[^\\d{]*(", $$('CC_ANY'), "*?),)? *(?!:)(", $$('CC_ANY'), "*?)(?: *(?!^),?: *(", $$('CC_ANY'), "*))?$"])); 2088 $const_set($nesting[0], 'ManpageTitleVolnumRx', $regexp(["^(", $$('CC_ANY'), "+?) *\\( *(", $$('CC_ANY'), "+?) *\\)$"])); 2089 $const_set($nesting[0], 'ManpageNamePurposeRx', $regexp(["^(", $$('CC_ANY'), "+?) +- +(", $$('CC_ANY'), "+)$"])); 2090 $const_set($nesting[0], 'ConditionalDirectiveRx', $regexp(["^(\\\\)?(ifdef|ifndef|ifeval|endif)::(\\S*?(?:([,+])\\S*?)?)\\[(", $$('CC_ANY'), "+)?\\]$"])); 2091 $const_set($nesting[0], 'EvalExpressionRx', $regexp(["^(", $$('CC_ANY'), "+?) *([=!><]=|[><]) *(", $$('CC_ANY'), "+)$"])); 2092 $const_set($nesting[0], 'IncludeDirectiveRx', $regexp(["^(\\\\)?include::([^\\s\\[](?:[^\\[]*[^\\s\\[])?)\\[(", $$('CC_ANY'), "+)?\\]$"])); 2093 $const_set($nesting[0], 'TagDirectiveRx', /\b(?:tag|(e)nd)::(\S+?)\[\](?=$|[ \r])/m); 2094 $const_set($nesting[0], 'AttributeEntryRx', $regexp(["^:(!?", $$('CG_WORD'), "[^:]*):(?:[ \\t]+(", $$('CC_ANY'), "*))?$"])); 2095 $const_set($nesting[0], 'InvalidAttributeNameCharsRx', $regexp(["[^", $$('CC_WORD'), "-]"])); 2096 $const_set($nesting[0], 'AttributeEntryPassMacroRx', $regexp(["^pass:([a-z]+(?:,[a-z-]+)*)?\\[(", $$('CC_ALL'), "*)\\]$"])); 2097 $const_set($nesting[0], 'AttributeReferenceRx', $regexp(["(\\\\)?\\{(", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*|(set|counter2?):", $$('CC_ANY'), "+?)(\\\\)?\\}"])); 2098 $const_set($nesting[0], 'BlockAnchorRx', $regexp(["^\\[\\[(?:|([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+))?)\\]\\]$"])); 2099 $const_set($nesting[0], 'BlockAttributeListRx', $regexp(["^\\[(|[", $$('CC_WORD'), ".#%{,\"']", $$('CC_ANY'), "*)\\]$"])); 2100 $const_set($nesting[0], 'BlockAttributeLineRx', $regexp(["^\\[(?:|[", $$('CC_WORD'), ".#%{,\"']", $$('CC_ANY'), "*|\\[(?:|[", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*(?:, *", $$('CC_ANY'), "+)?)\\])\\]$"])); 2101 $const_set($nesting[0], 'BlockTitleRx', $regexp(["^\\.(\\.?[^ \\t.]", $$('CC_ANY'), "*)$"])); 2102 $const_set($nesting[0], 'AdmonitionParagraphRx', $regexp(["^(", $$('ADMONITION_STYLES').$to_a().$join("|"), "):[ \\t]+"])); 2103 $const_set($nesting[0], 'LiteralParagraphRx', $regexp(["^([ \\t]+", $$('CC_ANY'), "*)$"])); 2104 $const_set($nesting[0], 'AtxSectionTitleRx', $regexp(["^(=={0,5})[ \\t]+(", $$('CC_ANY'), "+?)(?:[ \\t]+\\1)?$"])); 2105 $const_set($nesting[0], 'ExtAtxSectionTitleRx', $regexp(["^(=={0,5}|#\\\#{0,5})[ \\t]+(", $$('CC_ANY'), "+?)(?:[ \\t]+\\1)?$"])); 2106 $const_set($nesting[0], 'SetextSectionTitleRx', $regexp(["^((?!\\.)", $$('CC_ANY'), "*?", $$('CG_ALNUM'), $$('CC_ANY'), "*)$"])); 2107 $const_set($nesting[0], 'InlineSectionAnchorRx', $regexp([" (\\\\)?\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+))?\\]\\]$"])); 2108 $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'), "\\-.]+?"])); 2109 $const_set($nesting[0], 'SectionLevelStyleRx', /^sect\d$/); 2110 $const_set($nesting[0], 'AnyListRx', $regexp(["^(?:[ \\t]*(?:-|\\*\\**|\\.\\.*|\\u2022|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))[ \\t]|(?!//[^/])[ \\t]*[^ \\t]", $$('CC_ANY'), "*?(?::::{0,2}|;;)(?:$|[ \\t])|<(?:\\d+|\\.)>[ \\t])"])); 2111 $const_set($nesting[0], 'UnorderedListRx', $regexp(["^[ \\t]*(-|\\*\\**|\\u2022)[ \\t]+(", $$('CC_ANY'), "*)$"])); 2112 $const_set($nesting[0], 'OrderedListRx', $regexp(["^[ \\t]*(\\.\\.*|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))[ \\t]+(", $$('CC_ANY'), "*)$"])); 2113 $const_set($nesting[0], 'OrderedListMarkerRxMap', $hash2(["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"], {"arabic": /\d+\./, "loweralpha": /[a-z]\./, "lowerroman": /[ivx]+\)/, "upperalpha": /[A-Z]\./, "upperroman": /[IVX]+\)/})); 2114 $const_set($nesting[0], 'DescriptionListRx', $regexp(["^(?!//[^/])[ \\t]*([^ \\t]", $$('CC_ANY'), "*?)(:::{0,2}|;;)(?:$|[ \\t]+(", $$('CC_ANY'), "*)$)"])); 2115 $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'), "*)$)"])})); 2116 $const_set($nesting[0], 'CalloutListRx', $regexp(["^<(\\d+|\\.)>[ \\t]+(", $$('CC_ANY'), "*)$"])); 2117 $const_set($nesting[0], 'CalloutExtractRx', /((?:\/\/|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\3>(?=(?: ?\\?<!?\3(?:\d+|\.)\3>)*$)/); 2118 $const_set($nesting[0], 'CalloutExtractRxt', "(\\\\)?<()(\\d+|\\.)>(?=(?: ?\\\\?<(?:\\d+|\\.)>)*$)"); 2119 $const_set($nesting[0], 'CalloutExtractRxMap', $send($$$('Hash'), 'new', [], function $Asciidoctor$1(h, k){var $a; 2120 2121 2122 if (h == null) h = nil; 2123 if (k == null) k = nil; 2124 return ($a = [k, $regexp(["(", ($truthy(k['$empty?']()) ? ("") : ("" + ($$$('Regexp').$escape(k)) + " ?")), ")?", $$('CalloutExtractRxt')])], $send(h, '[]=', $a), $a[$a.length - 1]);})); 2125 $const_set($nesting[0], 'CalloutScanRx', $regexp(["\\\\?<!?(|--)(\\d+|\\.)\\1>(?=(?: ?\\\\?<!?\\1(?:\\d+|\\.)\\1>)*", $$('CC_EOL'), ")"])); 2126 $const_set($nesting[0], 'CalloutSourceRx', $regexp(["((?://|#|--|;;) ?)?(\\\\)?<!?(|--)(\\d+|\\.)\\3>(?=(?: ?\\\\?<!?\\3(?:\\d+|\\.)\\3>)*", $$('CC_EOL'), ")"])); 2127 $const_set($nesting[0], 'CalloutSourceRxt', "(\\\\)?<()(\\d+|\\.)>(?=(?: ?\\\\?<(?:\\d+|\\.)>)*" + ($$('CC_EOL')) + ")"); 2128 $const_set($nesting[0], 'CalloutSourceRxMap', $send($$$('Hash'), 'new', [], function $Asciidoctor$2(h, k){var $a; 2129 2130 2131 if (h == null) h = nil; 2132 if (k == null) k = nil; 2133 return ($a = [k, $regexp(["(", ($truthy(k['$empty?']()) ? ("") : ("" + ($$$('Regexp').$escape(k)) + " ?")), ")?", $$('CalloutSourceRxt')])], $send(h, '[]=', $a), $a[$a.length - 1]);})); 2134 $const_set($nesting[0], 'ListRxMap', $hash2(["ulist", "olist", "dlist", "colist"], {"ulist": $$('UnorderedListRx'), "olist": $$('OrderedListRx'), "dlist": $$('DescriptionListRx'), "colist": $$('CalloutListRx')})); 2135 $const_set($nesting[0], 'ColumnSpecRx', /^(?:(\d+)\*)?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?(\d+%?|~)?([a-z])?$/); 2136 $const_set($nesting[0], 'CellSpecStartRx', /^[ \t]*(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/); 2137 $const_set($nesting[0], 'CellSpecEndRx', /[ \t]+(?:(\d+(?:\.\d*)?|(?:\d*\.)?\d+)([*+]))?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?([a-z])?$/); 2138 $const_set($nesting[0], 'CustomBlockMacroRx', $regexp(["^(", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*)::(|\\S|\\S", $$('CC_ANY'), "*?\\S)\\[(", $$('CC_ANY'), "+)?\\]$"])); 2139 $const_set($nesting[0], 'BlockMediaMacroRx', $regexp(["^(image|video|audio)::(\\S|\\S", $$('CC_ANY'), "*?\\S)\\[(", $$('CC_ANY'), "+)?\\]$"])); 2140 $const_set($nesting[0], 'BlockTocMacroRx', $regexp(["^toc::\\[(", $$('CC_ANY'), "+)?\\]$"])); 2141 $const_set($nesting[0], 'InlineAnchorRx', $regexp(["(\\\\)?(?:\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]|anchor:([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)\\[(?:\\]|(", $$('CC_ANY'), "*?[^\\\\])\\]))"])); 2142 $const_set($nesting[0], 'InlineAnchorScanRx', $regexp(["(?:^|[^\\\\\\[])\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]|(?:^|[^\\\\])anchor:([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)\\[(?:\\]|(", $$('CC_ANY'), "*?[^\\\\])\\])"])); 2143 $const_set($nesting[0], 'LeadingInlineAnchorRx', $regexp(["^\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]"])); 2144 $const_set($nesting[0], 'InlineBiblioAnchorRx', $regexp(["^\\[\\[\\[([", $$('CC_ALPHA'), "_:][", $$('CC_WORD'), "\\-:.]*)(?:, *(", $$('CC_ANY'), "+?))?\\]\\]\\]"])); 2145 $const_set($nesting[0], 'InlineEmailRx', $regexp(["([\\\\>:/])?", $$('CG_WORD'), "(?:&|[", $$('CC_WORD'), "\\-.%+])*@", $$('CG_ALNUM'), "[", $$('CC_ALNUM'), "_\\-.]*\\.[a-zA-Z]{2,5}\\b"])); 2146 $const_set($nesting[0], 'InlineFootnoteMacroRx', $regexp(["\\\\?footnote(?:(ref):|:([", $$('CC_WORD'), "-]+)?)\\[(?:|(", $$('CC_ALL'), "*?[^\\\\]))\\](?!</a>)"], 'm')); 2147 $const_set($nesting[0], 'InlineImageMacroRx', $regexp(["\\\\?i(?:mage|con):([^:\\s\\[](?:[^\\n\\[]*[^\\s\\[])?)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm')); 2148 $const_set($nesting[0], 'InlineIndextermMacroRx', $regexp(["\\\\?(?:(indexterm2?):\\[(", $$('CC_ALL'), "*?[^\\\\])\\]|\\(\\((", $$('CC_ALL'), "+?)\\)\\)(?!\\)))"], 'm')); 2149 $const_set($nesting[0], 'InlineKbdBtnMacroRx', $regexp(["(\\\\)?(kbd|btn):\\[(", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm')); 2150 $const_set($nesting[0], 'InlineLinkRx', $regexp(["(^|link:|", $$('CG_BLANK'), "|<|[>\\(\\)\\[\\];\"'])(\\\\?(?:https?|file|ftp|irc)://)(?:([^\\s\\[\\]]+)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]|([^\\s\\[\\]<]*([^\\s,.?!\\[\\]<\\)])))"], 'm')); 2151 $const_set($nesting[0], 'InlineLinkMacroRx', $regexp(["\\\\?(?:link|(mailto)):(|[^:\\s\\[][^\\s\\[]*)\\[(|", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm')); 2152 $const_set($nesting[0], 'MacroNameRx', $regexp(["^", $$('CG_WORD'), "[", $$('CC_WORD'), "-]*$"])); 2153 $const_set($nesting[0], 'InlineStemMacroRx', $regexp(["\\\\?(stem|(?:latex|ascii)math):([a-z]+(?:,[a-z-]+)*)?\\[(", $$('CC_ALL'), "*?[^\\\\])\\]"], 'm')); 2154 $const_set($nesting[0], 'InlineMenuMacroRx', $regexp(["\\\\?menu:(", $$('CG_WORD'), "|[", $$('CC_WORD'), "&][^\\n\\[]*[^\\s\\[])\\[ *(?:|(", $$('CC_ALL'), "*?[^\\\\]))\\]"], 'm')); 2155 $const_set($nesting[0], 'InlineMenuRx', $regexp(["\\\\?\"([", $$('CC_WORD'), "&][^\"]*?[ \\n]+>[ \\n]+[^\"]*)\""])); 2156 $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')])); 2157 $const_set($nesting[0], 'InlinePassMacroRx', $regexp(["(?:(?:(\\\\?)\\[([^\\]]+)\\])?(\\\\{0,2})(\\+\\+\\+?|\\$\\$)(", $$('CC_ALL'), "*?)\\4|(\\\\?)pass:([a-z]+(?:,[a-z-]+)*)?\\[(|", $$('CC_ALL'), "*?[^\\\\])\\])"], 'm')); 2158 $const_set($nesting[0], 'InlineXrefMacroRx', $regexp(["\\\\?(?:<<([", $$('CC_WORD'), "#/.:{]", $$('CC_ALL'), "*?)>>|xref:([", $$('CC_WORD'), "#/.:{]", $$('CC_ALL'), "*?)\\[(?:\\]|(", $$('CC_ALL'), "*?[^\\\\])\\]))"], 'm')); 2159 $const_set($nesting[0], 'HardLineBreakRx', $regexp(["^(", $$('CC_ANY'), "*) \\+$"], 'm')); 2160 $const_set($nesting[0], 'MarkdownThematicBreakRx', /^ {0,3}([-*_])( *)\1\2\1$/); 2161 $const_set($nesting[0], 'ExtLayoutBreakRx', /^(?:'{3,}|<{3,}|([-*_])( *)\1\2\1)$/); 2162 $const_set($nesting[0], 'BlankLineRx', /\n{2,}/); 2163 $const_set($nesting[0], 'EscapedSpaceRx', /\\([ \t\n])/); 2164 $const_set($nesting[0], 'ReplaceableTextRx', /[&']|--|\.\.\.|\([CRT]M?\)/); 2165 $const_set($nesting[0], 'SpaceDelimiterRx', /([^\\])[ \t\n]+/); 2166 $const_set($nesting[0], 'SubModifierSniffRx', /[+-]/); 2167 $const_set($nesting[0], 'TrailingDigitsRx', /\d+$/); 2168 $const_set($nesting[0], 'UriSniffRx', $regexp(["^", $$('CG_ALPHA'), "[", $$('CC_ALNUM'), ".+-]+:/{0,2}"])); 2169 return $const_set($nesting[0], 'XmlSanitizeRx', /<[^>]+>/); 2170 })($nesting[0], $nesting) 2171}; 2172 2173Opal.modules["asciidoctor/substitutors"] = function(Opal) {/* Generated by Opal 1.7.3 */ 2174 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.$$$; 2175 2176 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'); 2177 return (function($base, $parent_nesting) { 2178 var self = $module($base, 'Asciidoctor'); 2179 2180 var $nesting = [self].concat($parent_nesting); 2181 2182 return (function($base, $parent_nesting) { 2183 var self = $module($base, 'Substitutors'); 2184 2185 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 2186 2187 2188 $const_set($nesting[0], 'SpecialCharsRx', /[<&>]/); 2189 $const_set($nesting[0], 'SpecialCharsTr', $hash2([">", "<", "&"], {">": ">", "<": "<", "&": "&"})); 2190 $const_set($nesting[0], 'QuotedTextSniffRx', $hash(false, /[*_`#^~]/, true, /[*'_+#^~]/)); 2191 $const_set($nesting[0], 'BASIC_SUBS', ["specialcharacters"]).$freeze(); 2192 $const_set($nesting[0], 'HEADER_SUBS', ["specialcharacters", "attributes"]).$freeze(); 2193 $const_set($nesting[0], 'NO_SUBS', []).$freeze(); 2194 $const_set($nesting[0], 'NORMAL_SUBS', ["specialcharacters", "quotes", "attributes", "replacements", "macros", "post_replacements"]).$freeze(); 2195 $const_set($nesting[0], 'REFTEXT_SUBS', ["specialcharacters", "quotes", "replacements"]).$freeze(); 2196 $const_set($nesting[0], 'VERBATIM_SUBS', ["specialcharacters", "callouts"]).$freeze(); 2197 $const_set($nesting[0], 'SUB_GROUPS', $hash2(["none", "normal", "verbatim", "specialchars"], {"none": $$('NO_SUBS'), "normal": $$('NORMAL_SUBS'), "verbatim": $$('VERBATIM_SUBS'), "specialchars": $$('BASIC_SUBS')})); 2198 $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"})); 2199 $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'))})); 2200 $const_set($nesting[0], 'CAN', "\u0018"); 2201 $const_set($nesting[0], 'DEL', "\u007F"); 2202 $const_set($nesting[0], 'PASS_START', "\u0096"); 2203 $const_set($nesting[0], 'PASS_END', "\u0097"); 2204 $const_set($nesting[0], 'PassSlotRx', $regexp([$$('PASS_START'), "(\\d+)", $$('PASS_END')])); 2205 $const_set($nesting[0], 'HighlightedPassSlotRx', $regexp(["<span\\b[^>]*>", $$('PASS_START'), "</span>[^\\d]*(\\d+)[^\\d]*<span\\b[^>]*>", $$('PASS_END'), "</span>"])); 2206 $const_set($nesting[0], 'RS', "\\"); 2207 $const_set($nesting[0], 'R_SB', "]"); 2208 $const_set($nesting[0], 'ESC_R_SB', "\\]"); 2209 $const_set($nesting[0], 'PLUS', "+"); 2210 2211 $def(self, '$apply_subs', function $$apply_subs(text, subs) { 2212 var self = this, is_multiline = nil, passthrus = nil, $ret_or_1 = nil, clear_passthrus = nil; 2213 if (self.passthroughs == null) self.passthroughs = nil; 2214 if (self.passthroughs_locked == null) self.passthroughs_locked = nil; 2215 2216 2217 if (subs == null) subs = $$('NORMAL_SUBS'); 2218 if (($truthy(text['$empty?']()) || ($not(subs)))) { 2219 return text 2220 } if ($truthy((is_multiline = $$$('Array')['$==='](text)))) { 2221 text = ($truthy(text['$[]'](1)) ? (text.$join($$('LF'))) : (text['$[]'](0))); 2222 } if ($truthy(subs['$include?']("macros"))) { 2223 2224 text = self.$extract_passthroughs(text); 2225 if (!$truthy(self.passthroughs['$empty?']())) { 2226 2227 passthrus = self.passthroughs; 2228 self.passthroughs_locked = ($truthy(($ret_or_1 = self.passthroughs_locked)) ? ($ret_or_1) : ((clear_passthrus = true))); 2229 } } $send(subs, 'each', [], function $$1(type){var self = $$1.$$s == null ? this : $$1.$$s; 2230 2231 2232 if (type == null) type = nil; 2233 2234 switch (type) { 2235 case "specialcharacters": 2236 return (text = self.$sub_specialchars(text)) 2237 case "quotes": 2238 return (text = self.$sub_quotes(text)) 2239 case "attributes": 2240 if ($truthy(text['$include?']($$('ATTR_REF_HEAD')))) { 2241 return (text = self.$sub_attributes(text)) 2242 } else { 2243 return nil 2244 } 2245 case "replacements": 2246 return (text = self.$sub_replacements(text)) 2247 case "macros": 2248 return (text = self.$sub_macros(text)) 2249 case "highlight": 2250 return (text = self.$highlight_source(text, subs['$include?']("callouts"))) 2251 case "callouts": 2252 if ($truthy(subs['$include?']("highlight"))) { 2253 return nil 2254 } else { 2255 return (text = self.$sub_callouts(text)) 2256 } 2257 case "post_replacements": 2258 return (text = self.$sub_post_replacements(text)) 2259 default: 2260 return self.$logger().$warn("unknown substitution type " + (type)) 2261 }}, {$$s: self}); 2262 if ($truthy(passthrus)) { 2263 2264 text = self.$restore_passthroughs(text); 2265 if ($truthy(clear_passthrus)) { 2266 2267 passthrus.$clear(); 2268 self.passthroughs_locked = nil; 2269 } } if ($truthy(is_multiline)) { 2270 2271 return text.$split($$('LF'), -1); 2272 } else { 2273 return text 2274 } }, -2); 2275 2276 $def(self, '$apply_normal_subs', function $$apply_normal_subs(text) { 2277 var self = this; 2278 2279 return self.$apply_subs(text, $$('NORMAL_SUBS')) 2280 }); 2281 2282 $def(self, '$apply_header_subs', function $$apply_header_subs(text) { 2283 var self = this; 2284 2285 return self.$apply_subs(text, $$('HEADER_SUBS')) 2286 }); 2287 $alias(self, "apply_title_subs", "apply_subs"); 2288 2289 $def(self, '$apply_reftext_subs', function $$apply_reftext_subs(text) { 2290 var self = this; 2291 2292 return self.$apply_subs(text, $$('REFTEXT_SUBS')) 2293 }); 2294 2295 $def(self, '$sub_specialchars', function $$sub_specialchars(text) { 2296 2297 if ((($truthy(text['$include?'](">")) || ($truthy(text['$include?']("&")))) || ($truthy(text['$include?']("<"))))) { 2298 2299 return text.$gsub($$('SpecialCharsRx'), $$('SpecialCharsTr')); 2300 } else { 2301 return text 2302 } 2303 }); 2304 $alias(self, "sub_specialcharacters", "sub_specialchars"); 2305 2306 $def(self, '$sub_quotes', function $$sub_quotes(text) { 2307 var self = this, compat = nil; 2308 if (self.document == null) self.document = nil; 2309 2310 2311 if ($truthy($$('QuotedTextSniffRx')['$[]']((compat = self.document.$compat_mode()))['$match?'](text))) { 2312 $send($$('QUOTE_SUBS')['$[]'](compat), 'each', [], function $$2(type, scope, pattern){var self = $$2.$$s == null ? this : $$2.$$s; 2313 2314 2315 if (type == null) type = nil; 2316 if (scope == null) scope = nil; 2317 if (pattern == null) pattern = nil; 2318 return (text = $send(text, 'gsub', [pattern], function $$3(){var self = $$3.$$s == null ? this : $$3.$$s; 2319 if ($gvars["~"] == null) $gvars["~"] = nil; 2320 2321 return self.$convert_quoted_text($gvars["~"], type, scope)}, {$$s: self}));}, {$$s: self}); 2322 } return text; 2323 }); 2324 2325 $def(self, '$sub_attributes', function $$sub_attributes(text, opts) { 2326 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; 2327 if (self.document == null) self.document = nil; 2328 2329 2330 if (opts == null) opts = $hash2([], {}); 2331 doc_attrs = self.document.$attributes(); 2332 drop = (drop_line = (drop_line_severity = (drop_empty_line = (attribute_undefined = (attribute_missing = nil))))); 2333 text = $send(text, 'gsub', [$$('AttributeReferenceRx')], function $$4(){var $a, $b, self = $$4.$$s == null ? this : $$4.$$s, args = nil, $ret_or_2 = nil, value = nil, $ret_or_3 = nil, key = nil, $ret_or_4 = nil; 2334 if (self.document == null) self.document = nil; 2335 2336 if (($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $$('RS')) || ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)), $$('RS'))))) { 2337 return "{" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2))) + "}" 2338 } else if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) { 2339 2340 switch ((args = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)).$split(":", 3)).$shift()) { 2341 case "set": 2342 2343 $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])); 2344 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")))) { 2345 return (drop = (drop_empty_line = $$('DEL'))) 2346 } else { 2347 return (drop = (drop_line = $$('CAN'))) 2348 } case "counter2": 2349 2350 $send(self.document, 'counter', $to_a(args)); 2351 return (drop = (drop_empty_line = $$('DEL'))); 2352 default: 2353 return $send(self.document, 'counter', $to_a(args)) 2354 } 2355 } else if ($truthy(doc_attrs['$key?']((key = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)).$downcase())))) { 2356 return doc_attrs['$[]'](key) 2357 } else if ($truthy((value = $$('INTRINSIC_ATTRIBUTES')['$[]'](key)))) { 2358 return value 2359 } else 2360 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())))))) { 2361 case "drop": 2362 return (drop = (drop_empty_line = $$('DEL'))) 2363 case "drop-line": 2364 2365 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")) { 2366 $send(self.$logger(), 'info', [], function $$5(){ 2367 return "dropping line containing reference to missing attribute: " + (key)}); 2368 } return (drop = (drop_line = $$('CAN'))); 2369 case "warn": 2370 2371 self.$logger().$warn("skipping reference to missing attribute: " + (key)); 2372 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)); 2373 default: 2374 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2375 }}, {$$s: self}); 2376 if ($truthy(drop)) { 2377 if ($truthy(drop_empty_line)) { 2378 2379 lines = text.$squeeze($$('DEL')).$split($$('LF'), -1); 2380 if ($truthy(drop_line)) { 2381 return $send(lines, 'reject', [], function $$6(line){var $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil; 2382 2383 2384 if (line == null) line = nil; 2385 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'))))))) { 2386 return $ret_or_1 2387 } else { 2388 2389 return line['$include?']($$('CAN')); 2390 }}).$join($$('LF')).$delete($$('DEL')) 2391 } else { 2392 return $send(lines, 'reject', [], function $$7(line){ 2393 2394 if (line == null) line = nil; 2395 return line['$==']($$('DEL'));}).$join($$('LF')).$delete($$('DEL')) 2396 } } else if ($truthy(text['$include?']($$('LF')))) { 2397 return $send(text.$split($$('LF'), -1), 'reject', [], function $$8(line){var $ret_or_1 = nil, $ret_or_2 = nil; 2398 2399 2400 if (line == null) line = nil; 2401 if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = line['$==']($$('CAN')))) ? ($ret_or_2) : (line['$start_with?']($$('CAN'))))))) { 2402 return $ret_or_1 2403 } else { 2404 2405 return line['$include?']($$('CAN')); 2406 }}).$join($$('LF')) 2407 } else { 2408 return "" 2409 } 2410 } else { 2411 return text 2412 } }, -2); 2413 2414 $def(self, '$sub_replacements', function $$sub_replacements(text) { 2415 var self = this; 2416 2417 2418 if ($truthy($$('ReplaceableTextRx')['$match?'](text))) { 2419 $send($$('REPLACEMENTS'), 'each', [], function $$9(pattern, replacement, restore){var self = $$9.$$s == null ? this : $$9.$$s; 2420 2421 2422 if (pattern == null) pattern = nil; 2423 if (replacement == null) replacement = nil; 2424 if (restore == null) restore = nil; 2425 return (text = $send(text, 'gsub', [pattern], function $$10(){var self = $$10.$$s == null ? this : $$10.$$s; 2426 if ($gvars["~"] == null) $gvars["~"] = nil; 2427 2428 return self.$do_replacement($gvars["~"], replacement, restore)}, {$$s: self}));}, {$$s: self}); 2429 } return text; 2430 }); 2431 2432 $def(self, '$sub_macros', function $$sub_macros(text) { 2433 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; 2434 if (self.document == null) self.document = nil; 2435 if (self.parent == null) self.parent = nil; 2436 if (self.context == null) self.context = nil; 2437 2438 2439 found_square_bracket = text['$include?']("["); 2440 found_colon = text['$include?'](":"); 2441 found_macroish = ($truthy(($ret_or_1 = found_square_bracket)) ? (found_colon) : ($ret_or_1)); 2442 found_macroish_short = ($truthy(($ret_or_1 = found_macroish)) ? (text['$include?'](":[")) : ($ret_or_1)); 2443 doc_attrs = (doc = self.document).$attributes(); 2444 if (($truthy((extensions = doc.$extensions())) && ($truthy(extensions['$inline_macros?']())))) { 2445 $send(extensions.$inline_macros(), 'each', [], function $$11(extension){var self = $$11.$$s == null ? this : $$11.$$s; 2446 2447 2448 if (extension == null) extension = nil; 2449 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; 2450 if ($gvars["~"] == null) $gvars["~"] = nil; 2451 2452 2453 if ($truthy((match = (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)))['$start_with?']($$('RS')))) { 2454 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2455 } if ($truthy($gvars["~"].$names()['$empty?']())) { 2456 $a = [(($b = $gvars['~']) === nil ? nil : $b['$[]'](1)), (($b = $gvars['~']) === nil ? nil : $b['$[]'](2))], (target = $a[0]), (content = $a[1]); 2457 } else { 2458 $a = [(function() { try { 2459 return $gvars["~"]['$[]']("target") 2460 } catch ($err) { 2461 if (Opal.rescue($err, [$$('StandardError')])) { 2462 try { 2463 return nil 2464 } finally { Opal.pop_exception(); } 2465 } else { throw $err; } 2466 }})(), (function() { try { 2467 return $gvars["~"]['$[]']("content") 2468 } catch ($err) { 2469 if (Opal.rescue($err, [$$('StandardError')])) { 2470 try { 2471 return nil 2472 } finally { Opal.pop_exception(); } 2473 } else { throw $err; } 2474 }})()], (target = $a[0]), (content = $a[1]); 2475 } attributes = ($truthy((default_attrs = (ext_config = extension.$config())['$[]']("default_attrs"))) ? (default_attrs.$merge()) : ($hash2([], {}))); 2476 if ($truthy(content)) { 2477 2478 if ($truthy(content['$empty?']())) { 2479 if (!$eqeq(ext_config['$[]']("content_model"), "attributes")) { 2480 attributes['$[]=']("text", content); 2481 } 2482 } else { 2483 2484 content = self.$normalize_text(content, true, true); 2485 if ($eqeq(ext_config['$[]']("content_model"), "attributes")) { 2486 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})); 2487 } else { 2488 attributes['$[]=']("text", content); 2489 } } target = ($truthy(($ret_or_1 = target)) ? ($ret_or_1) : ($eqeq(ext_config['$[]']("format"), "short") ? (content) : (target))); 2490 } if ($eqeqeq($$('Inline'), (replacement = extension.$process_method()['$[]'](self, target, attributes)))) { 2491 2492 if (($truthy((inline_subs = replacement.$attributes().$delete("subs"))) && ($truthy((inline_subs = self.$expand_subs(inline_subs, "custom inline macro")))))) { 2493 replacement['$text='](self.$apply_subs(replacement.$text(), inline_subs)); 2494 } return replacement.$convert(); 2495 } else if ($truthy(replacement)) { 2496 2497 $send(self.$logger(), 'info', [], function $$13(){ 2498 return "expected substitution value for custom inline macro to be of type Inline; got " + (replacement.$class()) + ": " + (match)}); 2499 return replacement; 2500 } else { 2501 return "" 2502 }}, {$$s: self}));}, {$$s: self}); 2503 } if ($truthy(doc_attrs['$key?']("experimental"))) { 2504 2505 if (($truthy(found_macroish_short) && (($truthy(text['$include?']("kbd:")) || ($truthy(text['$include?']("btn:"))))))) { 2506 text = $send(text, 'gsub', [$$('InlineKbdBtnMacroRx')], function $$14(){var $a, self = $$14.$$s == null ? this : $$14.$$s, keys = nil, delim_idx = nil, delim = nil; 2507 2508 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 2509 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2510 } else if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), "kbd")) { 2511 2512 if ($truthy((keys = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$strip())['$include?']($$('R_SB')))) { 2513 keys = keys.$gsub($$('ESC_R_SB'), $$('R_SB')); 2514 } 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)))))))) { 2515 2516 delim = keys.$slice(delim_idx, 1); 2517 if ($truthy(keys['$end_with?'](delim))) { 2518 2519 keys = $send(keys.$chop().$split(delim, -1), 'map', [], function $$15(key){ 2520 2521 if (key == null) key = nil; 2522 return key.$strip();}); 2523 keys['$[]='](-1, $rb_plus(keys['$[]'](-1), delim)); 2524 } else { 2525 keys = $send(keys.$split(delim), 'map', [], function $$16(key){ 2526 2527 if (key == null) key = nil; 2528 return key.$strip();}); 2529 } } else { 2530 keys = [keys]; 2531 } return $$('Inline').$new(self, "kbd", nil, $hash2(["attributes"], {"attributes": $hash2(["keys"], {"keys": keys})})).$convert(); 2532 } else { 2533 return $$('Inline').$new(self, "button", self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)), true, true)).$convert() 2534 }}, {$$s: self}); 2535 } if (($truthy(found_macroish) && ($truthy(text['$include?']("menu:"))))) { 2536 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; 2537 2538 2539 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2540 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2541 } menu = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)); 2542 if ($truthy((items = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) { 2543 2544 if ($truthy(items['$include?']($$('R_SB')))) { 2545 items = items.$gsub($$('ESC_R_SB'), $$('R_SB')); 2546 } if ($truthy((delim = ($truthy(items['$include?'](">")) ? (">") : (($truthy(items['$include?'](",")) ? (",") : (nil))))))) { 2547 2548 submenus = $send(items.$split(delim), 'map', [], function $$18(it){ 2549 2550 if (it == null) it = nil; 2551 return it.$strip();}); 2552 menuitem = submenus.$pop(); 2553 } else { 2554 $a = [[], items.$rstrip()], (submenus = $a[0]), (menuitem = $a[1]); 2555 } } else { 2556 $a = [[], nil], (submenus = $a[0]), (menuitem = $a[1]); 2557 } return $$('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, {$$s: self}); 2558 } if (($truthy(text['$include?']("\"")) && ($truthy(text['$include?'](">"))))) { 2559 text = $send(text, 'gsub', [$$('InlineMenuRx')], function $$19(){var $a, $b, $c, self = $$19.$$s == null ? this : $$19.$$s, menu = nil, submenus = nil, menuitem = nil; 2560 2561 2562 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2563 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2564 } $b = $send((($c = $gvars['~']) === nil ? nil : $c['$[]'](1)).$split(">"), 'map', [], function $$20(it){ 2565 2566 if (it == null) it = nil; 2567 return it.$strip();}), $a = $to_ary($b), (menu = ($a[0] == null ? nil : $a[0])), (submenus = $slice($a, 1)); 2568 menuitem = submenus.$pop(); 2569 return $$('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, {$$s: self}); 2570 } } if (($truthy(found_macroish) && (($truthy(text['$include?']("image:")) || ($truthy(text['$include?']("icon:"))))))) { 2571 text = $send(text, 'gsub', [$$('InlineImageMacroRx')], function $$21(){var $a, self = $$21.$$s == null ? this : $$21.$$s, type = nil, posattrs = nil, target = nil, attrs = nil; 2572 2573 2574 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2575 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2576 } else if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']("icon:"))) { 2577 $a = ["icon", ["size"]], (type = $a[0]), (posattrs = $a[1]); 2578 } else { 2579 $a = ["image", ["alt", "width", "height"]], (type = $a[0]), (posattrs = $a[1]); 2580 } target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)); 2581 attrs = self.$parse_attributes((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), posattrs, $hash2(["unescape_input"], {"unescape_input": true})); 2582 if (!$eqeq(type, "icon")) { 2583 2584 doc.$register("images", target); 2585 attrs['$[]=']("imagesdir", doc_attrs['$[]']("imagesdir")); 2586 } if ($truthy(($ret_or_1 = attrs['$[]']("alt")))) ; else { 2587 attrs['$[]=']("alt", ($a = ["default-alt", $$('Helpers').$basename(target, true).$tr("_-", " ")], $send(attrs, '[]=', $a), $a[$a.length - 1])); 2588 } return $$('Inline').$new(self, "image", nil, $hash2(["type", "target", "attributes"], {"type": type, "target": target, "attributes": attrs})).$convert();}, {$$s: self}); 2589 } if ((($truthy(text['$include?']("((")) && ($truthy(text['$include?']("))")))) || (($truthy(found_macroish_short) && ($truthy(text['$include?']("dexterm"))))))) { 2590 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, see = nil, subbed_term = nil, terms = nil; 2591 2592 2593 switch ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) { 2594 case "indexterm": 2595 2596 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2597 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2598 } if ($truthy((attrlist = self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), true, true))['$include?']("="))) { 2599 if ($truthy((primary = (attrs = $$('AttributeList').$new(attrlist, self).$parse())['$[]'](1)))) { 2600 2601 attrs['$[]=']("terms", [primary]); 2602 if ($truthy((see_also = attrs['$[]']("see-also")))) { 2603 attrs['$[]=']("see-also", ($truthy(see_also['$include?'](",")) ? ($send(see_also.$split(","), 'map', [], function $$23(it){ 2604 2605 if (it == null) it = nil; 2606 return it.$lstrip();})) : ([see_also]))); 2607 } } else { 2608 attrs = $hash2(["terms"], {"terms": attrlist}); 2609 } 2610 } else { 2611 attrs = $hash2(["terms"], {"terms": self.$split_simple_csv(attrlist)}); 2612 } return $$('Inline').$new(self, "indexterm", nil, $hash2(["attributes"], {"attributes": attrs})).$convert(); 2613 case "indexterm2": 2614 2615 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2616 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2617 } if ($truthy((term = self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), true, true))['$include?']("="))) { 2618 2619 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)); 2620 if (($truthy(attrs) && ($truthy((see_also = attrs['$[]']("see-also")))))) { 2621 attrs['$[]=']("see-also", ($truthy(see_also['$include?'](",")) ? ($send(see_also.$split(","), 'map', [], function $$24(it){ 2622 2623 if (it == null) it = nil; 2624 return it.$lstrip();})) : ([see_also]))); 2625 } } return $$('Inline').$new(self, "indexterm", term, $hash2(["attributes", "type"], {"attributes": attrs, "type": "visible"})).$convert(); 2626 default: 2627 2628 encl_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 2629 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2630 if (($truthy(encl_text['$start_with?']("(")) && ($truthy(encl_text['$end_with?'](")"))))) { 2631 2632 encl_text = encl_text.$slice(1, $rb_minus(encl_text.$length(), 2)); 2633 $a = [true, "(", ")"], (visible = $a[0]), (before = $a[1]), (after = $a[2]); 2634 } else { 2635 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2636 } 2637 } else { 2638 2639 visible = true; 2640 if ($truthy(encl_text['$start_with?']("("))) { 2641 if ($truthy(encl_text['$end_with?'](")"))) { 2642 $a = [encl_text.$slice(1, $rb_minus(encl_text.$length(), 2)), false], (encl_text = $a[0]), (visible = $a[1]); 2643 } else { 2644 $a = [encl_text.$slice(1, encl_text.$length()), "(", ""], (encl_text = $a[0]), (before = $a[1]), (after = $a[2]); 2645 } 2646 } else if ($truthy(encl_text['$end_with?'](")"))) { 2647 $a = [encl_text.$chop(), "", ")"], (encl_text = $a[0]), (before = $a[1]), (after = $a[2]); 2648 } } if ($truthy(visible)) { 2649 2650 if ($truthy((term = self.$normalize_text(encl_text, true))['$include?'](";&"))) { 2651 if ($truthy(term['$include?'](" >> "))) { 2652 2653 $b = term.$partition(" >> "), $a = $to_ary($b), (term = ($a[0] == null ? nil : $a[0])), (($a[1] == null ? nil : $a[1])), (see = ($a[2] == null ? nil : $a[2])); 2654 attrs = $hash2(["see"], {"see": see}); 2655 } else if ($truthy(term['$include?'](" &> "))) { 2656 2657 $b = term.$split(" &> "), $a = $to_ary($b), (term = ($a[0] == null ? nil : $a[0])), (see_also = $slice($a, 1)); 2658 attrs = $hash2(["see-also"], {"see-also": see_also}); 2659 } 2660 } subbed_term = $$('Inline').$new(self, "indexterm", term, $hash2(["attributes", "type"], {"attributes": attrs, "type": "visible"})).$convert(); 2661 } else { 2662 2663 attrs = $hash2([], {}); 2664 if ($truthy((terms = self.$normalize_text(encl_text, true))['$include?'](";&"))) { 2665 if ($truthy(terms['$include?'](" >> "))) { 2666 2667 $b = terms.$partition(" >> "), $a = $to_ary($b), (terms = ($a[0] == null ? nil : $a[0])), (($a[1] == null ? nil : $a[1])), (see = ($a[2] == null ? nil : $a[2])); 2668 attrs['$[]=']("see", see); 2669 } else if ($truthy(terms['$include?'](" &> "))) { 2670 2671 $b = terms.$split(" &> "), $a = $to_ary($b), (terms = ($a[0] == null ? nil : $a[0])), (see_also = $slice($a, 1)); 2672 attrs['$[]=']("see-also", see_also); 2673 } 2674 } attrs['$[]=']("terms", self.$split_simple_csv(terms)); 2675 subbed_term = $$('Inline').$new(self, "indexterm", nil, $hash2(["attributes"], {"attributes": attrs})).$convert(); 2676 } if ($truthy(before)) { 2677 return "" + (before) + (subbed_term) + (after) 2678 } else { 2679 return subbed_term 2680 } }}, {$$s: self}); 2681 } if (($truthy(found_colon) && ($truthy(text['$include?']("://"))))) { 2682 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; 2683 2684 2685 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')))) { 2686 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())) 2687 } $a = [(($b = $gvars['~']) === nil ? nil : $b['$[]'](1)), ""], (prefix = $a[0]), (suffix = $a[1]); 2688 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](4)))) { 2689 2690 if ($eqeq(prefix, "link:")) { 2691 prefix = ""; 2692 } if ($truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4)))['$empty?']())) { 2693 link_text = nil; 2694 } } else { 2695 2696 2697 switch (prefix) { 2698 case "link:": 2699 case "\"": 2700 case "'": 2701 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2702 } 2703 switch ((($a = $gvars['~']) === nil ? nil : $a['$[]'](6))) { 2704 case ";": 2705 2706 if (($truthy(prefix['$start_with?']("<")) && ($truthy(target['$end_with?'](">"))))) { 2707 2708 prefix = prefix.$slice(4, prefix.$length()); 2709 target = target.$slice(0, $rb_minus(target.$length(), 4)); 2710 } else if ($truthy((target = target.$chop())['$end_with?'](")"))) { 2711 2712 target = target.$chop(); 2713 suffix = ");"; 2714 } else { 2715 suffix = ";"; 2716 } if ($truthy(target['$end_with?']("://"))) { 2717 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2718 } break; 2719 case ":": 2720 2721 if ($truthy((target = target.$chop())['$end_with?'](")"))) { 2722 2723 target = target.$chop(); 2724 suffix = "):"; 2725 } else { 2726 suffix = ":"; 2727 } if ($truthy(target['$end_with?']("://"))) { 2728 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2729 } break; 2730 } } $a = [nil, $hash2(["type"], {"type": "link"})], (attrs = $a[0]), (link_opts = $a[1]); 2731 if ($truthy(link_text)) { 2732 2733 if ($truthy(link_text['$include?']($$('R_SB')))) { 2734 new_link_text = (link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB'))); 2735 } if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) { 2736 2737 $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])); 2738 new_link_text = link_text; 2739 link_opts['$[]=']("id", attrs['$[]']("id")); 2740 } if ($truthy(link_text['$end_with?']("^"))) { 2741 2742 new_link_text = (link_text = link_text.$chop()); 2743 if ($truthy(attrs)) { 2744 if ($truthy(($ret_or_1 = attrs['$[]']("window")))) ; else { 2745 attrs['$[]=']("window", "_blank"); 2746 } 2747 } else { 2748 attrs = $hash2(["window"], {"window": "_blank"}); 2749 } } if (($truthy(new_link_text) && ($truthy(new_link_text['$empty?']())))) { 2750 2751 link_text = ($truthy(doc_attrs['$key?']("hide-uri-scheme")) ? (target.$sub($$('UriSniffRx'), "")) : (target)); 2752 bare = true; 2753 } } else { 2754 2755 link_text = ($truthy(doc_attrs['$key?']("hide-uri-scheme")) ? (target.$sub($$('UriSniffRx'), "")) : (target)); 2756 bare = true; 2757 } if ($truthy(bare)) { 2758 if ($truthy(attrs)) { 2759 attrs['$[]=']("role", ($truthy(attrs['$key?']("role")) ? ("bare " + (attrs['$[]']("role"))) : ("bare"))); 2760 } else { 2761 attrs = $hash2(["role"], {"role": "bare"}); 2762 } 2763 } doc.$register("links", ($a = ["target", target], $send(link_opts, '[]=', $a), $a[$a.length - 1])); 2764 if ($truthy(attrs)) { 2765 link_opts['$[]=']("attributes", attrs); 2766 } return "" + (prefix) + ($$('Inline').$new(self, "anchor", link_text, link_opts).$convert()) + (suffix);}, {$$s: self}); 2767 } if (($truthy(found_macroish) && (($truthy(text['$include?']("link:")) || ($truthy(text['$include?']("ilto:"))))))) { 2768 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; 2769 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 } else if ($truthy((mailto = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) { 2774 target = $rb_plus("mailto:", (mailto_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))); 2775 } else { 2776 target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)); 2777 } $a = [nil, $hash2(["type"], {"type": "link"})], (attrs = $a[0]), (link_opts = $a[1]); 2778 if (!$truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))['$empty?']())) { 2779 2780 if ($truthy(link_text['$include?']($$('R_SB')))) { 2781 link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB')); 2782 } if ($truthy(mailto)) { 2783 if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?'](","))))) { 2784 2785 $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])); 2786 link_opts['$[]=']("id", attrs['$[]']("id")); 2787 if ($truthy(attrs['$key?'](2))) { 2788 if ($truthy(attrs['$key?'](3))) { 2789 target = "" + (target) + "?subject=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](2))) + "&body=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](3))); 2790 } else { 2791 target = "" + (target) + "?subject=" + ($$('Helpers').$encode_uri_component(attrs['$[]'](2))); 2792 } 2793 } } 2794 } else if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) { 2795 2796 $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])); 2797 link_opts['$[]=']("id", attrs['$[]']("id")); 2798 } if ($truthy(link_text['$end_with?']("^"))) { 2799 2800 link_text = link_text.$chop(); 2801 if ($truthy(attrs)) { 2802 if ($truthy(($ret_or_1 = attrs['$[]']("window")))) ; else { 2803 attrs['$[]=']("window", "_blank"); 2804 } 2805 } else { 2806 attrs = $hash2(["window"], {"window": "_blank"}); 2807 } } } if ($truthy(link_text['$empty?']())) { 2808 if ($truthy(mailto)) { 2809 link_text = mailto_text; 2810 } else { 2811 2812 if ($truthy(doc_attrs['$key?']("hide-uri-scheme"))) { 2813 if ($truthy((link_text = target.$sub($$('UriSniffRx'), ""))['$empty?']())) { 2814 link_text = target; 2815 } 2816 } else { 2817 link_text = target; 2818 } if ($truthy(attrs)) { 2819 attrs['$[]=']("role", ($truthy(attrs['$key?']("role")) ? ("bare " + (attrs['$[]']("role"))) : ("bare"))); 2820 } else { 2821 attrs = $hash2(["role"], {"role": "bare"}); 2822 } } 2823 } doc.$register("links", ($a = ["target", target], $send(link_opts, '[]=', $a), $a[$a.length - 1])); 2824 if ($truthy(attrs)) { 2825 link_opts['$[]=']("attributes", attrs); 2826 } return $$('Inline').$new(self, "anchor", link_text, link_opts).$convert();}, {$$s: self}); 2827 } if ($truthy(text['$include?']("@"))) { 2828 text = $send(text, 'gsub', [$$('InlineEmailRx')], function $$27(){var $a, self = $$27.$$s == null ? this : $$27.$$s, target = nil, address = nil; 2829 2830 2831 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 2832 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)))) 2833 } target = $rb_plus("mailto:", (address = (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)))); 2834 doc.$register("links", target); 2835 return $$('Inline').$new(self, "anchor", address, $hash2(["type", "target"], {"type": "link", "target": target})).$convert();}, {$$s: self}); 2836 } if ((($truthy(found_square_bracket) && ($eqeq(self.context, "list_item"))) && ($eqeq(self.parent.$style(), "bibliography")))) { 2837 text = $send(text, 'sub', [$$('InlineBiblioAnchorRx')], function $$28(){var $a, self = $$28.$$s == null ? this : $$28.$$s; 2838 2839 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}); 2840 } if ((($truthy(found_square_bracket) && ($truthy(text['$include?']("[[")))) || (($truthy(found_macroish) && ($truthy(text['$include?']("or:"))))))) { 2841 text = $send(text, 'gsub', [$$('InlineAnchorRx')], function $$29(){var $a, self = $$29.$$s == null ? this : $$29.$$s, id = nil, reftext = nil; 2842 2843 2844 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 2845 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2846 } if ($truthy((id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) { 2847 reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 2848 } else { 2849 2850 id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4)); 2851 if (($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)))) && ($truthy(reftext['$include?']($$('R_SB')))))) { 2852 reftext = reftext.$gsub($$('ESC_R_SB'), $$('R_SB')); 2853 } } return $$('Inline').$new(self, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id})).$convert();}, {$$s: self}); 2854 } if ((($truthy(text['$include?']("&")) && ($truthy(text['$include?'](";&l")))) || (($truthy(found_macroish) && ($truthy(text['$include?']("xref:"))))))) { 2855 text = $send(text, 'gsub', [$$('InlineXrefMacroRx')], function $$30(){var $a, $b, self = $$30.$$s == null ? this : $$30.$$s, attrs = nil, refid = nil, link_text = nil, macro = nil, fragment = nil, hash_idx = nil, fragment_len = nil, path = nil, src2src = nil, target = nil; 2856 2857 2858 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2859 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2860 } attrs = $hash2([], {}); 2861 if ($truthy((refid = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) { 2862 if ($truthy(refid['$include?'](","))) { 2863 2864 $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])); 2865 if ($truthy((link_text = link_text.$lstrip())['$empty?']())) { 2866 link_text = nil; 2867 } } 2868 } else { 2869 2870 macro = true; 2871 refid = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)); 2872 if ($truthy((link_text = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3))))) { 2873 2874 if ($truthy(link_text['$include?']($$('R_SB')))) { 2875 link_text = link_text.$gsub($$('ESC_R_SB'), $$('R_SB')); 2876 } if (($not(doc.$compat_mode()) && ($truthy(link_text['$include?']("="))))) { 2877 $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])); 2878 } } } if ($truthy(doc.$compat_mode())) { 2879 fragment = refid; 2880 } else if (($truthy((hash_idx = refid.$index("#"))) && ($neqeq(refid['$[]']($rb_minus(hash_idx, 1)), "&")))) { 2881 if ($truthy($rb_gt(hash_idx, 0))) { 2882 2883 if ($truthy($rb_gt((fragment_len = $rb_minus($rb_minus(refid.$length(), 1), hash_idx)), 0))) { 2884 $a = [refid.$slice(0, hash_idx), refid.$slice($rb_plus(hash_idx, 1), fragment_len)], (path = $a[0]), (fragment = $a[1]); 2885 } else { 2886 path = refid.$chop(); 2887 } if ($truthy(macro)) { 2888 if ($truthy(path['$end_with?'](".adoc"))) { 2889 src2src = (path = path.$slice(0, $rb_minus(path.$length(), 5))); 2890 } else if ($not($$('Helpers')['$extname?'](path))) { 2891 src2src = path; 2892 } 2893 } else if ($truthy($send(path, 'end_with?', $to_a($$('ASCIIDOC_EXTENSIONS').$keys())))) { 2894 src2src = (path = path.$slice(0, path.$rindex("."))); 2895 } else { 2896 src2src = path; 2897 } } else { 2898 $a = [refid, refid.$slice(1, refid.$length())], (target = $a[0]), (fragment = $a[1]); 2899 } 2900 } else if ($truthy(macro)) { 2901 if ($truthy(refid['$end_with?'](".adoc"))) { 2902 src2src = (path = refid.$slice(0, $rb_minus(refid.$length(), 5))); 2903 } else if ($truthy($$('Helpers')['$extname?'](refid))) { 2904 path = refid; 2905 } else { 2906 fragment = refid; 2907 } 2908 } else { 2909 fragment = refid; 2910 } if ($truthy(target)) { 2911 2912 refid = fragment; 2913 if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) { 2914 self.$logger().$info("possible invalid reference: " + (refid)); 2915 } } else if ($truthy(path)) { 2916 if (($truthy(src2src) && (($eqeq(doc.$attributes()['$[]']("docname"), path) || ($truthy(doc.$catalog()['$[]']("includes")['$[]'](path))))))) { 2917 if ($truthy(fragment)) { 2918 2919 $a = [fragment, nil, "#" + (fragment)], (refid = $a[0]), (path = $a[1]), (target = $a[2]); 2920 if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) { 2921 self.$logger().$info("possible invalid reference: " + (refid)); 2922 } } else { 2923 $a = [nil, nil, "#"], (refid = $a[0]), (path = $a[1]), (target = $a[2]); 2924 } 2925 } else { 2926 2927 $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]); 2928 if ($truthy(fragment)) { 2929 $a = ["" + (refid) + "#" + (fragment), "" + (path) + "#" + (fragment)], (refid = $a[0]), (target = $a[1]); 2930 } else { 2931 target = path; 2932 } } 2933 } else if (($truthy(doc.$compat_mode()) || ($not($$('Compliance').$natural_xrefs())))) { 2934 2935 $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]); 2936 if (($truthy(self.$logger()['$info?']()) && ($not(doc.$catalog()['$[]']("refs")['$[]'](refid))))) { 2937 self.$logger().$info("possible invalid reference: " + (refid)); 2938 } } else if ($truthy(doc.$catalog()['$[]']("refs")['$[]'](fragment))) { 2939 $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]); 2940 } else if ((($truthy(fragment['$include?'](" ")) || ($neqeq(fragment.$downcase(), fragment))) && ($truthy((refid = doc.$resolve_id(fragment)))))) { 2941 $a = [refid, "#" + (refid)], (fragment = $a[0]), (target = $a[1]); 2942 } else { 2943 2944 $a = [fragment, "#" + (fragment)], (refid = $a[0]), (target = $a[1]); 2945 if ($truthy(self.$logger()['$info?']())) { 2946 self.$logger().$info("possible invalid reference: " + (refid)); 2947 } } attrs['$[]=']("path", path); 2948 attrs['$[]=']("fragment", fragment); 2949 attrs['$[]=']("refid", refid); 2950 return $$('Inline').$new(self, "anchor", link_text, $hash2(["type", "target", "attributes"], {"type": "xref", "target": target, "attributes": attrs})).$convert();}, {$$s: self}); 2951 } if (($truthy(found_macroish) && ($truthy(text['$include?']("tnote"))))) { 2952 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; 2953 2954 2955 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']($$('RS')))) { 2956 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 2957 } if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 2958 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3)))) { 2959 2960 $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])); 2961 if (!$truthy(doc.$compat_mode())) { 2962 self.$logger().$warn("found deprecated footnoteref macro: " + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))) + "; use footnote macro with target instead"); 2963 } } else { 2964 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2965 } 2966 } else { 2967 2968 id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)); 2969 content = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 2970 } if ($truthy(id)) { 2971 if ($truthy((footnote = $send(doc.$footnotes(), 'find', [], function $$32(candidate){ 2972 2973 if (candidate == null) candidate = nil; 2974 return candidate.$id()['$=='](id);})))) { 2975 2976 $a = [footnote.$index(), footnote.$text()], (index = $a[0]), (content = $a[1]); 2977 $a = ["xref", id, nil], (type = $a[0]), (target = $a[1]), (id = $a[2]); 2978 } else if ($truthy(content)) { 2979 2980 content = self.$restore_passthroughs(self.$normalize_text(content, true, true)); 2981 index = doc.$counter("footnote-number"); 2982 doc.$register("footnotes", $$$($$('Document'), 'Footnote').$new(index, id, content)); 2983 $a = ["ref", nil], (type = $a[0]), (target = $a[1]); 2984 } else { 2985 2986 self.$logger().$warn("invalid footnote reference: " + (id)); 2987 $a = ["xref", id, id, nil], (type = $a[0]), (target = $a[1]), (content = $a[2]), (id = $a[3]); 2988 } 2989 } else if ($truthy(content)) { 2990 2991 content = self.$restore_passthroughs(self.$normalize_text(content, true, true)); 2992 index = doc.$counter("footnote-number"); 2993 doc.$register("footnotes", $$$($$('Document'), 'Footnote').$new(index, id, content)); 2994 type = (target = nil); 2995 } else { 2996 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) 2997 } 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}); 2998 } return text; 2999 }); 3000 3001 $def(self, '$sub_post_replacements', function $$sub_post_replacements(text) { 3002 var self = this, lines = nil, last = nil; 3003 if (self.document == null) self.document = nil; 3004 if (self.attributes == null) self.attributes = nil; 3005 3006 if (($truthy(self.attributes['$[]']("hardbreaks-option")) || ($truthy(self.document.$attributes()['$[]']("hardbreaks-option"))))) { 3007 3008 lines = text.$split($$('LF'), -1); 3009 if ($truthy($rb_lt(lines.$size(), 2))) { 3010 return text 3011 } last = lines.$pop(); 3012 return $send(lines, 'map', [], function $$33(line){var self = $$33.$$s == null ? this : $$33.$$s; 3013 3014 3015 if (line == null) line = nil; 3016 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')); 3017 } else if (($truthy(text['$include?']($$('PLUS'))) && ($truthy(text['$include?']($$('HARD_LINE_BREAK')))))) { 3018 return $send(text, 'gsub', [$$('HardLineBreakRx')], function $$34(){var $a, self = $$34.$$s == null ? this : $$34.$$s; 3019 3020 return $$('Inline').$new(self, "break", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $hash2(["type"], {"type": "line"})).$convert()}, {$$s: self}) 3021 } else { 3022 return text 3023 } 3024 }); 3025 3026 $def(self, '$sub_source', function $$sub_source(source, process_callouts) { 3027 var self = this; 3028 3029 if ($truthy(process_callouts)) { 3030 return self.$sub_callouts(self.$sub_specialchars(source)) 3031 } else { 3032 3033 return self.$sub_specialchars(source); 3034 } 3035 }); 3036 3037 $def(self, '$sub_callouts', function $$sub_callouts(text) { 3038 var self = this, callout_rx = nil, autonum = nil; 3039 3040 3041 callout_rx = ($truthy(self['$attr?']("line-comment")) ? ($$('CalloutSourceRxMap')['$[]'](self.$attr("line-comment"))) : ($$('CalloutSourceRx'))); 3042 autonum = 0; 3043 return $send(text, 'gsub', [callout_rx], function $$35(){var $a, self = $$35.$$s == null ? this : $$35.$$s, $ret_or_1 = nil; 3044 if (self.document == null) self.document = nil; 3045 3046 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) { 3047 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$sub($$('RS'), "") 3048 } else { 3049 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() 3050 }}, {$$s: self}); 3051 }); 3052 3053 $def(self, '$highlight_source', function $$highlight_source(source, process_callouts) { 3054 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; 3055 if (self.document == null) self.document = nil; 3056 if (self.passthroughs == null) self.passthroughs = nil; 3057 3058 3059 if (!($truthy((syntax_hl = self.document.$syntax_highlighter())) && ($truthy(syntax_hl['$highlight?']())))) { 3060 return self.$sub_source(source, process_callouts) 3061 } if ($truthy(process_callouts)) { 3062 $b = self.$extract_callouts(source), $a = $to_ary($b), (source = ($a[0] == null ? nil : $a[0])), (callout_marks = ($a[1] == null ? nil : $a[1])); 3063 } doc_attrs = self.document.$attributes(); 3064 syntax_hl_name = syntax_hl.$name(); 3065 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))))) { 3066 start_line_number = 1; 3067 } if ($truthy(self['$attr?']("highlight"))) { 3068 highlight_lines = self.$resolve_lines_to_highlight(source, self.$attr("highlight"), start_line_number); 3069 } $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])); 3070 if (!$truthy(self.passthroughs['$empty?']())) { 3071 highlighted = highlighted.$gsub($$('HighlightedPassSlotRx'), "" + ($$('PASS_START')) + "\\1" + ($$('PASS_END'))); 3072 } if ($truthy(callout_marks['$nil_or_empty?']())) { 3073 return highlighted 3074 } else { 3075 3076 return self.$restore_callouts(highlighted, callout_marks, source_offset); 3077 } }); 3078 3079 $def(self, '$resolve_lines_to_highlight', function $$resolve_lines_to_highlight(source, spec, start) { 3080 var lines = nil, shift = nil; 3081 3082 3083 if (start == null) start = nil; 3084 lines = []; 3085 if ($truthy(spec['$include?'](" "))) { 3086 spec = spec.$delete(" "); 3087 } $send(($truthy(spec['$include?'](",")) ? (spec.$split(",")) : (spec.$split(";"))), 'map', [], function $$36(entry){var $a, $b, negate = nil, delim = nil, from = nil, to = nil, line = nil; 3088 3089 3090 if (entry == null) entry = nil; 3091 if ($truthy(entry['$start_with?']("!"))) { 3092 3093 entry = entry.$slice(1, entry.$length()); 3094 negate = true; 3095 } if ($truthy((delim = ($truthy(entry['$include?']("..")) ? ("..") : (($truthy(entry['$include?']("-")) ? ("-") : (nil))))))) { 3096 3097 $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])); 3098 if (($truthy(to['$empty?']()) || ($truthy($rb_lt((to = to.$to_i()), 0))))) { 3099 to = $rb_plus(source.$count($$('LF')), 1); 3100 } if ($truthy(negate)) { 3101 return (lines = $rb_minus(lines, Opal.Range.$new(from.$to_i(), to, false).$to_a())) 3102 } else { 3103 return (lines = lines['$|'](Opal.Range.$new(from.$to_i(), to, false).$to_a())) 3104 } } else if ($truthy(negate)) { 3105 return lines.$delete(entry.$to_i()) 3106 } else if ($not(lines['$include?']((line = entry.$to_i())))) { 3107 return lines['$<<'](line) 3108 } else { 3109 return nil 3110 }}); 3111 if (!$eqeq((shift = ($truthy(start) ? ($rb_minus(start, 1)) : (0))), 0)) { 3112 lines = $send(lines, 'map', [], function $$37(it){ 3113 3114 if (it == null) it = nil; 3115 return $rb_minus(it, shift);}); 3116 } return lines.$sort(); 3117 }, -3); 3118 3119 $def(self, '$extract_passthroughs', function $$extract_passthroughs(text) { 3120 var $a, $b, self = this, compat_mode = nil, passthrus = nil, pass_inline_char1 = nil, pass_inline_char2 = nil, pass_inline_rx = nil; 3121 if (self.document == null) self.document = nil; 3122 if (self.passthroughs == null) self.passthroughs = nil; 3123 3124 3125 compat_mode = self.document.$compat_mode(); 3126 passthrus = self.passthroughs; 3127 if ((($truthy(text['$include?']("++")) || ($truthy(text['$include?']("$$")))) || ($truthy(text['$include?']("ss:"))))) { 3128 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; 3129 3130 3131 if ($truthy((boundary = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4))))) { 3132 3133 if (($truthy(compat_mode) && ($eqeq(boundary, "++")))) { 3134 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)))) + "++" 3135 } if ($truthy((attrlist = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) { 3136 if ($truthy($rb_gt((escape_count = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$length()), 0))) { 3137 return "" + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1))) + "[" + (attrlist) + "]" + ($rb_times($$('RS'), $rb_minus(escape_count, 1))) + (boundary) + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](5))) + (boundary) 3138 } else if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), $$('RS'))) { 3139 preceding = "[" + (attrlist) + "]"; 3140 } else if ($eqeq(boundary, "++")) { 3141 if ($eqeq(attrlist, "x-")) { 3142 3143 old_behavior = true; 3144 attributes = $hash2([], {}); 3145 } else if ($truthy(attrlist['$end_with?'](" x-"))) { 3146 3147 old_behavior = true; 3148 attributes = self.$parse_quoted_text_attributes(attrlist.$slice(0, $rb_minus(attrlist.$length(), 3))); 3149 } else { 3150 attributes = self.$parse_quoted_text_attributes(attrlist); 3151 } 3152 } else { 3153 attributes = self.$parse_quoted_text_attributes(attrlist); 3154 } 3155 } else if ($truthy($rb_gt((escape_count = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)).$length()), 0))) { 3156 return "" + ($rb_times($$('RS'), $rb_minus(escape_count, 1))) + (boundary) + ((($a = $gvars['~']) === nil ? nil : $a['$[]'](5))) + (boundary) 3157 } subs = ($eqeq(boundary, "+++") ? ([]) : ($$('BASIC_SUBS'))); 3158 if ($truthy(attributes)) { 3159 if ($truthy(old_behavior)) { 3160 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type", "attributes"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": $$('NORMAL_SUBS'), "type": "monospaced", "attributes": attributes})); 3161 } else { 3162 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type", "attributes"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": subs, "type": "unquoted", "attributes": attributes})); 3163 } 3164 } else { 3165 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs"], {"text": (($a = $gvars['~']) === nil ? nil : $a['$[]'](5)), "subs": subs})); 3166 } } else { 3167 3168 if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](6)), $$('RS'))) { 3169 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$slice(1, (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length()) 3170 } if ($truthy((subs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](7))))) { 3171 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)})); 3172 } else { 3173 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text"], {"text": self.$normalize_text((($a = $gvars['~']) === nil ? nil : $a['$[]'](8)), nil, true)})); 3174 } } return "" + (($truthy(($ret_or_1 = preceding)) ? ($ret_or_1) : (""))) + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self}); 3175 } $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])); 3176 if (($truthy(text['$include?'](pass_inline_char1)) || (($truthy(pass_inline_char2) && ($truthy(text['$include?'](pass_inline_char2))))))) { 3177 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; 3178 3179 3180 preceding = (($c = $gvars['~']) === nil ? nil : $c['$[]'](1)); 3181 attrlist = ($truthy(($ret_or_1 = (($c = $gvars['~']) === nil ? nil : $c['$[]'](4)))) ? ($ret_or_1) : ((($c = $gvars['~']) === nil ? nil : $c['$[]'](3)))); 3182 if ($truthy((($c = $gvars['~']) === nil ? nil : $c['$[]'](5)))) { 3183 escaped = true; 3184 } quoted_text = (($c = $gvars['~']) === nil ? nil : $c['$[]'](6)); 3185 format_mark = (($c = $gvars['~']) === nil ? nil : $c['$[]'](7)); 3186 content = (($c = $gvars['~']) === nil ? nil : $c['$[]'](8)); 3187 if ($truthy(compat_mode)) { 3188 old_behavior = true; 3189 } else if (($truthy(attrlist) && (($eqeq(attrlist, "x-") || ($truthy(attrlist['$end_with?'](" x-"))))))) { 3190 old_behavior = (old_behavior_forced = true); 3191 } if ($truthy(attrlist)) { 3192 if ($truthy(escaped)) { 3193 return "" + (preceding) + "[" + (attrlist) + "]" + (quoted_text.$slice(1, quoted_text.$length())) 3194 } else if ($eqeq(preceding, $$('RS'))) { 3195 3196 if (($truthy(old_behavior_forced) && ($eqeq(format_mark, "`")))) { 3197 return "" + (preceding) + "[" + (attrlist) + "]" + (quoted_text) 3198 } preceding = "[" + (attrlist) + "]"; 3199 } else if ($truthy(old_behavior_forced)) { 3200 attributes = ($eqeq(attrlist, "x-") ? ($hash2([], {})) : (self.$parse_quoted_text_attributes(attrlist.$slice(0, $rb_minus(attrlist.$length(), 3))))); 3201 } else { 3202 attributes = self.$parse_quoted_text_attributes(attrlist); 3203 } 3204 } else if ($truthy(escaped)) { 3205 return "" + (preceding) + (quoted_text.$slice(1, quoted_text.$length())) 3206 } else if (($truthy(compat_mode) && ($eqeq(preceding, $$('RS'))))) { 3207 return quoted_text 3208 } if ($truthy(compat_mode)) { 3209 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": $$('BASIC_SUBS'), "attributes": attributes, "type": "monospaced"})); 3210 } else if ($truthy(attributes)) { 3211 if ($truthy(old_behavior)) { 3212 3213 subs = ($eqeq(format_mark, "`") ? ($$('BASIC_SUBS')) : ($$('NORMAL_SUBS'))); 3214 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": subs, "attributes": attributes, "type": "monospaced"})); 3215 } else { 3216 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": $$('BASIC_SUBS'), "attributes": attributes, "type": "unquoted"})); 3217 } 3218 } else { 3219 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs"], {"text": content, "subs": $$('BASIC_SUBS')})); 3220 } return "" + (preceding) + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self}); 3221 } if (($truthy(text['$include?'](":")) && (($truthy(text['$include?']("stem:")) || ($truthy(text['$include?']("math:"))))))) { 3222 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; 3223 if (self.document == null) self.document = nil; 3224 3225 3226 if ($truthy((($c = $gvars['~']) === nil ? nil : $c['$[]'](0))['$start_with?']($$('RS')))) { 3227 return (($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$slice(1, (($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$length()) 3228 } if ($eqeq((type = (($c = $gvars['~']) === nil ? nil : $c['$[]'](1)).$to_sym()), "stem")) { 3229 type = $$('STEM_TYPE_ALIASES')['$[]'](self.document.$attributes()['$[]']("stem")).$to_sym(); 3230 } subs = (($c = $gvars['~']) === nil ? nil : $c['$[]'](2)); 3231 content = self.$normalize_text((($c = $gvars['~']) === nil ? nil : $c['$[]'](3)), nil, true); 3232 if ((($eqeq(type, "latexmath") && ($truthy(content['$start_with?']("$")))) && ($truthy(content['$end_with?']("$"))))) { 3233 content = content.$slice(1, $rb_minus(content.$length(), 2)); 3234 } subs = ($truthy(subs) ? (self.$resolve_pass_subs(subs)) : (($truthy(self.document['$basebackend?']("html")) ? ($$('BASIC_SUBS')) : (nil)))); 3235 passthrus['$[]=']((passthru_key = passthrus.$size()), $hash2(["text", "subs", "type"], {"text": content, "subs": subs, "type": type})); 3236 return "" + ($$('PASS_START')) + (passthru_key) + ($$('PASS_END'));}, {$$s: self}); 3237 } return text; 3238 }); 3239 3240 $def(self, '$restore_passthroughs', function $$restore_passthroughs(text) { 3241 var self = this, passthrus = nil; 3242 if (self.passthroughs == null) self.passthroughs = nil; 3243 3244 3245 passthrus = self.passthroughs; 3246 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; 3247 3248 if ($truthy((pass = passthrus['$[]']((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)).$to_i())))) { 3249 3250 subbed_text = self.$apply_subs(pass['$[]']("text"), pass['$[]']("subs")); 3251 if ($truthy((type = pass['$[]']("type")))) { 3252 3253 if ($truthy((attributes = pass['$[]']("attributes")))) { 3254 id = attributes['$[]']("id"); 3255 } subbed_text = $$('Inline').$new(self, "quoted", subbed_text, $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert(); 3256 } if ($truthy(subbed_text['$include?']($$('PASS_START')))) { 3257 return self.$restore_passthroughs(subbed_text) 3258 } else { 3259 return subbed_text 3260 } } else { 3261 3262 self.$logger().$error("unresolved passthrough detected: " + (text)); 3263 return "??pass??"; 3264 }}, {$$s: self}); 3265 }); 3266 3267 $def(self, '$resolve_subs', function $$resolve_subs(subs, type, defaults, subject) { 3268 var self = this, candidates = nil, modifiers_present = nil, resolved = nil, invalid = nil; 3269 3270 3271 if (type == null) type = "block"; 3272 if (defaults == null) defaults = nil; 3273 if (subject == null) subject = nil; 3274 if ($truthy(subs['$nil_or_empty?']())) { 3275 return nil 3276 } candidates = nil; 3277 if ($truthy(subs['$include?'](" "))) { 3278 subs = subs.$delete(" "); 3279 } modifiers_present = $$('SubModifierSniffRx')['$match?'](subs); 3280 $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; 3281 3282 3283 if (key == null) key = nil; 3284 modifier_operation = nil; 3285 if ($truthy(modifiers_present)) { 3286 if ($eqeq((first = key.$chr()), "+")) { 3287 3288 modifier_operation = "append"; 3289 key = key.$slice(1, key.$length()); 3290 } else if ($eqeq(first, "-")) { 3291 3292 modifier_operation = "remove"; 3293 key = key.$slice(1, key.$length()); 3294 } else if ($truthy(key['$end_with?']("+"))) { 3295 3296 modifier_operation = "prepend"; 3297 key = key.$chop(); 3298 } 3299 } key = key.$to_sym(); 3300 if (($eqeq(type, "inline") && (($eqeq(key, "verbatim") || ($eqeq(key, "v")))))) { 3301 resolved_keys = $$('BASIC_SUBS'); 3302 } else if ($truthy($$('SUB_GROUPS')['$key?'](key))) { 3303 resolved_keys = $$('SUB_GROUPS')['$[]'](key); 3304 } else if ((($eqeq(type, "inline") && ($eqeq(key.$length(), 1))) && ($truthy($$('SUB_HINTS')['$key?'](key))))) { 3305 3306 resolved_key = $$('SUB_HINTS')['$[]'](key); 3307 if ($truthy((candidate = $$('SUB_GROUPS')['$[]'](resolved_key)))) { 3308 resolved_keys = candidate; 3309 } else { 3310 resolved_keys = [resolved_key]; 3311 } } else { 3312 resolved_keys = [key]; 3313 } if ($truthy(modifier_operation)) { 3314 3315 candidates = ($truthy(($ret_or_1 = candidates)) ? ($ret_or_1) : (($truthy(defaults) ? (defaults.$drop(0)) : ([])))); 3316 3317 switch (modifier_operation) { 3318 case "append": 3319 return (candidates = $rb_plus(candidates, resolved_keys)) 3320 case "prepend": 3321 return (candidates = $rb_plus(resolved_keys, candidates)) 3322 case "remove": 3323 return (candidates = $rb_minus(candidates, resolved_keys)) 3324 default: 3325 return nil 3326 } } else { 3327 3328 candidates = ($truthy(($ret_or_1 = candidates)) ? ($ret_or_1) : ([])); 3329 return (candidates = $rb_plus(candidates, resolved_keys)); 3330 }}); 3331 if (!$truthy(candidates)) { 3332 return nil 3333 } resolved = candidates['$&']($$('SUB_OPTIONS')['$[]'](type)); 3334 if (!$truthy($rb_minus(candidates, resolved)['$empty?']())) { 3335 3336 invalid = $rb_minus(candidates, resolved); 3337 self.$logger().$warn("invalid substitution type" + (($truthy($rb_gt(invalid.$size(), 1)) ? ("s") : (""))) + (($truthy(subject) ? (" for ") : (""))) + (subject) + ": " + (invalid.$join(", "))); 3338 } return resolved; 3339 }, -2); 3340 3341 $def(self, '$resolve_block_subs', function $$resolve_block_subs(subs, defaults, subject) { 3342 var self = this; 3343 3344 return self.$resolve_subs(subs, "block", defaults, subject) 3345 }); 3346 3347 $def(self, '$resolve_pass_subs', function $$resolve_pass_subs(subs) { 3348 var self = this; 3349 3350 return self.$resolve_subs(subs, "inline", nil, "passthrough macro") 3351 }); 3352 3353 $def(self, '$expand_subs', function $$expand_subs(subs, subject) { 3354 var self = this, $ret_or_1 = nil, $ret_or_2 = nil, expanded_subs = nil; 3355 3356 3357 if (subject == null) subject = nil; 3358 if ($eqeqeq($$$('Symbol'), ($ret_or_1 = subs))) { 3359 if ($eqeq(subs, "none")) { 3360 return nil 3361 } else if ($truthy(($ret_or_2 = $$('SUB_GROUPS')['$[]'](subs)))) { 3362 return $ret_or_2 3363 } else { 3364 return [subs] 3365 } 3366 } else if ($eqeqeq($$$('Array'), $ret_or_1)) { 3367 3368 expanded_subs = []; 3369 $send(subs, 'each', [], function $$43(key){var sub_group = nil; 3370 3371 3372 if (key == null) key = nil; 3373 if ($eqeq(key, "none")) { 3374 return nil 3375 } else if ($truthy((sub_group = $$('SUB_GROUPS')['$[]'](key)))) { 3376 return (expanded_subs = $rb_plus(expanded_subs, sub_group)) 3377 } else { 3378 return expanded_subs['$<<'](key) 3379 }}); 3380 if ($truthy(expanded_subs['$empty?']())) { 3381 return nil 3382 } else { 3383 return expanded_subs 3384 } } else { 3385 return self.$resolve_subs(subs, "inline", nil, subject) 3386 } }, -2); 3387 3388 $def(self, '$commit_subs', function $$commit_subs() { 3389 var self = this, default_subs = nil, custom_subs = nil, $ret_or_1 = nil, idx = nil, syntax_hl = nil; 3390 if (self.default_subs == null) self.default_subs = nil; 3391 if (self.content_model == null) self.content_model = nil; 3392 if (self.context == null) self.context = nil; 3393 if (self.subs == null) self.subs = nil; 3394 if (self.attributes == null) self.attributes = nil; 3395 if (self.document == null) self.document = nil; 3396 if (self.style == null) self.style = nil; 3397 3398 3399 if (!$truthy((default_subs = self.default_subs))) { 3400 3401 switch (self.content_model) { 3402 case "simple": 3403 default_subs = $$('NORMAL_SUBS'); 3404 break; 3405 case "verbatim": 3406 default_subs = ($eqeq(self.context, "verse") ? ($$('NORMAL_SUBS')) : ($$('VERBATIM_SUBS'))); 3407 break; 3408 case "raw": 3409 default_subs = ($eqeq(self.context, "stem") ? ($$('BASIC_SUBS')) : ($$('NO_SUBS'))); 3410 break; 3411 default: 3412 return self.subs 3413 } 3414 } if ($truthy((custom_subs = self.attributes['$[]']("subs")))) { 3415 self.subs = ($truthy(($ret_or_1 = self.$resolve_block_subs(custom_subs, default_subs, self.context))) ? ($ret_or_1) : ([])); 3416 } else { 3417 self.subs = default_subs.$drop(0); 3418 } 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")))))) { 3419 self.subs['$[]='](idx, "highlight"); 3420 } return nil; 3421 }); 3422 3423 $def(self, '$parse_attributes', function $$parse_attributes(attrlist, posattrs, opts) { 3424 var self = this, block = nil, into = nil; 3425 if (self.document == null) self.document = nil; 3426 3427 3428 if (posattrs == null) posattrs = []; 3429 if (opts == null) opts = $hash2([], {}); 3430 if ($truthy(($truthy(attrlist) ? (attrlist['$empty?']()) : (true)))) { 3431 return $hash2([], {}) 3432 } if ($truthy(opts['$[]']("unescape_input"))) { 3433 attrlist = self.$normalize_text(attrlist, true, true); 3434 } if (($truthy(opts['$[]']("sub_input")) && ($truthy(attrlist['$include?']($$('ATTR_REF_HEAD')))))) { 3435 attrlist = self.document.$sub_attributes(attrlist); 3436 } if ($truthy(opts['$[]']("sub_result"))) { 3437 block = self; 3438 } if ($truthy((into = opts['$[]']("into")))) { 3439 return $$('AttributeList').$new(attrlist, block).$parse_into(into, posattrs) 3440 } else { 3441 return $$('AttributeList').$new(attrlist, block).$parse(posattrs) 3442 } }, -2); 3443 self.$private(); 3444 3445 $def(self, '$extract_attributes_from_text', function $$extract_attributes_from_text(text, default_text) { 3446 var self = this, attrlist = nil, resolved_text = nil, attrs = nil; 3447 3448 3449 if (default_text == null) default_text = nil; 3450 attrlist = ($truthy(text['$include?']($$('LF'))) ? (text.$tr($$('LF'), " ")) : (text)); 3451 if ($truthy((resolved_text = (attrs = $$('AttributeList').$new(attrlist, self).$parse())['$[]'](1)))) { 3452 if ($eqeq(resolved_text, attrlist)) { 3453 return [text, attrs.$clear()] 3454 } else { 3455 return [resolved_text, attrs] 3456 } 3457 } else { 3458 return [default_text, attrs] 3459 } }, -2); 3460 3461 $def(self, '$extract_callouts', function $$extract_callouts(source) { 3462 var self = this, callout_marks = nil, autonum = nil, lineno = nil, last_lineno = nil, callout_rx = nil; 3463 3464 3465 callout_marks = $hash2([], {}); 3466 autonum = (lineno = 0); 3467 last_lineno = nil; 3468 callout_rx = ($truthy(self['$attr?']("line-comment")) ? ($$('CalloutExtractRxMap')['$[]'](self.$attr("line-comment"))) : ($$('CalloutExtractRx'))); 3469 source = $send(source.$split($$('LF'), -1), 'map', [], function $$44(line){ 3470 3471 if (line == null) line = nil; 3472 lineno = $rb_plus(lineno, 1); 3473 return $send(line, 'gsub', [callout_rx], function $$45(){var $a, $ret_or_1 = nil; 3474 3475 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) { 3476 return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$sub($$('RS'), "") 3477 } else { 3478 3479 ($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))))]); 3480 last_lineno = lineno; 3481 return ""; 3482 }});}).$join($$('LF')); 3483 if ($truthy(last_lineno)) { 3484 if ($eqeq(last_lineno, lineno)) { 3485 source = "" + (source) + ($$('LF')); 3486 } 3487 } else { 3488 callout_marks = nil; 3489 } return [source, callout_marks]; 3490 }); 3491 3492 $def(self, '$restore_callouts', function $$restore_callouts(source, callout_marks, source_offset) { 3493 var self = this, preamble = nil, lineno = nil; 3494 3495 3496 if (source_offset == null) source_offset = nil; 3497 if ($truthy(source_offset)) { 3498 3499 preamble = source.$slice(0, source_offset); 3500 source = source.$slice(source_offset, source.$length()); 3501 } else { 3502 preamble = ""; 3503 } lineno = 0; 3504 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; 3505 if (self.document == null) self.document = nil; 3506 3507 3508 if (line == null) line = nil; 3509 if ($truthy((conums = callout_marks.$delete((lineno = $rb_plus(lineno, 1)))))) { 3510 if ($eqeq(conums.$size(), 1)) { 3511 3512 $b = conums['$[]'](0), $a = $to_ary($b), (guard = ($a[0] == null ? nil : $a[0])), (numeral = ($a[1] == null ? nil : $a[1])); 3513 return "" + (line) + ($$('Inline').$new(self, "callout", numeral, $hash2(["id", "attributes"], {"id": self.document.$callouts().$read_next_id(), "attributes": $hash2(["guard"], {"guard": guard})})).$convert()); 3514 } else { 3515 return "" + (line) + ($send(conums, 'map', [], function $$47(guard_it, numeral_it){var self = $$47.$$s == null ? this : $$47.$$s; 3516 if (self.document == null) self.document = nil; 3517 3518 3519 if (guard_it == null) guard_it = nil; 3520 if (numeral_it == null) numeral_it = nil; 3521 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(" ")) 3522 } 3523 } else { 3524 return line 3525 }}, {$$s: self}).$join($$('LF'))); 3526 }, -3); 3527 3528 $def(self, '$convert_quoted_text', function $$convert_quoted_text(match, type, scope) { 3529 var self = this, attrs = nil, unescaped_attrs = nil, attrlist = nil, id = nil, attributes = nil; 3530 3531 3532 if ($truthy(match['$[]'](0)['$start_with?']($$('RS')))) { 3533 if (($eqeq(scope, "constrained") && ($truthy((attrs = match['$[]'](2)))))) { 3534 unescaped_attrs = "[" + (attrs) + "]"; 3535 } else { 3536 return match['$[]'](0).$slice(1, match['$[]'](0).$length()) 3537 } 3538 } if ($eqeq(scope, "constrained")) { 3539 if ($truthy(unescaped_attrs)) { 3540 return "" + (unescaped_attrs) + ($$('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type"], {"type": type})).$convert()) 3541 } else { 3542 3543 if ($truthy((attrlist = match['$[]'](2)))) { 3544 3545 id = (attributes = self.$parse_quoted_text_attributes(attrlist))['$[]']("id"); 3546 if ($eqeq(type, "mark")) { 3547 type = "unquoted"; 3548 } } return "" + (match['$[]'](1)) + ($$('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert()); 3549 } 3550 } else { 3551 3552 if ($truthy((attrlist = match['$[]'](1)))) { 3553 3554 id = (attributes = self.$parse_quoted_text_attributes(attrlist))['$[]']("id"); 3555 if ($eqeq(type, "mark")) { 3556 type = "unquoted"; 3557 } } return $$('Inline').$new(self, "quoted", match['$[]'](2), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert(); 3558 } }); 3559 3560 $def(self, '$do_replacement', function $$do_replacement(m, replacement, restore) { 3561 var captured = nil; 3562 3563 if ($truthy((captured = m['$[]'](0))['$include?']($$('RS')))) { 3564 return captured.$sub($$('RS'), "") 3565 } else 3566 switch (restore) { 3567 case "none": 3568 return replacement 3569 case "bounding": 3570 return $rb_plus($rb_plus(m['$[]'](1), replacement), m['$[]'](2)) 3571 default: 3572 return $rb_plus(m['$[]'](1), replacement) 3573 } 3574 }); 3575 3576 $def(self, '$parse_quoted_text_attributes', function $$parse_quoted_text_attributes(str) { 3577 var $a, $b, self = this, before = nil, after = nil, attrs = nil, id = nil, roles = nil; 3578 3579 3580 if ($truthy(str['$include?']($$('ATTR_REF_HEAD')))) { 3581 str = self.$sub_attributes(str); 3582 } if ($truthy(str['$include?'](","))) { 3583 str = str.$slice(0, str.$index(",")); 3584 } if ($truthy((str = str.$strip())['$empty?']())) { 3585 return $hash2([], {}) 3586 } else if (($truthy(str['$start_with?'](".", "#")) && ($truthy($$('Compliance').$shorthand_property_syntax())))) { 3587 3588 $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])); 3589 attrs = $hash2([], {}); 3590 if ($truthy(after['$empty?']())) { 3591 if ($truthy($rb_gt(before.$length(), 1))) { 3592 attrs['$[]=']("role", before.$tr(".", " ").$lstrip()); 3593 } 3594 } else { 3595 3596 $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])); 3597 if (!$truthy(id['$empty?']())) { 3598 attrs['$[]=']("id", id); 3599 } if ($truthy(roles['$empty?']())) { 3600 if ($truthy($rb_gt(before.$length(), 1))) { 3601 attrs['$[]=']("role", before.$tr(".", " ").$lstrip()); 3602 } 3603 } else if ($truthy($rb_gt(before.$length(), 1))) { 3604 attrs['$[]=']("role", $rb_plus($rb_plus(before, "."), roles).$tr(".", " ").$lstrip()); 3605 } else { 3606 attrs['$[]=']("role", roles.$tr(".", " ")); 3607 } } return attrs; 3608 } else { 3609 return $hash2(["role"], {"role": str}) 3610 } }); 3611 3612 $def(self, '$normalize_text', function $$normalize_text(text, normalize_whitespace, unescape_closing_square_brackets) { 3613 3614 3615 if (normalize_whitespace == null) normalize_whitespace = nil; 3616 if (unescape_closing_square_brackets == null) unescape_closing_square_brackets = nil; 3617 if (!$truthy(text['$empty?']())) { 3618 3619 if ($truthy(normalize_whitespace)) { 3620 text = text.$strip().$tr($$('LF'), " "); 3621 } if (($truthy(unescape_closing_square_brackets) && ($truthy(text['$include?']($$('R_SB')))))) { 3622 text = text.$gsub($$('ESC_R_SB'), $$('R_SB')); 3623 } } return text; 3624 }, -2); 3625 return $def(self, '$split_simple_csv', function $$split_simple_csv(str) { 3626 var values = nil, accum = nil, quote_open = nil; 3627 3628 if ($truthy(str['$empty?']())) { 3629 return [] 3630 } else if ($truthy(str['$include?']("\""))) { 3631 3632 values = []; 3633 accum = ""; 3634 quote_open = nil; 3635 $send(str, 'each_char', [], function $$48(c){ 3636 3637 if (c == null) c = nil; 3638 3639 switch (c) { 3640 case ",": 3641 if ($truthy(quote_open)) { 3642 return (accum = $rb_plus(accum, c)) 3643 } else { 3644 3645 values['$<<'](accum.$strip()); 3646 return (accum = ""); 3647 } 3648 case "\"": 3649 return (quote_open = quote_open['$!']()) 3650 default: 3651 return (accum = $rb_plus(accum, c)) 3652 }}); 3653 return values['$<<'](accum.$strip()); 3654 } else { 3655 return $send(str.$split(","), 'map', [], function $$49(it){ 3656 3657 if (it == null) it = nil; 3658 return it.$strip();}) 3659 } 3660 }); 3661 })($nesting[0], $nesting) 3662 })($nesting[0], $nesting) 3663}; 3664 3665Opal.modules["asciidoctor/version"] = function(Opal) {/* Generated by Opal 1.7.3 */ 3666 var $module = Opal.module, $const_set = Opal.const_set, $nesting = []; Opal.nil; 3667 3668 return (function($base, $parent_nesting) { 3669 var self = $module($base, 'Asciidoctor'); 3670 3671 var $nesting = [self].concat($parent_nesting); 3672 3673 return $const_set($nesting[0], 'VERSION', "2.0.20") 3674 })($nesting[0], $nesting) 3675}; 3676 3677Opal.modules["asciidoctor/abstract_node"] = function(Opal) {/* Generated by Opal 1.7.3 */ 3678 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.$$$; 3679 3680 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'); 3681 return (function($base, $parent_nesting) { 3682 var self = $module($base, 'Asciidoctor'); 3683 3684 var $nesting = [self].concat($parent_nesting); 3685 3686 return (function($base, $super, $parent_nesting) { 3687 var self = $klass($base, $super, 'AbstractNode'); 3688 3689 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 3690 3691 $proto.document = $proto.attributes = $proto.parent = nil; 3692 3693 self.$include($$('Logging')); 3694 self.$include($$('Substitutors')); 3695 self.$attr_reader("attributes"); 3696 self.$attr_reader("context"); 3697 self.$attr_reader("document"); 3698 self.$attr_accessor("id"); 3699 self.$attr_reader("node_name"); 3700 self.$attr_reader("parent"); 3701 3702 $def(self, '$initialize', function $$initialize(parent, context, opts) { 3703 var self = this, attrs = nil; 3704 3705 3706 if (opts == null) opts = $hash2([], {}); 3707 if ($eqeq(context, "document")) { 3708 self.document = self; 3709 } else if ($truthy(parent)) { 3710 self.document = (self.parent = parent).$document(); 3711 } self.node_name = (self.context = context).$to_s(); 3712 self.attributes = ($truthy((attrs = opts['$[]']("attributes"))) ? (attrs.$merge()) : ($hash2([], {}))); 3713 return (self.passthroughs = []); 3714 }, -3); 3715 3716 $def(self, '$block?', function $AbstractNode_block$ques$1() { 3717 var self = this; 3718 3719 return self.$raise($$$('NotImplementedError')) 3720 }); 3721 3722 $def(self, '$inline?', function $AbstractNode_inline$ques$2() { 3723 var self = this; 3724 3725 return self.$raise($$$('NotImplementedError')) 3726 }); 3727 3728 $def(self, '$converter', function $$converter() { 3729 var self = this; 3730 3731 return self.document.$converter() 3732 }); 3733 3734 $def(self, '$parent=', function $AbstractNode_parent$eq$3(parent) { 3735 var $a, self = this; 3736 3737 return $a = [parent, parent.$document()], (self.parent = $a[0]), (self.document = $a[1]), $a 3738 }); 3739 3740 $def(self, '$attr', function $$attr(name, default_value, fallback_name) { 3741 var self = this, $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil, $ret_or_4 = nil; 3742 3743 3744 if (default_value == null) default_value = nil; 3745 if (fallback_name == null) fallback_name = nil; 3746 if ($truthy(($ret_or_1 = self.attributes['$[]'](name.$to_s())))) { 3747 return $ret_or_1 3748 } else { 3749 3750 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))))) { 3751 return $ret_or_2 3752 } else { 3753 return default_value 3754 } } }, -2); 3755 3756 $def(self, '$attr?', function $AbstractNode_attr$ques$4(name, expected_value, fallback_name) { 3757 var self = this, $ret_or_1 = nil; 3758 3759 3760 if (expected_value == null) expected_value = nil; 3761 if (fallback_name == null) fallback_name = nil; 3762 if ($truthy(expected_value)) { 3763 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))))) 3764 } else if ($truthy(($ret_or_1 = self.attributes['$key?'](name.$to_s())))) { 3765 return $ret_or_1 3766 } else { 3767 3768 if (($truthy(fallback_name) && ($truthy(self.parent)))) { 3769 3770 return self.document.$attributes()['$key?'](($eqeq(fallback_name, true) ? (name) : (fallback_name)).$to_s()); 3771 } else { 3772 return false 3773 } } }, -2); 3774 3775 $def(self, '$set_attr', function $$set_attr(name, value, overwrite) { 3776 var self = this; 3777 3778 3779 if (value == null) value = ""; 3780 if (overwrite == null) overwrite = true; 3781 if (($eqeq(overwrite, false) && ($truthy(self.attributes['$key?'](name))))) { 3782 return false 3783 } else { 3784 3785 self.attributes['$[]='](name, value); 3786 return true; 3787 } }, -2); 3788 3789 $def(self, '$remove_attr', function $$remove_attr(name) { 3790 var self = this; 3791 3792 return self.attributes.$delete(name) 3793 }); 3794 3795 $def(self, '$option?', function $AbstractNode_option$ques$5(name) { 3796 var self = this; 3797 3798 if ($truthy(self.attributes['$[]']("" + (name) + "-option"))) { 3799 return true 3800 } else { 3801 return false 3802 } 3803 }); 3804 3805 $def(self, '$set_option', function $$set_option(name) { 3806 var self = this; 3807 3808 3809 self.attributes['$[]=']("" + (name) + "-option", ""); 3810 return nil; 3811 }); 3812 3813 $def(self, '$enabled_options', function $$enabled_options() { 3814 var self = this; 3815 3816 return $send($$$('Set').$new(), 'tap', [], function $$6(accum){var self = $$6.$$s == null ? this : $$6.$$s; 3817 if (self.attributes == null) self.attributes = nil; 3818 3819 3820 if (accum == null) accum = nil; 3821 return $send(self.attributes, 'each_key', [], function $$7(k){ 3822 3823 if (k == null) k = nil; 3824 if ($truthy(k.$to_s()['$end_with?']("-option"))) { 3825 return accum['$<<'](k.$slice(0, $rb_minus(k.$length(), 7))) 3826 } else { 3827 return nil 3828 }});}, {$$s: self}) 3829 }); 3830 3831 $def(self, '$update_attributes', function $$update_attributes(new_attributes) { 3832 var self = this; 3833 3834 return self.attributes.$update(new_attributes) 3835 }); 3836 3837 $def(self, '$role', function $$role() { 3838 var self = this; 3839 3840 return self.attributes['$[]']("role") 3841 }); 3842 3843 $def(self, '$roles', function $$roles() { 3844 var self = this, val = nil; 3845 3846 if ($truthy((val = self.attributes['$[]']("role")))) { 3847 return val.$split() 3848 } else { 3849 return [] 3850 } 3851 }); 3852 3853 $def(self, '$role?', function $AbstractNode_role$ques$8(expected_value) { 3854 var self = this; 3855 3856 3857 if (expected_value == null) expected_value = nil; 3858 if ($truthy(expected_value)) { 3859 return expected_value['$=='](self.attributes['$[]']("role")) 3860 } else { 3861 3862 return self.attributes['$key?']("role"); 3863 } }, -1); 3864 3865 $def(self, '$has_role?', function $AbstractNode_has_role$ques$9(name) { 3866 var self = this, val = nil; 3867 3868 if ($truthy((val = self.attributes['$[]']("role")))) { 3869 3870 return (((" ") + (val)) + " ")['$include?'](" " + (name) + " "); 3871 } else { 3872 return false 3873 } 3874 }); 3875 3876 $def(self, '$role=', function $AbstractNode_role$eq$10(names) { 3877 var $a, self = this; 3878 3879 return ($a = ["role", ($eqeqeq($$$('Array'), names) ? (names.$join(" ")) : (names))], $send(self.attributes, '[]=', $a), $a[$a.length - 1]) 3880 }); 3881 3882 $def(self, '$add_role', function $$add_role(name) { 3883 var self = this, val = nil; 3884 3885 if ($truthy((val = self.attributes['$[]']("role")))) { 3886 if ($truthy((((" ") + (val)) + " ")['$include?'](" " + (name) + " "))) { 3887 return false 3888 } else { 3889 3890 self.attributes['$[]=']("role", "" + (val) + " " + (name)); 3891 return true; 3892 } 3893 } else { 3894 3895 self.attributes['$[]=']("role", name); 3896 return true; 3897 } 3898 }); 3899 3900 $def(self, '$remove_role', function $$remove_role(name) { 3901 var self = this, val = nil; 3902 3903 if (($truthy((val = self.attributes['$[]']("role"))) && ($truthy((val = val.$split()).$delete(name))))) { 3904 3905 if ($truthy(val['$empty?']())) { 3906 self.attributes.$delete("role"); 3907 } else { 3908 self.attributes['$[]=']("role", val.$join(" ")); 3909 } return true; 3910 } else { 3911 return false 3912 } 3913 }); 3914 3915 $def(self, '$reftext', function $$reftext() { 3916 var self = this, val = nil; 3917 3918 if ($truthy((val = self.attributes['$[]']("reftext")))) { 3919 3920 return self.$apply_reftext_subs(val); 3921 } else { 3922 return nil 3923 } 3924 }); 3925 3926 $def(self, '$reftext?', function $AbstractNode_reftext$ques$11() { 3927 var self = this; 3928 3929 return self.attributes['$key?']("reftext") 3930 }); 3931 3932 $def(self, '$icon_uri', function $$icon_uri(name) { 3933 var self = this, icon = nil; 3934 3935 3936 if ($truthy(self['$attr?']("icon"))) { 3937 3938 icon = self.$attr("icon"); 3939 if (!$truthy($$('Helpers')['$extname?'](icon))) { 3940 icon = "" + (icon) + "." + (self.document.$attr("icontype", "png")); 3941 } } else { 3942 icon = "" + (name) + "." + (self.document.$attr("icontype", "png")); 3943 } return self.$image_uri(icon, "iconsdir"); 3944 }); 3945 3946 $def(self, '$image_uri', function $$image_uri(target_image, asset_dir_key) { 3947 var self = this, doc = nil, images_base = nil; 3948 3949 3950 if (asset_dir_key == null) asset_dir_key = "imagesdir"; 3951 if (($truthy($rb_lt((doc = self.document).$safe(), $$$($$('SafeMode'), 'SECURE'))) && ($truthy(doc['$attr?']("data-uri"))))) { 3952 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)))))))) { 3953 if ($truthy(doc['$attr?']("allow-uri-read"))) { 3954 3955 return self.$generate_data_uri_from_uri(target_image, doc['$attr?']("cache-uri")); 3956 } else { 3957 return target_image 3958 } 3959 } else { 3960 return self.$generate_data_uri(target_image, asset_dir_key) 3961 } 3962 } else { 3963 return self.$normalize_web_path(target_image, ($truthy(asset_dir_key) ? (doc.$attr(asset_dir_key)) : (nil))) 3964 } }, -2); 3965 3966 $def(self, '$media_uri', function $$media_uri(target, asset_dir_key) { 3967 var self = this; 3968 3969 3970 if (asset_dir_key == null) asset_dir_key = "imagesdir"; 3971 return self.$normalize_web_path(target, ($truthy(asset_dir_key) ? (self.document.$attr(asset_dir_key)) : (nil))); 3972 }, -2); 3973 3974 $def(self, '$generate_data_uri', function $$generate_data_uri(target_image, asset_dir_key) { 3975 var self = this, ext = nil, mimetype = nil, image_path = nil; 3976 3977 3978 if (asset_dir_key == null) asset_dir_key = nil; 3979 if ($truthy((ext = $$('Helpers').$extname(target_image, nil)))) { 3980 mimetype = ($eqeq(ext, ".svg") ? ("image/svg+xml") : ("image/" + (ext.$slice(1, ext.$length())))); 3981 } else { 3982 mimetype = "application/octet-stream"; 3983 } if ($truthy(asset_dir_key)) { 3984 image_path = self.$normalize_system_path(target_image, self.document.$attr(asset_dir_key), nil, $hash2(["target_name"], {"target_name": "image"})); 3985 } else { 3986 image_path = self.$normalize_system_path(target_image); 3987 } if ($truthy($$$('File')['$readable?'](image_path))) { 3988 return "data:" + (mimetype) + ";base64," + ($$$('Base64').$strict_encode64($$$('File').$binread(image_path))) 3989 } else { 3990 3991 self.$logger().$warn("image to embed not found or not readable: " + (image_path)); 3992 return "data:" + (mimetype) + ";base64,"; 3993 } }, -2); 3994 3995 $def(self, '$generate_data_uri_from_uri', function $$generate_data_uri_from_uri(image_uri, cache_uri) { 3996 var $a, $b, self = this, mimetype = nil, bindata = nil; 3997 3998 3999 if (cache_uri == null) cache_uri = false; 4000 if ($truthy(cache_uri)) { 4001 $$('Helpers').$require_library("open-uri/cached", "open-uri-cached"); 4002 } else if ($not($$('RUBY_ENGINE_OPAL'))) { 4003 $$$('OpenURI'); 4004 } 4005 try { 4006 4007 $b = $send($$$('OpenURI'), 'open_uri', [image_uri, $$('URI_READ_MODE')], function $$12(f){ 4008 4009 if (f == null) f = nil; 4010 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; 4011 return "data:" + (mimetype) + ";base64," + ($$$('Base64').$strict_encode64(bindata)); 4012 } catch ($err) { 4013 if (Opal.rescue($err, [$$('StandardError')])) { 4014 try { 4015 4016 self.$logger().$warn("could not retrieve image data from URI: " + (image_uri)); 4017 return image_uri; 4018 } finally { Opal.pop_exception(); } 4019 } else { throw $err; } 4020 } }, -2); 4021 4022 $def(self, '$normalize_asset_path', function $$normalize_asset_path(asset_ref, asset_name, autocorrect) { 4023 var self = this; 4024 4025 4026 if (asset_name == null) asset_name = "path"; 4027 if (autocorrect == null) autocorrect = true; 4028 return self.$normalize_system_path(asset_ref, self.document.$base_dir(), nil, $hash2(["target_name", "recover"], {"target_name": asset_name, "recover": autocorrect})); 4029 }, -2); 4030 4031 $def(self, '$normalize_system_path', function $$normalize_system_path(target, start, jail, opts) { 4032 var self = this, doc = nil, $ret_or_1 = nil; 4033 4034 4035 if (start == null) start = nil; 4036 if (jail == null) jail = nil; 4037 if (opts == null) opts = $hash2([], {}); 4038 if ($truthy($rb_lt((doc = self.document).$safe(), $$$($$('SafeMode'), 'SAFE')))) { 4039 if ($truthy(start)) { 4040 if (!$truthy(doc.$path_resolver()['$root?'](start))) { 4041 start = $$$('File').$join(doc.$base_dir(), start); 4042 } 4043 } else { 4044 start = doc.$base_dir(); 4045 } 4046 } else { 4047 4048 start = ($truthy(($ret_or_1 = start)) ? ($ret_or_1) : (doc.$base_dir())); 4049 jail = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (doc.$base_dir())); 4050 } return doc.$path_resolver().$system_path(target, start, jail, opts); 4051 }, -2); 4052 4053 $def(self, '$normalize_web_path', function $$normalize_web_path(target, start, preserve_uri_target) { 4054 var self = this; 4055 4056 4057 if (start == null) start = nil; 4058 if (preserve_uri_target == null) preserve_uri_target = true; 4059 if (($truthy(preserve_uri_target) && ($truthy($$('Helpers')['$uriish?'](target))))) { 4060 return $$('Helpers').$encode_spaces_in_uri(target) 4061 } else { 4062 return self.document.$path_resolver().$web_path(target, start) 4063 } }, -2); 4064 4065 $def(self, '$read_asset', function $$read_asset(path, opts) { 4066 var self = this, $ret_or_1 = nil; 4067 4068 4069 if (opts == null) opts = $hash2([], {}); 4070 if (!$eqeqeq($$$('Hash'), opts)) { 4071 opts = $hash2(["warn_on_failure"], {"warn_on_failure": opts['$!='](false)}); 4072 } if ($truthy($$$('File')['$readable?'](path))) { 4073 if ($truthy(opts['$[]']("normalize"))) { 4074 4075 return $$('Helpers').$prepare_source_string($$$('File').$read(path, $hash2(["mode"], {"mode": $$('FILE_READ_MODE')}))).$join($$('LF')); 4076 } else { 4077 4078 return $$$('File').$read(path, $hash2(["mode"], {"mode": $$('FILE_READ_MODE')})); 4079 } 4080 } else if ($truthy(opts['$[]']("warn_on_failure"))) { 4081 4082 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)); 4083 return nil; 4084 } else { 4085 return nil 4086 } }, -2); 4087 4088 $def(self, '$read_contents', function $$read_contents(target, opts) { 4089 var self = this, doc = nil, start = nil, contents = nil, $ret_or_1 = nil; 4090 4091 4092 if (opts == null) opts = $hash2([], {}); 4093 doc = self.document; 4094 if (($truthy($$('Helpers')['$uriish?'](target)) || ((($truthy((start = opts['$[]']("start"))) && ($truthy($$('Helpers')['$uriish?'](start)))) && ($truthy((target = doc.$path_resolver().$web_path(target, start)))))))) { 4095 if ($truthy(doc['$attr?']("allow-uri-read"))) { 4096 4097 if ($truthy(doc['$attr?']("cache-uri"))) { 4098 $$('Helpers').$require_library("open-uri/cached", "open-uri-cached"); 4099 } 4100 try { 4101 if ($truthy(opts['$[]']("normalize"))) { 4102 contents = $$('Helpers').$prepare_source_string($send($$$('OpenURI'), 'open_uri', [target, $$('URI_READ_MODE')], function $$13(f){ 4103 4104 if (f == null) f = nil; 4105 return f.$read();})).$join($$('LF')); 4106 } else { 4107 contents = $send($$$('OpenURI'), 'open_uri', [target, $$('URI_READ_MODE')], function $$14(f){ 4108 4109 if (f == null) f = nil; 4110 return f.$read();}); 4111 } 4112 } catch ($err) { 4113 if (Opal.rescue($err, [$$('StandardError')])) { 4114 try { 4115 if ($truthy(opts.$fetch("warn_on_failure", true))) { 4116 self.$logger().$warn("could not retrieve contents of " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))) + " at URI: " + (target)); 4117 } 4118 } finally { Opal.pop_exception(); } 4119 } else { throw $err; } 4120 } } else if ($truthy(opts.$fetch("warn_on_failure", true))) { 4121 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)"); 4122 } 4123 } else { 4124 4125 target = self.$normalize_system_path(target, opts['$[]']("start"), nil, $hash2(["target_name"], {"target_name": ($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))})); 4126 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")})); 4127 } if ((($truthy(contents) && ($truthy(opts['$[]']("warn_if_empty")))) && ($truthy(contents['$empty?']())))) { 4128 self.$logger().$warn("contents of " + (($truthy(($ret_or_1 = opts['$[]']("label"))) ? ($ret_or_1) : ("asset"))) + " is empty: " + (target)); 4129 } return contents; 4130 }, -2); 4131 return $def(self, '$is_uri?', function $AbstractNode_is_uri$ques$15(str) { 4132 4133 return $$('Helpers')['$uriish?'](str) 4134 }); 4135 })($nesting[0], null, $nesting) 4136 })($nesting[0], $nesting) 4137}; 4138 4139Opal.modules["asciidoctor/abstract_block"] = function(Opal) {/* Generated by Opal 1.7.3 */ 4140 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.$$$; 4141 4142 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'); 4143 return (function($base, $parent_nesting) { 4144 var self = $module($base, 'Asciidoctor'); 4145 4146 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 4147 4148 return (function($base, $super, $parent_nesting) { 4149 var self = $klass($base, $super, 'AbstractBlock'); 4150 4151 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 4152 4153 $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; 4154 4155 self.$attr_reader("blocks"); 4156 self.$attr_writer("caption"); 4157 self.$attr_accessor("content_model"); 4158 self.$attr_accessor("level"); 4159 self.$attr_accessor("numeral"); 4160 self.$attr_accessor("source_location"); 4161 self.$attr_accessor("style"); 4162 self.$attr_reader("subs"); 4163 4164 $def(self, '$initialize', function $$initialize(parent, context, opts) { 4165 var $yield = $$initialize.$$p || nil, self = this; 4166 4167 $$initialize.$$p = null; 4168 4169 if (opts == null) opts = $hash2([], {}); 4170 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield); 4171 self.content_model = "compound"; 4172 self.blocks = []; 4173 self.subs = []; 4174 self.id = (self.title = (self.caption = (self.numeral = (self.style = (self.default_subs = (self.source_location = nil)))))); 4175 if (($eqeq(context, "document") || ($eqeq(context, "section")))) { 4176 4177 self.level = (self.next_section_index = 0); 4178 return (self.next_section_ordinal = 1); 4179 } else if ($eqeqeq($$('AbstractBlock'), parent)) { 4180 return (self.level = parent.$level()) 4181 } else { 4182 return (self.level = nil) 4183 } }, -3); 4184 4185 $def(self, '$block?', $return_val(true)); 4186 4187 $def(self, '$inline?', $return_val(false)); 4188 4189 $def(self, '$file', function $$file() { 4190 var self = this, $ret_or_1 = nil; 4191 4192 if ($truthy(($ret_or_1 = self.source_location))) { 4193 return self.source_location.$file() 4194 } else { 4195 return $ret_or_1 4196 } 4197 }); 4198 4199 $def(self, '$lineno', function $$lineno() { 4200 var self = this, $ret_or_1 = nil; 4201 4202 if ($truthy(($ret_or_1 = self.source_location))) { 4203 return self.source_location.$lineno() 4204 } else { 4205 return $ret_or_1 4206 } 4207 }); 4208 4209 $def(self, '$convert', function $$convert() { 4210 var self = this; 4211 4212 4213 self.document.$playback_attributes(self.attributes); 4214 return self.$converter().$convert(self); 4215 }); 4216 $alias(self, "render", "convert"); 4217 4218 $def(self, '$content', function $$content() { 4219 var self = this; 4220 4221 return $send(self.blocks, 'map', [], function $$1(b){ 4222 4223 if (b == null) b = nil; 4224 return b.$convert();}).$join($$('LF')) 4225 }); 4226 4227 $def(self, '$context=', function $AbstractBlock_context$eq$2(context) { 4228 var self = this; 4229 4230 return (self.node_name = (self.context = context).$to_s()) 4231 }); 4232 4233 $def(self, '$<<', function $AbstractBlock_$lt$lt$3(block) { 4234 var self = this; 4235 4236 4237 if (!$eqeq(block.$parent(), self)) { 4238 block['$parent='](self); 4239 } self.blocks['$<<'](block); 4240 return self; 4241 }); 4242 $alias(self, "append", "<<"); 4243 4244 $def(self, '$blocks?', function $AbstractBlock_blocks$ques$4() { 4245 var self = this; 4246 4247 if ($truthy(self.blocks['$empty?']())) { 4248 return false 4249 } else { 4250 return true 4251 } 4252 }); 4253 4254 $def(self, '$sections?', $return_val(false)); 4255 4256 $def(self, '$number', function $$number() { 4257 var self = this; 4258 4259 try { 4260 4261 return self.$Integer(self.numeral); 4262 } catch ($err) { 4263 if (Opal.rescue($err, [$$('StandardError')])) { 4264 try { 4265 return self.numeral 4266 } finally { Opal.pop_exception(); } 4267 } else { throw $err; } 4268 } 4269 }); 4270 4271 $def(self, '$number=', function $AbstractBlock_number$eq$5(val) { 4272 var self = this; 4273 4274 return (self.numeral = val.$to_s()) 4275 }); 4276 4277 $def(self, '$find_by', function $$find_by(selector) { 4278 var block = $$find_by.$$p || nil, self = this, result = nil; 4279 4280 $$find_by.$$p = null; 4281 if (selector == null) selector = $hash2([], {}); 4282 try { 4283 return $send(self, 'find_by_internal', [selector, (result = [])], block.$to_proc()) 4284 } catch ($err) { 4285 if (Opal.rescue($err, [$$$('StopIteration')])) { 4286 try { 4287 return result 4288 } finally { Opal.pop_exception(); } 4289 } else { throw $err; } 4290 } }, -1); 4291 $alias(self, "query", "find_by"); 4292 4293 $def(self, '$next_adjacent_block', function $$next_adjacent_block() { 4294 var self = this, p = nil, sib = nil; 4295 4296 if ($eqeq(self.context, "document")) { 4297 return nil 4298 } else if (($eqeq((p = self.parent).$context(), "dlist") && ($eqeq(self.context, "list_item")))) { 4299 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; 4300 4301 4302 if (terms == null) terms = nil; 4303 if (desc == null) desc = nil; 4304 if ($truthy(($ret_or_1 = terms['$include?'](self)))) { 4305 return $ret_or_1 4306 } else { 4307 return desc['$=='](self) 4308 }}, {$$s: self}), 1))))) { 4309 return sib 4310 } else { 4311 return p.$next_adjacent_block() 4312 } 4313 } else if ($truthy((sib = p.$blocks()['$[]']($rb_plus(p.$blocks().$find_index(self), 1))))) { 4314 return sib 4315 } else { 4316 return p.$next_adjacent_block() 4317 } 4318 }); 4319 4320 $def(self, '$sections', function $$sections() { 4321 var self = this; 4322 4323 return $send(self.blocks, 'select', [], function $$7(block){ 4324 4325 if (block == null) block = nil; 4326 return block.$context()['$==']("section");}) 4327 }); 4328 4329 $def(self, '$alt', function $$alt() { 4330 var self = this, text = nil; 4331 4332 if ($truthy((text = self.attributes['$[]']("alt")))) { 4333 if ($eqeq(text, self.attributes['$[]']("default-alt"))) { 4334 return self.$sub_specialchars(text) 4335 } else { 4336 4337 text = self.$sub_specialchars(text); 4338 if ($truthy($$('ReplaceableTextRx')['$match?'](text))) { 4339 4340 return self.$sub_replacements(text); 4341 } else { 4342 return text 4343 } } 4344 } else { 4345 return "" 4346 } 4347 }); 4348 4349 $def(self, '$caption', function $$caption() { 4350 var self = this; 4351 4352 if ($eqeq(self.context, "admonition")) { 4353 return self.attributes['$[]']("textlabel") 4354 } else { 4355 return self.caption 4356 } 4357 }); 4358 4359 $def(self, '$captioned_title', function $$captioned_title() { 4360 var self = this; 4361 4362 return "" + (self.caption) + (self.$title()) 4363 }); 4364 4365 $def(self, '$list_marker_keyword', function $$list_marker_keyword(list_type) { 4366 var self = this, $ret_or_1 = nil; 4367 4368 4369 if (list_type == null) list_type = nil; 4370 return $$('ORDERED_LIST_KEYWORDS')['$[]'](($truthy(($ret_or_1 = list_type)) ? ($ret_or_1) : (self.style))); 4371 }, -1); 4372 4373 $def(self, '$title', function $$title() { 4374 var self = this, $ret_or_1 = nil, $ret_or_2 = nil; 4375 4376 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)))) 4377 }); 4378 4379 $def(self, '$title?', function $AbstractBlock_title$ques$8() { 4380 var self = this; 4381 4382 if ($truthy(self.title)) { 4383 return true 4384 } else { 4385 return false 4386 } 4387 }); 4388 4389 $def(self, '$title=', function $AbstractBlock_title$eq$9(val) { 4390 var self = this; 4391 4392 4393 self.converted_title = nil; 4394 return (self.title = val); 4395 }); 4396 4397 $def(self, '$sub?', function $AbstractBlock_sub$ques$10(name) { 4398 var self = this; 4399 4400 return self.subs['$include?'](name) 4401 }); 4402 4403 $def(self, '$remove_sub', function $$remove_sub(sub) { 4404 var self = this; 4405 4406 4407 self.subs.$delete(sub); 4408 return nil; 4409 }); 4410 4411 $def(self, '$xreftext', function $$xreftext(xrefstyle) { 4412 var self = this, val = nil, quoted_title = nil, prefix = nil, caption_attr_name = nil; 4413 4414 4415 if (xrefstyle == null) xrefstyle = nil; 4416 if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) { 4417 return val 4418 } else if ((($truthy(xrefstyle) && ($truthy(self.title))) && ($not(self.caption['$nil_or_empty?']())))) { 4419 4420 switch (xrefstyle) { 4421 case "full": 4422 4423 quoted_title = self.$sub_placeholder(self.$sub_quotes(($truthy(self.document.$compat_mode()) ? ("``%s''") : ("\"`%s`\""))), self.$title()); 4424 if ((($truthy(self.numeral) && ($truthy((caption_attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](self.context))))) && ($truthy((prefix = self.document.$attributes()['$[]'](caption_attr_name)))))) { 4425 return "" + (prefix) + " " + (self.numeral) + ", " + (quoted_title) 4426 } else { 4427 return "" + (self.caption.$chomp(". ")) + ", " + (quoted_title) 4428 } case "short": 4429 if ((($truthy(self.numeral) && ($truthy((caption_attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](self.context))))) && ($truthy((prefix = self.document.$attributes()['$[]'](caption_attr_name)))))) { 4430 return "" + (prefix) + " " + (self.numeral) 4431 } else { 4432 return self.caption.$chomp(". ") 4433 } 4434 default: 4435 return self.$title() 4436 } 4437 } else { 4438 return self.$title() 4439 } }, -1); 4440 4441 $def(self, '$assign_caption', function $$assign_caption(value, caption_context) { 4442 var self = this, $ret_or_1 = nil, prefix = nil, attr_name = nil; 4443 4444 4445 if (caption_context == null) caption_context = self.context; 4446 if ((($truthy(self.caption) || ($not(self.title))) || ($truthy((self.caption = ($truthy(($ret_or_1 = value)) ? ($ret_or_1) : (self.document.$attributes()['$[]']("caption")))))))) { 4447 return nil 4448 } else if (($truthy((attr_name = $$('CAPTION_ATTRIBUTE_NAMES')['$[]'](caption_context))) && ($truthy((prefix = self.document.$attributes()['$[]'](attr_name)))))) { 4449 4450 self.caption = "" + (prefix) + " " + ((self.numeral = self.document.$increment_and_store_counter("" + (caption_context) + "-number", self))) + ". "; 4451 return nil; 4452 } else { 4453 return nil 4454 } }, -2); 4455 4456 $def(self, '$assign_numeral', function $$assign_numeral(section) { 4457 var $a, self = this, like = nil, sectname = nil, caption = nil; 4458 4459 4460 self.next_section_index = $rb_plus(($a = [self.next_section_index], $send(section, 'index=', $a), $a[$a.length - 1]), 1); 4461 if ($truthy((like = section.$numbered()))) { 4462 if ($eqeq((sectname = section.$sectname()), "appendix")) { 4463 4464 section['$numeral='](self.document.$counter("appendix-number", "A")); 4465 section['$caption='](($truthy((caption = self.document.$attributes()['$[]']("appendix-caption"))) ? ("" + (caption) + " " + (section.$numeral()) + ": ") : ("" + (section.$numeral()) + ". "))); 4466 } else if (($eqeq(sectname, "chapter") || ($eqeq(like, "chapter")))) { 4467 section['$numeral='](self.document.$counter("chapter-number", 1).$to_s()); 4468 } else { 4469 4470 section['$numeral='](($eqeq(sectname, "part") ? ($$('Helpers').$int_to_roman(self.next_section_ordinal)) : (self.next_section_ordinal.$to_s()))); 4471 self.next_section_ordinal = $rb_plus(self.next_section_ordinal, 1); 4472 } 4473 } return nil; 4474 }); 4475 4476 $def(self, '$reindex_sections', function $$reindex_sections() { 4477 var self = this; 4478 4479 4480 self.next_section_index = 0; 4481 self.next_section_ordinal = 1; 4482 return $send(self.blocks, 'each', [], function $$11(block){var self = $$11.$$s == null ? this : $$11.$$s; 4483 4484 4485 if (block == null) block = nil; 4486 if ($eqeq(block.$context(), "section")) { 4487 4488 self.$assign_numeral(block); 4489 return block.$reindex_sections(); 4490 } else { 4491 return nil 4492 }}, {$$s: self}); 4493 }); 4494 self.$protected(); 4495 return $def(self, '$find_by_internal', function $$find_by_internal(selector, result) { 4496 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; 4497 4498 $$find_by_internal.$$p = null; 4499 if (selector == null) selector = $hash2([], {}); 4500 if (result == null) result = []; 4501 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)))))) { 4502 if ((block !== nil)) { 4503 if ($truthy((verdict = Opal.yield1(block, self)))) { 4504 4505 switch (verdict) { 4506 case "prune": 4507 4508 result['$<<'](self); 4509 if ($truthy(id_selector)) { 4510 self.$raise($$$('StopIteration')); 4511 } return result; 4512 case "reject": 4513 4514 if ($truthy(id_selector)) { 4515 self.$raise($$$('StopIteration')); 4516 } return result; 4517 case "stop": 4518 self.$raise($$$('StopIteration')); 4519 break; 4520 default: 4521 4522 result['$<<'](self); 4523 if ($truthy(id_selector)) { 4524 self.$raise($$$('StopIteration')); 4525 } } 4526 } else if ($truthy(id_selector)) { 4527 self.$raise($$$('StopIteration')); 4528 } 4529 } else { 4530 4531 result['$<<'](self); 4532 if ($truthy(id_selector)) { 4533 self.$raise($$$('StopIteration')); 4534 } } 4535 } 4536 switch (self.context) { 4537 case "document": 4538 if (!$eqeq(context_selector, "document")) { 4539 4540 if (($truthy(self['$header?']()) && (($truthy(any_context) || ($eqeq(context_selector, "section")))))) { 4541 $send(self.header, 'find_by_internal', [selector, result], block.$to_proc()); 4542 } $send(self.blocks, 'each', [], function $$12(b){ 4543 4544 if (b == null) b = nil; 4545 if (($eqeq(context_selector, "section") && ($neqeq(b.$context(), "section")))) { 4546 return nil 4547 } return $send(b, 'find_by_internal', [selector, result], block.$to_proc());}); 4548 } 4549 break; 4550 case "dlist": 4551 if (($truthy(any_context) || ($neqeq(context_selector, "section")))) { 4552 $send(self.blocks.$flatten(), 'each', [], function $$13(b){ 4553 4554 if (b == null) b = nil; 4555 if ($truthy(b)) { 4556 return $send(b, 'find_by_internal', [selector, result], block.$to_proc()) 4557 } else { 4558 return nil 4559 }}); 4560 } 4561 break; 4562 case "table": 4563 if ($truthy(selector['$[]']("traverse_documents"))) { 4564 4565 $send(self.$rows().$head(), 'each', [], function $$14(r){ 4566 4567 if (r == null) r = nil; 4568 return $send(r, 'each', [], function $$15(c){ 4569 4570 if (c == null) c = nil; 4571 return $send(c, 'find_by_internal', [selector, result], block.$to_proc());});}); 4572 if ($eqeq(context_selector, "inner_document")) { 4573 selector = selector.$merge($hash2(["context"], {"context": "document"})); 4574 } $send($rb_plus(self.$rows().$body(), self.$rows().$foot()), 'each', [], function $$16(r){ 4575 4576 if (r == null) r = nil; 4577 return $send(r, 'each', [], function $$17(c){ 4578 4579 if (c == null) c = nil; 4580 $send(c, 'find_by_internal', [selector, result], block.$to_proc()); 4581 if ($eqeq(c.$style(), "asciidoc")) { 4582 return $send(c.$inner_document(), 'find_by_internal', [selector, result], block.$to_proc()) 4583 } else { 4584 return nil 4585 }});}); 4586 } else { 4587 $send($rb_plus($rb_plus(self.$rows().$head(), self.$rows().$body()), self.$rows().$foot()), 'each', [], function $$18(r){ 4588 4589 if (r == null) r = nil; 4590 return $send(r, 'each', [], function $$19(c){ 4591 4592 if (c == null) c = nil; 4593 return $send(c, 'find_by_internal', [selector, result], block.$to_proc());});}); 4594 } 4595 break; 4596 default: 4597 $send(self.blocks, 'each', [], function $$20(b){ 4598 4599 if (b == null) b = nil; 4600 if (($eqeq(context_selector, "section") && ($neqeq(b.$context(), "section")))) { 4601 return nil 4602 } return $send(b, 'find_by_internal', [selector, result], block.$to_proc());}); 4603 } return result; 4604 }, -1); 4605 })($nesting[0], $$('AbstractNode'), $nesting) 4606 })($nesting[0], $nesting) 4607}; 4608 4609Opal.modules["asciidoctor/attribute_list"] = function(Opal) {/* Generated by Opal 1.7.3 */ 4610 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.$$$; 4611 4612 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'); 4613 return (function($base, $parent_nesting) { 4614 var self = $module($base, 'Asciidoctor'); 4615 4616 var $nesting = [self].concat($parent_nesting); 4617 4618 return (function($base, $super, $parent_nesting) { 4619 var self = $klass($base, $super, 'AttributeList'); 4620 4621 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 4622 4623 $proto.attributes = $proto.scanner = $proto.delimiter = $proto.block = $proto.delimiter_skip_pattern = $proto.delimiter_boundary_pattern = nil; 4624 4625 $const_set($nesting[0], 'APOS', "'"); 4626 $const_set($nesting[0], 'BACKSLASH', "\\"); 4627 $const_set($nesting[0], 'QUOT', "\""); 4628 $const_set($nesting[0], 'BoundaryRx', $hash($$('QUOT'), /.*?[^\\](?=")/, $$('APOS'), /.*?[^\\](?=')/, ",", /.*?(?=[ \t]*(,|$))/)); 4629 $const_set($nesting[0], 'EscapedQuotes', $hash($$('QUOT'), "\\\"", $$('APOS'), "\\'")); 4630 $const_set($nesting[0], 'NameRx', $regexp([$$('CG_WORD'), "[", $$('CC_WORD'), "\\-.]*"])); 4631 $const_set($nesting[0], 'BlankRx', /[ \t]+/); 4632 $const_set($nesting[0], 'SkipRx', $hash2([","], {",": /[ \t]*(,|$)/})); 4633 4634 $def(self, '$initialize', function $$initialize(source, block, delimiter) { 4635 var self = this; 4636 4637 4638 if (block == null) block = nil; 4639 if (delimiter == null) delimiter = ","; 4640 self.scanner = $$$('StringScanner').$new(source); 4641 self.block = block; 4642 self.delimiter = delimiter; 4643 self.delimiter_skip_pattern = $$('SkipRx')['$[]'](delimiter); 4644 self.delimiter_boundary_pattern = $$('BoundaryRx')['$[]'](delimiter); 4645 return (self.attributes = nil); 4646 }, -2); 4647 4648 $def(self, '$parse_into', function $$parse_into(attributes, positional_attrs) { 4649 var self = this; 4650 4651 4652 if (positional_attrs == null) positional_attrs = []; 4653 return attributes.$update(self.$parse(positional_attrs)); 4654 }, -2); 4655 4656 $def(self, '$parse', function $$parse(positional_attrs) { 4657 var self = this, index = nil; 4658 4659 4660 if (positional_attrs == null) positional_attrs = []; 4661 if ($truthy(self.attributes)) { 4662 return self.attributes 4663 } self.attributes = $hash2([], {}); 4664 index = 0; 4665 while ($truthy(self.$parse_attribute(index, positional_attrs))) { 4666 4667 if ($truthy(self.scanner['$eos?']())) { 4668 break 4669 } self.$skip_delimiter(); 4670 index = $rb_plus(index, 1); 4671 } return self.attributes; 4672 }, -1); 4673 4674 $def(self, '$rekey', function $$rekey(positional_attrs) { 4675 var self = this; 4676 4677 return $$('AttributeList').$rekey(self.attributes, positional_attrs) 4678 }); 4679 $defs(self, '$rekey', function $$rekey(attributes, positional_attrs) { 4680 4681 4682 $send(positional_attrs, 'each_with_index', [], function $$1(key, index){var $a, val = nil; 4683 4684 4685 if (key == null) key = nil; 4686 if (index == null) index = nil; 4687 if (($truthy(key) && ($truthy((val = attributes['$[]']($rb_plus(index, 1))))))) { 4688 return ($a = [key, val], $send(attributes, '[]=', $a), $a[$a.length - 1]) 4689 } else { 4690 return nil 4691 }}); 4692 return attributes; 4693 }); 4694 self.$private(); 4695 4696 $def(self, '$parse_attribute', function $$parse_attribute(index, positional_attrs) { 4697 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; 4698 4699 4700 continue$ = true; 4701 self.$skip_blank(); 4702 if ($eqeqeq($$('QUOT'), ($ret_or_1 = self.scanner.$peek(1)))) { 4703 name = self.$parse_attribute_value(self.scanner.$get_byte()); 4704 } else if ($eqeqeq($$('APOS'), $ret_or_1)) { 4705 4706 name = self.$parse_attribute_value(self.scanner.$get_byte()); 4707 if (!$truthy(name['$start_with?']($$('APOS')))) { 4708 single_quoted = true; 4709 } } else { 4710 4711 skipped = ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = (name = self.$scan_name()))) ? (self.$skip_blank()) : ($ret_or_3)))) ? ($ret_or_2) : (0)); 4712 if ($truthy(self.scanner['$eos?']())) { 4713 4714 if (!($truthy(name) || ($truthy(self.scanner.$string().$rstrip()['$end_with?'](self.delimiter))))) { 4715 return nil 4716 } continue$ = nil; 4717 } else if ($eqeq((c = self.scanner.$get_byte()), self.delimiter)) { 4718 self.scanner.$unscan(); 4719 } else if ($truthy(name)) { 4720 if ($eqeq(c, "=")) { 4721 4722 self.$skip_blank(); 4723 if ($eqeqeq($$('QUOT'), ($ret_or_2 = (c = self.scanner.$get_byte())))) { 4724 value = self.$parse_attribute_value(c); 4725 } else if ($eqeqeq($$('APOS'), $ret_or_2)) { 4726 4727 value = self.$parse_attribute_value(c); 4728 if (!$truthy(value['$start_with?']($$('APOS')))) { 4729 single_quoted = true; 4730 } } else if ($eqeqeq(self.delimiter, $ret_or_2)) { 4731 4732 value = ""; 4733 self.scanner.$unscan(); 4734 } else if ($eqeqeq(nil, $ret_or_2)) { 4735 value = ""; 4736 } else { 4737 4738 value = "" + (c) + (self.$scan_to_delimiter()); 4739 if ($eqeq(value, "None")) { 4740 return true 4741 } } } else { 4742 name = "" + (name) + ($rb_times(" ", skipped)) + (c) + (self.$scan_to_delimiter()); 4743 } 4744 } else { 4745 name = "" + (c) + (self.$scan_to_delimiter()); 4746 } } if ($truthy(value)) { 4747 4748 switch (name) { 4749 case "options": 4750 case "opts": 4751 if ($truthy(value['$include?'](","))) { 4752 4753 if ($truthy(value['$include?'](" "))) { 4754 value = value.$delete(" "); 4755 } $send(value.$split(","), 'each', [], function $$2(opt){var $a, self = $$2.$$s == null ? this : $$2.$$s; 4756 if (self.attributes == null) self.attributes = nil; 4757 4758 4759 if (opt == null) opt = nil; 4760 if ($truthy(opt['$empty?']())) { 4761 return nil 4762 } else { 4763 return ($a = ["" + (opt) + "-option", ""], $send(self.attributes, '[]=', $a), $a[$a.length - 1]) 4764 }}, {$$s: self}); 4765 } else if (!$truthy(value['$empty?']())) { 4766 self.attributes['$[]=']("" + (value) + "-option", ""); 4767 } 4768 break; 4769 default: 4770 if (($truthy(single_quoted) && ($truthy(self.block)))) { 4771 4772 switch (name) { 4773 case "title": 4774 case "reftext": 4775 self.attributes['$[]='](name, value); 4776 break; 4777 default: 4778 self.attributes['$[]='](name, self.block.$apply_subs(value)); 4779 } 4780 } else { 4781 self.attributes['$[]='](name, value); 4782 } 4783 } 4784 } else { 4785 4786 if (($truthy(single_quoted) && ($truthy(self.block)))) { 4787 name = self.block.$apply_subs(name); 4788 } if (($truthy((positional_attr_name = positional_attrs['$[]'](index))) && ($truthy(name)))) { 4789 self.attributes['$[]='](positional_attr_name, name); 4790 } self.attributes['$[]=']($rb_plus(index, 1), name); 4791 } return continue$; 4792 }); 4793 4794 $def(self, '$parse_attribute_value', function $$parse_attribute_value(quote) { 4795 var self = this, value = nil; 4796 4797 if ($eqeq(self.scanner.$peek(1), quote)) { 4798 4799 self.scanner.$get_byte(); 4800 return ""; 4801 } else if ($truthy((value = self.$scan_to_quote(quote)))) { 4802 4803 self.scanner.$get_byte(); 4804 if ($truthy(value['$include?']($$('BACKSLASH')))) { 4805 4806 return value.$gsub($$('EscapedQuotes')['$[]'](quote), quote); 4807 } else { 4808 return value 4809 } } else { 4810 return "" + (quote) + (self.$scan_to_delimiter()) 4811 } 4812 }); 4813 4814 $def(self, '$skip_blank', function $$skip_blank() { 4815 var self = this; 4816 4817 return self.scanner.$skip($$('BlankRx')) 4818 }); 4819 4820 $def(self, '$skip_delimiter', function $$skip_delimiter() { 4821 var self = this; 4822 4823 return self.scanner.$skip(self.delimiter_skip_pattern) 4824 }); 4825 4826 $def(self, '$scan_name', function $$scan_name() { 4827 var self = this; 4828 4829 return self.scanner.$scan($$('NameRx')) 4830 }); 4831 4832 $def(self, '$scan_to_delimiter', function $$scan_to_delimiter() { 4833 var self = this; 4834 4835 return self.scanner.$scan(self.delimiter_boundary_pattern) 4836 }); 4837 return $def(self, '$scan_to_quote', function $$scan_to_quote(quote) { 4838 var self = this; 4839 4840 return self.scanner.$scan($$('BoundaryRx')['$[]'](quote)) 4841 }); 4842 })($nesting[0], null, $nesting) 4843 })($nesting[0], $nesting) 4844}; 4845 4846Opal.modules["asciidoctor/block"] = function(Opal) {/* Generated by Opal 1.7.3 */ 4847 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.$$$; 4848 4849 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'); 4850 return (function($base, $parent_nesting) { 4851 var self = $module($base, 'Asciidoctor'); 4852 4853 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 4854 4855 return (function($base, $super, $parent_nesting) { 4856 var self = $klass($base, $super, 'Block'); 4857 4858 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 4859 4860 $proto.attributes = $proto.content_model = $proto.lines = $proto.subs = $proto.blocks = $proto.context = $proto.style = nil; 4861 4862 $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"); 4863 $alias(self, "blockname", "context"); 4864 self.$attr_accessor("lines"); 4865 4866 $def(self, '$initialize', function $$initialize(parent, context, opts) { 4867 var $yield = $$initialize.$$p || nil, self = this, $ret_or_1 = nil, subs = nil, raw_source = nil; 4868 4869 $$initialize.$$p = null; 4870 4871 if (opts == null) opts = $hash2([], {}); 4872 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield); 4873 self.content_model = ($truthy(($ret_or_1 = opts['$[]']("content_model"))) ? ($ret_or_1) : ($$('DEFAULT_CONTENT_MODEL')['$[]'](context))); 4874 if ($truthy(opts['$key?']("subs"))) { 4875 if ($truthy((subs = opts['$[]']("subs")))) { 4876 4877 if ($eqeqeq("default", ($ret_or_1 = subs))) { 4878 self.default_subs = opts['$[]']("default_subs"); 4879 } else if ($eqeqeq($$$('Array'), $ret_or_1)) { 4880 4881 self.default_subs = subs.$drop(0); 4882 self.attributes.$delete("subs"); 4883 } else { 4884 4885 self.default_subs = nil; 4886 self.attributes['$[]=']("subs", subs.$to_s()); 4887 } self.$commit_subs(); 4888 } else { 4889 4890 self.default_subs = []; 4891 self.attributes.$delete("subs"); 4892 } 4893 } else { 4894 self.default_subs = nil; 4895 } if ($truthy((raw_source = opts['$[]']("source"))['$nil_or_empty?']())) { 4896 return (self.lines = []) 4897 } else if ($eqeqeq($$$('String'), raw_source)) { 4898 return (self.lines = $$('Helpers').$prepare_source_string(raw_source)) 4899 } else { 4900 return (self.lines = raw_source.$drop(0)) 4901 } }, -3); 4902 4903 $def(self, '$content', function $$content() { 4904 var $yield = $$content.$$p || nil, self = this, result = nil, $ret_or_2 = nil, first = nil, last = nil; 4905 4906 $$content.$$p = null; 4907 4908 switch (self.content_model) { 4909 case "compound": 4910 return $send2(self, $find_super(self, 'content', $$content, false, true), 'content', [], $yield) 4911 case "simple": 4912 return self.$apply_subs(self.lines.$join($$('LF')), self.subs) 4913 case "verbatim": 4914 case "raw": 4915 4916 result = self.$apply_subs(self.lines, self.subs); 4917 if ($truthy($rb_lt(result.$size(), 2))) { 4918 if ($truthy(($ret_or_2 = result['$[]'](0)))) { 4919 return $ret_or_2 4920 } else { 4921 return "" 4922 } 4923 } else { 4924 4925 while ($truthy(($truthy(($ret_or_2 = (first = result['$[]'](0)))) ? (first.$rstrip()['$empty?']()) : ($ret_or_2)))) { 4926 result.$shift(); 4927 } while ($truthy(($truthy(($ret_or_2 = (last = result['$[]'](-1)))) ? (last.$rstrip()['$empty?']()) : ($ret_or_2)))) { 4928 result.$pop(); 4929 } return result.$join($$('LF')); 4930 } default: 4931 4932 if (!$eqeq(self.content_model, "empty")) { 4933 self.$logger().$warn("unknown content model '" + (self.content_model) + "' for block: " + (self)); 4934 } return nil; 4935 } 4936 }); 4937 4938 $def(self, '$source', function $$source() { 4939 var self = this; 4940 4941 return self.lines.$join($$('LF')) 4942 }); 4943 return $def(self, '$to_s', function $$to_s() { 4944 var self = this, content_summary = nil; 4945 4946 4947 content_summary = ($eqeq(self.content_model, "compound") ? ("blocks: " + (self.blocks.$size())) : ("lines: " + (self.lines.$size()))); 4948 return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", content_model: " + (self.content_model.$inspect()) + ", style: " + (self.style.$inspect()) + ", " + (content_summary) + "}>"; 4949 }); 4950 })($nesting[0], $$('AbstractBlock'), $nesting) 4951 })($nesting[0], $nesting) 4952}; 4953 4954Opal.modules["asciidoctor/callouts"] = function(Opal) {/* Generated by Opal 1.7.3 */ 4955 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; 4956 4957 Opal.add_stubs('next_list,<<,current_list,to_i,generate_next_callout_id,+,<=,size,[],-,chop,join,map,==,<,private,generate_callout_id'); 4958 return (function($base, $parent_nesting) { 4959 var self = $module($base, 'Asciidoctor'); 4960 4961 var $nesting = [self].concat($parent_nesting); 4962 4963 return (function($base, $super) { 4964 var self = $klass($base, $super, 'Callouts'); 4965 4966 var $proto = self.$$prototype; 4967 4968 $proto.co_index = $proto.lists = $proto.list_index = nil; 4969 4970 4971 $def(self, '$initialize', function $$initialize() { 4972 var self = this; 4973 4974 4975 self.lists = []; 4976 self.list_index = 0; 4977 return self.$next_list(); 4978 }); 4979 4980 $def(self, '$register', function $$register(li_ordinal) { 4981 var self = this, id = nil; 4982 4983 4984 self.$current_list()['$<<']($hash2(["ordinal", "id"], {"ordinal": li_ordinal.$to_i(), "id": (id = self.$generate_next_callout_id())})); 4985 self.co_index = $rb_plus(self.co_index, 1); 4986 return id; 4987 }); 4988 4989 $def(self, '$read_next_id', function $$read_next_id() { 4990 var self = this, id = nil, list = nil; 4991 4992 4993 id = nil; 4994 list = self.$current_list(); 4995 if ($truthy($rb_le(self.co_index, list.$size()))) { 4996 id = list['$[]']($rb_minus(self.co_index, 1))['$[]']("id"); 4997 } self.co_index = $rb_plus(self.co_index, 1); 4998 return id; 4999 }); 5000 5001 $def(self, '$callout_ids', function $$callout_ids(li_ordinal) { 5002 var self = this; 5003 5004 return $send(self.$current_list(), 'map', [], function $$1(it){ 5005 5006 if (it == null) it = nil; 5007 if ($eqeq(it['$[]']("ordinal"), li_ordinal)) { 5008 return "" + (it['$[]']("id")) + " " 5009 } else { 5010 return "" 5011 }}).$join().$chop() 5012 }); 5013 5014 $def(self, '$current_list', function $$current_list() { 5015 var self = this; 5016 5017 return self.lists['$[]']($rb_minus(self.list_index, 1)) 5018 }); 5019 5020 $def(self, '$next_list', function $$next_list() { 5021 var self = this; 5022 5023 5024 self.list_index = $rb_plus(self.list_index, 1); 5025 if ($truthy($rb_lt(self.lists.$size(), self.list_index))) { 5026 self.lists['$<<']([]); 5027 } self.co_index = 1; 5028 return nil; 5029 }); 5030 5031 $def(self, '$rewind', function $$rewind() { 5032 var self = this; 5033 5034 5035 self.list_index = 1; 5036 self.co_index = 1; 5037 return nil; 5038 }); 5039 self.$private(); 5040 5041 $def(self, '$generate_next_callout_id', function $$generate_next_callout_id() { 5042 var self = this; 5043 5044 return self.$generate_callout_id(self.list_index, self.co_index) 5045 }); 5046 return $def(self, '$generate_callout_id', function $$generate_callout_id(list_index, co_index) { 5047 5048 return "CO" + (list_index) + "-" + (co_index) 5049 }); 5050 })($nesting[0], null) 5051 })($nesting[0], $nesting) 5052}; 5053 5054Opal.modules["asciidoctor/converter/composite"] = function(Opal) {/* Generated by Opal 1.7.3 */ 5055 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.$$$; 5056 5057 Opal.add_stubs('attr_reader,each,respond_to?,composed,init_backend_traits,backend_traits,new,[]=,find_converter,convert,converter_for,node_name,[],handles?,raise'); 5058 return (function($base, $parent_nesting) { 5059 var self = $module($base, 'Asciidoctor'); 5060 5061 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5062 5063 return (function($base, $super) { 5064 var self = $klass($base, $super, 'CompositeConverter'); 5065 5066 var $proto = self.$$prototype; 5067 5068 $proto.converter_cache = $proto.converters = nil; 5069 5070 self.$attr_reader("converters"); 5071 5072 $def(self, '$initialize', function $$initialize(backend, $a, $b) { 5073 var $post_args, $kwargs, converters, backend_traits_source, self = this; 5074 5075 5076 $post_args = $slice(arguments, 1); 5077 $kwargs = $extract_kwargs($post_args); 5078 $kwargs = $ensure_kwargs($kwargs); 5079 converters = $post_args; 5080 5081 backend_traits_source = $kwargs.$$smap["backend_traits_source"];if (backend_traits_source == null) backend_traits_source = nil; 5082 self.backend = backend; 5083 $send((self.converters = converters), 'each', [], function $$1(converter){var self = $$1.$$s == null ? this : $$1.$$s; 5084 5085 5086 if (converter == null) converter = nil; 5087 if ($truthy(converter['$respond_to?']("composed"))) { 5088 return converter.$composed(self) 5089 } else { 5090 return nil 5091 }}, {$$s: self}); 5092 if ($truthy(backend_traits_source)) { 5093 self.$init_backend_traits(backend_traits_source.$backend_traits()); 5094 } return (self.converter_cache = $send($$$('Hash'), 'new', [], function $$2(hash, key){var $c, self = $$2.$$s == null ? this : $$2.$$s; 5095 5096 5097 if (hash == null) hash = nil; 5098 if (key == null) key = nil; 5099 return ($c = [key, self.$find_converter(key)], $send(hash, '[]=', $c), $c[$c.length - 1]);}, {$$s: self})); 5100 }, -2); 5101 5102 $def(self, '$convert', function $$convert(node, transform, opts) { 5103 var self = this, $ret_or_1 = nil; 5104 5105 5106 if (transform == null) transform = nil; 5107 if (opts == null) opts = nil; 5108 return self.$converter_for((transform = ($truthy(($ret_or_1 = transform)) ? ($ret_or_1) : (node.$node_name())))).$convert(node, transform, opts); 5109 }, -2); 5110 5111 $def(self, '$converter_for', function $$converter_for(transform) { 5112 var self = this; 5113 5114 return self.converter_cache['$[]'](transform) 5115 }); 5116 return $def(self, '$find_converter', function $$find_converter(transform) {try { var $t_return = $thrower('return'); 5117 var self = this; 5118 5119 5120 $send(self.converters, 'each', [], function $$3(candidate){ 5121 5122 if (candidate == null) candidate = nil; 5123 if ($truthy(candidate['$handles?'](transform))) { 5124 $t_return.$throw(candidate); 5125 } else { 5126 return nil 5127 };}, {$$ret: $t_return}); 5128 return self.$raise("Could not find a converter to handle transform: " + (transform));} catch($e) { 5129 if ($e === $t_return) return $e.$v; 5130 throw $e; 5131 } 5132 }); 5133 })($$('Converter'), $$$($$('Converter'), 'Base')) 5134 })($nesting[0], $nesting) 5135}; 5136 5137Opal.modules["asciidoctor/converter"] = function(Opal) {/* Generated by Opal 1.7.3 */ 5138 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.$$$; 5139 5140 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'); 5141 return (function($base, $parent_nesting) { 5142 var self = $module($base, 'Asciidoctor'); 5143 5144 var $nesting = [self].concat($parent_nesting); 5145 5146 return (function($base, $parent_nesting) { 5147 var self = $module($base, 'Converter'); 5148 5149 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5150 5151 5152 self.$autoload("CompositeConverter", "" + ("asciidoctor") + "/converter/composite"); 5153 self.$attr_reader("backend"); 5154 5155 $def(self, '$initialize', function $$initialize(backend, opts) { 5156 var self = this; 5157 5158 5159 if (opts == null) opts = $hash2([], {}); 5160 return (self.backend = backend); 5161 }, -2); 5162 5163 $def(self, '$convert', function $$convert(node, transform, opts) { 5164 var self = this; 5165 if (self.backend == null) self.backend = nil; 5166 return self.$raise($$$('NotImplementedError'), "" + (self.$class()) + " (backend: " + (self.backend) + ") must implement the #" + ("convert") + " method"); 5167 }, -2); 5168 5169 $def(self, '$handles?', $return_val(true)); 5170 $defs(self, '$derive_backend_traits', function $$derive_backend_traits(backend, basebackend) { 5171 var outfilesuffix = nil, $ret_or_1 = nil, filetype = nil; 5172 5173 5174 if (basebackend == null) basebackend = nil; 5175 if (!$truthy(backend)) { 5176 return $hash2([], {}) 5177 } if ($truthy((outfilesuffix = $$('DEFAULT_EXTENSIONS')['$[]']((basebackend = ($truthy(($ret_or_1 = basebackend)) ? ($ret_or_1) : (backend.$sub($$('TrailingDigitsRx'), "")))))))) { 5178 filetype = outfilesuffix.$slice(1, outfilesuffix.$length()); 5179 } else { 5180 outfilesuffix = "." + ((filetype = basebackend)); 5181 } if ($eqeq(filetype, "html")) { 5182 return $hash2(["basebackend", "filetype", "htmlsyntax", "outfilesuffix"], {"basebackend": basebackend, "filetype": filetype, "htmlsyntax": "html", "outfilesuffix": outfilesuffix}) 5183 } else { 5184 return $hash2(["basebackend", "filetype", "outfilesuffix"], {"basebackend": basebackend, "filetype": filetype, "outfilesuffix": outfilesuffix}) 5185 } }, -2); 5186 (function($base, $parent_nesting) { 5187 var self = $module($base, 'BackendTraits'); 5188 5189 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5190 5191 5192 5193 $def(self, '$basebackend', function $$basebackend(value) { 5194 var $a, self = this; 5195 5196 5197 if (value == null) value = nil; 5198 if ($truthy(value)) { 5199 5200 return ($a = ["basebackend", value], $send(self.$backend_traits(value), '[]=', $a), $a[$a.length - 1]); 5201 } else { 5202 return self.$backend_traits()['$[]']("basebackend") 5203 } }, -1); 5204 5205 $def(self, '$filetype', function $$filetype(value) { 5206 var $a, self = this; 5207 5208 5209 if (value == null) value = nil; 5210 if ($truthy(value)) { 5211 5212 return ($a = ["filetype", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]); 5213 } else { 5214 return self.$backend_traits()['$[]']("filetype") 5215 } }, -1); 5216 5217 $def(self, '$htmlsyntax', function $$htmlsyntax(value) { 5218 var $a, self = this; 5219 5220 5221 if (value == null) value = nil; 5222 if ($truthy(value)) { 5223 5224 return ($a = ["htmlsyntax", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]); 5225 } else { 5226 return self.$backend_traits()['$[]']("htmlsyntax") 5227 } }, -1); 5228 5229 $def(self, '$outfilesuffix', function $$outfilesuffix(value) { 5230 var $a, self = this; 5231 5232 5233 if (value == null) value = nil; 5234 if ($truthy(value)) { 5235 5236 return ($a = ["outfilesuffix", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]); 5237 } else { 5238 return self.$backend_traits()['$[]']("outfilesuffix") 5239 } }, -1); 5240 5241 $def(self, '$supports_templates', function $$supports_templates(value) { 5242 var $a, self = this; 5243 5244 5245 if (value == null) value = true; 5246 return ($a = ["supports_templates", value], $send(self.$backend_traits(), '[]=', $a), $a[$a.length - 1]); 5247 }, -1); 5248 5249 $def(self, '$supports_templates?', function $BackendTraits_supports_templates$ques$1() { 5250 var self = this; 5251 5252 return self.$backend_traits()['$[]']("supports_templates") 5253 }); 5254 5255 $def(self, '$init_backend_traits', function $$init_backend_traits(value) { 5256 var self = this, $ret_or_1 = nil; 5257 5258 5259 if (value == null) value = nil; 5260 return (self.backend_traits = ($truthy(($ret_or_1 = value)) ? ($ret_or_1) : ($hash2([], {})))); 5261 }, -1); 5262 5263 $def(self, '$backend_traits', function $$backend_traits(basebackend) { 5264 var self = this, $ret_or_1 = nil; 5265 if (self.backend_traits == null) self.backend_traits = nil; 5266 if (self.backend == null) self.backend = nil; 5267 5268 5269 if (basebackend == null) basebackend = nil; 5270 return (self.backend_traits = ($truthy(($ret_or_1 = self.backend_traits)) ? ($ret_or_1) : ($$('Converter').$derive_backend_traits(self.backend, basebackend)))); 5271 }, -1); 5272 $alias(self, "backend_info", "backend_traits"); 5273 return $defs(self, '$derive_backend_traits', function $$derive_backend_traits(backend, basebackend) { 5274 5275 5276 if (basebackend == null) basebackend = nil; 5277 return $$('Converter').$derive_backend_traits(backend, basebackend); 5278 }, -2); 5279 })($nesting[0], $nesting); 5280 (function($base, $parent_nesting) { 5281 var self = $module($base, 'Config'); 5282 5283 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5284 5285 return $def(self, '$register_for', function $$register_for($a) { 5286 var $post_args, backends, self = this; 5287 5288 5289 $post_args = $slice(arguments); 5290 backends = $post_args; 5291 return $send($$('Converter'), 'register', [self].concat($to_a($send(backends, 'map', [], function $$2(backend){ 5292 5293 if (backend == null) backend = nil; 5294 return backend.$to_s();})))); 5295 }, -1) 5296 })($nesting[0], $nesting); 5297 (function($base, $parent_nesting) { 5298 var self = $module($base, 'Factory'); 5299 5300 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5301 5302 5303 $defs(self, '$new', function $Factory_new$3($a, $b) { 5304 var $post_args, $kwargs, converters, proxy_default; 5305 5306 5307 $post_args = $slice(arguments); 5308 $kwargs = $extract_kwargs($post_args); 5309 $kwargs = $ensure_kwargs($kwargs); 5310 5311 if ($post_args.length > 0) converters = $post_args.shift();if (converters == null) converters = nil; 5312 5313 proxy_default = $kwargs.$$smap["proxy_default"];if (proxy_default == null) proxy_default = true; 5314 if ($truthy(proxy_default)) { 5315 5316 return $$('DefaultFactoryProxy').$new(converters); 5317 } else { 5318 5319 return $$('CustomFactory').$new(converters); 5320 } }, -1); 5321 $defs(self, '$default', function $Factory_default$4($a) { 5322 5323 5324 $slice(arguments); 5325 return $$('Converter'); 5326 }, -1); 5327 $defs(self, '$create', function $$create(backend, opts) { 5328 var self = this; 5329 5330 5331 if (opts == null) opts = $hash2([], {}); 5332 return self.$default().$create(backend, opts); 5333 }, -2); 5334 5335 $def(self, '$register', function $$register(converter, $a) { 5336 var $post_args, backends, self = this; 5337 5338 5339 $post_args = $slice(arguments, 1); 5340 backends = $post_args; 5341 return $send(backends, 'each', [], function $$5(backend){var $b, self = $$5.$$s == null ? this : $$5.$$s; 5342 5343 5344 if (backend == null) backend = nil; 5345 if ($eqeq(backend, "*")) { 5346 5347 return ($b = [converter], $send(self.$registry(), 'default=', $b), $b[$b.length - 1]); 5348 } else { 5349 5350 return ($b = [backend, converter], $send(self.$registry(), '[]=', $b), $b[$b.length - 1]); 5351 }}, {$$s: self}); 5352 }, -2); 5353 5354 $def(self, '$for', function $Factory_for$6(backend) { 5355 var self = this; 5356 5357 return self.$registry()['$[]'](backend) 5358 }); 5359 5360 $def(self, '$create', function $$create(backend, opts) { 5361 var self = this, converter = nil, template_dirs = nil, delegate_backend = nil; 5362 5363 5364 if (opts == null) opts = $hash2([], {}); 5365 if ($truthy((converter = self.$for(backend)))) { 5366 5367 if ($eqeqeq($Class, converter)) { 5368 converter = converter.$new(backend, opts); 5369 } if ((($truthy((template_dirs = opts['$[]']("template_dirs"))) && ($eqeqeq($$('BackendTraits'), converter))) && ($truthy(converter['$supports_templates?']())))) { 5370 return $$('CompositeConverter').$new(backend, $$('TemplateConverter').$new(backend, template_dirs, opts), converter, $hash2(["backend_traits_source"], {"backend_traits_source": converter})) 5371 } else { 5372 return converter 5373 } } else if ($truthy((template_dirs = opts['$[]']("template_dirs")))) { 5374 if (($truthy((delegate_backend = opts['$[]']("delegate_backend"))) && ($truthy((converter = self.$for(delegate_backend)))))) { 5375 5376 if ($eqeqeq($Class, converter)) { 5377 converter = converter.$new(delegate_backend, opts); 5378 } return $$('CompositeConverter').$new(backend, $$('TemplateConverter').$new(backend, template_dirs, opts), converter, $hash2(["backend_traits_source"], {"backend_traits_source": converter})); 5379 } else { 5380 return $$('TemplateConverter').$new(backend, template_dirs, opts) 5381 } 5382 } else { 5383 return nil 5384 } }, -2); 5385 5386 $def(self, '$converters', function $$converters() { 5387 var self = this; 5388 5389 return self.$registry().$merge() 5390 }); 5391 self.$private(); 5392 return $def(self, '$registry', function $$registry() { 5393 var self = this; 5394 5395 return self.$raise($$$('NotImplementedError'), "" + ($$('Factory')) + " subclass " + (self.$class()) + " must implement the #" + ("registry") + " method") 5396 }); 5397 })($nesting[0], $nesting); 5398 (function($base, $super, $parent_nesting) { 5399 var self = $klass($base, $super, 'CustomFactory'); 5400 5401 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5402 5403 5404 self.$include($$('Factory')); 5405 5406 $def(self, '$initialize', function $$initialize(seed_registry) { 5407 var self = this; 5408 5409 5410 if (seed_registry == null) seed_registry = nil; 5411 if ($truthy(seed_registry)) { 5412 5413 seed_registry['$default='](seed_registry.$delete("*")); 5414 return (self.registry = seed_registry); 5415 } else { 5416 return (self.registry = $hash2([], {})) 5417 } }, -1); 5418 5419 $def(self, '$unregister_all', function $$unregister_all() { 5420 var $a, self = this; 5421 5422 return ($a = [nil], $send(self.$registry().$clear(), 'default=', $a), $a[$a.length - 1]) 5423 }); 5424 self.$private(); 5425 return self.$attr_reader("registry"); 5426 })($nesting[0], null, $nesting); 5427 (function($base, $parent_nesting) { 5428 var self = $module($base, 'DefaultFactory'); 5429 5430 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5431 5432 5433 self.$include($$('Factory')); 5434 self.$private(); 5435 $class_variable_set($nesting[0], '@@registry', $hash2([], {})); 5436 5437 $def(self, '$registry', function $$registry() { 5438 5439 return $class_variable_get($nesting[0], '@@registry', false) 5440 }); 5441 return nil; 5442 })($nesting[0], $nesting); 5443 (function($base, $super, $parent_nesting) { 5444 var self = $klass($base, $super, 'DefaultFactoryProxy'); 5445 5446 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5447 5448 5449 self.$include($$('DefaultFactory')); 5450 return nil; 5451 })($nesting[0], $$('CustomFactory'), $nesting); 5452 $defs(self, '$included', function $$included(into) { 5453 5454 5455 into.$send("include", $$('BackendTraits')); 5456 return into.$extend($$('Config')); 5457 }); 5458 self.$private_class_method("included"); 5459 (function($base, $super, $parent_nesting) { 5460 var self = $klass($base, $super, 'Base'); 5461 5462 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 5463 5464 $proto.backend = nil; 5465 5466 self.$include($$('Logging')); 5467 self.$include($$('Converter')); 5468 5469 $def(self, '$convert', function $$convert(node, transform, opts) { 5470 var self = this, ex = nil; 5471 if ($gvars["!"] == null) $gvars["!"] = nil; 5472 5473 5474 if (transform == null) transform = node.$node_name(); 5475 if (opts == null) opts = nil; 5476 try { 5477 if ($truthy(opts)) { 5478 5479 return self.$send($rb_plus("convert_", transform), node, opts); 5480 } else { 5481 5482 return self.$send($rb_plus("convert_", transform), node); 5483 } 5484 } catch ($err) { 5485 if (Opal.rescue($err, [$$('StandardError')])) { 5486 try { 5487 5488 if (!(($eqeqeq($$$('NoMethodError'), (ex = $gvars["!"])) && ($eqeq(ex.$receiver(), self))) && ($eqeq(ex.$name().$to_s(), transform)))) { 5489 self.$raise(); 5490 }; 5491 self.$logger().$warn("missing convert handler for " + (ex.$name()) + " node in " + (self.backend) + " backend (" + (self.$class()) + ")"); 5492 return nil; 5493 } finally { Opal.pop_exception(); } 5494 } else { throw $err; } 5495 } }, -2); 5496 5497 $def(self, '$handles?', function $Base_handles$ques$7(transform) { 5498 var self = this; 5499 5500 return self['$respond_to?']("convert_" + (transform)) 5501 }); 5502 5503 $def(self, '$content_only', function $$content_only(node) { 5504 5505 return node.$content() 5506 }); 5507 return $def(self, '$skip', $return_val(nil)); 5508 })($nesting[0], null, $nesting); 5509 return self.$extend($$('DefaultFactory')); 5510 })($nesting[0], $nesting) 5511 })($nesting[0], $nesting) 5512}; 5513 5514Opal.modules["asciidoctor/document"] = function(Opal) {/* Generated by Opal 1.7.3 */ 5515 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.$$$; 5516 5517 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'); 5518 return (function($base, $parent_nesting) { 5519 var self = $module($base, 'Asciidoctor'); 5520 5521 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 5522 5523 return (function($base, $super, $parent_nesting) { 5524 var self = $klass($base, $super, 'Document'); 5525 5526 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 5527 5528 $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; 5529 5530 $const_set($nesting[0], 'ImageReference', $send($$$('Struct'), 'new', ["target", "imagesdir"], function $Document$1(){var self = $Document$1.$$s == null ? this : $Document$1.$$s; 5531 5532 return $alias(self, "to_s", "target")}, {$$s: self})); 5533 $const_set($nesting[0], 'Footnote', $$$('Struct').$new("index", "id", "text")); 5534 (function($base, $super) { 5535 var self = $klass($base, $super, 'AttributeEntry'); 5536 5537 5538 5539 self.$attr_reader("name", "value", "negate"); 5540 5541 $def(self, '$initialize', function $$initialize(name, value, negate) { 5542 var self = this; 5543 5544 5545 if (negate == null) negate = nil; 5546 self.name = name; 5547 self.value = value; 5548 return (self.negate = ($truthy(negate['$nil?']()) ? (value['$nil?']()) : (negate))); 5549 }, -3); 5550 return $def(self, '$save_to', function $$save_to(block_attributes) { 5551 var $a, self = this, $ret_or_1 = nil; 5552 5553 5554 ($truthy(($ret_or_1 = block_attributes['$[]']("attribute_entries"))) ? ($ret_or_1) : (($a = ["attribute_entries", []], $send(block_attributes, '[]=', $a), $a[$a.length - 1])))['$<<'](self); 5555 return self; 5556 }); 5557 })($nesting[0], null); 5558 (function($base, $super, $parent_nesting) { 5559 var self = $klass($base, $super, 'Title'); 5560 5561 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 5562 5563 $proto.subtitle = nil; 5564 5565 self.$attr_reader("main"); 5566 $alias(self, "title", "main"); 5567 self.$attr_reader("subtitle"); 5568 self.$attr_reader("combined"); 5569 5570 $def(self, '$initialize', function $$initialize(val, opts) { 5571 var $a, $b, self = this, sep = nil, $ret_or_1 = nil; 5572 5573 5574 if (opts == null) opts = $hash2([], {}); 5575 if (($truthy((self.sanitized = opts['$[]']("sanitize"))) && ($truthy(val['$include?']("<"))))) { 5576 val = val.$gsub($$('XmlSanitizeRx'), "").$squeeze(" ").$strip(); 5577 } if (($truthy((sep = ($truthy(($ret_or_1 = opts['$[]']("separator"))) ? ($ret_or_1) : (":")))['$empty?']()) || ($not(val['$include?']((sep = "" + (sep) + " ")))))) { 5578 5579 self.main = val; 5580 self.subtitle = nil; 5581 } else { 5582 $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])); 5583 } return (self.combined = val); 5584 }, -2); 5585 5586 $def(self, '$sanitized?', $return_ivar("sanitized")); 5587 5588 $def(self, '$subtitle?', function $Title_subtitle$ques$2() { 5589 var self = this; 5590 5591 if ($truthy(self.subtitle)) { 5592 return true 5593 } else { 5594 return false 5595 } 5596 }); 5597 return $def(self, '$to_s', $return_ivar("combined")); 5598 })($nesting[0], null, $nesting); 5599 $const_set($nesting[0], 'Author', $$$('Struct').$new("name", "firstname", "middlename", "lastname", "initials", "email")); 5600 self.$attr_reader("safe"); 5601 self.$attr_reader("compat_mode"); 5602 self.$attr_reader("backend"); 5603 self.$attr_reader("doctype"); 5604 self.$attr_accessor("sourcemap"); 5605 self.$attr_reader("catalog"); 5606 $alias(self, "references", "catalog"); 5607 self.$attr_reader("counters"); 5608 self.$attr_reader("header"); 5609 self.$attr_reader("base_dir"); 5610 self.$attr_reader("options"); 5611 self.$attr_reader("outfilesuffix"); 5612 self.$attr_reader("parent_document"); 5613 self.$attr_reader("reader"); 5614 self.$attr_reader("path_resolver"); 5615 self.$attr_reader("converter"); 5616 self.$attr_reader("syntax_highlighter"); 5617 self.$attr_reader("extensions"); 5618 5619 $def(self, '$initialize', function $$initialize(data, options) { 5620 var $b, $c, $d, $e; $$initialize.$$p || nil; var 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; 5621 5622 $$initialize.$$p = null; 5623 5624 if (data == null) data = nil; 5625 if (options == null) options = $hash2([], {}); 5626 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [self, "document"], null); 5627 if ($truthy((parent_doc = options.$delete("parent")))) { 5628 5629 self.parent_document = parent_doc; 5630 if ($truthy(($ret_or_1 = options['$[]']("base_dir")))) ; else { 5631 options['$[]=']("base_dir", parent_doc.$base_dir()); 5632 } if ($truthy(parent_doc.$options()['$[]']("catalog_assets"))) { 5633 options['$[]=']("catalog_assets", true); 5634 } if ($truthy(parent_doc.$options()['$[]']("to_dir"))) { 5635 options['$[]=']("to_dir", parent_doc.$options()['$[]']("to_dir")); 5636 } self.catalog = parent_doc.$catalog().$merge($hash2(["footnotes"], {"footnotes": []})); 5637 self.attribute_overrides = (attr_overrides = parent_doc.$instance_variable_get("@attribute_overrides").$merge(parent_doc.$attributes())); 5638 attr_overrides.$delete("compat-mode"); 5639 parent_doctype = attr_overrides.$delete("doctype"); 5640 attr_overrides.$delete("notitle"); 5641 attr_overrides.$delete("showtitle"); 5642 attr_overrides.$delete("toc"); 5643 self.attributes['$[]=']("toc-placement", ($truthy(($ret_or_1 = attr_overrides.$delete("toc-placement"))) ? ($ret_or_1) : ("auto"))); 5644 attr_overrides.$delete("toc-position"); 5645 self.safe = parent_doc.$safe(); 5646 if ($truthy((self.compat_mode = parent_doc.$compat_mode()))) { 5647 self.attributes['$[]=']("compat-mode", ""); 5648 } self.outfilesuffix = parent_doc.$outfilesuffix(); 5649 self.sourcemap = parent_doc.$sourcemap(); 5650 self.timings = nil; 5651 self.path_resolver = parent_doc.$path_resolver(); 5652 self.converter = parent_doc.$converter(); 5653 initialize_extensions = nil; 5654 self.extensions = parent_doc.$extensions(); 5655 self.syntax_highlighter = parent_doc.$syntax_highlighter(); 5656 } else { 5657 5658 self.parent_document = nil; 5659 self.catalog = $hash2(["ids", "refs", "footnotes", "links", "images", "callouts", "includes"], {"ids": $hash2([], {}), "refs": $hash2([], {}), "footnotes": [], "links": [], "images": [], "callouts": $$('Callouts').$new(), "includes": $hash2([], {})}); 5660 self.attribute_overrides = (attr_overrides = $hash2([], {})); 5661 $send(($truthy(($ret_or_1 = options['$[]']("attributes"))) ? ($ret_or_1) : ($hash2([], {}))), 'each', [], function $$3(key, val){var $a; 5662 5663 5664 if (key == null) key = nil; 5665 if (val == null) val = nil; 5666 if ($truthy(key['$end_with?']("@"))) { 5667 if ($truthy(key['$start_with?']("!"))) { 5668 $a = [key.$slice(1, $rb_minus(key.$length(), 2)), false], (key = $a[0]), (val = $a[1]); 5669 } else if ($truthy(key['$end_with?']("!@"))) { 5670 $a = [key.$slice(0, $rb_minus(key.$length(), 2)), false], (key = $a[0]), (val = $a[1]); 5671 } else { 5672 $a = [key.$chop(), "" + (val) + "@"], (key = $a[0]), (val = $a[1]); 5673 } 5674 } else if ($truthy(key['$start_with?']("!"))) { 5675 $a = [key.$slice(1, key.$length()), ($eqeq(val, "@") ? (false) : (nil))], (key = $a[0]), (val = $a[1]); 5676 } else if ($truthy(key['$end_with?']("!"))) { 5677 $a = [key.$chop(), ($eqeq(val, "@") ? (false) : (nil))], (key = $a[0]), (val = $a[1]); 5678 } return ($a = [key.$downcase(), val], $send(attr_overrides, '[]=', $a), $a[$a.length - 1]);}); 5679 if ($eqeqeq($$$('String'), (to_file = options['$[]']("to_file")))) { 5680 attr_overrides['$[]=']("outfilesuffix", $$('Helpers').$extname(to_file)); 5681 } if ($not((safe_mode = options['$[]']("safe")))) { 5682 self.safe = $$$($$('SafeMode'), 'SECURE'); 5683 } else if ($eqeqeq($$$('Integer'), safe_mode)) { 5684 self.safe = safe_mode; 5685 } else { 5686 self.safe = (function() { try { 5687 5688 return $$('SafeMode').$value_for_name(safe_mode); 5689 } catch ($err) { 5690 if (Opal.rescue($err, [$$('StandardError')])) { 5691 try { 5692 return $$$($$('SafeMode'), 'SECURE') 5693 } finally { Opal.pop_exception(); } 5694 } else { throw $err; } 5695 }})(); 5696 } input_mtime = options.$delete("input_mtime"); 5697 self.compat_mode = attr_overrides['$key?']("compat-mode"); 5698 self.sourcemap = options['$[]']("sourcemap"); 5699 self.timings = options.$delete("timings"); 5700 self.path_resolver = $$('PathResolver').$new(); 5701 initialize_extensions = (($truthy((($b = $$$('::', 'Asciidoctor', 'skip_raise')) && ($$$($b, 'Extensions', 'skip_raise')) ? 'constant' : nil)) || ($truthy(options['$key?']("extensions")))) ? ($$$($$$('Asciidoctor'), 'Extensions')) : (nil)); 5702 self.extensions = nil; 5703 if (($truthy(options['$key?']("header_footer")) && ($not(options['$key?']("standalone"))))) { 5704 options['$[]=']("standalone", options['$[]']("header_footer")); 5705 } } self.parsed = (self.reftexts = (self.header = (self.header_attributes = nil))); 5706 self.counters = $hash2([], {}); 5707 self.attributes_modified = $$$('Set').$new(); 5708 self.docinfo_processor_extensions = $hash2([], {}); 5709 standalone = options['$[]']("standalone"); 5710 (self.options = options).$freeze(); 5711 attrs = self.attributes; 5712 if (!$truthy(parent_doc)) { 5713 5714 attrs['$[]=']("attribute-undefined", $$('Compliance').$attribute_undefined()); 5715 attrs['$[]=']("attribute-missing", $$('Compliance').$attribute_missing()); 5716 attrs.$update($$('DEFAULT_ATTRIBUTES')); 5717 } if ($truthy(standalone)) { 5718 5719 attr_overrides['$[]=']("embedded", nil); 5720 attrs['$[]=']("copycss", ""); 5721 attrs['$[]=']("iconfont-remote", ""); 5722 attrs['$[]=']("stylesheet", ""); 5723 attrs['$[]=']("webfonts", ""); 5724 } else { 5725 5726 attr_overrides['$[]=']("embedded", ""); 5727 if (($truthy(attr_overrides['$key?']("showtitle")) && ($eqeq(attr_overrides.$keys()['$&'](["notitle", "showtitle"])['$[]'](-1), "showtitle")))) { 5728 attr_overrides['$[]=']("notitle", $hash(nil, "", false, "@", "@", false)['$[]'](attr_overrides['$[]']("showtitle"))); 5729 } else if ($truthy(attr_overrides['$key?']("notitle"))) { 5730 attr_overrides['$[]=']("showtitle", $hash(nil, "", false, "@", "@", false)['$[]'](attr_overrides['$[]']("notitle"))); 5731 } else { 5732 attrs['$[]=']("notitle", ""); 5733 } } attr_overrides['$[]=']("asciidoctor", ""); 5734 attr_overrides['$[]=']("asciidoctor-version", $$$($$$('Asciidoctor'), 'VERSION')); 5735 attr_overrides['$[]=']("safe-mode-name", (safe_mode_name = $$('SafeMode').$name_for_value(self.safe))); 5736 attr_overrides['$[]=']("safe-mode-" + (safe_mode_name), ""); 5737 attr_overrides['$[]=']("safe-mode-level", self.safe); 5738 if ($truthy(($ret_or_1 = attr_overrides['$[]']("max-include-depth")))) ; else { 5739 attr_overrides['$[]=']("max-include-depth", 64); 5740 } if ($truthy(($ret_or_1 = attr_overrides['$[]']("allow-uri-read")))) ; else { 5741 attr_overrides['$[]=']("allow-uri-read", nil); 5742 } if ($truthy(attr_overrides['$key?']("numbered"))) { 5743 attr_overrides['$[]=']("sectnums", attr_overrides.$delete("numbered")); 5744 } if ($truthy(attr_overrides['$key?']("hardbreaks"))) { 5745 attr_overrides['$[]=']("hardbreaks-option", attr_overrides.$delete("hardbreaks")); 5746 } if ($truthy((base_dir_val = options['$[]']("base_dir")))) { 5747 self.base_dir = ($c = ["docdir", $$$('File').$expand_path(base_dir_val)], $send(attr_overrides, '[]=', $c), $c[$c.length - 1]); 5748 } else if ($truthy(attr_overrides['$[]']("docdir"))) { 5749 self.base_dir = attr_overrides['$[]']("docdir"); 5750 } else { 5751 self.base_dir = ($c = ["docdir", $$$('Dir').$pwd()], $send(attr_overrides, '[]=', $c), $c[$c.length - 1]); 5752 } if ($truthy((backend_val = options['$[]']("backend")))) { 5753 attr_overrides['$[]=']("backend", backend_val.$to_s()); 5754 } if ($truthy((doctype_val = options['$[]']("doctype")))) { 5755 attr_overrides['$[]=']("doctype", doctype_val.$to_s()); 5756 } if ($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SERVER')))) { 5757 5758 if ($truthy(($ret_or_1 = attr_overrides['$[]']("copycss")))) ; else { 5759 attr_overrides['$[]=']("copycss", nil); 5760 } if ($truthy(($ret_or_1 = attr_overrides['$[]']("source-highlighter")))) ; else { 5761 attr_overrides['$[]=']("source-highlighter", nil); 5762 } if ($truthy(($ret_or_1 = attr_overrides['$[]']("backend")))) ; else { 5763 attr_overrides['$[]=']("backend", $$('DEFAULT_BACKEND')); 5764 } if (($not(parent_doc) && ($truthy(attr_overrides['$key?']("docfile"))))) { 5765 attr_overrides['$[]=']("docfile", attr_overrides['$[]']("docfile")['$[]'](Opal.Range.$new($rb_plus(attr_overrides['$[]']("docdir").$length(), 1), -1, false))); 5766 } attr_overrides['$[]=']("docdir", ""); 5767 if ($truthy(($ret_or_1 = attr_overrides['$[]']("user-home")))) ; else { 5768 attr_overrides['$[]=']("user-home", "."); 5769 } if ($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SECURE')))) { 5770 5771 if (!$truthy(attr_overrides['$key?']("max-attribute-value-size"))) { 5772 attr_overrides['$[]=']("max-attribute-value-size", 4096); 5773 } if (!$truthy(attr_overrides['$key?']("linkcss"))) { 5774 attr_overrides['$[]=']("linkcss", ""); 5775 } if ($truthy(($ret_or_1 = attr_overrides['$[]']("icons")))) ; else { 5776 attr_overrides['$[]=']("icons", nil); 5777 } } } else if ($truthy(($ret_or_1 = attr_overrides['$[]']("user-home")))) ; else { 5778 attr_overrides['$[]=']("user-home", $$('USER_HOME')); 5779 } 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)); 5780 $send(attr_overrides, 'delete_if', [], function $$4(key, val){var $d, verdict = nil; 5781 5782 5783 if (key == null) key = nil; 5784 if (val == null) val = nil; 5785 if ($truthy(val)) { 5786 5787 if (($eqeqeq($$$('String'), val) && ($truthy(val['$end_with?']("@"))))) { 5788 $d = [val.$chop(), true], (val = $d[0]), (verdict = $d[1]); 5789 } attrs['$[]='](key, val); 5790 } else { 5791 5792 attrs.$delete(key); 5793 verdict = val['$=='](false); 5794 } return verdict;}); 5795 if ($truthy(parent_doc)) { 5796 5797 self.backend = attrs['$[]']("backend"); 5798 if (!$eqeq((self.doctype = ($c = ["doctype", parent_doctype], $send(attrs, '[]=', $c), $c[$c.length - 1])), $$('DEFAULT_DOCTYPE'))) { 5799 self.$update_doctype_attributes($$('DEFAULT_DOCTYPE')); 5800 } self.reader = $$('Reader').$new(data, options['$[]']("cursor")); 5801 if ($truthy(self.sourcemap)) { 5802 self.source_location = self.reader.$cursor(); 5803 } $$('Parser').$parse(self.reader, self); 5804 self.$restore_attributes(); 5805 return (self.parsed = true); 5806 } else { 5807 5808 self.backend = nil; 5809 if ($eqeq((initial_backend = ($truthy(($ret_or_1 = attrs['$[]']("backend"))) ? ($ret_or_1) : ($$('DEFAULT_BACKEND')))), "manpage")) { 5810 self.doctype = ($c = ["doctype", ($d = ["doctype", "manpage"], $send(attr_overrides, '[]=', $d), $d[$d.length - 1])], $send(attrs, '[]=', $c), $c[$c.length - 1]); 5811 } else { 5812 self.doctype = ($truthy(($ret_or_1 = attrs['$[]']("doctype"))) ? ($ret_or_1) : (($c = ["doctype", $$('DEFAULT_DOCTYPE')], $send(attrs, '[]=', $c), $c[$c.length - 1]))); 5813 } self.$update_backend_attributes(initial_backend, true); 5814 if ($truthy(($ret_or_1 = attrs['$[]']("stylesdir")))) ; else { 5815 attrs['$[]=']("stylesdir", "."); 5816 } if ($truthy(($ret_or_1 = attrs['$[]']("iconsdir")))) ; else { 5817 attrs['$[]=']("iconsdir", "" + (attrs.$fetch("imagesdir", "./images")) + "/icons"); 5818 } self.$fill_datetime_attributes(attrs, input_mtime); 5819 if ($truthy(initialize_extensions)) { 5820 if ($truthy((ext_registry = options['$[]']("extension_registry")))) { 5821 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)))))) { 5822 self.extensions = ext_registry.$activate(self); 5823 } 5824 } else if ($truthy((ext_block = options['$[]']("extensions"))['$nil?']())) { 5825 if (!$truthy($$('Extensions').$groups()['$empty?']())) { 5826 self.extensions = $$$($$('Extensions'), 'Registry').$new().$activate(self); 5827 } 5828 } else if ($eqeqeq($$$('Proc'), ext_block)) { 5829 self.extensions = $send($$('Extensions'), 'create', [], ext_block.$to_proc()).$activate(self); 5830 } 5831 } self.reader = $$('PreprocessorReader').$new(self, data, $$$($$('Reader'), 'Cursor').$new(attrs['$[]']("docfile"), self.base_dir), $hash2(["normalize"], {"normalize": true})); 5832 if ($truthy(self.sourcemap)) { 5833 return (self.source_location = self.reader.$cursor()) 5834 } else { 5835 return nil 5836 } } }, -1); 5837 5838 $def(self, '$parse', function $$parse(data) { 5839 var self = this, doc = nil, exts = nil; 5840 5841 5842 if (data == null) data = nil; 5843 if ($truthy(self.parsed)) { 5844 return self 5845 } else { 5846 5847 doc = self; 5848 if ($truthy(data)) { 5849 5850 self.reader = $$('PreprocessorReader').$new(doc, data, $$$($$('Reader'), 'Cursor').$new(self.attributes['$[]']("docfile"), self.base_dir), $hash2(["normalize"], {"normalize": true})); 5851 if ($truthy(self.sourcemap)) { 5852 self.source_location = self.reader.$cursor(); 5853 } } if (($truthy((exts = ($truthy(self.parent_document) ? (nil) : (self.extensions)))) && ($truthy(exts['$preprocessors?']())))) { 5854 $send(exts.$preprocessors(), 'each', [], function $$5(ext){var self = $$5.$$s == null ? this : $$5.$$s, $ret_or_1 = nil; 5855 if (self.reader == null) self.reader = nil; 5856 5857 5858 if (ext == null) ext = nil; 5859 return (self.reader = ($truthy(($ret_or_1 = ext.$process_method()['$[]'](doc, self.reader))) ? ($ret_or_1) : (self.reader)));}, {$$s: self}); 5860 } $$('Parser').$parse(self.reader, doc, $hash2(["header_only"], {"header_only": self.options['$[]']("parse_header_only")})); 5861 self.$restore_attributes(); 5862 if (($truthy(exts) && ($truthy(exts['$tree_processors?']())))) { 5863 $send(exts.$tree_processors(), 'each', [], function $$6(ext){var result = nil; 5864 5865 5866 if (ext == null) ext = nil; 5867 if ((($truthy((result = ext.$process_method()['$[]'](doc))) && ($eqeqeq($$('Document'), result))) && ($neqeq(result, doc)))) { 5868 return (doc = result) 5869 } else { 5870 return nil 5871 }}); 5872 } self.parsed = true; 5873 return doc; 5874 } }, -1); 5875 5876 $def(self, '$parsed?', $return_ivar("parsed")); 5877 5878 $def(self, '$counter', function $$counter(name, seed) { 5879 var $a, self = this, curr_val = nil, locked = nil, next_val = nil; 5880 5881 5882 if (seed == null) seed = nil; 5883 if ($truthy(self.parent_document)) { 5884 return self.parent_document.$counter(name, seed) 5885 } if ((($truthy((locked = self['$attribute_locked?'](name))) && ($truthy((curr_val = self.counters['$[]'](name))))) || ($not((curr_val = self.attributes['$[]'](name))['$nil_or_empty?']())))) { 5886 next_val = ($a = [name, $$('Helpers').$nextval(curr_val)], $send(self.counters, '[]=', $a), $a[$a.length - 1]); 5887 } else if ($truthy(seed)) { 5888 next_val = ($a = [name, ($eqeq(seed, seed.$to_i().$to_s()) ? (seed.$to_i()) : (seed))], $send(self.counters, '[]=', $a), $a[$a.length - 1]); 5889 } else { 5890 next_val = ($a = [name, 1], $send(self.counters, '[]=', $a), $a[$a.length - 1]); 5891 } if (!$truthy(locked)) { 5892 self.attributes['$[]='](name, next_val); 5893 } return next_val; 5894 }, -2); 5895 5896 $def(self, '$increment_and_store_counter', function $$increment_and_store_counter(counter_name, block) { 5897 var self = this; 5898 5899 return $$('AttributeEntry').$new(counter_name, self.$counter(counter_name)).$save_to(block.$attributes()).$value() 5900 }); 5901 $alias(self, "counter_increment", "increment_and_store_counter"); 5902 5903 $def(self, '$register', function $$register(type, value) { 5904 var self = this, id = nil, $logical_op_recvr_tmp_1 = nil, ref = nil; 5905 5906 5907 switch (type) { 5908 case "ids": 5909 return self.$register("refs", [(id = value['$[]'](0)), $$('Inline').$new(self, "anchor", value['$[]'](1), $hash2(["type", "id"], {"type": "ref", "id": id}))]) 5910 case "refs": 5911 5912 5913 $logical_op_recvr_tmp_1 = self.catalog['$[]']("refs"); 5914 if ($truthy(($logical_op_recvr_tmp_1['$[]'](value['$[]'](0))))) ; else { 5915 $logical_op_recvr_tmp_1['$[]='](value['$[]'](0), (ref = value['$[]'](1))); 5916 } return ref; 5917 case "footnotes": 5918 return self.catalog['$[]'](type)['$<<'](value) 5919 default: 5920 if ($truthy(self.options['$[]']("catalog_assets"))) { 5921 return self.catalog['$[]'](type)['$<<'](($eqeq(type, "images") ? ($$('ImageReference').$new(value, self.attributes['$[]']("imagesdir"))) : (value))) 5922 } else { 5923 return nil 5924 } 5925 } 5926 }); 5927 5928 $def(self, '$resolve_id', function $$resolve_id(text) { 5929 var self = this, resolved_id = nil, accum = nil; 5930 5931 if ($truthy(self.reftexts)) { 5932 return self.reftexts['$[]'](text) 5933 } else if ($truthy(self.parsed)) { 5934 return $send((self.reftexts = $hash2([], {})), 'tap', [], function $$7(accum){var self = $$7.$$s == null ? this : $$7.$$s; 5935 if (self.catalog == null) self.catalog = nil; 5936 5937 5938 if (accum == null) accum = nil; 5939 return $send(self.catalog['$[]']("refs"), 'each', [], function $$8(id, ref){var $a, $ret_or_1 = nil; 5940 5941 5942 if (id == null) id = nil; 5943 if (ref == null) ref = nil; 5944 if ($truthy(($ret_or_1 = accum['$[]'](ref.$xreftext())))) { 5945 return $ret_or_1 5946 } else { 5947 return ($a = [ref.$xreftext(), id], $send(accum, '[]=', $a), $a[$a.length - 1]) 5948 }});}, {$$s: self})['$[]'](text) 5949 } else { 5950 5951 resolved_id = nil; 5952 self.reftexts = (accum = $hash2([], {})); 5953 (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; 5954 5955 5956 if (id == null) id = nil; 5957 if (ref == null) ref = nil; 5958 if ($eqeq((xreftext = ref.$xreftext()), text)) { 5959 5960 resolved_id = id; 5961 $t_break.$throw(); 5962 }; 5963 if ($truthy(($ret_or_1 = accum['$[]'](xreftext)))) { 5964 return $ret_or_1 5965 } else { 5966 return ($a = [xreftext, id], $send(accum, '[]=', $a), $a[$a.length - 1]) 5967 };})} catch($e) { 5968 if ($e === $t_break) return $e.$v; 5969 throw $e; 5970 }})(); 5971 self.reftexts = nil; 5972 return resolved_id; 5973 } 5974 }); 5975 5976 $def(self, '$sections?', function $Document_sections$ques$10() { 5977 var self = this; 5978 5979 return $rb_gt(self.next_section_index, 0) 5980 }); 5981 5982 $def(self, '$footnotes?', function $Document_footnotes$ques$11() { 5983 var self = this; 5984 5985 if ($truthy(self.catalog['$[]']("footnotes")['$empty?']())) { 5986 return false 5987 } else { 5988 return true 5989 } 5990 }); 5991 5992 $def(self, '$footnotes', function $$footnotes() { 5993 var self = this; 5994 5995 return self.catalog['$[]']("footnotes") 5996 }); 5997 5998 $def(self, '$callouts', function $$callouts() { 5999 var self = this; 6000 6001 return self.catalog['$[]']("callouts") 6002 }); 6003 6004 $def(self, '$nested?', function $Document_nested$ques$12() { 6005 var self = this; 6006 6007 if ($truthy(self.parent_document)) { 6008 return true 6009 } else { 6010 return false 6011 } 6012 }); 6013 6014 $def(self, '$embedded?', function $Document_embedded$ques$13() { 6015 var self = this; 6016 6017 return self.attributes['$key?']("embedded") 6018 }); 6019 6020 $def(self, '$extensions?', function $Document_extensions$ques$14() { 6021 var self = this; 6022 6023 if ($truthy(self.extensions)) { 6024 return true 6025 } else { 6026 return false 6027 } 6028 }); 6029 6030 $def(self, '$source', function $$source() { 6031 var self = this; 6032 6033 if ($truthy(self.reader)) { 6034 return self.reader.$source() 6035 } else { 6036 return nil 6037 } 6038 }); 6039 6040 $def(self, '$source_lines', function $$source_lines() { 6041 var self = this; 6042 6043 if ($truthy(self.reader)) { 6044 return self.reader.$source_lines() 6045 } else { 6046 return nil 6047 } 6048 }); 6049 6050 $def(self, '$basebackend?', function $Document_basebackend$ques$15(base) { 6051 var self = this; 6052 6053 return self.attributes['$[]']("basebackend")['$=='](base) 6054 }); 6055 6056 $def(self, '$title', function $$title() { 6057 var self = this; 6058 6059 return self.$doctitle() 6060 }); 6061 6062 $def(self, '$title=', function $Document_title$eq$16(title) { 6063 var $a, self = this, sect = nil; 6064 6065 6066 if (!$truthy((sect = self.header))) { 6067 (sect = (self.header = $$('Section').$new(self, 0)))['$sectname=']("header"); 6068 } return ($a = [title], $send(sect, 'title=', $a), $a[$a.length - 1]); 6069 }); 6070 6071 $def(self, '$doctitle', function $$doctitle(opts) { 6072 var self = this, val = nil, sect = nil, $ret_or_1 = nil, separator = nil; 6073 6074 6075 if (opts == null) opts = $hash2([], {}); 6076 if (!$truthy((val = self.attributes['$[]']("title")))) { 6077 if ($truthy((sect = self.$first_section()))) { 6078 val = sect.$title(); 6079 } else if ($not(($truthy(($ret_or_1 = opts['$[]']("use_fallback"))) ? ((val = self.attributes['$[]']("untitled-label"))) : ($ret_or_1)))) { 6080 return nil 6081 } 6082 } if ($truthy((separator = opts['$[]']("partition")))) { 6083 return $$('Title').$new(val, opts.$merge($hash2(["separator"], {"separator": ($eqeq(separator, true) ? (self.attributes['$[]']("title-separator")) : (separator))}))) 6084 } else if (($truthy(opts['$[]']("sanitize")) && ($truthy(val['$include?']("<"))))) { 6085 return val.$gsub($$('XmlSanitizeRx'), "").$squeeze(" ").$strip() 6086 } else { 6087 return val 6088 } }, -1); 6089 $alias(self, "name", "doctitle"); 6090 6091 $def(self, '$xreftext', function $$xreftext(xrefstyle) { 6092 var self = this, val = nil; 6093 if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) { 6094 return val 6095 } else { 6096 return self.$title() 6097 } }, -1); 6098 6099 $def(self, '$author', function $$author() { 6100 var self = this; 6101 6102 return self.attributes['$[]']("author") 6103 }); 6104 6105 $def(self, '$authors', function $$authors() { 6106 var self = this, attrs = nil, authors = nil, num_authors = nil, $ret_or_1 = nil, idx = nil; 6107 6108 if ($truthy((attrs = self.attributes)['$key?']("author"))) { 6109 6110 authors = [$$('Author').$new(attrs['$[]']("author"), attrs['$[]']("firstname"), attrs['$[]']("middlename"), attrs['$[]']("lastname"), attrs['$[]']("authorinitials"), attrs['$[]']("email"))]; 6111 if ($truthy($rb_gt((num_authors = ($truthy(($ret_or_1 = attrs['$[]']("authorcount"))) ? ($ret_or_1) : (0))), 1))) { 6112 6113 idx = 1; 6114 while ($truthy($rb_lt(idx, num_authors))) { 6115 6116 idx = $rb_plus(idx, 1); 6117 authors['$<<']($$('Author').$new(attrs['$[]']("author_" + (idx)), attrs['$[]']("firstname_" + (idx)), attrs['$[]']("middlename_" + (idx)), attrs['$[]']("lastname_" + (idx)), attrs['$[]']("authorinitials_" + (idx)), attrs['$[]']("email_" + (idx)))); 6118 } } return authors; 6119 } else { 6120 return [] 6121 } 6122 }); 6123 6124 $def(self, '$revdate', function $$revdate() { 6125 var self = this; 6126 6127 return self.attributes['$[]']("revdate") 6128 }); 6129 6130 $def(self, '$notitle', function $$notitle() { 6131 var self = this; 6132 6133 return self.attributes['$key?']("notitle") 6134 }); 6135 6136 $def(self, '$noheader', function $$noheader() { 6137 var self = this; 6138 6139 return self.attributes['$key?']("noheader") 6140 }); 6141 6142 $def(self, '$nofooter', function $$nofooter() { 6143 var self = this; 6144 6145 return self.attributes['$key?']("nofooter") 6146 }); 6147 6148 $def(self, '$first_section', function $$first_section() { 6149 var self = this, $ret_or_1 = nil; 6150 6151 if ($truthy(($ret_or_1 = self.header))) { 6152 return $ret_or_1 6153 } else { 6154 return $send(self.blocks, 'find', [], function $$17(e){ 6155 6156 if (e == null) e = nil; 6157 return e.$context()['$==']("section");}) 6158 } 6159 }); 6160 6161 $def(self, '$header?', function $Document_header$ques$18() { 6162 var self = this; 6163 6164 if ($truthy(self.header)) { 6165 return true 6166 } else { 6167 return false 6168 } 6169 }); 6170 $alias(self, "has_header?", "header?"); 6171 6172 $def(self, '$<<', function $Document_$lt$lt$19(block) { 6173 var $yield = $Document_$lt$lt$19.$$p || nil, self = this; 6174 6175 $Document_$lt$lt$19.$$p = null; 6176 6177 if ($eqeq(block.$context(), "section")) { 6178 self.$assign_numeral(block); 6179 } return $send2(self, $find_super(self, '<<', $Document_$lt$lt$19, false, true), '<<', [block], $yield); 6180 }); 6181 6182 $def(self, '$finalize_header', function $$finalize_header(unrooted_attributes, header_valid) { 6183 var self = this; 6184 6185 6186 if (header_valid == null) header_valid = true; 6187 self.$clear_playback_attributes(unrooted_attributes); 6188 self.$save_attributes(); 6189 if (!$truthy(header_valid)) { 6190 unrooted_attributes['$[]=']("invalid-header", true); 6191 } return unrooted_attributes; 6192 }, -2); 6193 6194 $def(self, '$playback_attributes', function $$playback_attributes(block_attributes) { 6195 var self = this; 6196 6197 if ($truthy(block_attributes['$key?']("attribute_entries"))) { 6198 return $send(block_attributes['$[]']("attribute_entries"), 'each', [], function $$20(entry){var self = $$20.$$s == null ? this : $$20.$$s, name = nil; 6199 if (self.attributes == null) self.attributes = nil; 6200 6201 6202 if (entry == null) entry = nil; 6203 name = entry.$name(); 6204 if ($truthy(entry.$negate())) { 6205 6206 self.attributes.$delete(name); 6207 if ($eqeq(name, "compat-mode")) { 6208 return (self.compat_mode = false) 6209 } else { 6210 return nil 6211 } } else { 6212 6213 self.attributes['$[]='](name, entry.$value()); 6214 if ($eqeq(name, "compat-mode")) { 6215 return (self.compat_mode = true) 6216 } else { 6217 return nil 6218 } }}, {$$s: self}) 6219 } else { 6220 return nil 6221 } 6222 }); 6223 6224 $def(self, '$restore_attributes', function $$restore_attributes() { 6225 var self = this; 6226 6227 6228 if (!$truthy(self.parent_document)) { 6229 self.catalog['$[]']("callouts").$rewind(); 6230 } return self.attributes.$replace(self.header_attributes); 6231 }); 6232 6233 $def(self, '$set_attribute', function $$set_attribute(name, value) { 6234 var self = this, $ret_or_2 = nil; 6235 6236 6237 if (value == null) value = ""; 6238 if ($truthy(self['$attribute_locked?'](name))) { 6239 return nil 6240 } else { 6241 6242 if (!$truthy(value['$empty?']())) { 6243 value = self.$apply_attribute_value_subs(value); 6244 } if ($truthy(self.header_attributes)) { 6245 self.attributes['$[]='](name, value); 6246 } else { 6247 6248 6249 switch (name) { 6250 case "backend": 6251 self.$update_backend_attributes(value, ($truthy(($ret_or_2 = self.attributes_modified['$delete?']("htmlsyntax"))) ? (value['$=='](self.backend)) : ($ret_or_2))); 6252 break; 6253 case "doctype": 6254 self.$update_doctype_attributes(value); 6255 break; 6256 default: 6257 self.attributes['$[]='](name, value); 6258 } self.attributes_modified['$<<'](name); 6259 } return value; 6260 } }, -2); 6261 6262 $def(self, '$delete_attribute', function $$delete_attribute(name) { 6263 var self = this; 6264 6265 if ($truthy(self['$attribute_locked?'](name))) { 6266 return false 6267 } else { 6268 6269 self.attributes.$delete(name); 6270 self.attributes_modified['$<<'](name); 6271 return true; 6272 } 6273 }); 6274 6275 $def(self, '$attribute_locked?', function $Document_attribute_locked$ques$21(name) { 6276 var self = this; 6277 6278 return self.attribute_overrides['$key?'](name) 6279 }); 6280 6281 $def(self, '$set_header_attribute', function $$set_header_attribute(name, value, overwrite) { 6282 var self = this, attrs = nil, $ret_or_1 = nil; 6283 6284 6285 if (value == null) value = ""; 6286 if (overwrite == null) overwrite = true; 6287 attrs = ($truthy(($ret_or_1 = self.header_attributes)) ? ($ret_or_1) : (self.attributes)); 6288 if (($eqeq(overwrite, false) && ($truthy(attrs['$key?'](name))))) { 6289 return false 6290 } else { 6291 6292 attrs['$[]='](name, value); 6293 return true; 6294 } }, -2); 6295 6296 $def(self, '$convert', function $$convert(opts) { 6297 var $a, self = this, block = nil, $ret_or_1 = nil, output = nil, transform = nil, exts = nil; 6298 6299 6300 if (opts == null) opts = $hash2([], {}); 6301 if ($truthy(self.timings)) { 6302 self.timings.$start("convert"); 6303 } if (!$truthy(self.parsed)) { 6304 self.$parse(); 6305 } if (!($truthy($rb_ge(self.safe, $$$($$('SafeMode'), 'SERVER'))) || ($truthy(opts['$empty?']())))) { 6306 6307 if (!$truthy(($a = ["outfile", opts['$[]']("outfile")], $send(self.attributes, '[]=', $a), $a[$a.length - 1]))) { 6308 self.attributes.$delete("outfile"); 6309 } if (!$truthy(($a = ["outdir", opts['$[]']("outdir")], $send(self.attributes, '[]=', $a), $a[$a.length - 1]))) { 6310 self.attributes.$delete("outdir"); 6311 } } if ($eqeq(self.$doctype(), "inline")) { 6312 if ($truthy((block = ($truthy(($ret_or_1 = self.blocks['$[]'](0))) ? ($ret_or_1) : (self.header))))) { 6313 if (($eqeq(block.$content_model(), "compound") || ($eqeq(block.$content_model(), "empty")))) { 6314 self.$logger().$warn("no inline candidate; use the inline doctype to convert a single paragragh, verbatim, or raw block"); 6315 } else { 6316 output = block.$content(); 6317 } 6318 } 6319 } else { 6320 6321 if ($truthy(opts['$key?']("standalone"))) { 6322 transform = ($truthy(opts['$[]']("standalone")) ? ("document") : ("embedded")); 6323 } else if ($truthy(opts['$key?']("header_footer"))) { 6324 transform = ($truthy(opts['$[]']("header_footer")) ? ("document") : ("embedded")); 6325 } else { 6326 transform = ($truthy(self.options['$[]']("standalone")) ? ("document") : ("embedded")); 6327 } output = self.converter.$convert(self, transform); 6328 } if (!$truthy(self.parent_document)) { 6329 if (($truthy((exts = self.extensions)) && ($truthy(exts['$postprocessors?']())))) { 6330 $send(exts.$postprocessors(), 'each', [], function $$22(ext){var self = $$22.$$s == null ? this : $$22.$$s; 6331 6332 6333 if (ext == null) ext = nil; 6334 return (output = ext.$process_method()['$[]'](self, output));}, {$$s: self}); 6335 } 6336 } if ($truthy(self.timings)) { 6337 self.timings.$record("convert"); 6338 } return output; 6339 }, -1); 6340 $alias(self, "render", "convert"); 6341 6342 $def(self, '$write', function $$write(output, target) { 6343 var self = this; 6344 6345 6346 if ($truthy(self.timings)) { 6347 self.timings.$start("write"); 6348 } if ($eqeqeq($$('Writer'), self.converter)) { 6349 self.converter.$write(output, target); 6350 } else { 6351 6352 if ($truthy(target['$respond_to?']("write"))) { 6353 if (!$truthy(output['$nil_or_empty?']())) { 6354 6355 target.$write(output.$chomp()); 6356 target.$write($$('LF')); 6357 } 6358 } else { 6359 $$$('File').$write(target, output, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 6360 } if ((($eqeq(self.backend, "manpage") && ($eqeqeq($$$('String'), target))) && ($truthy(self.converter.$class()['$respond_to?']("write_alternate_pages"))))) { 6361 self.converter.$class().$write_alternate_pages(self.attributes['$[]']("mannames"), self.attributes['$[]']("manvolnum"), target); 6362 } } if ($truthy(self.timings)) { 6363 self.timings.$record("write"); 6364 } return nil; 6365 }); 6366 6367 $def(self, '$content', function $$content() { 6368 var $yield = $$content.$$p || nil, self = this; 6369 6370 $$content.$$p = null; 6371 6372 self.attributes.$delete("title"); 6373 return $send2(self, $find_super(self, 'content', $$content, false, true), 'content', [], $yield); 6374 }); 6375 6376 $def(self, '$docinfo', function $$docinfo(location, suffix) { 6377 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; 6378 6379 6380 if (location == null) location = "head"; 6381 if (suffix == null) suffix = nil; 6382 if ($truthy($rb_lt(self.$safe(), $$$($$('SafeMode'), 'SECURE')))) { 6383 6384 if (!$eqeq(location, "head")) { 6385 qualifier = "-" + (location); 6386 } suffix = ($truthy(($ret_or_1 = suffix)) ? ($ret_or_1) : (self.outfilesuffix)); 6387 if ($truthy((docinfo = self.attributes['$[]']("docinfo"))['$nil_or_empty?']())) { 6388 if ($truthy(self.attributes['$key?']("docinfo2"))) { 6389 docinfo = ["private", "shared"]; 6390 } else if ($truthy(self.attributes['$key?']("docinfo1"))) { 6391 docinfo = ["shared"]; 6392 } else { 6393 docinfo = ($truthy(docinfo) ? (["private"]) : (nil)); 6394 } 6395 } else { 6396 docinfo = $send(docinfo.$split(","), 'map', [], function $$23(it){ 6397 6398 if (it == null) it = nil; 6399 return it.$strip();}); 6400 } if ($truthy(docinfo)) { 6401 6402 content = []; 6403 $a = ["docinfo" + (qualifier) + (suffix), self.attributes['$[]']("docinfodir"), self.$resolve_docinfo_subs()], (docinfo_file = $a[0]), (docinfo_dir = $a[1]), (docinfo_subs = $a[2]); 6404 if (!$truthy(docinfo['$&'](["shared", "shared-" + (location)])['$empty?']())) { 6405 6406 docinfo_path = self.$normalize_system_path(docinfo_file, docinfo_dir); 6407 if ($truthy((shared_docinfo = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true}))))) { 6408 content['$<<'](self.$apply_subs(shared_docinfo, docinfo_subs)); 6409 } } if (!($truthy(self.attributes['$[]']("docname")['$nil_or_empty?']()) || ($truthy(docinfo['$&'](["private", "private-" + (location)])['$empty?']())))) { 6410 6411 docinfo_path = self.$normalize_system_path("" + (self.attributes['$[]']("docname")) + "-" + (docinfo_file), docinfo_dir); 6412 if ($truthy((private_docinfo = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true}))))) { 6413 content['$<<'](self.$apply_subs(private_docinfo, docinfo_subs)); 6414 } } } } if (($truthy(self.extensions) && ($truthy(self['$docinfo_processors?'](location))))) { 6415 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; 6416 6417 6418 if (ext == null) ext = nil; 6419 return ext.$process_method()['$[]'](self);}, {$$s: self}).$compact()).$join($$('LF')) 6420 } else if ($truthy(content)) { 6421 return content.$join($$('LF')) 6422 } else { 6423 return "" 6424 } }, -1); 6425 6426 $def(self, '$docinfo_processors?', function $Document_docinfo_processors$ques$25(location) { 6427 var $a, self = this; 6428 6429 6430 if (location == null) location = "head"; 6431 if ($truthy(self.docinfo_processor_extensions['$key?'](location))) { 6432 return self.docinfo_processor_extensions['$[]'](location)['$!='](false) 6433 } else if (($truthy(self.extensions) && ($truthy(self.document.$extensions()['$docinfo_processors?'](location))))) { 6434 return ($a = [location, self.document.$extensions().$docinfo_processors(location)], $send(self.docinfo_processor_extensions, '[]=', $a), $a[$a.length - 1])['$!']()['$!']() 6435 } else { 6436 return ($a = [location, false], $send(self.docinfo_processor_extensions, '[]=', $a), $a[$a.length - 1]) 6437 } }, -1); 6438 6439 $def(self, '$to_s', function $$to_s() { 6440 var self = this, $ret_or_1 = nil; 6441 6442 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()) + "}>" 6443 }); 6444 self.$private(); 6445 6446 $def(self, '$apply_attribute_value_subs', function $$apply_attribute_value_subs(value) { 6447 var $a, self = this; 6448 6449 6450 if ($truthy($$('AttributeEntryPassMacroRx')['$=~'](value))) { 6451 6452 value = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)); 6453 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 6454 value = self.$apply_subs(value, self.$resolve_pass_subs((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))); 6455 } } else { 6456 value = self.$apply_header_subs(value); 6457 } if ($truthy(self.max_attribute_value_size)) { 6458 6459 return self.$limit_bytesize(value, self.max_attribute_value_size); 6460 } else { 6461 return value 6462 } }); 6463 6464 $def(self, '$limit_bytesize', function $$limit_bytesize(str, max) { 6465 6466 6467 if ($truthy($rb_gt(str.$bytesize(), max))) { 6468 while (!($truthy((str = str.$byteslice(0, max))['$valid_encoding?']()))) { 6469 max = $rb_minus(max, 1); 6470 } 6471 } return str; 6472 }); 6473 6474 $def(self, '$resolve_docinfo_subs', function $$resolve_docinfo_subs() { 6475 var self = this; 6476 6477 if ($truthy(self.attributes['$key?']("docinfosubs"))) { 6478 6479 return self.$resolve_subs(self.attributes['$[]']("docinfosubs"), "block", nil, "docinfo"); 6480 } else { 6481 return ["attributes"] 6482 } 6483 }); 6484 6485 $def(self, '$create_converter', function $$create_converter(backend, delegate_backend) { 6486 var self = this, converter_opts = nil, template_dirs = nil, $ret_or_1 = nil, opts = nil, converter = nil; 6487 6488 6489 converter_opts = $hash2(["document", "htmlsyntax"], {"document": self, "htmlsyntax": self.attributes['$[]']("htmlsyntax")}); 6490 if ($truthy((template_dirs = ($truthy(($ret_or_1 = (opts = self.options)['$[]']("template_dirs"))) ? ($ret_or_1) : (opts['$[]']("template_dir")))))) { 6491 6492 converter_opts['$[]=']("template_dirs", [].concat($to_a(template_dirs))); 6493 converter_opts['$[]=']("template_cache", opts.$fetch("template_cache", true)); 6494 converter_opts['$[]=']("template_engine", opts['$[]']("template_engine")); 6495 converter_opts['$[]=']("template_engine_options", opts['$[]']("template_engine_options")); 6496 converter_opts['$[]=']("eruby", opts['$[]']("eruby")); 6497 converter_opts['$[]=']("safe", self.safe); 6498 if ($truthy(delegate_backend)) { 6499 converter_opts['$[]=']("delegate_backend", delegate_backend); 6500 } } if ($truthy((converter = opts['$[]']("converter")))) { 6501 return $$$($$('Converter'), 'CustomFactory').$new($hash(backend, converter)).$create(backend, converter_opts) 6502 } else { 6503 return opts.$fetch("converter_factory", $$('Converter')).$create(backend, converter_opts) 6504 } }); 6505 6506 $def(self, '$clear_playback_attributes', function $$clear_playback_attributes(attributes) { 6507 6508 return attributes.$delete("attribute_entries") 6509 }); 6510 6511 $def(self, '$save_attributes', function $$save_attributes() { 6512 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; 6513 6514 6515 if (!($truthy((attrs = self.attributes)['$key?']("doctitle")) || ($not((doctitle_val = self.$doctitle()))))) { 6516 attrs['$[]=']("doctitle", doctitle_val); 6517 } self.id = ($truthy(($ret_or_1 = self.id)) ? ($ret_or_1) : (attrs['$[]']("css-signature"))); 6518 if ($truthy((toc_val = ($truthy(attrs.$delete("toc2")) ? ("left") : (attrs['$[]']("toc")))))) { 6519 6520 toc_position_val = (($truthy((toc_placement_val = attrs.$fetch("toc-placement", "macro"))) && ($neqeq(toc_placement_val, "auto"))) ? (toc_placement_val) : (attrs['$[]']("toc-position"))); 6521 if (!($truthy(toc_val['$empty?']()) && ($truthy(toc_position_val['$nil_or_empty?']())))) { 6522 6523 default_toc_position = "left"; 6524 default_toc_class = "toc2"; 6525 position = ($truthy(toc_position_val['$nil_or_empty?']()) ? (($truthy(toc_val['$empty?']()) ? (default_toc_position) : (toc_val))) : (toc_position_val)); 6526 attrs['$[]=']("toc", ""); 6527 attrs['$[]=']("toc-placement", "auto"); 6528 6529 switch (position) { 6530 case "left": 6531 case "<": 6532 case "<": 6533 attrs['$[]=']("toc-position", "left"); 6534 break; 6535 case "right": 6536 case ">": 6537 case ">": 6538 attrs['$[]=']("toc-position", "right"); 6539 break; 6540 case "top": 6541 case "^": 6542 attrs['$[]=']("toc-position", "top"); 6543 break; 6544 case "bottom": 6545 case "v": 6546 attrs['$[]=']("toc-position", "bottom"); 6547 break; 6548 case "preamble": 6549 case "macro": 6550 6551 attrs['$[]=']("toc-position", "content"); 6552 attrs['$[]=']("toc-placement", position); 6553 default_toc_class = nil; 6554 break; 6555 default: 6556 6557 attrs.$delete("toc-position"); 6558 default_toc_class = nil; 6559 } if ($truthy(default_toc_class)) { 6560 if ($truthy(($ret_or_1 = attrs['$[]']("toc-class")))) ; else { 6561 attrs['$[]=']("toc-class", default_toc_class); 6562 } 6563 } } } if (($truthy((icons_val = attrs['$[]']("icons"))) && ($not(attrs['$key?']("icontype"))))) { 6564 6565 switch (icons_val) { 6566 case "": 6567 case "font": 6568 6569 break; 6570 default: 6571 6572 attrs['$[]=']("icons", ""); 6573 if (!$eqeq(icons_val, "image")) { 6574 attrs['$[]=']("icontype", icons_val); 6575 } } 6576 } if (($truthy((self.compat_mode = attrs['$key?']("compat-mode"))) && ($truthy(attrs['$key?']("language"))))) { 6577 attrs['$[]=']("source-language", attrs['$[]']("language")); 6578 } if (!$truthy(self.parent_document)) { 6579 6580 if ($eqeq((basebackend = attrs['$[]']("basebackend")), "html")) { 6581 if (($truthy((syntax_hl_name = attrs['$[]']("source-highlighter"))) && ($not(attrs['$[]']("" + (syntax_hl_name) + "-unavailable"))))) { 6582 if ($truthy((syntax_hl_factory = self.options['$[]']("syntax_highlighter_factory")))) { 6583 self.syntax_highlighter = syntax_hl_factory.$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self})); 6584 } else if ($truthy((syntax_hls = self.options['$[]']("syntax_highlighters")))) { 6585 self.syntax_highlighter = $$$($$('SyntaxHighlighter'), 'DefaultFactoryProxy').$new(syntax_hls).$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self})); 6586 } else { 6587 self.syntax_highlighter = $$('SyntaxHighlighter').$create(syntax_hl_name, self.backend, $hash2(["document"], {"document": self})); 6588 } 6589 } 6590 } else if ($eqeq(basebackend, "docbook")) { 6591 6592 if (!($truthy(self['$attribute_locked?']("toc")) || ($truthy(self.attributes_modified['$include?']("toc"))))) { 6593 attrs['$[]=']("toc", ""); 6594 } if (!($truthy(self['$attribute_locked?']("sectnums")) || ($truthy(self.attributes_modified['$include?']("sectnums"))))) { 6595 attrs['$[]=']("sectnums", ""); 6596 } } self.outfilesuffix = attrs['$[]']("outfilesuffix"); 6597 $send($$('FLEXIBLE_ATTRIBUTES'), 'each', [], function $$26(name){var self = $$26.$$s == null ? this : $$26.$$s; 6598 if (self.attribute_overrides == null) self.attribute_overrides = nil; 6599 6600 6601 if (name == null) name = nil; 6602 if (($truthy(self.attribute_overrides['$key?'](name)) && ($truthy(self.attribute_overrides['$[]'](name))))) { 6603 return self.attribute_overrides.$delete(name) 6604 } else { 6605 return nil 6606 }}, {$$s: self}); 6607 } return (self.header_attributes = attrs.$merge()); 6608 }); 6609 6610 $def(self, '$fill_datetime_attributes', function $$fill_datetime_attributes(attrs, input_mtime) { 6611 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; 6612 6613 6614 now = ($truthy($$$('ENV')['$key?']("SOURCE_DATE_EPOCH")) ? ((source_date_epoch = $$$('Time').$at(self.$Integer($$$('ENV')['$[]']("SOURCE_DATE_EPOCH"))).$utc())) : ($$$('Time').$now())); 6615 if ($truthy((localdate = attrs['$[]']("localdate")))) { 6616 if ($truthy(($ret_or_1 = attrs['$[]']("localyear")))) ; else { 6617 attrs['$[]=']("localyear", ($eqeq(localdate.$index("-"), 4) ? (localdate.$slice(0, 4)) : (nil))); 6618 } 6619 } else { 6620 6621 localdate = ($a = ["localdate", now.$strftime("%F")], $send(attrs, '[]=', $a), $a[$a.length - 1]); 6622 if ($truthy(($ret_or_1 = attrs['$[]']("localyear")))) ; else { 6623 attrs['$[]=']("localyear", now.$year().$to_s()); 6624 } } 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]))); 6625 if ($truthy(($ret_or_1 = attrs['$[]']("localdatetime")))) ; else { 6626 attrs['$[]=']("localdatetime", "" + (localdate) + " " + (localtime)); 6627 } input_mtime = ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = source_date_epoch)) ? ($ret_or_2) : (input_mtime)))) ? ($ret_or_1) : (now)); 6628 if ($truthy((docdate = attrs['$[]']("docdate")))) { 6629 if ($truthy(($ret_or_1 = attrs['$[]']("docyear")))) ; else { 6630 attrs['$[]=']("docyear", ($eqeq(docdate.$index("-"), 4) ? (docdate.$slice(0, 4)) : (nil))); 6631 } 6632 } else { 6633 6634 docdate = ($a = ["docdate", input_mtime.$strftime("%F")], $send(attrs, '[]=', $a), $a[$a.length - 1]); 6635 if ($truthy(($ret_or_1 = attrs['$[]']("docyear")))) ; else { 6636 attrs['$[]=']("docyear", input_mtime.$year().$to_s()); 6637 } } 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]))); 6638 if ($truthy(($ret_or_1 = attrs['$[]']("docdatetime")))) ; else { 6639 attrs['$[]=']("docdatetime", "" + (docdate) + " " + (doctime)); 6640 } return nil; 6641 }); 6642 6643 $def(self, '$update_backend_attributes', function $$update_backend_attributes(new_backend, init) { 6644 var $a, $b, self = this, current_backend = nil, current_basebackend = nil, attrs = nil, current_doctype = nil, actual_backend = 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; 6645 6646 6647 if (init == null) init = nil; 6648 if (($truthy(init) || ($neqeq(new_backend, self.backend)))) { 6649 6650 current_backend = self.backend; 6651 current_basebackend = (attrs = self.attributes)['$[]']("basebackend"); 6652 current_doctype = self.doctype; 6653 if ($truthy(new_backend['$include?'](":"))) { 6654 $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])); 6655 } if ($truthy(new_backend['$start_with?']("xhtml"))) { 6656 6657 attrs['$[]=']("htmlsyntax", "xml"); 6658 new_backend = new_backend.$slice(1, new_backend.$length()); 6659 } else if ($truthy(new_backend['$start_with?']("html"))) { 6660 if ($truthy(($ret_or_1 = attrs['$[]']("htmlsyntax")))) ; else { 6661 attrs['$[]=']("htmlsyntax", "html"); 6662 } 6663 } new_backend = ($truthy(($ret_or_1 = $$('BACKEND_ALIASES')['$[]'](new_backend))) ? ($ret_or_1) : (new_backend)); 6664 if ($truthy(actual_backend)) { 6665 $a = [actual_backend, new_backend], (new_backend = $a[0]), (delegate_backend = $a[1]); 6666 } if ($truthy(current_doctype)) { 6667 6668 if ($truthy(current_backend)) { 6669 6670 attrs.$delete("backend-" + (current_backend)); 6671 attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype)); 6672 } attrs['$[]=']("backend-" + (new_backend) + "-doctype-" + (current_doctype), ""); 6673 attrs['$[]=']("doctype-" + (current_doctype), ""); 6674 } else if ($truthy(current_backend)) { 6675 attrs.$delete("backend-" + (current_backend)); 6676 } attrs['$[]=']("backend-" + (new_backend), ""); 6677 self.backend = ($a = ["backend", new_backend], $send(attrs, '[]=', $a), $a[$a.length - 1]); 6678 if ($eqeqeq($$$($$('Converter'), 'BackendTraits'), (converter = self.$create_converter(new_backend, delegate_backend)))) { 6679 6680 new_basebackend = converter.$basebackend(); 6681 new_filetype = converter.$filetype(); 6682 if ($truthy((htmlsyntax = converter.$htmlsyntax()))) { 6683 attrs['$[]=']("htmlsyntax", htmlsyntax); 6684 } if ($truthy(init)) { 6685 if ($truthy(($ret_or_1 = attrs['$[]']("outfilesuffix")))) ; else { 6686 attrs['$[]=']("outfilesuffix", converter.$outfilesuffix()); 6687 } 6688 } else if (!$truthy(self['$attribute_locked?']("outfilesuffix"))) { 6689 attrs['$[]=']("outfilesuffix", converter.$outfilesuffix()); 6690 } } else if ($truthy(converter)) { 6691 6692 backend_traits = $$('Converter').$derive_backend_traits(new_backend); 6693 new_basebackend = backend_traits['$[]']("basebackend"); 6694 new_filetype = backend_traits['$[]']("filetype"); 6695 if ($truthy(init)) { 6696 if ($truthy(($ret_or_1 = attrs['$[]']("outfilesuffix")))) ; else { 6697 attrs['$[]=']("outfilesuffix", backend_traits['$[]']("outfilesuffix")); 6698 } 6699 } else if (!$truthy(self['$attribute_locked?']("outfilesuffix"))) { 6700 attrs['$[]=']("outfilesuffix", backend_traits['$[]']("outfilesuffix")); 6701 } } else { 6702 self.$raise($$$('NotImplementedError'), "asciidoctor: FAILED: missing converter for backend '" + (new_backend) + "'. Processing aborted."); 6703 } self.converter = converter; 6704 if ($truthy((current_filetype = attrs['$[]']("filetype")))) { 6705 attrs.$delete("filetype-" + (current_filetype)); 6706 } attrs['$[]=']("filetype", new_filetype); 6707 attrs['$[]=']("filetype-" + (new_filetype), ""); 6708 if ($truthy((page_width = $$('DEFAULT_PAGE_WIDTHS')['$[]'](new_basebackend)))) { 6709 attrs['$[]=']("pagewidth", page_width); 6710 } else { 6711 attrs.$delete("pagewidth"); 6712 } if ($neqeq(new_basebackend, current_basebackend)) { 6713 6714 if ($truthy(current_doctype)) { 6715 6716 if ($truthy(current_basebackend)) { 6717 6718 attrs.$delete("basebackend-" + (current_basebackend)); 6719 attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype)); 6720 } attrs['$[]=']("basebackend-" + (new_basebackend) + "-doctype-" + (current_doctype), ""); 6721 } else if ($truthy(current_basebackend)) { 6722 attrs.$delete("basebackend-" + (current_basebackend)); 6723 } attrs['$[]=']("basebackend-" + (new_basebackend), ""); 6724 attrs['$[]=']("basebackend", new_basebackend); 6725 } return new_backend; 6726 } else { 6727 return nil 6728 } }, -2); 6729 return $def(self, '$update_doctype_attributes', function $$update_doctype_attributes(new_doctype) { 6730 var $a, self = this, attrs = nil, current_backend = nil, current_basebackend = nil, current_doctype = nil; 6731 6732 if (($truthy(new_doctype) && ($neqeq(new_doctype, self.doctype)))) { 6733 6734 $a = [self.backend, (attrs = self.attributes)['$[]']("basebackend"), self.doctype], (current_backend = $a[0]), (current_basebackend = $a[1]), (current_doctype = $a[2]); 6735 if ($truthy(current_doctype)) { 6736 6737 attrs.$delete("doctype-" + (current_doctype)); 6738 if ($truthy(current_backend)) { 6739 6740 attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype)); 6741 attrs['$[]=']("backend-" + (current_backend) + "-doctype-" + (new_doctype), ""); 6742 } if ($truthy(current_basebackend)) { 6743 6744 attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype)); 6745 attrs['$[]=']("basebackend-" + (current_basebackend) + "-doctype-" + (new_doctype), ""); 6746 } } else { 6747 6748 if ($truthy(current_backend)) { 6749 attrs['$[]=']("backend-" + (current_backend) + "-doctype-" + (new_doctype), ""); 6750 } if ($truthy(current_basebackend)) { 6751 attrs['$[]=']("basebackend-" + (current_basebackend) + "-doctype-" + (new_doctype), ""); 6752 } } attrs['$[]=']("doctype-" + (new_doctype), ""); 6753 return (self.doctype = ($a = ["doctype", new_doctype], $send(attrs, '[]=', $a), $a[$a.length - 1])); 6754 } else { 6755 return nil 6756 } 6757 }); 6758 })($nesting[0], $$('AbstractBlock'), $nesting) 6759 })($nesting[0], $nesting) 6760}; 6761 6762Opal.modules["asciidoctor/inline"] = function(Opal) {/* Generated by Opal 1.7.3 */ 6763 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; 6764 6765 Opal.add_stubs('attr_accessor,attr_reader,[],convert,converter,attr,==,apply_reftext_subs,reftext'); 6766 return (function($base, $parent_nesting) { 6767 var self = $module($base, 'Asciidoctor'); 6768 6769 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 6770 6771 return (function($base, $super) { 6772 var self = $klass($base, $super, 'Inline'); 6773 6774 var $proto = self.$$prototype; 6775 6776 $proto.text = $proto.type = nil; 6777 6778 self.$attr_accessor("text"); 6779 self.$attr_reader("type"); 6780 self.$attr_accessor("target"); 6781 6782 $def(self, '$initialize', function $$initialize(parent, context, text, opts) { 6783 var self = this; 6784 6785 $$initialize.$$p = null; 6786 6787 if (text == null) text = nil; 6788 if (opts == null) opts = $hash2([], {}); 6789 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], null); 6790 self.node_name = "inline_" + (context); 6791 self.text = text; 6792 self.id = opts['$[]']("id"); 6793 self.type = opts['$[]']("type"); 6794 return (self.target = opts['$[]']("target")); 6795 }, -3); 6796 6797 $def(self, '$block?', $return_val(false)); 6798 6799 $def(self, '$inline?', $return_val(true)); 6800 6801 $def(self, '$convert', function $$convert() { 6802 var self = this; 6803 6804 return self.$converter().$convert(self) 6805 }); 6806 $alias(self, "render", "convert"); 6807 6808 $def(self, '$alt', function $$alt() { 6809 var self = this, $ret_or_1 = nil; 6810 6811 if ($truthy(($ret_or_1 = self.$attr("alt")))) { 6812 return $ret_or_1 6813 } else { 6814 return "" 6815 } 6816 }); 6817 6818 $def(self, '$reftext?', function $Inline_reftext$ques$1() { 6819 var self = this, $ret_or_1 = nil, $ret_or_2 = nil; 6820 6821 if ($truthy(($ret_or_1 = self.text))) { 6822 6823 if ($truthy(($ret_or_2 = self.type['$==']("ref")))) { 6824 return $ret_or_2 6825 } else { 6826 return self.type['$==']("bibref") 6827 } } else { 6828 return $ret_or_1 6829 } 6830 }); 6831 6832 $def(self, '$reftext', function $$reftext() { 6833 var self = this, val = nil; 6834 6835 if ($truthy((val = self.text))) { 6836 6837 return self.$apply_reftext_subs(val); 6838 } else { 6839 return nil 6840 } 6841 }); 6842 return $def(self, '$xreftext', function $$xreftext(xrefstyle) { 6843 var self = this; 6844 return self.$reftext(); 6845 }, -1); 6846 })($nesting[0], $$('AbstractNode')) 6847 })($nesting[0], $nesting) 6848}; 6849 6850Opal.modules["asciidoctor/list"] = function(Opal) {/* Generated by Opal 1.7.3 */ 6851 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; 6852 6853 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'); 6854 return (function($base, $parent_nesting) { 6855 var self = $module($base, 'Asciidoctor'); 6856 6857 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 6858 6859 6860 (function($base, $super) { 6861 var self = $klass($base, $super, 'List'); 6862 6863 var $proto = self.$$prototype; 6864 6865 $proto.context = $proto.document = $proto.style = nil; 6866 6867 $alias(self, "items", "blocks"); 6868 $alias(self, "content", "blocks"); 6869 $alias(self, "items?", "blocks?"); 6870 6871 $def(self, '$initialize', function $$initialize(parent, context, opts) { 6872 var $yield = $$initialize.$$p || nil, self = this; 6873 6874 $$initialize.$$p = null; 6875 6876 if (opts == null) opts = $hash2([], {}); 6877 return $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, context, opts], $yield); 6878 }, -3); 6879 6880 $def(self, '$outline?', function $List_outline$ques$1() { 6881 var self = this, $ret_or_1 = nil; 6882 6883 if ($truthy(($ret_or_1 = self.context['$==']("ulist")))) { 6884 return $ret_or_1 6885 } else { 6886 return self.context['$==']("olist") 6887 } 6888 }); 6889 6890 $def(self, '$convert', function $$convert() { 6891 var $yield = $$convert.$$p || nil, self = this, result = nil; 6892 6893 $$convert.$$p = null; 6894 if ($eqeq(self.context, "colist")) { 6895 6896 result = $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [], $yield); 6897 self.document.$callouts().$next_list(); 6898 return result; 6899 } else { 6900 return $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [], $yield) 6901 } 6902 }); 6903 $alias(self, "render", "convert"); 6904 return $def(self, '$to_s', function $$to_s() { 6905 var self = this; 6906 6907 return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", style: " + (self.style.$inspect()) + ", items: " + (self.$items().$size()) + "}>" 6908 }); 6909 })($nesting[0], $$('AbstractBlock')); 6910 return (function($base, $super, $parent_nesting) { 6911 var self = $klass($base, $super, 'ListItem'); 6912 6913 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 6914 6915 $proto.text = $proto.subs = $proto.blocks = nil; 6916 6917 $alias(self, "list", "parent"); 6918 self.$attr_accessor("marker"); 6919 6920 $def(self, '$initialize', function $$initialize(parent, text) { 6921 $$initialize.$$p || nil; var self = this; 6922 6923 $$initialize.$$p = null; 6924 6925 if (text == null) text = nil; 6926 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "list_item"], null); 6927 self.text = text; 6928 self.level = parent.$level(); 6929 return (self.subs = $$('NORMAL_SUBS').$drop(0)); 6930 }, -2); 6931 6932 $def(self, '$text?', function $ListItem_text$ques$2() { 6933 var self = this; 6934 6935 if ($truthy(self.text['$nil_or_empty?']())) { 6936 return false 6937 } else { 6938 return true 6939 } 6940 }); 6941 6942 $def(self, '$text', function $$text() { 6943 var self = this, $ret_or_1 = nil; 6944 6945 if ($truthy(($ret_or_1 = self.text))) { 6946 6947 return self.$apply_subs(self.text, self.subs); 6948 } else { 6949 return $ret_or_1 6950 } 6951 }); 6952 self.$attr_writer("text"); 6953 6954 $def(self, '$simple?', function $ListItem_simple$ques$3() { 6955 var self = this, $ret_or_1 = nil, $ret_or_2 = nil, $ret_or_3 = nil, blk = nil; 6956 6957 if ($truthy(($ret_or_1 = self.blocks['$empty?']()))) { 6958 return $ret_or_1 6959 } else { 6960 6961 if ($truthy(($ret_or_2 = ($truthy(($ret_or_3 = self.blocks.$size()['$=='](1))) ? ($$('List')['$===']((blk = self.blocks['$[]'](0)))) : ($ret_or_3))))) { 6962 return blk['$outline?']() 6963 } else { 6964 return $ret_or_2 6965 } } 6966 }); 6967 6968 $def(self, '$compound?', function $ListItem_compound$ques$4() { 6969 var self = this; 6970 6971 return self['$simple?']()['$!']() 6972 }); 6973 6974 $def(self, '$fold_first', function $$fold_first() { 6975 var self = this; 6976 6977 6978 self.text = ($truthy(self.text['$nil_or_empty?']()) ? (self.blocks.$shift().$source()) : ("" + (self.text) + ($$('LF')) + (self.blocks.$shift().$source()))); 6979 return nil; 6980 }); 6981 return $def(self, '$to_s', function $$to_s() { 6982 var self = this, $ret_or_1 = nil; 6983 6984 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()) + "}>" 6985 }); 6986 })($nesting[0], $$('AbstractBlock'), $nesting); 6987 })($nesting[0], $nesting) 6988}; 6989 6990Opal.modules["asciidoctor/parser"] = function(Opal) {/* Generated by Opal 1.7.3 */ 6991 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.$$$; 6992 6993 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,%'); 6994 return (function($base, $parent_nesting) { 6995 var self = $module($base, 'Asciidoctor'); 6996 6997 var $nesting = [self].concat($parent_nesting); 6998 6999 return (function($base, $super, $parent_nesting) { 7000 var self = $klass($base, $super, 'Parser'); 7001 7002 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 7003 7004 7005 self.$include($$('Logging')); 7006 $const_set($nesting[0], 'BlockMatchData', $$('Struct').$new("context", "masq", "tip", "terminator")); 7007 $const_set($nesting[0], 'TAB', "\t"); 7008 $const_set($nesting[0], 'TabIndentRx', /^\t+/); 7009 $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; 7010 7011 7012 if (l == null) l = nil; 7013 if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = l['$start_with?']("["))) ? ($$('BlockAttributeLineRx')['$match?'](l)) : ($ret_or_2))))) { 7014 return $ret_or_1 7015 } else { 7016 7017 return self['$is_delimited_block?'](l); 7018 }}, {$$s: self})); 7019 $const_set($nesting[0], 'StartOfListProc', $send(self, 'proc', [], function $Parser$2(l){ 7020 7021 if (l == null) l = nil; 7022 return $$('AnyListRx')['$match?'](l);})); 7023 $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; 7024 7025 7026 if (l == null) l = nil; 7027 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))))))) { 7028 return $ret_or_1 7029 } else { 7030 7031 return $$('AnyListRx')['$match?'](l); 7032 }}, {$$s: self})); 7033 $const_set($nesting[0], 'NoOp', nil); 7034 $const_set($nesting[0], 'AuthorKeys', ["author", "authorinitials", "firstname", "middlename", "lastname", "email"]); 7035 $const_set($nesting[0], 'TableCellHorzAlignments', $hash2(["<", ">", "^"], {"<": "left", ">": "right", "^": "center"})); 7036 $const_set($nesting[0], 'TableCellVertAlignments', $hash2(["<", ">", "^"], {"<": "top", ">": "bottom", "^": "middle"})); 7037 $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"})); 7038 self.$private_class_method("new"); 7039 $defs(self, '$parse', function $$parse(reader, document, options) { 7040 var $a, $b, self = this, block_attributes = nil, header_only = nil, new_section = nil; 7041 7042 7043 if (options == null) options = $hash2([], {}); 7044 block_attributes = self.$parse_document_header(reader, document, (header_only = options['$[]']("header_only"))); 7045 if (!$truthy(header_only)) { 7046 while ($truthy(reader['$has_more_lines?']())) { 7047 7048 $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])); 7049 if ($truthy(new_section)) { 7050 7051 document.$assign_numeral(new_section); 7052 document.$blocks()['$<<'](new_section); 7053 } } 7054 } return document; 7055 }, -3); 7056 $defs(self, '$parse_document_header', function $$parse_document_header(reader, document, header_only) { 7057 var $a, $b, $c, self = this, block_attrs = nil, doc_attrs = nil, implicit_doctitle = nil, val = nil, doctitle_attr_val = nil, source_location = nil, l0_section_title = nil, atx = nil, separator = nil, doc_id = nil, role = nil, reftext = nil, modified_attrs = nil, author = nil, author_metadata = nil; 7058 7059 7060 if (header_only == null) header_only = false; 7061 block_attrs = ($truthy(reader.$skip_blank_lines()) ? (self.$parse_block_metadata_lines(reader, document)) : ($hash2([], {}))); 7062 doc_attrs = document.$attributes(); 7063 if (($truthy((implicit_doctitle = self['$is_next_line_doctitle?'](reader, block_attrs, doc_attrs['$[]']("leveloffset")))) && ($truthy(block_attrs['$[]']("title"))))) { 7064 7065 doc_attrs['$[]=']("authorcount", 0); 7066 return document.$finalize_header(block_attrs, false); 7067 } if (!$truthy((val = doc_attrs['$[]']("doctitle"))['$nil_or_empty?']())) { 7068 document['$title=']((doctitle_attr_val = val)); 7069 } if ($truthy(implicit_doctitle)) { 7070 7071 if ($truthy(document.$sourcemap())) { 7072 source_location = reader.$cursor(); 7073 } $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])); 7074 if ($truthy(doctitle_attr_val)) { 7075 l0_section_title = nil; 7076 } else { 7077 7078 document['$title='](l0_section_title); 7079 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')))) { 7080 doc_attrs['$[]=']("doctitle", (doctitle_attr_val = document.$sub_attributes(doctitle_attr_val, $hash2(["attribute_missing"], {"attribute_missing": "skip"})))); 7081 } } if ($truthy(source_location)) { 7082 document.$header()['$source_location='](source_location); 7083 } if (!($truthy(atx) || ($truthy(document['$attribute_locked?']("compat-mode"))))) { 7084 doc_attrs['$[]=']("compat-mode", ""); 7085 } if ($truthy((separator = block_attrs['$[]']("separator")))) { 7086 if (!$truthy(document['$attribute_locked?']("title-separator"))) { 7087 doc_attrs['$[]=']("title-separator", separator); 7088 } 7089 } if ($truthy((doc_id = block_attrs['$[]']("id")))) { 7090 document['$id='](doc_id); 7091 } else { 7092 doc_id = document.$id(); 7093 } if ($truthy((role = block_attrs['$[]']("role")))) { 7094 doc_attrs['$[]=']("role", role); 7095 } if ($truthy((reftext = block_attrs['$[]']("reftext")))) { 7096 doc_attrs['$[]=']("reftext", reftext); 7097 } block_attrs.$clear(); 7098 (modified_attrs = document.$instance_variable_get("@attributes_modified")).$delete("doctitle"); 7099 self.$parse_header_metadata(reader, document, nil); 7100 if ($truthy(modified_attrs['$include?']("doctitle"))) { 7101 if (($truthy((val = doc_attrs['$[]']("doctitle"))['$nil_or_empty?']()) || ($eqeq(val, doctitle_attr_val)))) { 7102 doc_attrs['$[]=']("doctitle", doctitle_attr_val); 7103 } else { 7104 document['$title='](val); 7105 } 7106 } else if ($not(l0_section_title)) { 7107 modified_attrs['$<<']("doctitle"); 7108 } if ($truthy(doc_id)) { 7109 document.$register("refs", [doc_id, document]); 7110 } } else if ($truthy((author = doc_attrs['$[]']("author")))) { 7111 7112 author_metadata = self.$process_authors(author, true, false); 7113 if ($truthy(doc_attrs['$[]']("authorinitials"))) { 7114 author_metadata.$delete("authorinitials"); 7115 } doc_attrs.$update(author_metadata); 7116 } else if ($truthy((author = doc_attrs['$[]']("authors")))) { 7117 7118 author_metadata = self.$process_authors(author, true); 7119 doc_attrs.$update(author_metadata); 7120 } else { 7121 doc_attrs['$[]=']("authorcount", 0); 7122 } if ($eqeq(document.$doctype(), "manpage")) { 7123 self.$parse_manpage_header(reader, document, block_attrs, header_only); 7124 } return document.$finalize_header(block_attrs); 7125 }, -3); 7126 $defs(self, '$parse_manpage_header', function $$parse_manpage_header(reader, document, block_attributes, header_only) { 7127 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; 7128 7129 7130 if (header_only == null) header_only = false; 7131 if ($truthy($$('ManpageTitleVolnumRx')['$=~']((doc_attrs = document.$attributes())['$[]']("doctitle")))) { 7132 7133 doc_attrs['$[]=']("manvolnum", (manvolnum = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))); 7134 doc_attrs['$[]=']("mantitle", ($truthy((mantitle = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))['$include?']($$('ATTR_REF_HEAD'))) ? (document.$sub_attributes(mantitle)) : (mantitle)).$downcase()); 7135 } else { 7136 7137 self.$logger().$error(self.$message_with_context("non-conforming manpage title", $hash2(["source_location"], {"source_location": reader.$cursor_at_line(1)}))); 7138 doc_attrs['$[]=']("mantitle", ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = doc_attrs['$[]']("doctitle"))) ? ($ret_or_2) : (doc_attrs['$[]']("docname"))))) ? ($ret_or_1) : ("command"))); 7139 doc_attrs['$[]=']("manvolnum", (manvolnum = "1")); 7140 } if (($truthy((manname = doc_attrs['$[]']("manname"))) && ($truthy(doc_attrs['$[]']("manpurpose"))))) { 7141 7142 if ($truthy(($ret_or_1 = doc_attrs['$[]']("manname-title")))) ; else { 7143 doc_attrs['$[]=']("manname-title", "Name"); 7144 } doc_attrs['$[]=']("mannames", [manname]); 7145 if ($eqeq(document.$backend(), "manpage")) { 7146 7147 doc_attrs['$[]=']("docname", manname); 7148 doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum)); 7149 } } else if (!$truthy(header_only)) { 7150 7151 reader.$skip_blank_lines(); 7152 reader.$save(); 7153 block_attributes.$update(self.$parse_block_metadata_lines(reader, document)); 7154 if ($truthy((name_section_level = self['$is_next_line_section?'](reader, $hash2([], {}))))) { 7155 if ($eqeq(name_section_level, 1)) { 7156 7157 name_section = self.$initialize_section(reader, document, $hash2([], {})); 7158 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){ 7159 7160 if (l == null) l = nil; 7161 return l.$lstrip();}).$join(" "); 7162 if ($truthy($$('ManpageNamePurposeRx')['$=~'](name_section_buffer))) { 7163 7164 if ($truthy((manname = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))['$include?']($$('ATTR_REF_HEAD')))) { 7165 manname = document.$sub_attributes(manname); 7166 } if ($truthy(manname['$include?'](","))) { 7167 manname = (mannames = $send(manname.$split(","), 'map', [], function $$5(n){ 7168 7169 if (n == null) n = nil; 7170 return n.$lstrip();}))['$[]'](0); 7171 } else { 7172 mannames = [manname]; 7173 } if ($truthy((manpurpose = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))['$include?']($$('ATTR_REF_HEAD')))) { 7174 manpurpose = document.$sub_attributes(manpurpose); 7175 } if ($truthy(($ret_or_1 = doc_attrs['$[]']("manname-title")))) ; else { 7176 doc_attrs['$[]=']("manname-title", name_section.$title()); 7177 } if ($truthy(name_section.$id())) { 7178 doc_attrs['$[]=']("manname-id", name_section.$id()); 7179 } doc_attrs['$[]=']("manname", manname); 7180 doc_attrs['$[]=']("mannames", mannames); 7181 doc_attrs['$[]=']("manpurpose", manpurpose); 7182 if ($eqeq(document.$backend(), "manpage")) { 7183 7184 doc_attrs['$[]=']("docname", manname); 7185 doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum)); 7186 } } else { 7187 error_msg = "non-conforming name section body"; 7188 } } else { 7189 error_msg = "name section must be at level 1"; 7190 } 7191 } else { 7192 error_msg = "name section expected"; 7193 } if ($truthy(error_msg)) { 7194 7195 reader.$restore_save(); 7196 self.$logger().$error(self.$message_with_context(error_msg, $hash2(["source_location"], {"source_location": reader.$cursor()}))); 7197 doc_attrs['$[]=']("manname", (manname = ($truthy(($ret_or_1 = doc_attrs['$[]']("docname"))) ? ($ret_or_1) : ("command")))); 7198 doc_attrs['$[]=']("mannames", [manname]); 7199 if ($eqeq(document.$backend(), "manpage")) { 7200 7201 doc_attrs['$[]=']("docname", manname); 7202 doc_attrs['$[]=']("outfilesuffix", "." + (manvolnum)); 7203 } } else { 7204 reader.$discard_save(); 7205 } } return nil; 7206 }, -4); 7207 $defs(self, '$next_section', function $$next_section(reader, parent, attributes) { 7208 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; 7209 7210 7211 if (attributes == null) attributes = $hash2([], {}); 7212 preamble = (intro = (part = false)); 7213 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))))))) { 7214 7215 book = (document = parent).$doctype()['$==']("book"); 7216 if (($truthy(has_header) || (($truthy(book) && ($neqeq(attributes['$[]'](1), "abstract")))))) { 7217 7218 preamble = (intro = $$('Block').$new(parent, "preamble", $hash2(["content_model"], {"content_model": "compound"}))); 7219 if (($truthy(book) && ($truthy(parent['$attr?']("preface-title"))))) { 7220 preamble['$title='](parent.$attr("preface-title")); 7221 } parent.$blocks()['$<<'](preamble); 7222 } section = parent; 7223 current_level = 0; 7224 if ($truthy(parent.$attributes()['$key?']("fragment"))) { 7225 expected_next_level = -1; 7226 } else if ($truthy(book)) { 7227 $a = [1, 0], (expected_next_level = $a[0]), (expected_next_level_alt = $a[1]); 7228 } else { 7229 expected_next_level = 1; 7230 } } else { 7231 7232 book = (document = parent.$document()).$doctype()['$==']("book"); 7233 section = self.$initialize_section(reader, parent, attributes); 7234 attributes = ($truthy((title = attributes['$[]']("title"))) ? ($hash2(["title"], {"title": title})) : ($hash2([], {}))); 7235 expected_next_level = $rb_plus((current_level = section.$level()), 1); 7236 if ($eqeq(current_level, 0)) { 7237 part = book; 7238 } else if (($eqeq(current_level, 1) && ($truthy(section.$special())))) { 7239 if (!(($eqeq((sectname = section.$sectname()), "appendix") || ($eqeq(sectname, "preface"))) || ($eqeq(sectname, "abstract")))) { 7240 expected_next_level = nil; 7241 } 7242 } } reader.$skip_blank_lines(); 7243 while ($truthy(reader['$has_more_lines?']())) { 7244 7245 self.$parse_block_metadata_lines(reader, document, attributes); 7246 if ($truthy((next_level = self['$is_next_line_section?'](reader, attributes)))) { 7247 7248 if ($truthy(document['$attr?']("leveloffset"))) { 7249 7250 next_level = $rb_plus(next_level, document.$attr("leveloffset").$to_i()); 7251 if ($truthy($rb_lt(next_level, 0))) { 7252 next_level = 0; 7253 } } if ($truthy($rb_gt(next_level, current_level))) { 7254 7255 if ($truthy(expected_next_level)) { 7256 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))))) { 7257 7258 expected_condition = ($truthy(expected_next_level_alt) ? ("expected levels " + (expected_next_level_alt) + " or " + (expected_next_level)) : ("expected level " + (expected_next_level))); 7259 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()}))); 7260 } 7261 } else { 7262 self.$logger().$error(self.$message_with_context("" + (sectname) + " sections do not support nested sections", $hash2(["source_location"], {"source_location": reader.$cursor()}))); 7263 } $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])); 7264 section.$assign_numeral(new_section); 7265 section.$blocks()['$<<'](new_section); 7266 } else if (($eqeq(next_level, 0) && ($eqeq(section, document)))) { 7267 7268 if (!$truthy(book)) { 7269 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()}))); 7270 } $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])); 7271 section.$assign_numeral(new_section); 7272 section.$blocks()['$<<'](new_section); 7273 } else { 7274 break 7275 } } else { 7276 7277 block_cursor = reader.$cursor(); 7278 if ($truthy((new_block = self.$next_block(reader, ($truthy(($ret_or_1 = intro)) ? ($ret_or_1) : (section)), attributes, $hash2(["parse_metadata"], {"parse_metadata": false}))))) { 7279 7280 if ($truthy(part)) { 7281 if ($not(section['$blocks?']())) { 7282 if ($neqeq(new_block.$style(), "partintro")) { 7283 if (($eqeq(new_block.$style(), "open") && ($eqeq(new_block.$context(), "open")))) { 7284 new_block['$style=']("partintro"); 7285 } else { 7286 7287 new_block['$parent=']((intro = $$('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"})))); 7288 intro['$style=']("partintro"); 7289 section.$blocks()['$<<'](intro); 7290 } 7291 } else if ($eqeq(new_block.$content_model(), "simple")) { 7292 7293 new_block['$content_model=']("compound"); 7294 new_block['$<<']($$('Block').$new(new_block, "paragraph", $hash2(["source", "subs"], {"source": new_block.$lines(), "subs": new_block.$subs()}))); 7295 new_block.$lines().$clear(); 7296 new_block.$subs().$clear(); 7297 } 7298 } else if ($eqeq(section.$blocks().$size(), 1)) { 7299 7300 first_block = section.$blocks()['$[]'](0); 7301 if (($not(intro) && ($eqeq(first_block.$content_model(), "compound")))) { 7302 self.$logger().$error(self.$message_with_context("illegal block content outside of partintro block", $hash2(["source_location"], {"source_location": block_cursor}))); 7303 } else if ($neqeq(first_block.$content_model(), "compound")) { 7304 7305 new_block['$parent=']((intro = $$('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"})))); 7306 if ($eqeq(first_block.$style(), ($a = ["partintro"], $send(intro, 'style=', $a), $a[$a.length - 1]))) { 7307 7308 first_block['$context=']("paragraph"); 7309 first_block['$style='](nil); 7310 } section.$blocks().$shift(); 7311 intro['$<<'](first_block); 7312 section.$blocks()['$<<'](intro); 7313 } } 7314 } ($truthy(($ret_or_1 = intro)) ? ($ret_or_1) : (section)).$blocks()['$<<'](new_block); 7315 attributes.$clear(); 7316 } } if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) ; else { 7317 break 7318 } } if ($truthy(part)) { 7319 if (!($truthy(section['$blocks?']()) && ($eqeq(section.$blocks()['$[]'](-1).$context(), "section")))) { 7320 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()}))); 7321 } 7322 } else if ($truthy(preamble)) { 7323 if ($truthy(preamble['$blocks?']())) { 7324 if ((($truthy(book) || ($truthy(document.$blocks()['$[]'](1)))) || ($not($$('Compliance').$unwrap_standalone_preamble())))) { 7325 if ($truthy(document.$sourcemap())) { 7326 preamble['$source_location='](preamble.$blocks()['$[]'](0).$source_location()); 7327 } 7328 } else { 7329 7330 document.$blocks().$shift(); 7331 while ($truthy((child_block = preamble.$blocks().$shift()))) { 7332 document['$<<'](child_block); 7333 } } 7334 } else { 7335 document.$blocks().$shift(); 7336 } 7337 } return [($eqeq(section, parent) ? (nil) : (section)), attributes.$merge()]; 7338 }, -3); 7339 $defs(self, '$next_block', function $$next_block(reader, parent, attributes, options) { 7340 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; 7341 if ($gvars["~"] == null) $gvars["~"] = nil; 7342 7343 7344 if (attributes == null) attributes = $hash2([], {}); 7345 if (options == null) options = $hash2([], {}); 7346 if (!$truthy((skipped = reader.$skip_blank_lines()))) { 7347 return nil 7348 } if (($truthy((text_only = options['$[]']("text_only"))) && ($truthy($rb_gt(skipped, 0))))) { 7349 7350 options.$delete("text_only"); 7351 text_only = nil; 7352 } document = parent.$document(); 7353 if ($truthy(options.$fetch("parse_metadata", true))) { 7354 while ($truthy(self.$parse_block_metadata_line(reader, document, attributes, options))) { 7355 7356 reader.$shift(); 7357 if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) ; else { 7358 return nil 7359 } } 7360 } if ($truthy((extensions = document.$extensions()))) { 7361 $a = [extensions['$blocks?'](), extensions['$block_macros?']()], (block_extensions = $a[0]), (block_macro_extensions = $a[1]); 7362 } reader.$mark(); 7363 $a = [reader.$read_line(), document.$attributes(), attributes['$[]'](1)], (this_line = $a[0]), (doc_attrs = $a[1]), (style = $a[2]); 7364 block = (block_context = (cloaked_context = (terminator = nil))); 7365 if ($truthy((delimited_block = self['$is_delimited_block?'](this_line, true)))) { 7366 7367 block_context = (cloaked_context = delimited_block.$context()); 7368 terminator = delimited_block.$terminator(); 7369 if ($truthy(style)) { 7370 if (!$eqeq(style, block_context.$to_s())) { 7371 if ($truthy(delimited_block.$masq()['$include?'](style))) { 7372 block_context = style.$to_sym(); 7373 } else if (($truthy(delimited_block.$masq()['$include?']("admonition")) && ($truthy($$('ADMONITION_STYLES')['$include?'](style))))) { 7374 block_context = "admonition"; 7375 } else if (($truthy(block_extensions) && ($truthy(extensions['$registered_for_block?'](style, block_context))))) { 7376 block_context = style.$to_sym(); 7377 } else { 7378 7379 if ($truthy(self.$logger()['$debug?']())) { 7380 self.$logger().$debug(self.$message_with_context("unknown style for " + (block_context) + " block: " + (style), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()}))); 7381 } style = block_context.$to_s(); 7382 } 7383 } 7384 } else { 7385 style = ($a = ["style", block_context.$to_s()], $send(attributes, '[]=', $a), $a[$a.length - 1]); 7386 } } if (!$truthy(delimited_block)) { 7387 while ($truthy(true)) { 7388 7389 if ((($truthy(style) && ($truthy($$('Compliance').$strict_verbatim_paragraphs()))) && ($truthy($$('VERBATIM_STYLES')['$include?'](style))))) { 7390 7391 block_context = style.$to_sym(); 7392 reader.$unshift_line(this_line); 7393 break; 7394 } if ($truthy(text_only)) { 7395 indented = this_line['$start_with?'](" ", $$('TAB')); 7396 } else { 7397 7398 md_syntax = $$('Compliance').$markdown_syntax(); 7399 if ($truthy(this_line['$start_with?'](" "))) { 7400 7401 $a = [true, " "], (indented = $a[0]), (ch0 = $a[1]); 7402 if ((($truthy(md_syntax) && ($truthy($send(this_line.$lstrip(), 'start_with?', $to_a($$('MARKDOWN_THEMATIC_BREAK_CHARS').$keys()))))) && ($truthy($$('MarkdownThematicBreakRx')['$match?'](this_line))))) { 7403 7404 block = $$('Block').$new(parent, "thematic_break", $hash2(["content_model"], {"content_model": "empty"})); 7405 break; 7406 } } else if ($truthy(this_line['$start_with?']($$('TAB')))) { 7407 $a = [true, $$('TAB')], (indented = $a[0]), (ch0 = $a[1]); 7408 } else { 7409 7410 $a = [false, this_line.$chr()], (indented = $a[0]), (ch0 = $a[1]); 7411 layout_break_chars = ($truthy(md_syntax) ? ($$('HYBRID_LAYOUT_BREAK_CHARS')) : ($$('LAYOUT_BREAK_CHARS'))); 7412 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))))))) { 7413 7414 block = $$('Block').$new(parent, layout_break_chars['$[]'](ch0), $hash2(["content_model"], {"content_model": "empty"})); 7415 break; 7416 } else if (($truthy(this_line['$end_with?']("]")) && ($truthy(this_line['$include?']("::"))))) { 7417 if ((($eqeq(ch0, "i") || ($truthy(this_line['$start_with?']("video:", "audio:")))) && ($truthy($$('BlockMediaMacroRx')['$=~'](this_line))))) { 7418 7419 $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]); 7420 block = $$('Block').$new(parent, blk_ctx, $hash2(["content_model"], {"content_model": "empty"})); 7421 if ($truthy(blk_attrs)) { 7422 7423 7424 switch (blk_ctx) { 7425 case "video": 7426 posattrs = ["poster", "width", "height"]; 7427 break; 7428 case "audio": 7429 posattrs = []; 7430 break; 7431 default: 7432 posattrs = ["alt", "width", "height"]; 7433 } block.$parse_attributes(blk_attrs, posattrs, $hash2(["sub_input", "into"], {"sub_input": true, "into": attributes})); 7434 } if ($truthy(attributes['$key?']("style"))) { 7435 attributes.$delete("style"); 7436 } if ($truthy(target['$include?']($$('ATTR_REF_HEAD')))) { 7437 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?']())))) { 7438 7439 attributes.$clear(); 7440 return nil; 7441 } else { 7442 target = expanded_target; 7443 } 7444 } if ($eqeq(blk_ctx, "image")) { 7445 7446 document.$register("images", target); 7447 attributes['$[]=']("imagesdir", doc_attrs['$[]']("imagesdir")); 7448 if ($truthy(($ret_or_1 = attributes['$[]']("alt")))) ; else { 7449 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])))); 7450 } if (!$truthy((scaledwidth = attributes.$delete("scaledwidth"))['$nil_or_empty?']())) { 7451 attributes['$[]=']("scaledwidth", ($truthy($$('TrailingDigitsRx')['$match?'](scaledwidth)) ? ("" + (scaledwidth) + "%") : (scaledwidth))); 7452 } if ($truthy(attributes['$[]']("title"))) { 7453 7454 block['$title=']((block_title = attributes.$delete("title"))); 7455 block.$assign_caption(attributes.$delete("caption"), "figure"); 7456 } } attributes['$[]=']("target", target); 7457 break; 7458 } else if ((($eqeq(ch0, "t") && ($truthy(this_line['$start_with?']("toc:")))) && ($truthy($$('BlockTocMacroRx')['$=~'](this_line))))) { 7459 7460 block = $$('Block').$new(parent, "toc", $hash2(["content_model"], {"content_model": "empty"})); 7461 if ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) { 7462 block.$parse_attributes((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), [], $hash2(["into"], {"into": attributes})); 7463 } break; 7464 } 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)))))) { 7465 if ($truthy(report_unknown_block_macro)) { 7466 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()}))); 7467 } else { 7468 7469 content = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 7470 if ($truthy((target = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))['$include?']($$('ATTR_REF_HEAD')))) { 7471 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?']())))) { 7472 7473 attributes.$clear(); 7474 return nil; 7475 } else { 7476 target = expanded_target; 7477 } 7478 } if ($eqeq((ext_config = extension.$config())['$[]']("content_model"), "attributes")) { 7479 if ($truthy(content)) { 7480 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})); 7481 } 7482 } else { 7483 attributes['$[]=']("text", ($truthy(($ret_or_1 = content)) ? ($ret_or_1) : (""))); 7484 } if ($truthy((default_attrs = ext_config['$[]']("default_attrs")))) { 7485 $send(attributes, 'update', [default_attrs], function $$6(_, old_v){ 7486 if (old_v == null) old_v = nil; 7487 return old_v;}); 7488 } if (($truthy((block = extension.$process_method()['$[]'](parent, target, attributes))) && ($neqeq(block, parent)))) { 7489 7490 attributes.$replace(block.$attributes()); 7491 break; 7492 } else { 7493 7494 attributes.$clear(); 7495 return nil; 7496 } } 7497 } 7498 } } } if ((($not(indented) && ($eqeq((ch0 = ($truthy(($ret_or_1 = ch0)) ? ($ret_or_1) : (this_line.$chr()))), "<"))) && ($truthy($$('CalloutListRx')['$=~'](this_line))))) { 7499 7500 reader.$unshift_line(this_line); 7501 block = self.$parse_callout_list(reader, $gvars["~"], parent, document.$callouts()); 7502 attributes['$[]=']("style", "arabic"); 7503 break; 7504 } else if ($truthy($$('UnorderedListRx')['$match?'](this_line))) { 7505 7506 reader.$unshift_line(this_line); 7507 if ((($not(style) && ($eqeqeq($$('Section'), parent))) && ($eqeq(parent.$sectname(), "bibliography")))) { 7508 attributes['$[]=']("style", (style = "bibliography")); 7509 } block = self.$parse_list(reader, "ulist", parent, style); 7510 break; 7511 } else if ($truthy($$('OrderedListRx')['$match?'](this_line))) { 7512 7513 reader.$unshift_line(this_line); 7514 block = self.$parse_list(reader, "olist", parent, style); 7515 if ($truthy(block.$style())) { 7516 attributes['$[]=']("style", block.$style()); 7517 } break; 7518 } else if ((($truthy(this_line['$include?']("::")) || ($truthy(this_line['$include?'](";;")))) && ($truthy($$('DescriptionListRx')['$=~'](this_line))))) { 7519 7520 reader.$unshift_line(this_line); 7521 block = self.$parse_description_list(reader, $gvars["~"], parent); 7522 break; 7523 } 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))))))) { 7524 7525 reader.$unshift_line(this_line); 7526 $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])); 7527 if ($truthy(float_reftext)) { 7528 attributes['$[]=']("reftext", float_reftext); 7529 } block = $$('Block').$new(parent, "floating_title", $hash2(["content_model"], {"content_model": "empty"})); 7530 block['$title='](block_title); 7531 attributes.$delete("title"); 7532 block['$id='](($truthy(($ret_or_1 = float_id)) ? ($ret_or_1) : (($truthy(doc_attrs['$key?']("sectids")) ? ($$('Section').$generate_id(block.$title(), document)) : (nil))))); 7533 block['$level='](float_level); 7534 break; 7535 } else if (($truthy(style) && ($neqeq(style, "normal")))) { 7536 if ($truthy($$('PARAGRAPH_STYLES')['$include?'](style))) { 7537 7538 block_context = style.$to_sym(); 7539 cloaked_context = "paragraph"; 7540 reader.$unshift_line(this_line); 7541 break; 7542 } else if ($truthy($$('ADMONITION_STYLES')['$include?'](style))) { 7543 7544 block_context = "admonition"; 7545 cloaked_context = "paragraph"; 7546 reader.$unshift_line(this_line); 7547 break; 7548 } else if (($truthy(block_extensions) && ($truthy(extensions['$registered_for_block?'](style, "paragraph"))))) { 7549 7550 block_context = style.$to_sym(); 7551 cloaked_context = "paragraph"; 7552 reader.$unshift_line(this_line); 7553 break; 7554 } else { 7555 7556 if ($truthy(self.$logger()['$debug?']())) { 7557 self.$logger().$debug(self.$message_with_context("unknown style for paragraph: " + (style), $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()}))); 7558 } style = nil; 7559 } 7560 } reader.$unshift_line(this_line); 7561 if (($truthy(indented) && ($not(style)))) { 7562 7563 lines = self.$read_paragraph_lines(reader, (content_adjacent = ($eqeq(skipped, 0) ? (options['$[]']("list_type")) : (nil))), $hash2(["skip_line_comments"], {"skip_line_comments": text_only})); 7564 self['$adjust_indentation!'](lines); 7565 if (($truthy(text_only) || ($eqeq(content_adjacent, "dlist")))) { 7566 block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes})); 7567 } else { 7568 block = $$('Block').$new(parent, "literal", $hash2(["content_model", "source", "attributes"], {"content_model": "verbatim", "source": lines, "attributes": attributes})); 7569 } } else { 7570 7571 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})); 7572 if ($truthy(text_only)) { 7573 7574 if (($truthy(indented) && ($eqeq(style, "normal")))) { 7575 self['$adjust_indentation!'](lines); 7576 } block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes})); 7577 } else if ((($truthy($$('ADMONITION_STYLE_HEADS')['$include?'](ch0)) && ($truthy(this_line['$include?'](":")))) && ($truthy($$('AdmonitionParagraphRx')['$=~'](this_line))))) { 7578 7579 lines['$[]='](0, (($a = $gvars['~']) === nil ? nil : $a.$post_match())); 7580 attributes['$[]=']("name", (admonition_name = ($a = ["style", (($b = $gvars['~']) === nil ? nil : $b['$[]'](1))], $send(attributes, '[]=', $a), $a[$a.length - 1]).$downcase())); 7581 attributes['$[]=']("textlabel", ($truthy(($ret_or_1 = attributes.$delete("caption"))) ? ($ret_or_1) : (doc_attrs['$[]']("" + (admonition_name) + "-caption")))); 7582 block = $$('Block').$new(parent, "admonition", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes})); 7583 } else if ((($truthy(md_syntax) && ($eqeq(ch0, ">"))) && ($truthy(this_line['$start_with?']("> "))))) { 7584 7585 $send(lines, 'map!', [], function $$7(line){ 7586 7587 if (line == null) line = nil; 7588 if ($eqeq(line, ">")) { 7589 7590 return line.$slice(1, line.$length()); 7591 } else { 7592 7593 if ($truthy(line['$start_with?']("> "))) { 7594 7595 return line.$slice(2, line.$length()); 7596 } else { 7597 return line 7598 } }}); 7599 if ($truthy(lines['$[]'](-1)['$start_with?']("-- "))) { 7600 7601 credit_line = (credit_line = lines.$pop()).$slice(3, credit_line.$length()); 7602 if (!$truthy(lines['$empty?']())) { 7603 while ($truthy(lines['$[]'](-1)['$empty?']())) { 7604 lines.$pop(); 7605 } 7606 } } attributes['$[]=']("style", "quote"); 7607 block = self.$build_block("quote", "compound", false, parent, $$('Reader').$new(lines), attributes); 7608 if ($truthy(credit_line)) { 7609 7610 $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])); 7611 if ($truthy(attribution)) { 7612 attributes['$[]=']("attribution", attribution); 7613 } if ($truthy(citetitle)) { 7614 attributes['$[]=']("citetitle", citetitle); 7615 } } } else if (((($eqeq(ch0, "\"") && ($truthy($rb_gt(lines.$size(), 1)))) && ($truthy(lines['$[]'](-1)['$start_with?']("-- ")))) && ($truthy(lines['$[]'](-2)['$end_with?']("\""))))) { 7616 7617 lines['$[]='](0, this_line.$slice(1, this_line.$length())); 7618 credit_line = (credit_line = lines.$pop()).$slice(3, credit_line.$length()); 7619 while ($truthy(lines['$[]'](-1)['$empty?']())) { 7620 lines.$pop(); 7621 } lines['$<<'](lines.$pop().$chop()); 7622 attributes['$[]=']("style", "quote"); 7623 block = $$('Block').$new(parent, "quote", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes})); 7624 $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])); 7625 if ($truthy(attribution)) { 7626 attributes['$[]=']("attribution", attribution); 7627 } if ($truthy(citetitle)) { 7628 attributes['$[]=']("citetitle", citetitle); 7629 } } else { 7630 7631 if (($truthy(indented) && ($eqeq(style, "normal")))) { 7632 self['$adjust_indentation!'](lines); 7633 } block = $$('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes})); 7634 } self.$catalog_inline_anchors(lines.$join($$('LF')), block, document, reader); 7635 } break; 7636 } 7637 } if (!$truthy(block)) { 7638 7639 switch (block_context) { 7640 case "listing": 7641 case "source": 7642 7643 if (($eqeq(block_context, "source") || (($not(attributes['$[]'](1)) && ($truthy((language = ($truthy(($ret_or_2 = attributes['$[]'](2))) ? ($ret_or_2) : (doc_attrs['$[]']("source-language")))))))))) { 7644 7645 if ($truthy(language)) { 7646 7647 attributes['$[]=']("style", "source"); 7648 attributes['$[]=']("language", language); 7649 $$('AttributeList').$rekey(attributes, [nil, nil, "linenums"]); 7650 } else { 7651 7652 $$('AttributeList').$rekey(attributes, [nil, "language", "linenums"]); 7653 if (!$truthy(attributes['$key?']("language"))) { 7654 if ($truthy(doc_attrs['$key?']("source-language"))) { 7655 attributes['$[]=']("language", doc_attrs['$[]']("source-language")); 7656 } 7657 } } if (!$truthy(attributes['$key?']("linenums"))) { 7658 if (($truthy(attributes['$[]']("linenums-option")) || ($truthy(doc_attrs['$[]']("source-linenums-option"))))) { 7659 attributes['$[]=']("linenums", ""); 7660 } 7661 } if (!$truthy(attributes['$key?']("indent"))) { 7662 if ($truthy(doc_attrs['$key?']("source-indent"))) { 7663 attributes['$[]=']("indent", doc_attrs['$[]']("source-indent")); 7664 } 7665 } } block = self.$build_block("listing", "verbatim", terminator, parent, reader, attributes); 7666 break; 7667 case "fenced_code": 7668 7669 attributes['$[]=']("style", "source"); 7670 if ($truthy($rb_gt((ll = this_line.$length()), 3))) { 7671 if ($truthy((comma_idx = (language = this_line.$slice(3, ll)).$index(",")))) { 7672 if ($truthy($rb_gt(comma_idx, 0))) { 7673 7674 language = language.$slice(0, comma_idx).$strip(); 7675 if ($truthy($rb_lt(comma_idx, $rb_minus(ll, 4)))) { 7676 attributes['$[]=']("linenums", ""); 7677 } } else if ($truthy($rb_gt(ll, 4))) { 7678 attributes['$[]=']("linenums", ""); 7679 } 7680 } else { 7681 language = language.$lstrip(); 7682 } 7683 } if ($truthy(language['$nil_or_empty?']())) { 7684 if ($truthy(doc_attrs['$key?']("source-language"))) { 7685 attributes['$[]=']("language", doc_attrs['$[]']("source-language")); 7686 } 7687 } else { 7688 attributes['$[]=']("language", language); 7689 } if (!$truthy(attributes['$key?']("linenums"))) { 7690 if (($truthy(attributes['$[]']("linenums-option")) || ($truthy(doc_attrs['$[]']("source-linenums-option"))))) { 7691 attributes['$[]=']("linenums", ""); 7692 } 7693 } if (!$truthy(attributes['$key?']("indent"))) { 7694 if ($truthy(doc_attrs['$key?']("source-indent"))) { 7695 attributes['$[]=']("indent", doc_attrs['$[]']("source-indent")); 7696 } 7697 } terminator = terminator.$slice(0, 3); 7698 block = self.$build_block("listing", "verbatim", terminator, parent, reader, attributes); 7699 break; 7700 case "table": 7701 7702 block_cursor = reader.$cursor(); 7703 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); 7704 if (!$truthy(terminator['$start_with?']("|", "!"))) { 7705 if ($truthy(($ret_or_2 = attributes['$[]']("format")))) ; else { 7706 attributes['$[]=']("format", ($truthy(terminator['$start_with?'](",")) ? ("csv") : ("dsv"))); 7707 } 7708 } block = self.$parse_table(block_reader, parent, attributes); 7709 break; 7710 case "sidebar": 7711 block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes); 7712 break; 7713 case "admonition": 7714 7715 attributes['$[]=']("name", (admonition_name = style.$downcase())); 7716 attributes['$[]=']("textlabel", ($truthy(($ret_or_2 = attributes.$delete("caption"))) ? ($ret_or_2) : (doc_attrs['$[]']("" + (admonition_name) + "-caption")))); 7717 block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes); 7718 break; 7719 case "open": 7720 case "abstract": 7721 case "partintro": 7722 block = self.$build_block("open", "compound", terminator, parent, reader, attributes); 7723 break; 7724 case "literal": 7725 block = self.$build_block(block_context, "verbatim", terminator, parent, reader, attributes); 7726 break; 7727 case "example": 7728 7729 if ($truthy(attributes['$[]']("collapsible-option"))) { 7730 attributes['$[]=']("caption", ""); 7731 } block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes); 7732 break; 7733 case "quote": 7734 case "verse": 7735 7736 $$('AttributeList').$rekey(attributes, [nil, "attribution", "citetitle"]); 7737 block = self.$build_block(block_context, ($eqeq(block_context, "verse") ? ("verbatim") : ("compound")), terminator, parent, reader, attributes); 7738 break; 7739 case "stem": 7740 case "latexmath": 7741 case "asciimath": 7742 7743 if ($eqeq(block_context, "stem")) { 7744 attributes['$[]=']("style", $$('STEM_TYPE_ALIASES')['$[]'](($truthy(($ret_or_2 = attributes['$[]'](2))) ? ($ret_or_2) : (doc_attrs['$[]']("stem"))))); 7745 } block = self.$build_block("stem", "raw", terminator, parent, reader, attributes); 7746 break; 7747 case "pass": 7748 block = self.$build_block(block_context, "raw", terminator, parent, reader, attributes); 7749 break; 7750 case "comment": 7751 7752 self.$build_block(block_context, "skip", terminator, parent, reader, attributes); 7753 attributes.$clear(); 7754 return nil; 7755 default: 7756 if (($truthy(block_extensions) && ($truthy((extension = extensions['$registered_for_block?'](block_context, cloaked_context)))))) { 7757 7758 if (!$eqeq((content_model = (ext_config = extension.$config())['$[]']("content_model")), "skip")) { 7759 7760 if (!$truthy((positional_attrs = ($truthy(($ret_or_2 = ext_config['$[]']("positional_attrs"))) ? ($ret_or_2) : (ext_config['$[]']("pos_attrs"))))['$nil_or_empty?']())) { 7761 $$('AttributeList').$rekey(attributes, $rb_plus([nil], positional_attrs)); 7762 } if ($truthy((default_attrs = ext_config['$[]']("default_attrs")))) { 7763 $send(default_attrs, 'each', [], function $$8(k, v){var $c; 7764 7765 7766 if (k == null) k = nil; 7767 if (v == null) v = nil; 7768 if ($truthy(($ret_or_2 = attributes['$[]'](k)))) { 7769 return $ret_or_2 7770 } else { 7771 return ($c = [k, v], $send(attributes, '[]=', $c), $c[$c.length - 1]) 7772 }}); 7773 } attributes['$[]=']("cloaked-context", cloaked_context); 7774 } if (!$truthy((block = self.$build_block(block_context, content_model, terminator, parent, reader, attributes, $hash2(["extension"], {"extension": extension}))))) { 7775 7776 attributes.$clear(); 7777 return nil; 7778 } } else { 7779 self.$raise("Unsupported block type " + (block_context) + " at " + (reader.$cursor())); 7780 } 7781 } 7782 } if ($truthy(document.$sourcemap())) { 7783 block['$source_location='](reader.$cursor_at_mark()); 7784 } if ($truthy(attributes['$[]']("title"))) { 7785 7786 block['$title=']((block_title = attributes.$delete("title"))); 7787 if ($truthy($$('CAPTION_ATTRIBUTE_NAMES')['$[]'](block.$context()))) { 7788 block.$assign_caption(attributes.$delete("caption")); 7789 } } block['$style='](attributes['$[]']("style")); 7790 if ($truthy((block_id = ($truthy(($ret_or_1 = block.$id())) ? ($ret_or_1) : (($a = [attributes['$[]']("id")], $send(block, 'id=', $a), $a[$a.length - 1])))))) { 7791 7792 if ($truthy(($truthy(block_title) ? (block_title['$include?']($$('ATTR_REF_HEAD'))) : (block['$title?']())))) { 7793 block.$title(); 7794 } if (!$truthy(document.$register("refs", [block_id, block]))) { 7795 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()}))); 7796 } } if (!$truthy(attributes['$empty?']())) { 7797 block.$update_attributes(attributes); 7798 } block.$commit_subs(); 7799 if ($truthy(block['$sub?']("callouts"))) { 7800 if (!$truthy(self.$catalog_callouts(block.$source(), document))) { 7801 block.$remove_sub("callouts"); 7802 } 7803 } return block; 7804 }, -3); 7805 $defs(self, '$read_paragraph_lines', function $$read_paragraph_lines(reader, break_at_list, opts) { 7806 var break_condition = nil; 7807 7808 7809 if (opts == null) opts = $hash2([], {}); 7810 opts['$[]=']("break_on_blank_lines", true); 7811 opts['$[]=']("break_on_list_continuation", true); 7812 opts['$[]=']("preserve_last_line", true); 7813 break_condition = ($truthy(break_at_list) ? (($truthy($$('Compliance').$block_terminates_paragraph()) ? ($$('StartOfBlockOrListProc')) : ($$('StartOfListProc')))) : (($truthy($$('Compliance').$block_terminates_paragraph()) ? ($$('StartOfBlockProc')) : ($$('NoOp'))))); 7814 return $send(reader, 'read_lines_until', [opts], break_condition.$to_proc()); 7815 }, -3); 7816 $defs(self, '$is_delimited_block?', function $Parser_is_delimited_block$ques$9(line, return_match_data) { 7817 var $a, $b, self = this, line_len = nil, tip = nil, tip_len = nil, context = nil, masq = nil; 7818 7819 7820 if (return_match_data == null) return_match_data = nil; 7821 if (!($truthy($rb_gt((line_len = line.$length()), 1)) && ($truthy($$('DELIMITED_BLOCK_HEADS')['$[]'](line.$slice(0, 2)))))) { 7822 return nil 7823 } if ($eqeq(line_len, 2)) { 7824 7825 tip = line; 7826 tip_len = 2; 7827 } else { 7828 7829 if ($truthy($rb_lt(line_len, 5))) { 7830 7831 tip = line; 7832 tip_len = line_len; 7833 } else { 7834 tip = line.$slice(0, (tip_len = 4)); 7835 } if (($truthy($$('Compliance').$markdown_syntax()) && ($truthy(tip['$start_with?']("`"))))) { 7836 if ($eqeq(tip_len, 4)) { 7837 7838 if (($eqeq(tip, "````") || ($neqeq((tip = tip.$chop()), "```")))) { 7839 return nil 7840 } line = tip; 7841 line_len = (tip_len = 3); 7842 } else if ($neqeq(tip, "```")) { 7843 return nil 7844 } 7845 } else if ($eqeq(tip_len, 3)) { 7846 return nil 7847 } } $b = $$('DELIMITED_BLOCKS')['$[]'](tip), $a = $to_ary($b), (context = ($a[0] == null ? nil : $a[0])), (masq = ($a[1] == null ? nil : $a[1])); 7848 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)))))))) { 7849 if ($truthy(return_match_data)) { 7850 7851 return $$('BlockMatchData').$new(context, masq, tip, line); 7852 } else { 7853 return true 7854 } 7855 } else { 7856 return nil 7857 } }, -2); 7858 $defs(self, '$build_block', function $$build_block(block_context, content_model, terminator, parent, reader, attributes, options) { 7859 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; 7860 7861 7862 if (options == null) options = $hash2([], {}); 7863 7864 switch (content_model) { 7865 case "skip": 7866 $a = [true, "simple"], (skip_processing = $a[0]), (parse_as_content_model = $a[1]); 7867 break; 7868 case "raw": 7869 $a = [false, "simple"], (skip_processing = $a[0]), (parse_as_content_model = $a[1]); 7870 break; 7871 default: 7872 $a = [false, content_model], (skip_processing = $a[0]), (parse_as_content_model = $a[1]); 7873 } if ($truthy(terminator['$nil?']())) { 7874 7875 if ($eqeq(parse_as_content_model, "verbatim")) { 7876 lines = reader.$read_lines_until($hash2(["break_on_blank_lines", "break_on_list_continuation"], {"break_on_blank_lines": true, "break_on_list_continuation": true})); 7877 } else { 7878 7879 if ($eqeq(content_model, "compound")) { 7880 content_model = "simple"; 7881 } lines = self.$read_paragraph_lines(reader, false, $hash2(["skip_line_comments", "skip_processing"], {"skip_line_comments": true, "skip_processing": skip_processing})); 7882 } block_reader = nil; 7883 } else if ($neqeq(parse_as_content_model, "compound")) { 7884 7885 lines = reader.$read_lines_until($hash2(["terminator", "skip_processing", "context", "cursor"], {"terminator": terminator, "skip_processing": skip_processing, "context": block_context, "cursor": "at_mark"})); 7886 block_reader = nil; 7887 } else if ($eqeq(terminator, false)) { 7888 7889 lines = nil; 7890 block_reader = reader; 7891 } else { 7892 7893 lines = nil; 7894 block_cursor = reader.$cursor(); 7895 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); 7896 } 7897 switch (content_model) { 7898 case "verbatim": 7899 7900 tab_size = ($truthy(($ret_or_2 = attributes['$[]']("tabsize"))) ? ($ret_or_2) : (parent.$document().$attributes()['$[]']("tabsize"))).$to_i(); 7901 if ($truthy((indent = attributes['$[]']("indent")))) { 7902 self['$adjust_indentation!'](lines, indent.$to_i(), tab_size); 7903 } else if ($truthy($rb_gt(tab_size, 0))) { 7904 self['$adjust_indentation!'](lines, -1, tab_size); 7905 } break; 7906 case "skip": 7907 return nil 7908 } if ($truthy((extension = options['$[]']("extension")))) { 7909 7910 attributes.$delete("style"); 7911 if (($truthy((block = extension.$process_method()['$[]'](parent, ($truthy(($ret_or_1 = block_reader)) ? ($ret_or_1) : ($$('Reader').$new(lines))), attributes.$merge()))) && ($neqeq(block, parent)))) { 7912 7913 attributes.$replace(block.$attributes()); 7914 if ((($eqeq(block.$content_model(), "compound") && ($eqeqeq($$('Block'), block))) && ($not((lines = block.$lines())['$empty?']())))) { 7915 7916 content_model = "compound"; 7917 block_reader = $$('Reader').$new(lines); 7918 } } else { 7919 return nil 7920 } } else { 7921 block = $$('Block').$new(parent, block_context, $hash2(["content_model", "source", "attributes"], {"content_model": content_model, "source": lines, "attributes": attributes})); 7922 } if ($eqeq(content_model, "compound")) { 7923 self.$parse_blocks(block_reader, block); 7924 } return block; 7925 }, -7); 7926 $defs(self, '$parse_blocks', function $$parse_blocks(reader, parent, attributes) { 7927 var self = this, $ret_or_1 = nil, $ret_or_2 = nil, block = nil; 7928 7929 7930 if (attributes == null) attributes = nil; 7931 if ($truthy(attributes)) { 7932 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?']())))) { 7933 7934 } 7935 } else { 7936 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?']())))) { 7937 7938 } 7939 } return nil; 7940 }, -3); 7941 $defs(self, '$parse_list', function $$parse_list(reader, list_type, parent, style) { 7942 var $a, self = this, list_block = nil, list_rx = nil, $ret_or_1 = nil, list_item = nil; 7943 if ($gvars["~"] == null) $gvars["~"] = nil; 7944 7945 7946 list_block = $$('List').$new(parent, list_type); 7947 list_rx = $$('ListRxMap')['$[]'](list_type); 7948 while ($truthy(($truthy(($ret_or_1 = reader['$has_more_lines?']())) ? (list_rx['$=~'](reader.$peek_line())) : ($ret_or_1)))) { 7949 7950 if ($truthy((list_item = self.$parse_list_item(reader, list_block, $gvars["~"], (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), style)))) { 7951 list_block.$items()['$<<'](list_item); 7952 } if ($truthy(($ret_or_1 = reader.$skip_blank_lines()))) ; else { 7953 break 7954 } } return list_block; 7955 }); 7956 $defs(self, '$catalog_callouts', function $$catalog_callouts(text, document) { 7957 var found = nil, autonum = nil; 7958 7959 7960 found = false; 7961 autonum = 0; 7962 if ($truthy(text['$include?']("<"))) { 7963 $send(text, 'scan', [$$('CalloutScanRx')], function $$10(){var $a; 7964 7965 7966 if (!$truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](0))['$start_with?']("\\"))) { 7967 document.$callouts().$register(($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), ".") ? ((autonum = $rb_plus(autonum, 1)).$to_s()) : ((($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))); 7968 } return (found = true);}); 7969 } return found; 7970 }); 7971 $defs(self, '$catalog_inline_anchor', function $$catalog_inline_anchor(id, reftext, node, location, doc) { 7972 var self = this; 7973 7974 7975 if (doc == null) doc = node.$document(); 7976 if (($truthy(reftext) && ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))))) { 7977 reftext = doc.$sub_attributes(reftext); 7978 } if (!$truthy(doc.$register("refs", [id, $$('Inline').$new(node, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id}))]))) { 7979 7980 if ($eqeqeq($$('Reader'), location)) { 7981 location = location.$cursor(); 7982 } self.$logger().$warn(self.$message_with_context("id assigned to anchor already in use: " + (id), $hash2(["source_location"], {"source_location": location}))); 7983 } return nil; 7984 }, -5); 7985 $defs(self, '$catalog_inline_anchors', function $$catalog_inline_anchors(text, block, document, reader) { 7986 var self = this; 7987 7988 7989 if (($truthy(text['$include?']("[[")) || ($truthy(text['$include?']("or:"))))) { 7990 $send(text, 'scan', [$$('InlineAnchorScanRx')], function $$11(){var $a, self = $$11.$$s == null ? this : $$11.$$s, id = nil, reftext = nil, location = nil, offset = nil; 7991 7992 7993 if ($truthy((id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))))) { 7994 if ((($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)))) && ($truthy(reftext['$include?']($$('ATTR_REF_HEAD'))))) && ($truthy((reftext = document.$sub_attributes(reftext))['$empty?']())))) { 7995 return nil 7996 } 7997 } else { 7998 7999 id = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 8000 if ($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](4))))) { 8001 if ($truthy(reftext['$include?']("]"))) { 8002 8003 reftext = reftext.$gsub("\\]", "]"); 8004 if ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))) { 8005 reftext = document.$sub_attributes(reftext); 8006 } } else if ($truthy(reftext['$include?']($$('ATTR_REF_HEAD')))) { 8007 if ($truthy((reftext = document.$sub_attributes(reftext))['$empty?']())) { 8008 reftext = nil; 8009 } 8010 } 8011 } } if ($truthy(document.$register("refs", [id, $$('Inline').$new(block, "anchor", reftext, $hash2(["type", "id"], {"type": "ref", "id": id}))]))) { 8012 return nil 8013 } else { 8014 8015 location = reader.$cursor_at_mark(); 8016 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))) { 8017 (location = location.$dup()).$advance(offset); 8018 } return self.$logger().$warn(self.$message_with_context("id assigned to anchor already in use: " + (id), $hash2(["source_location"], {"source_location": location}))); 8019 }}, {$$s: self}); 8020 } return nil; 8021 }); 8022 $defs(self, '$catalog_inline_biblio_anchor', function $$catalog_inline_biblio_anchor(id, reftext, node, reader) { 8023 var self = this, $ret_or_1 = nil; 8024 8025 8026 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}))]))) { 8027 self.$logger().$warn(self.$message_with_context("id assigned to bibliography anchor already in use: " + (id), $hash2(["source_location"], {"source_location": reader.$cursor()}))); 8028 } return nil; 8029 }); 8030 $defs(self, '$parse_description_list', function $$parse_description_list(reader, match, parent) { 8031 var self = this, list_block = nil, sibling_pattern = nil, current_pair = nil, $ret_or_1 = nil, next_pair = nil; 8032 if ($gvars["~"] == null) $gvars["~"] = nil; 8033 8034 8035 list_block = $$('List').$new(parent, "dlist"); 8036 sibling_pattern = $$('DescriptionListSiblingRx')['$[]'](match['$[]'](2)); 8037 list_block.$items()['$<<']((current_pair = self.$parse_list_item(reader, list_block, match, sibling_pattern))); 8038 while ($truthy(($truthy(($ret_or_1 = reader['$has_more_lines?']())) ? (sibling_pattern['$=~'](reader.$peek_line())) : ($ret_or_1)))) { 8039 8040 next_pair = self.$parse_list_item(reader, list_block, $gvars["~"], sibling_pattern); 8041 if ($truthy(current_pair['$[]'](1))) { 8042 list_block.$items()['$<<']((current_pair = next_pair)); 8043 } else { 8044 8045 current_pair['$[]'](0)['$<<'](next_pair['$[]'](0)['$[]'](0)); 8046 current_pair['$[]='](1, next_pair['$[]'](1)); 8047 } } return list_block; 8048 }); 8049 $defs(self, '$parse_callout_list', function $$parse_callout_list(reader, match, parent, callouts) { 8050 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; 8051 8052 8053 list_block = $$('List').$new(parent, "colist"); 8054 next_index = 1; 8055 autonum = 0; 8056 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)))))) { 8057 8058 if ($eqeq((num = match['$[]'](1)), ".")) { 8059 num = (autonum = $rb_plus(autonum, 1)).$to_s(); 8060 } if (!$eqeq(num, next_index.$to_s())) { 8061 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()}))); 8062 } if ($truthy((list_item = self.$parse_list_item(reader, list_block, match, "<1>")))) { 8063 8064 list_block.$items()['$<<'](list_item); 8065 if ($truthy((coids = callouts.$callout_ids(list_block.$items().$size()))['$empty?']())) { 8066 self.$logger().$warn(self.$message_with_context("no callout found for <" + (list_block.$items().$size()) + ">", $hash2(["source_location"], {"source_location": reader.$cursor_at_mark()}))); 8067 } else { 8068 list_item.$attributes()['$[]=']("coids", coids); 8069 } } next_index = $rb_plus(next_index, 1); 8070 match = nil; 8071 } callouts.$next_list(); 8072 return list_block; 8073 }); 8074 $defs(self, '$parse_list_item', function $$parse_list_item(reader, list_block, match, sibling_trait, style) { 8075 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; 8076 8077 8078 if (style == null) style = nil; 8079 if ($eqeq((list_type = list_block.$context()), "dlist")) { 8080 8081 dlist = true; 8082 list_term = $$('ListItem').$new(list_block, (term_text = match['$[]'](1))); 8083 if (($truthy(term_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](term_text))))) { 8084 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); 8085 } if ($truthy((item_text = match['$[]'](3)))) { 8086 has_text = true; 8087 } list_item = $$('ListItem').$new(list_block, item_text); 8088 if ($truthy(list_block.$document().$sourcemap())) { 8089 8090 list_term['$source_location='](reader.$cursor()); 8091 if ($truthy(has_text)) { 8092 list_item['$source_location='](list_term.$source_location()); 8093 } else { 8094 sourcemap_assignment_deferred = true; 8095 } } } else { 8096 8097 has_text = true; 8098 list_item = $$('ListItem').$new(list_block, (item_text = match['$[]'](2))); 8099 if ($truthy(list_block.$document().$sourcemap())) { 8100 list_item['$source_location='](reader.$cursor()); 8101 } 8102 switch (list_type) { 8103 case "ulist": 8104 8105 list_item['$marker='](sibling_trait); 8106 if ($truthy(item_text['$start_with?']("["))) { 8107 if (($truthy(style) && ($eqeq(style, "bibliography")))) { 8108 if ($truthy($$('InlineBiblioAnchorRx')['$=~'](item_text))) { 8109 self.$catalog_inline_biblio_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader); 8110 } 8111 } else if ($truthy(item_text['$start_with?']("[["))) { 8112 if ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))) { 8113 self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader); 8114 } 8115 } else if ($truthy(item_text['$start_with?']("[ ] ", "[x] ", "[*] "))) { 8116 8117 list_block.$set_option("checklist"); 8118 list_item.$attributes()['$[]=']("checkbox", ""); 8119 if (!$truthy(item_text['$start_with?']("[ "))) { 8120 list_item.$attributes()['$[]=']("checked", ""); 8121 } list_item['$text='](item_text.$slice(4, item_text.$length())); 8122 } 8123 } break; 8124 case "olist": 8125 8126 $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])); 8127 list_item['$marker='](sibling_trait); 8128 if (($eqeq(ordinal, 0) && ($not(style)))) { 8129 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()))); 8130 } if (($truthy(item_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))))) { 8131 self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader); 8132 } break; 8133 default: 8134 8135 list_item['$marker='](sibling_trait); 8136 if (($truthy(item_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](item_text))))) { 8137 self.$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), list_item, reader); 8138 } } } reader.$shift(); 8139 block_cursor = reader.$cursor(); 8140 list_item_reader = $$('Reader').$new(self.$read_lines_for_list_item(reader, list_type, sibling_trait, has_text), block_cursor); 8141 if ($truthy(list_item_reader['$has_more_lines?']())) { 8142 8143 if ($truthy(sourcemap_assignment_deferred)) { 8144 list_item['$source_location='](block_cursor); 8145 } comment_lines = list_item_reader.$skip_line_comments(); 8146 if ($truthy((subsequent_line = list_item_reader.$peek_line()))) { 8147 8148 if (!$truthy(comment_lines['$empty?']())) { 8149 list_item_reader.$unshift_lines(comment_lines); 8150 } if (!$truthy(subsequent_line['$empty?']())) { 8151 8152 content_adjacent = true; 8153 if (!$truthy(dlist)) { 8154 has_text = nil; 8155 } } } 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}))))) { 8156 list_item.$blocks()['$<<'](block); 8157 } while ($truthy(list_item_reader['$has_more_lines?']())) { 8158 if ($truthy((block = self.$next_block(list_item_reader, list_item, $hash2([], {}), $hash2(["list_type"], {"list_type": list_type}))))) { 8159 list_item.$blocks()['$<<'](block); 8160 } 8161 } if ((($truthy(content_adjacent) && ($truthy((first_block = list_item.$blocks()['$[]'](0))))) && ($eqeq(first_block.$context(), "paragraph")))) { 8162 list_item.$fold_first(); 8163 } } if ($truthy(dlist)) { 8164 return [[list_term], (($truthy(list_item['$text?']()) || ($truthy(list_item['$blocks?']()))) ? (list_item) : (nil))] 8165 } else { 8166 return list_item 8167 } }, -5); 8168 $defs(self, '$read_lines_for_list_item', function $$read_lines_for_list_item(reader, list_type, sibling_trait, has_text) { 8169 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; 8170 8171 8172 if (sibling_trait == null) sibling_trait = nil; 8173 if (has_text == null) has_text = true; 8174 buffer = []; 8175 continuation = "inactive"; 8176 within_nested_list = false; 8177 detached_continuation = nil; 8178 dlist = list_type['$==']("dlist"); 8179 while ($truthy(reader['$has_more_lines?']())) { 8180 8181 this_line = reader.$read_line(); 8182 if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) { 8183 break 8184 } prev_line = ($truthy(buffer['$empty?']()) ? (nil) : (buffer['$[]'](-1))); 8185 if ($eqeq(prev_line, $$('LIST_CONTINUATION'))) { 8186 8187 if ($eqeq(continuation, "inactive")) { 8188 8189 continuation = "active"; 8190 has_text = true; 8191 if (!$truthy(within_nested_list)) { 8192 buffer['$[]='](-1, ""); 8193 } } if ($eqeq(this_line, $$('LIST_CONTINUATION'))) { 8194 8195 if ($neqeq(continuation, "frozen")) { 8196 8197 continuation = "frozen"; 8198 buffer['$<<'](this_line); 8199 } this_line = nil; 8200 continue; 8201 } } if ($truthy((match = self['$is_delimited_block?'](this_line, true)))) { 8202 8203 if (!$eqeq(continuation, "active")) { 8204 break 8205 } buffer['$<<'](this_line); 8206 buffer.$concat(reader.$read_lines_until($hash2(["terminator", "read_last_line", "context"], {"terminator": match.$terminator(), "read_last_line": true, "context": nil}))); 8207 continuation = "inactive"; 8208 } else if (((($truthy(dlist) && ($neqeq(continuation, "active"))) && ($truthy(this_line['$start_with?']("[")))) && ($truthy($$('BlockAttributeLineRx')['$match?'](this_line))))) { 8209 8210 block_attribute_lines = [this_line]; 8211 while ($truthy((next_line = reader.$peek_line()))) { 8212 8213 if ($truthy(self['$is_delimited_block?'](next_line))) { 8214 interrupt = true; 8215 } else if (($truthy(next_line['$empty?']()) || (($truthy(next_line['$start_with?']("[")) && ($truthy($$('BlockAttributeLineRx')['$match?'](next_line))))))) { 8216 8217 block_attribute_lines['$<<'](reader.$read_line()); 8218 continue; 8219 } else if (($truthy($$('AnyListRx')['$match?'](next_line)) && ($not(self['$is_sibling_list_item?'](next_line, list_type, sibling_trait))))) { 8220 buffer.$concat(block_attribute_lines); 8221 } else { 8222 interrupt = true; 8223 } break; 8224 } if ($truthy(interrupt)) { 8225 8226 reader.$unshift_lines(block_attribute_lines); 8227 break; 8228 } } else if (($eqeq(continuation, "active") && ($not(this_line['$empty?']())))) { 8229 if ($truthy($$('LiteralParagraphRx')['$match?'](this_line))) { 8230 8231 reader.$unshift_line(this_line); 8232 if ($truthy(dlist)) { 8233 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; 8234 8235 8236 if (line == null) line = nil; 8237 return self['$is_sibling_list_item?'](line, list_type, sibling_trait);}, {$$s: self})); 8238 } else { 8239 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}))); 8240 } continuation = "inactive"; 8241 } 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))))))) { 8242 buffer['$<<'](this_line); 8243 } else { 8244 8245 if ($truthy((nested_list_type = $send(($truthy(within_nested_list) ? (["dlist"]) : ($$('NESTABLE_LIST_CONTEXTS'))), 'find', [], function $$13(ctx){ 8246 8247 if (ctx == null) ctx = nil; 8248 return $$('ListRxMap')['$[]'](ctx)['$match?'](this_line);})))) { 8249 8250 within_nested_list = true; 8251 if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) { 8252 has_text = false; 8253 } } buffer['$<<'](this_line); 8254 continuation = "inactive"; 8255 } 8256 } else if (($truthy(prev_line) && ($truthy(prev_line['$empty?']())))) { 8257 8258 if ($truthy(this_line['$empty?']())) { 8259 8260 if (!$truthy((this_line = ($truthy(($ret_or_1 = reader.$skip_blank_lines())) ? (reader.$read_line()) : ($ret_or_1))))) { 8261 break 8262 } if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) { 8263 break 8264 } } if ($eqeq(this_line, $$('LIST_CONTINUATION'))) { 8265 8266 detached_continuation = buffer.$size(); 8267 buffer['$<<'](this_line); 8268 } else if ($truthy(has_text)) { 8269 if ($truthy(self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) { 8270 break 8271 } else if ($truthy((nested_list_type = $send($$('NESTABLE_LIST_CONTEXTS'), 'find', [], function $$14(ctx){ 8272 8273 if (ctx == null) ctx = nil; 8274 return $$('ListRxMap')['$[]'](ctx)['$=~'](this_line);})))) { 8275 8276 buffer['$<<'](this_line); 8277 within_nested_list = true; 8278 if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) { 8279 has_text = false; 8280 } } else if ($truthy($$('LiteralParagraphRx')['$match?'](this_line))) { 8281 8282 reader.$unshift_line(this_line); 8283 if ($truthy(dlist)) { 8284 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; 8285 8286 8287 if (line == null) line = nil; 8288 return self['$is_sibling_list_item?'](line, list_type, sibling_trait);}, {$$s: self})); 8289 } else { 8290 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}))); 8291 } } else { 8292 break 8293 } 8294 } else { 8295 8296 if (!$truthy(within_nested_list)) { 8297 buffer.$pop(); 8298 } buffer['$<<'](this_line); 8299 has_text = true; 8300 } } else { 8301 8302 if (!$truthy(this_line['$empty?']())) { 8303 has_text = true; 8304 } if ($truthy((nested_list_type = $send(($truthy(within_nested_list) ? (["dlist"]) : ($$('NESTABLE_LIST_CONTEXTS'))), 'find', [], function $$16(ctx){ 8305 8306 if (ctx == null) ctx = nil; 8307 return $$('ListRxMap')['$[]'](ctx)['$=~'](this_line);})))) { 8308 8309 within_nested_list = true; 8310 if (($eqeq(nested_list_type, "dlist") && ($truthy((($a = $gvars['~']) === nil ? nil : $a['$[]'](3))['$nil_or_empty?']())))) { 8311 has_text = false; 8312 } } buffer['$<<'](this_line); 8313 } this_line = nil; 8314 } if ($truthy(this_line)) { 8315 reader.$unshift_line(this_line); 8316 } if ($truthy(detached_continuation)) { 8317 buffer['$[]='](detached_continuation, ""); 8318 } while (!($truthy(buffer['$empty?']()))) { 8319 if ($truthy((last_line = buffer['$[]'](-1))['$empty?']())) { 8320 buffer.$pop(); 8321 } else { 8322 8323 if ($eqeq(last_line, $$('LIST_CONTINUATION'))) { 8324 buffer.$pop(); 8325 } break; 8326 } 8327 } return buffer; 8328 }, -3); 8329 $defs(self, '$initialize_section', function $$initialize_section(reader, parent, attributes) { 8330 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; 8331 8332 8333 if (attributes == null) attributes = $hash2([], {}); 8334 document = parent.$document(); 8335 book = (doctype = document.$doctype())['$==']("book"); 8336 if ($truthy(document.$sourcemap())) { 8337 source_location = reader.$cursor(); 8338 } sect_style = attributes['$[]'](1); 8339 $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])); 8340 if ($truthy(sect_style)) { 8341 if (($truthy(book) && ($eqeq(sect_style, "abstract")))) { 8342 $a = ["chapter", 1], (sect_name = $a[0]), (sect_level = $a[1]); 8343 } else if (($truthy(sect_style['$start_with?']("sect")) && ($truthy($$('SectionLevelStyleRx')['$match?'](sect_style))))) { 8344 sect_name = "section"; 8345 } else { 8346 8347 $a = [sect_style, true], (sect_name = $a[0]), (sect_special = $a[1]); 8348 if ($eqeq(sect_level, 0)) { 8349 sect_level = 1; 8350 } sect_numbered = sect_name['$==']("appendix"); 8351 } 8352 } else if ($truthy(book)) { 8353 sect_name = ($eqeq(sect_level, 0) ? ("part") : (($truthy($rb_gt(sect_level, 1)) ? ("section") : ("chapter")))); 8354 } else if (($eqeq(doctype, "manpage") && ($eqeq(sect_title.$casecmp("synopsis"), 0)))) { 8355 $a = ["synopsis", true], (sect_name = $a[0]), (sect_special = $a[1]); 8356 } else { 8357 sect_name = "section"; 8358 } if ($truthy(sect_reftext)) { 8359 attributes['$[]=']("reftext", sect_reftext); 8360 } section = $$('Section').$new(parent, sect_level); 8361 $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]); 8362 if ($truthy(sect_special)) { 8363 8364 section['$special='](true); 8365 if ($truthy(sect_numbered)) { 8366 section['$numbered='](true); 8367 } else if ($eqeq(document.$attributes()['$[]']("sectnums"), "all")) { 8368 section['$numbered=']((($truthy(book) && ($eqeq(sect_level, 1))) ? ("chapter") : (true))); 8369 } } else if (($truthy(document.$attributes()['$[]']("sectnums")) && ($truthy($rb_gt(sect_level, 0))))) { 8370 section['$numbered='](($truthy(section.$special()) ? (($truthy(($ret_or_1 = parent.$numbered())) || ($ret_or_1))) : (true))); 8371 } else if ((($truthy(book) && ($eqeq(sect_level, 0))) && ($truthy(document.$attributes()['$[]']("partnums"))))) { 8372 section['$numbered='](true); 8373 } 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])))))) { 8374 8375 if (!($truthy(generated_id) || ($not(sect_title['$include?']($$('ATTR_REF_HEAD')))))) { 8376 section.$title(); 8377 } if (!$truthy(document.$register("refs", [id, section]))) { 8378 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))))}))); 8379 } } section.$update_attributes(attributes); 8380 reader.$skip_blank_lines(); 8381 return section; 8382 }, -3); 8383 $defs(self, '$is_next_line_section?', function $Parser_is_next_line_section$ques$17(reader, attributes) { 8384 var self = this, style = nil, next_lines = nil, $ret_or_1 = nil; 8385 8386 8387 if (($truthy((style = attributes['$[]'](1))) && (($eqeq(style, "discrete") || ($eqeq(style, "float")))))) { 8388 return nil 8389 } if ($truthy($$('Compliance').$underline_style_section_titles())) { 8390 8391 next_lines = reader.$peek_lines(2, ($truthy(($ret_or_1 = style)) ? (style['$==']("comment")) : ($ret_or_1))); 8392 return self['$is_section_title?'](($truthy(($ret_or_1 = next_lines['$[]'](0))) ? ($ret_or_1) : ("")), next_lines['$[]'](1)); 8393 } else { 8394 return self['$atx_section_title?'](($truthy(($ret_or_1 = reader.$peek_line())) ? ($ret_or_1) : (""))) 8395 } }); 8396 $defs(self, '$is_next_line_doctitle?', function $Parser_is_next_line_doctitle$ques$18(reader, attributes, leveloffset) { 8397 var self = this, $ret_or_1 = nil, sect_level = nil; 8398 8399 if ($truthy(leveloffset)) { 8400 if ($truthy(($ret_or_1 = (sect_level = self['$is_next_line_section?'](reader, attributes))))) { 8401 8402 return $rb_plus(sect_level, leveloffset.$to_i())['$=='](0); 8403 } else { 8404 return $ret_or_1 8405 } 8406 } else { 8407 return self['$is_next_line_section?'](reader, attributes)['$=='](0) 8408 } 8409 }); 8410 $defs(self, '$is_section_title?', function $Parser_is_section_title$ques$19(line1, line2) { 8411 var self = this, $ret_or_1 = nil; 8412 8413 8414 if (line2 == null) line2 = nil; 8415 if ($truthy(($ret_or_1 = self['$atx_section_title?'](line1)))) { 8416 return $ret_or_1 8417 } else { 8418 8419 if ($truthy(line2['$nil_or_empty?']())) { 8420 return nil 8421 } else { 8422 return self['$setext_section_title?'](line1, line2) 8423 } } }, -2); 8424 $defs(self, '$atx_section_title?', function $Parser_atx_section_title$ques$20(line) { 8425 var $a, $ret_or_1 = nil; 8426 8427 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)))))) { 8428 return $rb_minus((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)).$length(), 1) 8429 } else { 8430 return nil 8431 } 8432 }); 8433 $defs(self, '$setext_section_title?', function $Parser_setext_section_title$ques$21(line1, line2) { 8434 var self = this, line2_len = nil, level = nil, line2_ch0 = nil; 8435 8436 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))))) { 8437 return level 8438 } else { 8439 return nil 8440 } 8441 }); 8442 $defs(self, '$parse_section_title', function $$parse_section_title(reader, document, sect_id) { 8443 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; 8444 8445 8446 if (sect_id == null) sect_id = nil; 8447 sect_reftext = nil; 8448 line1 = reader.$read_line(); 8449 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)))))) { 8450 8451 $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]); 8452 if (!$truthy(sect_id)) { 8453 if ((($truthy(sect_title['$end_with?']("]]")) && ($truthy($$('InlineSectionAnchorRx')['$=~'](sect_title)))) && ($not((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))))) { 8454 $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]); 8455 } 8456 } } 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))))) { 8457 8458 atx = false; 8459 if (!$truthy(sect_id)) { 8460 if ((($truthy(sect_title['$end_with?']("]]")) && ($truthy($$('InlineSectionAnchorRx')['$=~'](sect_title)))) && ($not((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))))) { 8461 $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]); 8462 } 8463 } reader.$shift(); 8464 } else { 8465 self.$raise("Unrecognized section at " + (reader.$cursor_at_prev_line())); 8466 } if ($truthy(document['$attr?']("leveloffset"))) { 8467 8468 sect_level = $rb_plus(sect_level, document.$attr("leveloffset").$to_i()); 8469 if ($truthy($rb_lt(sect_level, 0))) { 8470 sect_level = 0; 8471 } } return [sect_id, sect_reftext, sect_title, sect_level, atx]; 8472 }, -3); 8473 $defs(self, '$parse_header_metadata', function $$parse_header_metadata(reader, document, retrieve) { 8474 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; 8475 8476 8477 if (document == null) document = nil; 8478 if (retrieve == null) retrieve = true; 8479 doc_attrs = ($truthy(($ret_or_1 = document)) ? (document.$attributes()) : ($ret_or_1)); 8480 self.$process_attribute_entries(reader, document); 8481 if (($truthy(reader['$has_more_lines?']()) && ($not(reader['$next_line_empty?']())))) { 8482 8483 authorcount = (implicit_author_metadata = self.$process_authors(reader.$read_line())).$delete("authorcount"); 8484 if (($truthy(document) && ($truthy($rb_gt(($a = ["authorcount", authorcount], $send(doc_attrs, '[]=', $a), $a[$a.length - 1]), 0))))) { 8485 8486 $send(implicit_author_metadata, 'each', [], function $$22(key, val){var $b; 8487 8488 8489 if (key == null) key = nil; 8490 if (val == null) val = nil; 8491 if ($truthy(doc_attrs['$key?'](key))) { 8492 return nil 8493 } else { 8494 return ($b = [key, document.$apply_header_subs(val)], $send(doc_attrs, '[]=', $b), $b[$b.length - 1]) 8495 }}); 8496 implicit_author = doc_attrs['$[]']("author"); 8497 implicit_authorinitials = doc_attrs['$[]']("authorinitials"); 8498 implicit_authors = doc_attrs['$[]']("authors"); 8499 } implicit_author_metadata['$[]=']("authorcount", authorcount); 8500 self.$process_attribute_entries(reader, document); 8501 if (($truthy(reader['$has_more_lines?']()) && ($not(reader['$next_line_empty?']())))) { 8502 8503 rev_line = reader.$read_line(); 8504 if ($truthy((match = $$('RevisionInfoLineRx').$match(rev_line)))) { 8505 8506 rev_metadata = $hash2([], {}); 8507 if ($truthy(match['$[]'](1))) { 8508 rev_metadata['$[]=']("revnumber", match['$[]'](1).$rstrip()); 8509 } if (!$truthy((component = match['$[]'](2).$strip())['$empty?']())) { 8510 if (($not(match['$[]'](1)) && ($truthy(component['$start_with?']("v"))))) { 8511 rev_metadata['$[]=']("revnumber", component.$slice(1, component.$length())); 8512 } else { 8513 rev_metadata['$[]=']("revdate", component); 8514 } 8515 } if ($truthy(match['$[]'](3))) { 8516 rev_metadata['$[]=']("revremark", match['$[]'](3).$rstrip()); 8517 } if (($truthy(document) && ($not(rev_metadata['$empty?']())))) { 8518 $send(rev_metadata, 'each', [], function $$23(key, val){var $b; 8519 8520 8521 if (key == null) key = nil; 8522 if (val == null) val = nil; 8523 if ($truthy(doc_attrs['$key?'](key))) { 8524 return nil 8525 } else { 8526 return ($b = [key, document.$apply_header_subs(val)], $send(doc_attrs, '[]=', $b), $b[$b.length - 1]) 8527 }}); 8528 } } else { 8529 reader.$unshift_line(rev_line); 8530 } } self.$process_attribute_entries(reader, document); 8531 reader.$skip_blank_lines(); 8532 } else { 8533 implicit_author_metadata = $hash2([], {}); 8534 } if ($truthy(document)) { 8535 8536 if (($truthy(doc_attrs['$key?']("author")) && ($neqeq((author_line = doc_attrs['$[]']("author")), implicit_author)))) { 8537 8538 author_metadata = self.$process_authors(author_line, true, false); 8539 if ($neqeq(doc_attrs['$[]']("authorinitials"), implicit_authorinitials)) { 8540 author_metadata.$delete("authorinitials"); 8541 } } else if (($truthy(doc_attrs['$key?']("authors")) && ($neqeq((author_line = doc_attrs['$[]']("authors")), implicit_authors)))) { 8542 author_metadata = self.$process_authors(author_line, true); 8543 } else { 8544 8545 $a = [[], 1, "author_1", false, false], (authors = $a[0]), (author_idx = $a[1]), (author_key = $a[2]), (explicit = $a[3]), (sparse = $a[4]); 8546 while ($truthy(doc_attrs['$key?'](author_key))) { 8547 8548 if ($eqeq((author_override = doc_attrs['$[]'](author_key)), implicit_author_metadata['$[]'](author_key))) { 8549 8550 authors['$<<'](nil); 8551 sparse = true; 8552 } else { 8553 8554 authors['$<<'](author_override); 8555 explicit = true; 8556 } author_key = "author_" + ((author_idx = $rb_plus(author_idx, 1))); 8557 } if ($truthy(explicit)) { 8558 8559 if ($truthy(sparse)) { 8560 $send(authors, 'each_with_index', [], function $$24(author, idx){var $b, name_idx = nil; 8561 8562 8563 if (author == null) author = nil; 8564 if (idx == null) idx = nil; 8565 if ($truthy(author)) { 8566 return nil 8567 } 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){ 8568 8569 if (it == null) it = nil; 8570 return it.$tr(" ", "_");}).$join(" ")], $send(authors, '[]=', $b), $b[$b.length - 1]);}); 8571 } author_metadata = self.$process_authors(authors, true, false); 8572 } else { 8573 author_metadata = $hash2(["authorcount"], {"authorcount": 0}); 8574 } } if ($eqeq(author_metadata['$[]']("authorcount"), 0)) { 8575 if ($truthy(authorcount)) { 8576 author_metadata = nil; 8577 } else { 8578 doc_attrs['$[]=']("authorcount", 0); 8579 } 8580 } else { 8581 8582 doc_attrs.$update(author_metadata); 8583 if (($not(doc_attrs['$key?']("email")) && ($truthy(doc_attrs['$key?']("email_1"))))) { 8584 doc_attrs['$[]=']("email", doc_attrs['$[]']("email_1")); 8585 } } } if ($truthy(retrieve)) { 8586 return implicit_author_metadata.$merge(rev_metadata.$to_h(), author_metadata.$to_h()) 8587 } else { 8588 return nil 8589 } }, -2); 8590 $defs(self, '$process_authors', function $$process_authors(author_line, names_only, multiple) { 8591 var author_metadata = nil, author_idx = nil; 8592 8593 8594 if (names_only == null) names_only = false; 8595 if (multiple == null) multiple = true; 8596 author_metadata = $hash2([], {}); 8597 author_idx = 0; 8598 $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; 8599 8600 8601 if (author_entry == null) author_entry = nil; 8602 if ($truthy(author_entry['$empty?']())) { 8603 return nil 8604 } key_map = $hash2([], {}); 8605 if ($eqeq((author_idx = $rb_plus(author_idx, 1)), 1)) { 8606 $send($$('AuthorKeys'), 'each', [], function $$27(key){var $a; 8607 8608 8609 if (key == null) key = nil; 8610 return ($a = [key.$to_sym(), key], $send(key_map, '[]=', $a), $a[$a.length - 1]);}); 8611 } else { 8612 $send($$('AuthorKeys'), 'each', [], function $$28(key){var $a; 8613 8614 8615 if (key == null) key = nil; 8616 return ($a = [key.$to_sym(), "" + (key) + "_" + (author_idx)], $send(key_map, '[]=', $a), $a[$a.length - 1]);}); 8617 } if ($truthy(names_only)) { 8618 8619 if ($truthy(author_entry['$include?']("<"))) { 8620 8621 author_metadata['$[]='](key_map['$[]']("author"), author_entry.$tr("_", " ")); 8622 author_entry = author_entry.$gsub($$('XmlSanitizeRx'), ""); 8623 } if ($eqeq((segments = author_entry.$split(nil, 3)).$size(), 3)) { 8624 segments['$<<'](segments.$pop().$squeeze(" ")); 8625 } } else if ($truthy((match = $$('AuthorInfoLineRx').$match(author_entry)))) { 8626 (segments = match.$to_a()).$shift(); 8627 } if ($truthy(segments)) { 8628 8629 author = ($a = [key_map['$[]']("firstname"), (fname = segments['$[]'](0).$tr("_", " "))], $send(author_metadata, '[]=', $a), $a[$a.length - 1]); 8630 author_metadata['$[]='](key_map['$[]']("authorinitials"), fname.$chr()); 8631 if ($truthy(segments['$[]'](1))) { 8632 if ($truthy(segments['$[]'](2))) { 8633 8634 author_metadata['$[]='](key_map['$[]']("middlename"), (mname = segments['$[]'](1).$tr("_", " "))); 8635 author_metadata['$[]='](key_map['$[]']("lastname"), (lname = segments['$[]'](2).$tr("_", " "))); 8636 author = $rb_plus($rb_plus($rb_plus($rb_plus(fname, " "), mname), " "), lname); 8637 author_metadata['$[]='](key_map['$[]']("authorinitials"), "" + (fname.$chr()) + (mname.$chr()) + (lname.$chr())); 8638 } else { 8639 8640 author_metadata['$[]='](key_map['$[]']("lastname"), (lname = segments['$[]'](1).$tr("_", " "))); 8641 author = $rb_plus($rb_plus(fname, " "), lname); 8642 author_metadata['$[]='](key_map['$[]']("authorinitials"), "" + (fname.$chr()) + (lname.$chr())); 8643 } 8644 } if ($truthy((author_metadata['$[]'](key_map['$[]']("author"))))) ; else { 8645 author_metadata['$[]='](key_map['$[]']("author"), author); 8646 } if (!($truthy(names_only) || ($not(segments['$[]'](3))))) { 8647 author_metadata['$[]='](key_map['$[]']("email"), segments['$[]'](3)); 8648 } } else { 8649 8650 author_metadata['$[]='](key_map['$[]']("author"), ($a = [key_map['$[]']("firstname"), (fname = author_entry.$squeeze(" ").$strip())], $send(author_metadata, '[]=', $a), $a[$a.length - 1])); 8651 author_metadata['$[]='](key_map['$[]']("authorinitials"), fname.$chr()); 8652 } if ($eqeq(author_idx, 1)) { 8653 return ($a = ["authors", author_metadata['$[]'](key_map['$[]']("author"))], $send(author_metadata, '[]=', $a), $a[$a.length - 1]) 8654 } else { 8655 8656 if ($eqeq(author_idx, 2)) { 8657 $send($$('AuthorKeys'), 'each', [], function $$29(key){var $b; 8658 8659 8660 if (key == null) key = nil; 8661 if ($truthy(author_metadata['$key?'](key))) { 8662 return ($b = ["" + (key) + "_1", author_metadata['$[]'](key)], $send(author_metadata, '[]=', $b), $b[$b.length - 1]) 8663 } else { 8664 return nil 8665 }}); 8666 } return ($a = ["authors", "" + (author_metadata['$[]']("authors")) + ", " + (author_metadata['$[]'](key_map['$[]']("author")))], $send(author_metadata, '[]=', $a), $a[$a.length - 1]); 8667 }}); 8668 author_metadata['$[]=']("authorcount", author_idx); 8669 return author_metadata; 8670 }, -2); 8671 $defs(self, '$parse_block_metadata_lines', function $$parse_block_metadata_lines(reader, document, attributes, options) { 8672 var self = this; 8673 8674 8675 if (attributes == null) attributes = $hash2([], {}); 8676 if (options == null) options = $hash2([], {}); 8677 while ($truthy(self.$parse_block_metadata_line(reader, document, attributes, options))) { 8678 8679 reader.$shift(); 8680 if ($truthy((reader.$skip_blank_lines()))) ; else { 8681 break 8682 } } return attributes; 8683 }, -3); 8684 $defs(self, '$parse_block_metadata_line', function $$parse_block_metadata_line(reader, document, attributes, options) { 8685 var $a, self = this, normal = nil, next_line = nil, reftext = nil, current_style = nil, $ret_or_1 = nil, ll = nil; 8686 if ($gvars["~"] == null) $gvars["~"] = nil; 8687 8688 8689 if (options == null) options = $hash2([], {}); 8690 if (($truthy((next_line = reader.$peek_line())) && ($truthy(($truthy(options['$[]']("text_only")) ? (next_line['$start_with?']("[", "/")) : ((normal = next_line['$start_with?']("[", ".", "/", ":")))))))) { 8691 if ($truthy(next_line['$start_with?']("["))) { 8692 if ($truthy(next_line['$start_with?']("[["))) { 8693 if (($truthy(next_line['$end_with?']("]]")) && ($truthy($$('BlockAnchorRx')['$=~'](next_line))))) { 8694 8695 attributes['$[]=']("id", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))); 8696 if ($truthy((reftext = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2))))) { 8697 attributes['$[]=']("reftext", ($truthy(reftext['$include?']($$('ATTR_REF_HEAD'))) ? (document.$sub_attributes(reftext)) : (reftext))); 8698 } return true; 8699 } 8700 } else if (($truthy(next_line['$end_with?']("]")) && ($truthy($$('BlockAttributeListRx')['$=~'](next_line))))) { 8701 8702 current_style = attributes['$[]'](1); 8703 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))) { 8704 attributes['$[]='](1, ($truthy(($ret_or_1 = self.$parse_style_attribute(attributes, reader))) ? ($ret_or_1) : (current_style))); 8705 } return true; 8706 } 8707 } else if (($truthy(normal) && ($truthy(next_line['$start_with?']("."))))) { 8708 if ($truthy($$('BlockTitleRx')['$=~'](next_line))) { 8709 8710 attributes['$[]=']("title", (($a = $gvars['~']) === nil ? nil : $a['$[]'](1))); 8711 return true; 8712 } 8713 } else if (($not(normal) || ($truthy(next_line['$start_with?']("/"))))) { 8714 if ($truthy(next_line['$start_with?']("//"))) { 8715 if ($eqeq(next_line, "//")) { 8716 return true 8717 } else if (($truthy(normal) && ($truthy(self['$uniform?'](next_line, "/", (ll = next_line.$length())))))) { 8718 if (!$eqeq(ll, 3)) { 8719 8720 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"})); 8721 return true; 8722 } 8723 } else if (!$truthy(next_line['$start_with?']("///"))) { 8724 return true 8725 } 8726 } 8727 } else if ((($truthy(normal) && ($truthy(next_line['$start_with?'](":")))) && ($truthy($$('AttributeEntryRx')['$=~'](next_line))))) { 8728 8729 self.$process_attribute_entry(reader, document, attributes, $gvars["~"]); 8730 return true; 8731 } 8732 } return nil; 8733 }, -4); 8734 $defs(self, '$process_attribute_entries', function $$process_attribute_entries(reader, document, attributes) { 8735 var self = this; 8736 8737 8738 if (attributes == null) attributes = nil; 8739 reader.$skip_comment_lines(); 8740 while ($truthy(self.$process_attribute_entry(reader, document, attributes))) { 8741 8742 reader.$shift(); 8743 reader.$skip_comment_lines(); 8744 } }, -3); 8745 $defs(self, '$process_attribute_entry', function $$process_attribute_entry(reader, document, attributes, match) { 8746 var $a, self = this, value = nil, con = nil, $ret_or_1 = nil, next_line = nil, $ret_or_2 = nil, keep_open = nil; 8747 8748 8749 if (attributes == null) attributes = nil; 8750 if (match == null) match = nil; 8751 if (($truthy(match) || ($truthy((match = ($truthy(reader['$has_more_lines?']()) ? ($$('AttributeEntryRx').$match(reader.$peek_line())) : (nil))))))) { 8752 8753 if ($truthy((value = match['$[]'](2))['$nil_or_empty?']())) { 8754 value = ""; 8755 } else if ($truthy(value['$end_with?']($$('LINE_CONTINUATION'), $$('LINE_CONTINUATION_LEGACY')))) { 8756 8757 $a = [value.$slice($rb_minus(value.$length(), 2), 2), value.$slice(0, $rb_minus(value.$length(), 2)).$rstrip()], (con = $a[0]), (value = $a[1]); 8758 while ($truthy(($truthy(($ret_or_1 = reader.$advance())) ? ((next_line = ($truthy(($ret_or_2 = reader.$peek_line())) ? ($ret_or_2) : ("")))['$empty?']()['$!']()) : ($ret_or_1)))) { 8759 8760 next_line = next_line.$lstrip(); 8761 if ($truthy((keep_open = next_line['$end_with?'](con)))) { 8762 next_line = next_line.$slice(0, $rb_minus(next_line.$length(), 2)).$rstrip(); 8763 } value = "" + (value) + (($truthy(value['$end_with?']($$('HARD_LINE_BREAK'))) ? ($$('LF')) : (" "))) + (next_line); 8764 if (!$truthy(keep_open)) { 8765 break 8766 } } } self.$store_attribute(match['$[]'](1), value, document, attributes); 8767 return true; 8768 } else { 8769 return nil 8770 } }, -3); 8771 $defs(self, '$store_attribute', function $$store_attribute(name, value, doc, attrs) { 8772 var self = this, resolved_value = nil; 8773 8774 8775 if (doc == null) doc = nil; 8776 if (attrs == null) attrs = nil; 8777 if ($truthy(name['$end_with?']("!"))) { 8778 8779 name = name.$chop(); 8780 value = nil; 8781 } else if ($truthy(name['$start_with?']("!"))) { 8782 8783 name = name.$slice(1, name.$length()); 8784 value = nil; 8785 } if ($eqeq((name = self.$sanitize_attribute_name(name)), "numbered")) { 8786 name = "sectnums"; 8787 } else if ($eqeq(name, "hardbreaks")) { 8788 name = "hardbreaks-option"; 8789 } else if ($eqeq(name, "showtitle")) { 8790 self.$store_attribute("notitle", ($truthy(value) ? (nil) : ("")), doc, attrs); 8791 } if ($truthy(doc)) { 8792 if ($truthy(value)) { 8793 8794 if ($eqeq(name, "leveloffset")) { 8795 if ($truthy(value['$start_with?']("+"))) { 8796 value = $rb_plus(doc.$attr("leveloffset", 0).$to_i(), value.$slice(1, value.$length()).$to_i()).$to_s(); 8797 } else if ($truthy(value['$start_with?']("-"))) { 8798 value = $rb_minus(doc.$attr("leveloffset", 0).$to_i(), value.$slice(1, value.$length()).$to_i()).$to_s(); 8799 } 8800 } if ($truthy((resolved_value = doc.$set_attribute(name, value)))) { 8801 8802 value = resolved_value; 8803 if ($truthy(attrs)) { 8804 $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs); 8805 } } } else if (($truthy(doc.$delete_attribute(name)) && ($truthy(attrs)))) { 8806 $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs); 8807 } 8808 } else if ($truthy(attrs)) { 8809 $$$($$('Document'), 'AttributeEntry').$new(name, value).$save_to(attrs); 8810 } return [name, value]; 8811 }, -3); 8812 $defs(self, '$resolve_list_marker', function $$resolve_list_marker(list_type, marker, ordinal, validate, reader) { 8813 var self = this; 8814 8815 8816 if (ordinal == null) ordinal = 0; 8817 if (validate == null) validate = false; 8818 if (reader == null) reader = nil; 8819 8820 switch (list_type) { 8821 case "ulist": 8822 return marker 8823 case "olist": 8824 return self.$resolve_ordered_list_marker(marker, ordinal, validate, reader)['$[]'](0) 8825 default: 8826 return "<1>" 8827 } }, -3); 8828 $defs(self, '$resolve_ordered_list_marker', function $$resolve_ordered_list_marker(marker, ordinal, validate, reader) { 8829 var self = this, style = nil, expected = nil, actual = nil; 8830 8831 8832 if (ordinal == null) ordinal = 0; 8833 if (validate == null) validate = false; 8834 if (reader == null) reader = nil; 8835 if ($truthy(marker['$start_with?']("."))) { 8836 return [marker] 8837 } 8838 switch ((style = $send($$('ORDERED_LIST_STYLES'), 'find', [], function $$30(s){ 8839 8840 if (s == null) s = nil; 8841 return $$('OrderedListMarkerRxMap')['$[]'](s)['$match?'](marker);}))) { 8842 case "arabic": 8843 8844 if ($truthy(validate)) { 8845 8846 expected = $rb_plus(ordinal, 1); 8847 actual = marker.$to_i(); 8848 } marker = "1."; 8849 break; 8850 case "loweralpha": 8851 8852 if ($truthy(validate)) { 8853 8854 expected = $rb_plus("a"['$[]'](0).$ord(), ordinal).$chr(); 8855 actual = marker.$chop(); 8856 } marker = "a."; 8857 break; 8858 case "upperalpha": 8859 8860 if ($truthy(validate)) { 8861 8862 expected = $rb_plus("A"['$[]'](0).$ord(), ordinal).$chr(); 8863 actual = marker.$chop(); 8864 } marker = "A."; 8865 break; 8866 case "lowerroman": 8867 8868 if ($truthy(validate)) { 8869 8870 expected = $$('Helpers').$int_to_roman($rb_plus(ordinal, 1)).$downcase(); 8871 actual = marker.$chop(); 8872 } marker = "i)"; 8873 break; 8874 case "upperroman": 8875 8876 if ($truthy(validate)) { 8877 8878 expected = $$('Helpers').$int_to_roman($rb_plus(ordinal, 1)); 8879 actual = marker.$chop(); 8880 } marker = "I)"; 8881 break; 8882 } if (($truthy(validate) && ($neqeq(expected, actual)))) { 8883 self.$logger().$warn(self.$message_with_context("list item index: expected " + (expected) + ", got " + (actual), $hash2(["source_location"], {"source_location": reader.$cursor()}))); 8884 } return [marker, style]; 8885 }, -2); 8886 $defs(self, '$is_sibling_list_item?', function $Parser_is_sibling_list_item$ques$31(line, list_type, sibling_trait) { 8887 var $a, self = this, $ret_or_1 = nil; 8888 8889 if ($eqeqeq($$$('Regexp'), sibling_trait)) { 8890 return sibling_trait['$match?'](line) 8891 } else if ($truthy(($ret_or_1 = $$('ListRxMap')['$[]'](list_type)['$=~'](line)))) { 8892 return sibling_trait['$=='](self.$resolve_list_marker(list_type, (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)))) 8893 } else { 8894 return $ret_or_1 8895 } 8896 }); 8897 $defs(self, '$parse_table', function $$parse_table(table_reader, parent, attributes) { 8898 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; 8899 8900 8901 table = $$('Table').$new(parent, attributes); 8902 if (($truthy(attributes['$key?']("cols")) && ($not((colspecs = self.$parse_colspecs(attributes['$[]']("cols")))['$empty?']())))) { 8903 8904 table.$create_columns(colspecs); 8905 explicit_colspecs = true; 8906 } skipped = ($truthy(($ret_or_1 = table_reader.$skip_blank_lines())) ? ($ret_or_1) : (0)); 8907 if ($truthy(attributes['$[]']("header-option"))) { 8908 table['$has_header_option='](true); 8909 } else if (($eqeq(skipped, 0) && ($not(attributes['$[]']("noheader-option"))))) { 8910 8911 table['$has_header_option=']("implicit"); 8912 implicit_header = true; 8913 } parser_ctx = $$$($$('Table'), 'ParserContext').$new(table_reader, table, attributes); 8914 $a = [parser_ctx.$format(), -1, nil], (format = $a[0]), (loop_idx = $a[1]), (implicit_header_boundary = $a[2]); 8915 while ($truthy((line = table_reader.$read_line()))) { 8916 8917 if (($truthy((beyond_first = $rb_gt((loop_idx = $rb_plus(loop_idx, 1)), 0))) && ($truthy(line['$empty?']())))) { 8918 8919 line = nil; 8920 if ($truthy(implicit_header_boundary)) { 8921 implicit_header_boundary = $rb_plus(implicit_header_boundary, 1); 8922 } } else if ($eqeq(format, "psv")) { 8923 if ($truthy(parser_ctx['$starts_with_delimiter?'](line))) { 8924 8925 line = line.$slice(1, line.$length()); 8926 parser_ctx.$close_open_cell(); 8927 if ($truthy(implicit_header_boundary)) { 8928 implicit_header_boundary = nil; 8929 } } else { 8930 8931 $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])); 8932 if ($truthy(next_cellspec)) { 8933 8934 parser_ctx.$close_open_cell(next_cellspec); 8935 if ($truthy(implicit_header_boundary)) { 8936 implicit_header_boundary = nil; 8937 } } else if (($truthy(implicit_header_boundary) && ($eqeq(implicit_header_boundary, loop_idx)))) { 8938 table['$has_header_option=']((implicit_header = (implicit_header_boundary = nil))); 8939 } } 8940 } if (!$truthy(beyond_first)) { 8941 8942 table_reader.$mark(); 8943 if ($truthy(implicit_header)) { 8944 if (($truthy(table_reader['$has_more_lines?']()) && ($truthy(table_reader.$peek_line()['$empty?']())))) { 8945 implicit_header_boundary = 1; 8946 } else { 8947 table['$has_header_option=']((implicit_header = nil)); 8948 } 8949 } } $a = false;while ($a || $truthy(true)) {$a = false; 8950 if (($truthy(line) && ($truthy((m = parser_ctx.$match_delimiter(line)))))) { 8951 8952 $b = [m.$pre_match(), m.$post_match()], (pre_match = $b[0]), (post_match = $b[1]); 8953 if ($eqeqeq("csv", ($ret_or_1 = format))) { 8954 8955 if ($truthy(parser_ctx['$buffer_has_unclosed_quotes?'](pre_match))) { 8956 8957 parser_ctx.$skip_past_delimiter(pre_match); 8958 if ($truthy((line = post_match)['$empty?']())) { 8959 break 8960 } $a = true;continue; 8961 } parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (pre_match)); 8962 } else if ($eqeqeq("dsv", $ret_or_1)) { 8963 8964 if ($truthy(pre_match['$end_with?']("\\"))) { 8965 8966 parser_ctx.$skip_past_escaped_delimiter(pre_match); 8967 if ($truthy((line = post_match)['$empty?']())) { 8968 8969 parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + ($$('LF'))); 8970 parser_ctx.$keep_cell_open(); 8971 break; 8972 } $a = true;continue; 8973 } parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (pre_match)); 8974 } else { 8975 8976 if ($truthy(pre_match['$end_with?']("\\"))) { 8977 8978 parser_ctx.$skip_past_escaped_delimiter(pre_match); 8979 if ($truthy((line = post_match)['$empty?']())) { 8980 8981 parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + ($$('LF'))); 8982 parser_ctx.$keep_cell_open(); 8983 break; 8984 } $a = true;continue; 8985 } $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])); 8986 parser_ctx.$push_cellspec(next_cellspec); 8987 parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (cell_text)); 8988 } if ($truthy((line = post_match)['$empty?']())) { 8989 line = nil; 8990 } parser_ctx.$close_cell(); 8991 } else { 8992 8993 parser_ctx['$buffer=']("" + (parser_ctx.$buffer()) + (line) + ($$('LF'))); 8994 8995 switch (format) { 8996 case "csv": 8997 if ($truthy(parser_ctx['$buffer_has_unclosed_quotes?']())) { 8998 8999 if (($truthy(implicit_header_boundary) && ($eqeq(loop_idx, 0)))) { 9000 table['$has_header_option=']((implicit_header = (implicit_header_boundary = nil))); 9001 } parser_ctx.$keep_cell_open(); 9002 } else { 9003 parser_ctx.$close_cell(true); 9004 } 9005 break; 9006 case "dsv": 9007 parser_ctx.$close_cell(true); 9008 break; 9009 default: 9010 parser_ctx.$keep_cell_open(); 9011 } break; 9012 } 9013 } if ($truthy(parser_ctx['$cell_open?']())) { 9014 if (!$truthy(table_reader['$has_more_lines?']())) { 9015 parser_ctx.$close_cell(true); 9016 } 9017 } else if ($truthy(($ret_or_1 = table_reader.$skip_blank_lines()))) ; else { 9018 break 9019 } } 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)))) { 9020 table.$assign_column_widths(); 9021 } if ($truthy(implicit_header)) { 9022 table['$has_header_option='](true); 9023 } table.$partition_header_footer(attributes); 9024 return table; 9025 }); 9026 $defs(self, '$parse_colspecs', function $$parse_colspecs(records) { 9027 var specs = nil; 9028 9029 9030 if ($truthy(records['$include?'](" "))) { 9031 records = records.$delete(" "); 9032 } if ($eqeq(records, records.$to_i().$to_s())) { 9033 return $send($$$('Array'), 'new', [records.$to_i()], function $$32(){ 9034 return $hash2(["width"], {"width": 1})}) 9035 } specs = []; 9036 $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; 9037 9038 9039 if (record == null) record = nil; 9040 if ($truthy(record['$empty?']())) { 9041 return specs['$<<']($hash2(["width"], {"width": 1})) 9042 } else if ($truthy((m = $$('ColumnSpecRx').$match(record)))) { 9043 9044 spec = $hash2([], {}); 9045 if ($truthy(m['$[]'](2))) { 9046 9047 $b = m['$[]'](2).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])); 9048 if (($not(colspec['$nil_or_empty?']()) && ($truthy($$('TableCellHorzAlignments')['$key?'](colspec))))) { 9049 spec['$[]=']("halign", $$('TableCellHorzAlignments')['$[]'](colspec)); 9050 } if (($not(rowspec['$nil_or_empty?']()) && ($truthy($$('TableCellVertAlignments')['$key?'](rowspec))))) { 9051 spec['$[]=']("valign", $$('TableCellVertAlignments')['$[]'](rowspec)); 9052 } } if ($truthy((width = m['$[]'](3)))) { 9053 spec['$[]=']("width", ($eqeq(width, "~") ? (-1) : (width.$to_i()))); 9054 } else { 9055 spec['$[]=']("width", 1); 9056 } if (($truthy(m['$[]'](4)) && ($truthy($$('TableCellStyles')['$key?'](m['$[]'](4)))))) { 9057 spec['$[]=']("style", $$('TableCellStyles')['$[]'](m['$[]'](4))); 9058 } if ($truthy(m['$[]'](1))) { 9059 return $send((1), 'upto', [m['$[]'](1).$to_i()], function $$34(){ 9060 return specs['$<<'](spec.$merge())}) 9061 } else { 9062 return specs['$<<'](spec) 9063 } } else { 9064 return nil 9065 }}); 9066 return specs; 9067 }); 9068 $defs(self, '$parse_cellspec', function $$parse_cellspec(line, pos, delimiter) { 9069 var $a, $b, m = nil, rest = nil, spec_part = nil, spec = nil, colspec = nil, rowspec = nil; 9070 9071 9072 if (pos == null) pos = "end"; 9073 if (delimiter == null) delimiter = nil; 9074 $a = [nil, ""], (m = $a[0]), (rest = $a[1]); 9075 if ($eqeq(pos, "start")) { 9076 if ($truthy(line['$include?'](delimiter))) { 9077 9078 $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])); 9079 if ($truthy((m = $$('CellSpecStartRx').$match(spec_part)))) { 9080 if ($truthy(m['$[]'](0)['$empty?']())) { 9081 return [$hash2([], {}), rest] 9082 } 9083 } else { 9084 return [nil, line] 9085 } } else { 9086 return [nil, line] 9087 } 9088 } else if ($truthy((m = $$('CellSpecEndRx').$match(line)))) { 9089 9090 if ($truthy(m['$[]'](0).$lstrip()['$empty?']())) { 9091 return [$hash2([], {}), line.$rstrip()] 9092 } rest = m.$pre_match(); 9093 } else { 9094 return [$hash2([], {}), line] 9095 } spec = $hash2([], {}); 9096 if ($truthy(m['$[]'](1))) { 9097 9098 $b = m['$[]'](1).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])); 9099 colspec = ($truthy(colspec['$nil_or_empty?']()) ? (1) : (colspec.$to_i())); 9100 rowspec = ($truthy(rowspec['$nil_or_empty?']()) ? (1) : (rowspec.$to_i())); 9101 9102 switch (m['$[]'](2)) { 9103 case "+": 9104 9105 if (!$eqeq(colspec, 1)) { 9106 spec['$[]=']("colspan", colspec); 9107 } if (!$eqeq(rowspec, 1)) { 9108 spec['$[]=']("rowspan", rowspec); 9109 } break; 9110 case "*": 9111 if (!$eqeq(colspec, 1)) { 9112 spec['$[]=']("repeatcol", colspec); 9113 } 9114 break; 9115 } } if ($truthy(m['$[]'](3))) { 9116 9117 $b = m['$[]'](3).$split("."), $a = $to_ary($b), (colspec = ($a[0] == null ? nil : $a[0])), (rowspec = ($a[1] == null ? nil : $a[1])); 9118 if (($not(colspec['$nil_or_empty?']()) && ($truthy($$('TableCellHorzAlignments')['$key?'](colspec))))) { 9119 spec['$[]=']("halign", $$('TableCellHorzAlignments')['$[]'](colspec)); 9120 } if (($not(rowspec['$nil_or_empty?']()) && ($truthy($$('TableCellVertAlignments')['$key?'](rowspec))))) { 9121 spec['$[]=']("valign", $$('TableCellVertAlignments')['$[]'](rowspec)); 9122 } } if (($truthy(m['$[]'](4)) && ($truthy($$('TableCellStyles')['$key?'](m['$[]'](4)))))) { 9123 spec['$[]=']("style", $$('TableCellStyles')['$[]'](m['$[]'](4))); 9124 } return [spec, rest]; 9125 }, -2); 9126 $defs(self, '$parse_style_attribute', function $$parse_style_attribute(attributes, reader) { 9127 var $a, self = this, raw_style = nil, name = nil, accum = nil, parsed_attrs = nil, parsed_style = nil, existing_role = nil; 9128 9129 9130 if (reader == null) reader = nil; 9131 if ((($truthy((raw_style = attributes['$[]'](1))) && ($not(raw_style['$include?'](" ")))) && ($truthy($$('Compliance').$shorthand_property_syntax())))) { 9132 9133 name = nil; 9134 accum = ""; 9135 parsed_attrs = $hash2([], {}); 9136 $send(raw_style, 'each_char', [], function $$35(c){var self = $$35.$$s == null ? this : $$35.$$s; 9137 9138 9139 if (c == null) c = nil; 9140 9141 switch (c) { 9142 case ".": 9143 9144 self.$yield_buffered_attribute(parsed_attrs, name, accum, reader); 9145 accum = ""; 9146 return (name = "role"); 9147 case "#": 9148 9149 self.$yield_buffered_attribute(parsed_attrs, name, accum, reader); 9150 accum = ""; 9151 return (name = "id"); 9152 case "%": 9153 9154 self.$yield_buffered_attribute(parsed_attrs, name, accum, reader); 9155 accum = ""; 9156 return (name = "option"); 9157 default: 9158 return (accum = $rb_plus(accum, c)) 9159 }}, {$$s: self}); 9160 if ($truthy(name)) { 9161 9162 self.$yield_buffered_attribute(parsed_attrs, name, accum, reader); 9163 if ($truthy((parsed_style = parsed_attrs['$[]']("style")))) { 9164 attributes['$[]=']("style", parsed_style); 9165 } if ($truthy(parsed_attrs['$key?']("id"))) { 9166 attributes['$[]=']("id", parsed_attrs['$[]']("id")); 9167 } if ($truthy(parsed_attrs['$key?']("role"))) { 9168 attributes['$[]=']("role", ($truthy((existing_role = attributes['$[]']("role"))['$nil_or_empty?']()) ? (parsed_attrs['$[]']("role").$join(" ")) : ("" + (existing_role) + " " + (parsed_attrs['$[]']("role").$join(" "))))); 9169 } if ($truthy(parsed_attrs['$key?']("option"))) { 9170 $send(parsed_attrs['$[]']("option"), 'each', [], function $$36(opt){var $a; 9171 9172 9173 if (opt == null) opt = nil; 9174 return ($a = ["" + (opt) + "-option", ""], $send(attributes, '[]=', $a), $a[$a.length - 1]);}); 9175 } return parsed_style; 9176 } else { 9177 return ($a = ["style", raw_style], $send(attributes, '[]=', $a), $a[$a.length - 1]) 9178 } } else { 9179 return ($a = ["style", raw_style], $send(attributes, '[]=', $a), $a[$a.length - 1]) 9180 } }, -2); 9181 $defs(self, '$yield_buffered_attribute', function $$yield_buffered_attribute(attrs, name, value, reader) { 9182 var $a, self = this, $ret_or_1 = nil; 9183 9184 9185 if ($truthy(name)) { 9186 if ($truthy(value['$empty?']())) { 9187 if ($truthy(reader)) { 9188 self.$logger().$warn(self.$message_with_context("invalid empty " + (name) + " detected in style attribute", $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()}))); 9189 } else { 9190 self.$logger().$warn("invalid empty " + (name) + " detected in style attribute"); 9191 } 9192 } else if ($eqeq(name, "id")) { 9193 9194 if ($truthy(attrs['$key?']("id"))) { 9195 if ($truthy(reader)) { 9196 self.$logger().$warn(self.$message_with_context("multiple ids detected in style attribute", $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()}))); 9197 } else { 9198 self.$logger().$warn("multiple ids detected in style attribute"); 9199 } 9200 } attrs['$[]='](name, value); 9201 } else { 9202 ($truthy(($ret_or_1 = attrs['$[]'](name))) ? ($ret_or_1) : (($a = [name, []], $send(attrs, '[]=', $a), $a[$a.length - 1])))['$<<'](value); 9203 } 9204 } else if (!$truthy(value['$empty?']())) { 9205 attrs['$[]=']("style", value); 9206 } return nil; 9207 }); 9208 $defs(self, '$adjust_indentation!', function $Parser_adjust_indentation$excl$37(lines, indent_size, tab_size) { 9209 var full_tab_space = nil, block_indent = nil, new_block_indent = nil; 9210 9211 9212 if (indent_size == null) indent_size = 0; 9213 if (tab_size == null) tab_size = 0; 9214 if ($truthy(lines['$empty?']())) { 9215 return nil 9216 } if (($truthy($rb_gt(tab_size, 0)) && ($truthy($send(lines, 'any?', [], function $$38(line){ 9217 9218 if (line == null) line = nil; 9219 return line['$include?']($$('TAB'));}))))) { 9220 9221 full_tab_space = $rb_times(" ", tab_size); 9222 $send(lines, 'map!', [], function $$39(line){var tab_idx = nil, leading_tabs = nil, spaces_added = nil, idx = nil, result = nil; 9223 9224 9225 if (line == null) line = nil; 9226 if (($truthy(line['$empty?']()) || ($truthy((tab_idx = line.$index($$('TAB')))['$nil?']())))) { 9227 return line 9228 } else { 9229 9230 if ($eqeq(tab_idx, 0)) { 9231 9232 leading_tabs = 0; 9233 (function(){try { var $t_break = $thrower('break'); return $send(line, 'each_byte', [], function $$40(b){ 9234 9235 if (b == null) b = nil; 9236 if (!$eqeq(b, 9)) { 9237 $t_break.$throw(); 9238 }; 9239 return (leading_tabs = $rb_plus(leading_tabs, 1));})} catch($e) { 9240 if ($e === $t_break) return $e.$v; 9241 throw $e; 9242 }})(); 9243 line = "" + ($rb_times(full_tab_space, leading_tabs)) + (line.$slice(leading_tabs, line.$length())); 9244 if (!$truthy(line['$include?']($$('TAB')))) { 9245 return line 9246 } } spaces_added = 0; 9247 idx = 0; 9248 result = ""; 9249 $send(line, 'each_char', [], function $$41(c){var offset = nil, spaces = nil; 9250 9251 9252 if (c == null) c = nil; 9253 if ($eqeq(c, $$('TAB'))) { 9254 if ($eqeq((offset = $rb_plus(idx, spaces_added))['$%'](tab_size), 0)) { 9255 9256 spaces_added = $rb_plus(spaces_added, $rb_minus(tab_size, 1)); 9257 result = $rb_plus(result, full_tab_space); 9258 } else { 9259 9260 if (!$eqeq((spaces = $rb_minus(tab_size, offset['$%'](tab_size))), 1)) { 9261 spaces_added = $rb_plus(spaces_added, $rb_minus(spaces, 1)); 9262 } result = $rb_plus(result, $rb_times(" ", spaces)); 9263 } 9264 } else { 9265 result = $rb_plus(result, c); 9266 } return (idx = $rb_plus(idx, 1));}); 9267 return result; 9268 }}); 9269 } if ($truthy($rb_lt(indent_size, 0))) { 9270 return nil 9271 } block_indent = nil; 9272 (function(){try { var $t_break = $thrower('break'); return $send(lines, 'each', [], function $$42(line){var line_indent = nil; 9273 9274 9275 if (line == null) line = nil; 9276 if ($truthy(line['$empty?']())) { 9277 return nil 9278 }; 9279 if ($eqeq((line_indent = $rb_minus(line.$length(), line.$lstrip().$length())), 0)) { 9280 9281 block_indent = nil; 9282 $t_break.$throw(); 9283 }; 9284 if (($truthy(block_indent) && ($truthy($rb_lt(block_indent, line_indent))))) { 9285 return nil 9286 } else { 9287 return (block_indent = line_indent) 9288 };})} catch($e) { 9289 if ($e === $t_break) return $e.$v; 9290 throw $e; 9291 }})(); 9292 if ($eqeq(indent_size, 0)) { 9293 if ($truthy(block_indent)) { 9294 $send(lines, 'map!', [], function $$43(line){ 9295 9296 if (line == null) line = nil; 9297 if ($truthy(line['$empty?']())) { 9298 return line 9299 } else { 9300 9301 return line.$slice(block_indent, line.$length()); 9302 }}); 9303 } 9304 } else { 9305 9306 new_block_indent = $rb_times(" ", indent_size); 9307 if ($truthy(block_indent)) { 9308 $send(lines, 'map!', [], function $$44(line){ 9309 9310 if (line == null) line = nil; 9311 if ($truthy(line['$empty?']())) { 9312 return line 9313 } else { 9314 return $rb_plus(new_block_indent, line.$slice(block_indent, line.$length())) 9315 }}); 9316 } else { 9317 $send(lines, 'map!', [], function $$45(line){ 9318 9319 if (line == null) line = nil; 9320 if ($truthy(line['$empty?']())) { 9321 return line 9322 } else { 9323 return $rb_plus(new_block_indent, line) 9324 }}); 9325 } } return nil; 9326 }, -2); 9327 $defs(self, '$uniform?', function $Parser_uniform$ques$46(str, chr, len) { 9328 9329 return str.$count(chr)['$=='](len) 9330 }); 9331 return $defs(self, '$sanitize_attribute_name', function $$sanitize_attribute_name(name) { 9332 9333 return name.$gsub($$('InvalidAttributeNameCharsRx'), "").$downcase() 9334 }); 9335 })($nesting[0], null, $nesting) 9336 })($nesting[0], $nesting) 9337}; 9338 9339Opal.modules["asciidoctor/path_resolver"] = function(Opal) {/* Generated by Opal 1.7.3 */ 9340 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.$$$; 9341 9342 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,=~'); 9343 return (function($base, $parent_nesting) { 9344 var self = $module($base, 'Asciidoctor'); 9345 9346 var $nesting = [self].concat($parent_nesting); 9347 9348 return (function($base, $super, $parent_nesting) { 9349 var self = $klass($base, $super, 'PathResolver'); 9350 9351 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 9352 9353 $proto.file_separator = $proto._partition_path_web = $proto._partition_path_sys = $proto.working_dir = nil; 9354 9355 self.$include($$('Logging')); 9356 $const_set($nesting[0], 'DOT', "."); 9357 $const_set($nesting[0], 'DOT_DOT', ".."); 9358 $const_set($nesting[0], 'DOT_SLASH', "./"); 9359 $const_set($nesting[0], 'SLASH', "/"); 9360 $const_set($nesting[0], 'BACKSLASH', "\\"); 9361 $const_set($nesting[0], 'DOUBLE_SLASH', "//"); 9362 $const_set($nesting[0], 'URI_CLASSLOADER', "uri:classloader:"); 9363 $const_set($nesting[0], 'WindowsRootRx', /^(?:[a-zA-Z]:)?[\\\/]/); 9364 self.$attr_accessor("file_separator"); 9365 self.$attr_accessor("working_dir"); 9366 9367 $def(self, '$initialize', function $$initialize(file_separator, working_dir) { 9368 var self = this, $ret_or_1 = nil, $ret_or_2 = nil; 9369 9370 9371 if (file_separator == null) file_separator = nil; 9372 if (working_dir == null) working_dir = nil; 9373 self.file_separator = ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = file_separator)) ? ($ret_or_2) : ($$$($$$('File'), 'ALT_SEPARATOR'))))) ? ($ret_or_1) : ($$$($$$('File'), 'SEPARATOR'))); 9374 self.working_dir = ($truthy(working_dir) ? (($truthy(self['$root?'](working_dir)) ? (self.$posixify(working_dir)) : ($$$('File').$expand_path(working_dir)))) : ($$$('Dir').$pwd())); 9375 self._partition_path_sys = $hash2([], {}); 9376 return (self._partition_path_web = $hash2([], {})); 9377 }, -1); 9378 9379 $def(self, '$absolute_path?', function $PathResolver_absolute_path$ques$1(path) { 9380 var self = this, $ret_or_1 = nil, $ret_or_2 = nil; 9381 9382 if ($truthy(($ret_or_1 = path['$start_with?']($$('SLASH'))))) { 9383 return $ret_or_1 9384 } else { 9385 9386 if ($truthy(($ret_or_2 = self.file_separator['$==']($$('BACKSLASH'))))) { 9387 9388 return $$('WindowsRootRx')['$match?'](path); 9389 } else { 9390 return $ret_or_2 9391 } } 9392 }); 9393 if (($eqeq($$('RUBY_ENGINE'), "opal") && ($eqeq($$$('JAVASCRIPT_IO_MODULE'), "xmlhttprequest")))) { 9394 9395 $def(self, '$root?', function $PathResolver_root$ques$2(path) { 9396 var self = this, $ret_or_1 = nil; 9397 9398 if ($truthy(($ret_or_1 = self['$absolute_path?'](path)))) { 9399 return $ret_or_1 9400 } else { 9401 9402 return path['$start_with?']("file://", "http://", "https://"); 9403 } 9404 }); 9405 } else if ($eqeq($$$('RUBY_ENGINE'), "jruby")) { 9406 9407 $def(self, '$root?', function $PathResolver_root$ques$3(path) { 9408 var self = this, $ret_or_1 = nil; 9409 9410 if ($truthy(($ret_or_1 = self['$absolute_path?'](path)))) { 9411 return $ret_or_1 9412 } else { 9413 9414 return path['$start_with?']($$('URI_CLASSLOADER')); 9415 } 9416 }); 9417 } else { 9418 $alias(self, "root?", "absolute_path?"); 9419 } 9420 $def(self, '$unc?', function $PathResolver_unc$ques$4(path) { 9421 9422 return path['$start_with?']($$('DOUBLE_SLASH')) 9423 }); 9424 9425 $def(self, '$web_root?', function $PathResolver_web_root$ques$5(path) { 9426 9427 return path['$start_with?']($$('SLASH')) 9428 }); 9429 9430 $def(self, '$descends_from?', function $PathResolver_descends_from$ques$6(path, base) { 9431 var $ret_or_1 = nil; 9432 9433 if ($eqeq(base, path)) { 9434 return 0 9435 } else if ($eqeq(base, $$('SLASH'))) { 9436 if ($truthy(($ret_or_1 = path['$start_with?']($$('SLASH'))))) { 9437 return 1 9438 } else { 9439 return $ret_or_1 9440 } 9441 } else if ($truthy(($ret_or_1 = path['$start_with?']($rb_plus(base, $$('SLASH')))))) { 9442 9443 return $rb_plus(base.$length(), 1); 9444 } else { 9445 return $ret_or_1 9446 } 9447 }); 9448 9449 $def(self, '$relative_path', function $$relative_path(path, base) { 9450 var self = this, offset = nil; 9451 9452 if ($truthy(self['$root?'](path))) { 9453 if ($truthy((offset = self['$descends_from?'](path, base)))) { 9454 return path.$slice(offset, path.$length()) 9455 } else { 9456 9457 try { 9458 return $$('Pathname').$new(path).$relative_path_from($$('Pathname').$new(base)).$to_s() 9459 } catch ($err) { 9460 if (Opal.rescue($err, [$$('StandardError')])) { 9461 try { 9462 return path 9463 } finally { Opal.pop_exception(); } 9464 } else { throw $err; } 9465 } } 9466 } else { 9467 return path 9468 } 9469 }); 9470 9471 $def(self, '$posixify', function $$posixify(path) { 9472 var self = this; 9473 9474 if ($truthy(path)) { 9475 if (($eqeq(self.file_separator, $$('BACKSLASH')) && ($truthy(path['$include?']($$('BACKSLASH')))))) { 9476 9477 return path.$tr($$('BACKSLASH'), $$('SLASH')); 9478 } else { 9479 return path 9480 } 9481 } else { 9482 return "" 9483 } 9484 }); 9485 $alias(self, "posixfy", "posixify"); 9486 9487 $def(self, '$expand_path', function $$expand_path(path) { 9488 var $a, $b, self = this, path_segments = nil, path_root = nil, resolved_segments = nil; 9489 9490 9491 $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])); 9492 if ($truthy(path['$include?']($$('DOT_DOT')))) { 9493 9494 resolved_segments = []; 9495 $send(path_segments, 'each', [], function $$7(segment){ 9496 9497 if (segment == null) segment = nil; 9498 if ($eqeq(segment, $$('DOT_DOT'))) { 9499 return resolved_segments.$pop() 9500 } else { 9501 return resolved_segments['$<<'](segment) 9502 }}); 9503 return self.$join_path(resolved_segments, path_root); 9504 } else { 9505 return self.$join_path(path_segments, path_root) 9506 } }); 9507 9508 $def(self, '$partition_path', function $$partition_path(path, web) { 9509 var $a, self = this, result = nil, cache = nil, posix_path = nil, root = nil, path_segments = nil; 9510 9511 9512 if (web == null) web = nil; 9513 if ($truthy((result = (cache = ($truthy(web) ? (self._partition_path_web) : (self._partition_path_sys)))['$[]'](path)))) { 9514 return result 9515 } posix_path = self.$posixify(path); 9516 if ($truthy(web)) { 9517 if ($truthy(self['$web_root?'](posix_path))) { 9518 root = $$('SLASH'); 9519 } else if ($truthy(posix_path['$start_with?']($$('DOT_SLASH')))) { 9520 root = $$('DOT_SLASH'); 9521 } 9522 } else if ($truthy(self['$root?'](posix_path))) { 9523 if ($truthy(self['$unc?'](posix_path))) { 9524 root = $$('DOUBLE_SLASH'); 9525 } else if ($truthy(posix_path['$start_with?']($$('SLASH')))) { 9526 root = $$('SLASH'); 9527 } else if ($truthy(posix_path['$start_with?']($$('URI_CLASSLOADER')))) { 9528 root = posix_path.$slice(0, $$('URI_CLASSLOADER').$length()); 9529 } else { 9530 root = posix_path.$slice(0, $rb_plus(posix_path.$index($$('SLASH')), 1)); 9531 } 9532 } else if ($truthy(posix_path['$start_with?']($$('DOT_SLASH')))) { 9533 root = $$('DOT_SLASH'); 9534 } path_segments = ($truthy(root) ? (posix_path.$slice(root.$length(), posix_path.$length())) : (posix_path)).$split($$('SLASH')); 9535 path_segments.$delete($$('DOT')); 9536 return ($a = [path, [path_segments, root]], $send(cache, '[]=', $a), $a[$a.length - 1]); 9537 }, -2); 9538 9539 $def(self, '$join_path', function $$join_path(segments, root) { 9540 9541 9542 if (root == null) root = nil; 9543 if ($truthy(root)) { 9544 return "" + (root) + (segments.$join($$('SLASH'))) 9545 } else { 9546 9547 return segments.$join($$('SLASH')); 9548 } }, -2); 9549 9550 $def(self, '$system_path', function $$system_path(target, start, jail, opts) { 9551 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; 9552 9553 9554 if (start == null) start = nil; 9555 if (jail == null) jail = nil; 9556 if (opts == null) opts = $hash2([], {}); 9557 if ($truthy(jail)) { 9558 9559 if (!$truthy(self['$root?'](jail))) { 9560 self.$raise($$$('SecurityError'), "Jail is not an absolute path: " + (jail)); 9561 } jail = self.$posixify(jail); 9562 } if ($truthy(target)) { 9563 if ($truthy(self['$root?'](target))) { 9564 9565 target_path = self.$expand_path(target); 9566 if (($truthy(jail) && ($not(self['$descends_from?'](target_path, jail))))) { 9567 if ($truthy(opts.$fetch("recover", true))) { 9568 9569 self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail; recovering automatically"); 9570 $b = self.$partition_path(target_path), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])); 9571 $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])); 9572 return self.$join_path($rb_plus(jail_segments, target_segments), jail_root); 9573 } else { 9574 self.$raise($$$('SecurityError'), "" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " " + (target) + " is outside of jail: " + (jail) + " (disallowed in safe mode)"); 9575 } 9576 } return target_path; 9577 } else { 9578 $b = self.$partition_path(target), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])); 9579 } 9580 } else { 9581 target_segments = []; 9582 } if ($truthy(target_segments['$empty?']())) { 9583 if ($truthy(start['$nil_or_empty?']())) { 9584 return ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir)) 9585 } else if ($truthy(self['$root?'](start))) { 9586 if ($truthy(jail)) { 9587 start = self.$posixify(start); 9588 } else { 9589 return self.$expand_path(start) 9590 } 9591 } else { 9592 9593 $b = self.$partition_path(start), $a = $to_ary($b), (target_segments = ($a[0] == null ? nil : $a[0])); 9594 start = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir)); 9595 } 9596 } else if ($truthy(start['$nil_or_empty?']())) { 9597 start = ($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir)); 9598 } else if ($truthy(self['$root?'](start))) { 9599 if ($truthy(jail)) { 9600 start = self.$posixify(start); 9601 } 9602 } else { 9603 start = "" + (($truthy(($ret_or_1 = jail)) ? ($ret_or_1) : (self.working_dir)).$chomp("/")) + "/" + (start); 9604 } if ((($truthy(jail) && ($truthy((recheck = self['$descends_from?'](start, jail)['$!']())))) && ($eqeq(self.file_separator, $$('BACKSLASH'))))) { 9605 9606 $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])); 9607 $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])); 9608 if ($neqeq(start_root, jail_root)) { 9609 if ($truthy(opts.$fetch("recover", true))) { 9610 9611 self.$logger().$warn("start path for " + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail root; recovering automatically"); 9612 start_segments = jail_segments; 9613 recheck = false; 9614 } else { 9615 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)"); 9616 } 9617 } } else { 9618 $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])); 9619 } if ($truthy((resolved_segments = $rb_plus(start_segments, target_segments))['$include?']($$('DOT_DOT')))) { 9620 9621 $a = [resolved_segments, []], (unresolved_segments = $a[0]), (resolved_segments = $a[1]); 9622 if ($truthy(jail)) { 9623 9624 if (!$truthy(jail_segments)) { 9625 $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])); 9626 } warned = false; 9627 $send(unresolved_segments, 'each', [], function $$8(segment){var self = $$8.$$s == null ? this : $$8.$$s; 9628 9629 9630 if (segment == null) segment = nil; 9631 if ($eqeq(segment, $$('DOT_DOT'))) { 9632 if ($truthy($rb_gt(resolved_segments.$size(), jail_segments.$size()))) { 9633 return resolved_segments.$pop() 9634 } else if ($truthy(opts.$fetch("recover", true))) { 9635 if ($truthy(warned)) { 9636 return nil 9637 } else { 9638 9639 self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " has illegal reference to ancestor of jail; recovering automatically"); 9640 return (warned = true); 9641 } 9642 } else { 9643 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)") 9644 } 9645 } else { 9646 return resolved_segments['$<<'](segment) 9647 }}, {$$s: self}); 9648 } else { 9649 $send(unresolved_segments, 'each', [], function $$9(segment){ 9650 9651 if (segment == null) segment = nil; 9652 if ($eqeq(segment, $$('DOT_DOT'))) { 9653 return resolved_segments.$pop() 9654 } else { 9655 return resolved_segments['$<<'](segment) 9656 }}); 9657 } } if ($truthy(recheck)) { 9658 9659 target_path = self.$join_path(resolved_segments, jail_root); 9660 if ($truthy(self['$descends_from?'](target_path, jail))) { 9661 return target_path 9662 } else if ($truthy(opts.$fetch("recover", true))) { 9663 9664 self.$logger().$warn("" + (($truthy(($ret_or_1 = opts['$[]']("target_name"))) ? ($ret_or_1) : ("path"))) + " is outside of jail; recovering automatically"); 9665 if (!$truthy(jail_segments)) { 9666 $b = self.$partition_path(jail), $a = $to_ary($b), (jail_segments = ($a[0] == null ? nil : $a[0])); 9667 } return self.$join_path($rb_plus(jail_segments, target_segments), jail_root); 9668 } else { 9669 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)") 9670 } } else { 9671 return self.$join_path(resolved_segments, jail_root) 9672 } }, -2); 9673 9674 $def(self, '$web_path', function $$web_path(target, start) { 9675 var $a, $b, self = this, uri_prefix = nil, target_segments = nil, target_root = nil, resolved_segments = nil, resolved_path = nil; 9676 9677 9678 if (start == null) start = nil; 9679 target = self.$posixify(target); 9680 start = self.$posixify(start); 9681 if (!($truthy(start['$nil_or_empty?']()) || ($truthy(self['$web_root?'](target))))) { 9682 $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])); 9683 } $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])); 9684 resolved_segments = []; 9685 $send(target_segments, 'each', [], function $$10(segment){ 9686 9687 if (segment == null) segment = nil; 9688 if ($eqeq(segment, $$('DOT_DOT'))) { 9689 if ($truthy(resolved_segments['$empty?']())) { 9690 if (($truthy(target_root) && ($neqeq(target_root, $$('DOT_SLASH'))))) { 9691 return nil 9692 } else { 9693 return resolved_segments['$<<'](segment) 9694 } 9695 } else if ($eqeq(resolved_segments['$[]'](-1), $$('DOT_DOT'))) { 9696 return resolved_segments['$<<'](segment) 9697 } else { 9698 return resolved_segments.$pop() 9699 } 9700 } else { 9701 return resolved_segments['$<<'](segment) 9702 }}); 9703 if ($truthy((resolved_path = self.$join_path(resolved_segments, target_root))['$include?'](" "))) { 9704 resolved_path = resolved_path.$gsub(" ", "%20"); 9705 } if ($truthy(uri_prefix)) { 9706 return "" + (uri_prefix) + (resolved_path) 9707 } else { 9708 return resolved_path 9709 } }, -2); 9710 self.$private(); 9711 return $def(self, '$extract_uri_prefix', function $$extract_uri_prefix(str) { 9712 var $a; 9713 9714 if (($truthy(str['$include?'](":")) && ($truthy($$('UriSniffRx')['$=~'](str))))) { 9715 return [str.$slice((($a = $gvars['~']) === nil ? nil : $a['$[]'](0)).$length(), str.$length()), (($a = $gvars['~']) === nil ? nil : $a['$[]'](0))] 9716 } else { 9717 return str 9718 } 9719 }); 9720 })($nesting[0], null, $nesting) 9721 })($nesting[0], $nesting) 9722}; 9723 9724Opal.modules["asciidoctor/reader"] = function(Opal) {/* Generated by Opal 1.7.3 */ 9725 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.$$$; 9726 9727 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'); 9728 return (function($base, $parent_nesting) { 9729 var self = $module($base, 'Asciidoctor'); 9730 9731 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 9732 9733 9734 (function($base, $super, $parent_nesting) { 9735 var self = $klass($base, $super, 'Reader'); 9736 9737 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 9738 9739 $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; 9740 9741 self.$include($$('Logging')); 9742 (function($base, $super) { 9743 var self = $klass($base, $super, 'Cursor'); 9744 9745 var $proto = self.$$prototype; 9746 9747 $proto.lineno = $proto.path = nil; 9748 9749 self.$attr_reader("file", "dir", "path", "lineno"); 9750 9751 $def(self, '$initialize', function $$initialize(file, dir, path, lineno) { 9752 var $a, self = this; 9753 9754 9755 if (dir == null) dir = nil; 9756 if (path == null) path = nil; 9757 if (lineno == null) lineno = 1; 9758 return $a = [file, dir, path, lineno], (self.file = $a[0]), (self.dir = $a[1]), (self.path = $a[2]), (self.lineno = $a[3]), $a; 9759 }, -2); 9760 9761 $def(self, '$advance', function $$advance(num) { 9762 var self = this; 9763 9764 return (self.lineno = $rb_plus(self.lineno, num)) 9765 }); 9766 9767 $def(self, '$line_info', function $$line_info() { 9768 var self = this; 9769 9770 return "" + (self.path) + ": line " + (self.lineno) 9771 }); 9772 return $alias(self, "to_s", "line_info"); 9773 })($nesting[0], null); 9774 self.$attr_reader("file"); 9775 self.$attr_reader("dir"); 9776 self.$attr_reader("path"); 9777 self.$attr_reader("lineno"); 9778 self.$attr_reader("source_lines"); 9779 self.$attr_accessor("process_lines"); 9780 self.$attr_accessor("unterminated"); 9781 9782 $def(self, '$initialize', function $$initialize(data, cursor, opts) { 9783 var $a, $b, self = this, $ret_or_1 = nil; 9784 9785 9786 if (data == null) data = nil; 9787 if (cursor == null) cursor = nil; 9788 if (opts == null) opts = $hash2([], {}); 9789 if ($not(cursor)) { 9790 9791 self.file = nil; 9792 self.dir = "."; 9793 self.path = "<stdin>"; 9794 self.lineno = 1; 9795 } else if ($eqeqeq($$$('String'), cursor)) { 9796 9797 self.file = cursor; 9798 $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])); 9799 self.lineno = 1; 9800 } else { 9801 9802 if ($truthy((self.file = cursor.$file()))) { 9803 9804 self.dir = ($truthy(($ret_or_1 = cursor.$dir())) ? ($ret_or_1) : ($$$('File').$dirname(self.file))); 9805 self.path = ($truthy(($ret_or_1 = cursor.$path())) ? ($ret_or_1) : ($$$('File').$basename(self.file))); 9806 } else { 9807 9808 self.dir = ($truthy(($ret_or_1 = cursor.$dir())) ? ($ret_or_1) : (".")); 9809 self.path = ($truthy(($ret_or_1 = cursor.$path())) ? ($ret_or_1) : ("<stdin>")); 9810 } self.lineno = ($truthy(($ret_or_1 = cursor.$lineno())) ? ($ret_or_1) : (1)); 9811 } self.lines = (self.source_lines = self.$prepare_lines(data, opts)).$reverse(); 9812 self.mark = nil; 9813 self.look_ahead = 0; 9814 self.process_lines = true; 9815 self.unescape_next_line = false; 9816 self.unterminated = nil; 9817 return (self.saved = nil); 9818 }, -1); 9819 9820 $def(self, '$has_more_lines?', function $Reader_has_more_lines$ques$1() { 9821 var self = this; 9822 9823 if ($truthy(self.lines['$empty?']())) { 9824 9825 self.look_ahead = 0; 9826 return false; 9827 } else { 9828 return true 9829 } 9830 }); 9831 9832 $def(self, '$empty?', function $Reader_empty$ques$2() { 9833 var self = this; 9834 9835 if ($truthy(self.lines['$empty?']())) { 9836 9837 self.look_ahead = 0; 9838 return true; 9839 } else { 9840 return false 9841 } 9842 }); 9843 $alias(self, "eof?", "empty?"); 9844 9845 $def(self, '$next_line_empty?', function $Reader_next_line_empty$ques$3() { 9846 var self = this; 9847 9848 return self.$peek_line()['$nil_or_empty?']() 9849 }); 9850 9851 $def(self, '$peek_line', function $$peek_line(direct) { 9852 var self = this, next_line = nil, line = nil; 9853 9854 9855 if (direct == null) direct = false; 9856 while ($truthy(true)) { 9857 9858 next_line = self.lines['$[]'](-1); 9859 if (($truthy(direct) || ($truthy($rb_gt(self.look_ahead, 0))))) { 9860 return ($truthy(self.unescape_next_line) ? (next_line.$slice(1, next_line.$length())) : (next_line)) 9861 } else if ($truthy(next_line)) { 9862 if ($truthy((line = self.$process_line(next_line)))) { 9863 return line 9864 } 9865 } else { 9866 9867 self.look_ahead = 0; 9868 return nil; 9869 } } }, -1); 9870 9871 $def(self, '$peek_lines', function $$peek_lines(num, direct) { 9872 var self = this, old_look_ahead = nil, result = nil, $ret_or_1 = nil; 9873 9874 9875 if (num == null) num = nil; 9876 if (direct == null) direct = false; 9877 old_look_ahead = self.look_ahead; 9878 result = []; 9879 (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; 9880 if (self.lineno == null) self.lineno = nil; 9881 9882 if ($truthy((line = ($truthy(direct) ? (self.$shift()) : (self.$read_line()))))) { 9883 return result['$<<'](line) 9884 } else { 9885 9886 if ($truthy(direct)) { 9887 self.lineno = $rb_minus(self.lineno, 1); 9888 }; 9889 $t_break.$throw(); 9890 }}, {$$s: self})} catch($e) { 9891 if ($e === $t_break) return $e.$v; 9892 throw $e; 9893 }})(); 9894 if (!$truthy(result['$empty?']())) { 9895 9896 self.$unshift_all(result); 9897 if ($truthy(direct)) { 9898 self.look_ahead = old_look_ahead; 9899 } } return result; 9900 }, -1); 9901 9902 $def(self, '$read_line', function $$read_line() { 9903 var self = this; 9904 9905 if (($truthy($rb_gt(self.look_ahead, 0)) || ($truthy(self['$has_more_lines?']())))) { 9906 return self.$shift() 9907 } else { 9908 return nil 9909 } 9910 }); 9911 9912 $def(self, '$read_lines', function $$read_lines() { 9913 var self = this, lines = nil; 9914 9915 9916 lines = []; 9917 while ($truthy(self['$has_more_lines?']())) { 9918 lines['$<<'](self.$shift()); 9919 } return lines; 9920 }); 9921 $alias(self, "readlines", "read_lines"); 9922 9923 $def(self, '$read', function $$read() { 9924 var self = this; 9925 9926 return self.$read_lines().$join($$('LF')) 9927 }); 9928 9929 $def(self, '$advance', function $$advance() { 9930 var self = this; 9931 9932 if ($truthy(self.$shift())) { 9933 return true 9934 } else { 9935 return false 9936 } 9937 }); 9938 9939 $def(self, '$unshift_line', function $$unshift_line(line_to_restore) { 9940 var self = this; 9941 9942 9943 self.$unshift(line_to_restore); 9944 return nil; 9945 }); 9946 $alias(self, "restore_line", "unshift_line"); 9947 9948 $def(self, '$unshift_lines', function $$unshift_lines(lines_to_restore) { 9949 var self = this; 9950 9951 return self.$unshift_all(lines_to_restore) 9952 }); 9953 $alias(self, "restore_lines", "unshift_lines"); 9954 9955 $def(self, '$replace_next_line', function $$replace_next_line(replacement) { 9956 var self = this; 9957 9958 9959 self.$shift(); 9960 self.$unshift(replacement); 9961 return true; 9962 }); 9963 $alias(self, "replace_line", "replace_next_line"); 9964 9965 $def(self, '$skip_blank_lines', function $$skip_blank_lines() { 9966 var self = this, num_skipped = nil, next_line = nil; 9967 9968 9969 if ($truthy(self['$empty?']())) { 9970 return nil 9971 } num_skipped = 0; 9972 while ($truthy((next_line = self.$peek_line()))) { 9973 if ($truthy(next_line['$empty?']())) { 9974 9975 self.$shift(); 9976 num_skipped = $rb_plus(num_skipped, 1); 9977 } else { 9978 return num_skipped 9979 } 9980 } }); 9981 9982 $def(self, '$skip_comment_lines', function $$skip_comment_lines() { 9983 var self = this, $ret_or_1 = nil, next_line = nil, ll = nil; 9984 9985 9986 if ($truthy(self['$empty?']())) { 9987 return nil 9988 } while ($truthy(($truthy(($ret_or_1 = (next_line = self.$peek_line()))) ? (next_line['$empty?']()['$!']()) : ($ret_or_1)))) { 9989 if ($truthy(next_line['$start_with?']("//"))) { 9990 if ($truthy(next_line['$start_with?']("///"))) { 9991 if (($truthy($rb_gt((ll = next_line.$length()), 3)) && ($eqeq(next_line, $rb_times("/", ll))))) { 9992 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"})); 9993 } else { 9994 break 9995 } 9996 } else { 9997 self.$shift(); 9998 } 9999 } else { 10000 break 10001 } 10002 } return nil; 10003 }); 10004 10005 $def(self, '$skip_line_comments', function $$skip_line_comments() { 10006 var self = this, comment_lines = nil, $ret_or_1 = nil, next_line = nil; 10007 10008 10009 if ($truthy(self['$empty?']())) { 10010 return [] 10011 } comment_lines = []; 10012 while ($truthy(($truthy(($ret_or_1 = (next_line = self.$peek_line()))) ? (next_line['$empty?']()['$!']()) : ($ret_or_1)))) { 10013 if ($truthy(next_line['$start_with?']("//"))) { 10014 comment_lines['$<<'](self.$shift()); 10015 } else { 10016 break 10017 } 10018 } return comment_lines; 10019 }); 10020 10021 $def(self, '$terminate', function $$terminate() { 10022 var self = this; 10023 10024 10025 self.lineno = $rb_plus(self.lineno, self.lines.$size()); 10026 self.lines.$clear(); 10027 self.look_ahead = 0; 10028 return nil; 10029 }); 10030 10031 $def(self, '$read_lines_until', function $$read_lines_until(options) { 10032 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; 10033 10034 $$read_lines_until.$$p = null; 10035 10036 if (options == null) options = $hash2([], {}); 10037 result = []; 10038 if (($truthy(self.process_lines) && ($truthy(options['$[]']("skip_processing"))))) { 10039 10040 self.process_lines = false; 10041 restore_process_lines = true; 10042 } if ($truthy((terminator = options['$[]']("terminator")))) { 10043 10044 start_cursor = ($truthy(($ret_or_1 = options['$[]']("cursor"))) ? ($ret_or_1) : (self.$cursor())); 10045 break_on_blank_lines = false; 10046 break_on_list_continuation = false; 10047 } else { 10048 10049 break_on_blank_lines = options['$[]']("break_on_blank_lines"); 10050 break_on_list_continuation = options['$[]']("break_on_list_continuation"); 10051 } skip_comments = options['$[]']("skip_line_comments"); 10052 line_read = (line_restored = nil); 10053 if ($truthy(options['$[]']("skip_first_line"))) { 10054 self.$shift(); 10055 } while ($truthy((line = self.$read_line()))) { 10056 10057 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)))))))) { 10058 10059 if ($truthy(options['$[]']("read_last_line"))) { 10060 result['$<<'](line); 10061 } if ($truthy(options['$[]']("preserve_last_line"))) { 10062 10063 self.$unshift(line); 10064 line_restored = true; 10065 } break; 10066 } if (!(($truthy(skip_comments) && ($truthy(line['$start_with?']("//")))) && ($not(line['$start_with?']("///"))))) { 10067 10068 result['$<<'](line); 10069 line_read = true; 10070 } } if ($truthy(restore_process_lines)) { 10071 10072 self.process_lines = true; 10073 if (($truthy(line_restored) && ($not(terminator)))) { 10074 self.look_ahead = $rb_minus(self.look_ahead, 1); 10075 } } if ((($truthy(terminator) && ($neqeq(terminator, line))) && ($truthy((context = options.$fetch("context", terminator)))))) { 10076 10077 if ($eqeq(start_cursor, "at_mark")) { 10078 start_cursor = self.$cursor_at_mark(); 10079 } self.$logger().$warn(self.$message_with_context("unterminated " + (context) + " block", $hash2(["source_location"], {"source_location": start_cursor}))); 10080 self.unterminated = true; 10081 } return result; 10082 }, -1); 10083 10084 $def(self, '$shift', function $$shift() { 10085 var self = this; 10086 10087 10088 self.lineno = $rb_plus(self.lineno, 1); 10089 if (!$eqeq(self.look_ahead, 0)) { 10090 self.look_ahead = $rb_minus(self.look_ahead, 1); 10091 } return self.lines.$pop(); 10092 }); 10093 10094 $def(self, '$unshift', function $$unshift(line) { 10095 var self = this; 10096 10097 10098 self.lineno = $rb_minus(self.lineno, 1); 10099 self.look_ahead = $rb_plus(self.look_ahead, 1); 10100 self.lines.$push(line); 10101 return nil; 10102 }); 10103 if ($eqeq($$$('RUBY_ENGINE'), "jruby")) { 10104 10105 $def(self, '$unshift_all', function $$unshift_all(lines_to_restore) { 10106 var self = this; 10107 10108 10109 self.lineno = $rb_minus(self.lineno, lines_to_restore.$size()); 10110 self.look_ahead = $rb_plus(self.look_ahead, lines_to_restore.$size()); 10111 if ($truthy(lines_to_restore['$respond_to?']("reverse"))) { 10112 $send(self.lines, 'push', $to_a(lines_to_restore.$reverse())); 10113 } else { 10114 $send(lines_to_restore, 'reverse_each', [], function $$5(it){var self = $$5.$$s == null ? this : $$5.$$s; 10115 if (self.lines == null) self.lines = nil; 10116 10117 10118 if (it == null) it = nil; 10119 return self.lines.$push(it);}, {$$s: self}); 10120 } return nil; 10121 }); 10122 } else { 10123 10124 $def(self, '$unshift_all', function $$unshift_all(lines_to_restore) { 10125 var self = this; 10126 10127 10128 self.lineno = $rb_minus(self.lineno, lines_to_restore.$size()); 10129 self.look_ahead = $rb_plus(self.look_ahead, lines_to_restore.$size()); 10130 $send(self.lines, 'push', $to_a(lines_to_restore.$reverse())); 10131 return nil; 10132 }); 10133 } 10134 $def(self, '$cursor', function $$cursor() { 10135 var self = this; 10136 10137 return $$('Cursor').$new(self.file, self.dir, self.path, self.lineno) 10138 }); 10139 10140 $def(self, '$cursor_at_line', function $$cursor_at_line(lineno) { 10141 var self = this; 10142 10143 return $$('Cursor').$new(self.file, self.dir, self.path, lineno) 10144 }); 10145 10146 $def(self, '$cursor_at_mark', function $$cursor_at_mark() { 10147 var self = this; 10148 10149 if ($truthy(self.mark)) { 10150 return $send($$('Cursor'), 'new', $to_a(self.mark)) 10151 } else { 10152 return self.$cursor() 10153 } 10154 }); 10155 10156 $def(self, '$cursor_before_mark', function $$cursor_before_mark() { 10157 var $a, $b, self = this, m_file = nil, m_dir = nil, m_path = nil, m_lineno = nil; 10158 10159 if ($truthy(self.mark)) { 10160 10161 $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])); 10162 return $$('Cursor').$new(m_file, m_dir, m_path, $rb_minus(m_lineno, 1)); 10163 } else { 10164 return $$('Cursor').$new(self.file, self.dir, self.path, $rb_minus(self.lineno, 1)) 10165 } 10166 }); 10167 10168 $def(self, '$cursor_at_prev_line', function $$cursor_at_prev_line() { 10169 var self = this; 10170 10171 return $$('Cursor').$new(self.file, self.dir, self.path, $rb_minus(self.lineno, 1)) 10172 }); 10173 10174 $def(self, '$mark', function $$mark() { 10175 var self = this; 10176 10177 return (self.mark = [self.file, self.dir, self.path, self.lineno]) 10178 }); 10179 10180 $def(self, '$line_info', function $$line_info() { 10181 var self = this; 10182 10183 return "" + (self.path) + ": line " + (self.lineno) 10184 }); 10185 10186 $def(self, '$lines', function $$lines() { 10187 var self = this; 10188 10189 return self.lines.$reverse() 10190 }); 10191 10192 $def(self, '$string', function $$string() { 10193 var self = this; 10194 10195 return self.lines.$reverse().$join($$('LF')) 10196 }); 10197 10198 $def(self, '$source', function $$source() { 10199 var self = this; 10200 10201 return self.source_lines.$join($$('LF')) 10202 }); 10203 10204 $def(self, '$save', function $$save() { 10205 var self = this; 10206 10207 10208 self.saved = $send($hash2([], {}), 'tap', [], function $$6(accum){var self = $$6.$$s == null ? this : $$6.$$s; 10209 10210 10211 if (accum == null) accum = nil; 10212 return $send(self.$instance_variables(), 'each', [], function $$7(name){var $a, self = $$7.$$s == null ? this : $$7.$$s, val = nil; 10213 10214 10215 if (name == null) name = nil; 10216 if (($eqeq(name, "@saved") || ($eqeq(name, "@source_lines")))) { 10217 return nil 10218 } else { 10219 return ($a = [name, ($eqeqeq($$$('Array'), (val = self.$instance_variable_get(name))) ? (val.$drop(0)) : (val))], $send(accum, '[]=', $a), $a[$a.length - 1]) 10220 }}, {$$s: self});}, {$$s: self}); 10221 return nil; 10222 }); 10223 10224 $def(self, '$restore_save', function $$restore_save() { 10225 var self = this; 10226 10227 if ($truthy(self.saved)) { 10228 10229 $send(self.saved, 'each', [], function $$8(name, val){var self = $$8.$$s == null ? this : $$8.$$s; 10230 10231 10232 if (name == null) name = nil; 10233 if (val == null) val = nil; 10234 return self.$instance_variable_set(name, val);}, {$$s: self}); 10235 return (self.saved = nil); 10236 } else { 10237 return nil 10238 } 10239 }); 10240 10241 $def(self, '$discard_save', $assign_ivar_val("saved", nil)); 10242 10243 $def(self, '$to_s', function $$to_s() { 10244 var self = this; 10245 10246 return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {path: " + (self.path.$inspect()) + ", line: " + (self.lineno) + "}>" 10247 }); 10248 self.$private(); 10249 10250 $def(self, '$prepare_lines', function $$prepare_lines(data, opts) { 10251 var self = this, normalize = nil; 10252 10253 10254 if (opts == null) opts = $hash2([], {}); 10255 try { 10256 if ($truthy((normalize = opts['$[]']("normalize")))) { 10257 if ($eqeqeq($$$('Array'), data)) { 10258 10259 return $$('Helpers').$prepare_source_array(data, normalize['$!=']("chomp")); 10260 } else { 10261 10262 return $$('Helpers').$prepare_source_string(data, normalize['$!=']("chomp")); 10263 } 10264 } else if ($eqeqeq($$$('Array'), data)) { 10265 return data.$drop(0) 10266 } else if ($truthy(data)) { 10267 return data.$chomp().$split($$('LF'), -1) 10268 } else { 10269 return [] 10270 } 10271 } catch ($err) { 10272 if (Opal.rescue($err, [$$('StandardError')])) { 10273 try { 10274 if ($truthy(($eqeqeq($$$('Array'), data) ? (data.$join()) : (data.$to_s()))['$valid_encoding?']())) { 10275 return self.$raise() 10276 } else { 10277 return self.$raise($$$('ArgumentError'), "source is either binary or contains invalid Unicode data") 10278 } 10279 } finally { Opal.pop_exception(); } 10280 } else { throw $err; } 10281 } }, -2); 10282 return $def(self, '$process_line', function $$process_line(line) { 10283 var self = this; 10284 10285 10286 if ($truthy(self.process_lines)) { 10287 self.look_ahead = $rb_plus(self.look_ahead, 1); 10288 } return line; 10289 }); 10290 })($nesting[0], null, $nesting); 10291 return (function($base, $super, $parent_nesting) { 10292 var self = $klass($base, $super, 'PreprocessorReader'); 10293 10294 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 10295 10296 $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; 10297 10298 self.$attr_reader("include_stack"); 10299 10300 $def(self, '$initialize', function $$initialize(document, data, cursor, opts) { 10301 $$initialize.$$p || nil; var self = this, default_include_depth = nil, $ret_or_1 = nil; 10302 10303 $$initialize.$$p = null; 10304 10305 if (data == null) data = nil; 10306 if (cursor == null) cursor = nil; 10307 if (opts == null) opts = $hash2([], {}); 10308 self.document = document; 10309 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [data, cursor, opts], null); 10310 if ($truthy($rb_gt((default_include_depth = ($truthy(($ret_or_1 = document.$attributes()['$[]']("max-include-depth"))) ? ($ret_or_1) : (64)).$to_i()), 0))) { 10311 self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": default_include_depth, "curr": default_include_depth, "rel": default_include_depth}); 10312 } else { 10313 self.maxdepth = nil; 10314 } self.include_stack = []; 10315 self.includes = document.$catalog()['$[]']("includes"); 10316 self.skipping = false; 10317 self.conditional_stack = []; 10318 return (self.include_processor_extensions = nil); 10319 }, -2); 10320 10321 $def(self, '$has_more_lines?', function $PreprocessorReader_has_more_lines$ques$9() { 10322 var self = this; 10323 10324 if ($truthy(self.$peek_line())) { 10325 return true 10326 } else { 10327 return false 10328 } 10329 }); 10330 10331 $def(self, '$empty?', function $PreprocessorReader_empty$ques$10() { 10332 var self = this; 10333 10334 if ($truthy(self.$peek_line())) { 10335 return false 10336 } else { 10337 return true 10338 } 10339 }); 10340 $alias(self, "eof?", "empty?"); 10341 10342 $def(self, '$peek_line', function $$peek_line(direct) { 10343 var $yield = $$peek_line.$$p || nil, self = this, line = nil; 10344 10345 $$peek_line.$$p = null; 10346 10347 if (direct == null) direct = false; 10348 if ($truthy((line = $send2(self, $find_super(self, 'peek_line', $$peek_line, false, true), 'peek_line', [direct], $yield)))) { 10349 return line 10350 } else if ($truthy(self.include_stack['$empty?']())) { 10351 return nil 10352 } else { 10353 10354 self.$pop_include(); 10355 return self.$peek_line(direct); 10356 } }, -1); 10357 10358 $def(self, '$push_include', function $$push_include(data, file, path, lineno, attributes) { 10359 var self = this, dir = nil, $ret_or_1 = nil, rel_maxdepth = nil, curr_maxdepth = nil, abs_maxdepth = nil, leveloffset = nil; 10360 10361 10362 if (file == null) file = nil; 10363 if (path == null) path = nil; 10364 if (lineno == null) lineno = 1; 10365 if (attributes == null) attributes = $hash2([], {}); 10366 self.include_stack['$<<']([self.lines, self.file, self.dir, self.path, self.lineno, self.maxdepth, self.process_lines]); 10367 if ($truthy((self.file = file))) { 10368 10369 if ($eqeqeq($$$('String'), file)) { 10370 self.dir = $$$('File').$dirname(file); 10371 } else if ($truthy($$('RUBY_ENGINE_OPAL'))) { 10372 self.dir = $$$('URI').$parse($$$('File').$dirname((file = file.$to_s()))); 10373 } else { 10374 10375 (self.dir = file.$dup())['$path='](($eqeq((dir = $$$('File').$dirname(file.$path())), "/") ? ("") : (dir))); 10376 file = file.$to_s(); 10377 } self.path = (path = ($truthy(($ret_or_1 = path)) ? ($ret_or_1) : ($$$('File').$basename(file)))); 10378 if ($truthy((self.process_lines = $send(file, 'end_with?', $to_a($$('ASCIIDOC_EXTENSIONS').$keys()))))) { 10379 if ($truthy(($ret_or_1 = self.includes['$[]'](path.$slice(0, path.$rindex(".")))))) ; else { 10380 self.includes['$[]='](path.$slice(0, path.$rindex(".")), ($truthy(attributes['$[]']("partial-option")) ? (nil) : (true))); 10381 } 10382 } } else { 10383 10384 self.dir = "."; 10385 self.process_lines = true; 10386 if ($truthy((self.path = path))) { 10387 if ($truthy(($ret_or_1 = self.includes['$[]']($$('Helpers').$rootname(path))))) ; else { 10388 self.includes['$[]=']($$('Helpers').$rootname(path), ($truthy(attributes['$[]']("partial-option")) ? (nil) : (true))); 10389 } 10390 } else { 10391 self.path = "<stdin>"; 10392 } } self.lineno = lineno; 10393 if (($truthy(self.maxdepth) && ($truthy(attributes['$key?']("depth"))))) { 10394 if ($truthy($rb_gt((rel_maxdepth = attributes['$[]']("depth").$to_i()), 0))) { 10395 10396 if ($truthy($rb_gt((curr_maxdepth = $rb_plus(self.include_stack.$size(), rel_maxdepth)), (abs_maxdepth = self.maxdepth['$[]']("abs"))))) { 10397 curr_maxdepth = (rel_maxdepth = abs_maxdepth); 10398 } self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": abs_maxdepth, "curr": curr_maxdepth, "rel": rel_maxdepth}); 10399 } else { 10400 self.maxdepth = $hash2(["abs", "curr", "rel"], {"abs": self.maxdepth['$[]']("abs"), "curr": self.include_stack.$size(), "rel": 0}); 10401 } 10402 } 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?']())) { 10403 self.$pop_include(); 10404 } else { 10405 10406 if ($truthy(attributes['$key?']("leveloffset"))) { 10407 10408 self.lines = $rb_plus($rb_plus([($truthy((leveloffset = self.document.$attr("leveloffset"))) ? (":leveloffset: " + (leveloffset)) : (":leveloffset!:")), ""], self.lines.$reverse()), ["", ":leveloffset: " + (attributes['$[]']("leveloffset"))]); 10409 self.lineno = $rb_minus(self.lineno, 2); 10410 } else { 10411 self.lines['$reverse!'](); 10412 } self.look_ahead = 0; 10413 } return self; 10414 }, -2); 10415 10416 $def(self, '$include_depth', function $$include_depth() { 10417 var self = this; 10418 10419 return self.include_stack.$size() 10420 }); 10421 10422 $def(self, '$exceeds_max_depth?', function $PreprocessorReader_exceeds_max_depth$ques$11() { 10423 var self = this, $ret_or_1 = nil, $ret_or_2 = nil; 10424 10425 if ($truthy(($ret_or_1 = ($truthy(($ret_or_2 = self.maxdepth)) ? ($rb_ge(self.include_stack.$size(), self.maxdepth['$[]']("curr"))) : ($ret_or_2))))) { 10426 return self.maxdepth['$[]']("rel") 10427 } else { 10428 return $ret_or_1 10429 } 10430 }); 10431 $alias(self, "exceeded_max_depth?", "exceeds_max_depth?"); 10432 10433 $def(self, '$shift', function $$shift() { 10434 var $yield = $$shift.$$p || nil, self = this, line = nil; 10435 10436 $$shift.$$p = null; 10437 if ($truthy(self.unescape_next_line)) { 10438 10439 self.unescape_next_line = false; 10440 return (line = $send2(self, $find_super(self, 'shift', $$shift, false, true), 'shift', [], $yield)).$slice(1, line.$length()); 10441 } else { 10442 return $send2(self, $find_super(self, 'shift', $$shift, false, true), 'shift', [], $yield) 10443 } 10444 }); 10445 10446 $def(self, '$include_processors?', function $PreprocessorReader_include_processors$ques$12() { 10447 var self = this; 10448 10449 if ($truthy(self.include_processor_extensions['$nil?']())) { 10450 if (($truthy(self.document['$extensions?']()) && ($truthy(self.document.$extensions()['$include_processors?']())))) { 10451 return (self.include_processor_extensions = self.document.$extensions().$include_processors())['$!']()['$!']() 10452 } else { 10453 return (self.include_processor_extensions = false) 10454 } 10455 } else { 10456 return self.include_processor_extensions['$!='](false) 10457 } 10458 }); 10459 10460 $def(self, '$create_include_cursor', function $$create_include_cursor(file, path, lineno) { 10461 var dir = nil; 10462 10463 10464 if ($eqeqeq($$$('String'), file)) { 10465 dir = $$$('File').$dirname(file); 10466 } else if ($truthy($$('RUBY_ENGINE_OPAL'))) { 10467 dir = $$$('File').$dirname((file = file.$to_s())); 10468 } else { 10469 10470 dir = ($eqeq((dir = $$$('File').$dirname(file.$path())), "") ? ("/") : (dir)); 10471 file = file.$to_s(); 10472 } return $$('Cursor').$new(file, dir, path, lineno); 10473 }); 10474 10475 $def(self, '$to_s', function $$to_s() { 10476 var self = this; 10477 10478 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){ 10479 10480 if (inc == null) inc = nil; 10481 return inc.$to_s();}).$join(", ")) + "]}>" 10482 }); 10483 self.$private(); 10484 10485 $def(self, '$prepare_lines', function $$prepare_lines(data, opts) { 10486 var $yield = $$prepare_lines.$$p || nil, self = this, result = nil, front_matter = nil, $ret_or_1 = nil, last = nil; 10487 10488 $$prepare_lines.$$p = null; 10489 10490 if (opts == null) opts = $hash2([], {}); 10491 result = $send2(self, $find_super(self, 'prepare_lines', $$prepare_lines, false, true), 'prepare_lines', [data, opts], $yield); 10492 if ((($truthy(self.document) && ($truthy(self.document.$attributes()['$[]']("skip-front-matter")))) && ($truthy((front_matter = self['$skip_front_matter!'](result)))))) { 10493 self.document.$attributes()['$[]=']("front-matter", front_matter.$join($$('LF'))); 10494 } if ($truthy(opts.$fetch("condense", true))) { 10495 while ($truthy(($truthy(($ret_or_1 = (last = result['$[]'](-1)))) ? (last['$empty?']()) : ($ret_or_1)))) { 10496 result.$pop(); 10497 } 10498 } if ($truthy(opts['$[]']("indent"))) { 10499 $$('Parser')['$adjust_indentation!'](result, opts['$[]']("indent").$to_i(), self.document.$attr("tabsize").$to_i()); 10500 } return result; 10501 }, -2); 10502 10503 $def(self, '$process_line', function $$process_line(line) { 10504 var $a, self = this; 10505 10506 10507 if (!$truthy(self.process_lines)) { 10508 return line 10509 } if ($truthy(line['$empty?']())) { 10510 10511 self.look_ahead = $rb_plus(self.look_ahead, 1); 10512 return line; 10513 } if ((($truthy(line['$end_with?']("]")) && ($not(line['$start_with?']("[")))) && ($truthy(line['$include?']("::"))))) { 10514 if (($truthy(line['$include?']("if")) && ($truthy($$('ConditionalDirectiveRx')['$=~'](line))))) { 10515 if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), "\\")) { 10516 10517 self.unescape_next_line = true; 10518 self.look_ahead = $rb_plus(self.look_ahead, 1); 10519 return line.$slice(1, line.$length()); 10520 } 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))))) { 10521 10522 self.$shift(); 10523 return nil; 10524 } else { 10525 10526 self.look_ahead = $rb_plus(self.look_ahead, 1); 10527 return line; 10528 } 10529 } else if ($truthy(self.skipping)) { 10530 10531 self.$shift(); 10532 return nil; 10533 } else if (($truthy(line['$start_with?']("inc", "\\inc")) && ($truthy($$('IncludeDirectiveRx')['$=~'](line))))) { 10534 if ($eqeq((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), "\\")) { 10535 10536 self.unescape_next_line = true; 10537 self.look_ahead = $rb_plus(self.look_ahead, 1); 10538 return line.$slice(1, line.$length()); 10539 } else if ($truthy(self.$preprocess_include_directive((($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](3))))) { 10540 return nil 10541 } else { 10542 10543 self.look_ahead = $rb_plus(self.look_ahead, 1); 10544 return line; 10545 } 10546 } else { 10547 10548 self.look_ahead = $rb_plus(self.look_ahead, 1); 10549 return line; 10550 } 10551 } else if ($truthy(self.skipping)) { 10552 10553 self.$shift(); 10554 return nil; 10555 } else { 10556 10557 self.look_ahead = $rb_plus(self.look_ahead, 1); 10558 return line; 10559 } }); 10560 10561 $def(self, '$preprocess_conditional_directive', function $$preprocess_conditional_directive(keyword, target, delimiter, text) { 10562 var $a, self = this, no_target = nil, pair = nil, skip = nil, lhs = nil, op = nil, rhs = nil; 10563 10564 10565 if (!$truthy((no_target = target['$empty?']()))) { 10566 target = target.$downcase(); 10567 } if ($eqeq(keyword, "endif")) { 10568 10569 if ($truthy(text)) { 10570 self.$logger().$error(self.$message_with_context("malformed preprocessor directive - text not permitted: endif::" + (target) + "[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10571 } else if ($truthy(self.conditional_stack['$empty?']())) { 10572 self.$logger().$error(self.$message_with_context("unmatched preprocessor directive: endif::" + (target) + "[]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10573 } else if (($truthy(no_target) || ($eqeq(target, (pair = self.conditional_stack['$[]'](-1))['$[]']("target"))))) { 10574 10575 self.conditional_stack.$pop(); 10576 self.skipping = ($truthy(self.conditional_stack['$empty?']()) ? (false) : (self.conditional_stack['$[]'](-1)['$[]']("skipping"))); 10577 } else { 10578 self.$logger().$error(self.$message_with_context("mismatched preprocessor directive: endif::" + (target) + "[], expected endif::" + (pair['$[]']("target")) + "[]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10579 } return true; 10580 } else if ($truthy(self.skipping)) { 10581 skip = false; 10582 } else 10583 switch (keyword) { 10584 case "ifdef": 10585 10586 if ($truthy(no_target)) { 10587 10588 self.$logger().$error(self.$message_with_context("malformed preprocessor directive - missing target: ifdef::[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10589 return true; 10590 } 10591 switch (delimiter) { 10592 case ",": 10593 skip = $send(target.$split(",", -1), 'none?', [], function $$14(name){var self = $$14.$$s == null ? this : $$14.$$s; 10594 if (self.document == null) self.document = nil; 10595 10596 10597 if (name == null) name = nil; 10598 return self.document.$attributes()['$key?'](name);}, {$$s: self}); 10599 break; 10600 case "+": 10601 skip = $send(target.$split("+", -1), 'any?', [], function $$15(name){var self = $$15.$$s == null ? this : $$15.$$s; 10602 if (self.document == null) self.document = nil; 10603 10604 10605 if (name == null) name = nil; 10606 return self.document.$attributes()['$key?'](name)['$!']();}, {$$s: self}); 10607 break; 10608 default: 10609 skip = self.document.$attributes()['$key?'](target)['$!'](); 10610 } break; 10611 case "ifndef": 10612 10613 if ($truthy(no_target)) { 10614 10615 self.$logger().$error(self.$message_with_context("malformed preprocessor directive - missing target: ifndef::[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10616 return true; 10617 } 10618 switch (delimiter) { 10619 case ",": 10620 skip = $send(target.$split(",", -1), 'any?', [], function $$16(name){var self = $$16.$$s == null ? this : $$16.$$s; 10621 if (self.document == null) self.document = nil; 10622 10623 10624 if (name == null) name = nil; 10625 return self.document.$attributes()['$key?'](name);}, {$$s: self}); 10626 break; 10627 case "+": 10628 skip = $send(target.$split("+", -1), 'all?', [], function $$17(name){var self = $$17.$$s == null ? this : $$17.$$s; 10629 if (self.document == null) self.document = nil; 10630 10631 10632 if (name == null) name = nil; 10633 return self.document.$attributes()['$key?'](name);}, {$$s: self}); 10634 break; 10635 default: 10636 skip = self.document.$attributes()['$key?'](target); 10637 } break; 10638 case "ifeval": 10639 if ($truthy(no_target)) { 10640 if (($truthy(text) && ($truthy($$('EvalExpressionRx')['$=~'](text.$strip()))))) { 10641 10642 lhs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](1)); 10643 op = (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)); 10644 rhs = (($a = $gvars['~']) === nil ? nil : $a['$[]'](3)); 10645 skip = (function() { try { 10646 if ($truthy(self.$resolve_expr_val(lhs).$send(op, self.$resolve_expr_val(rhs)))) { 10647 return false 10648 } else { 10649 return true 10650 } 10651 } catch ($err) { 10652 if (Opal.rescue($err, [$$('StandardError')])) { 10653 try { 10654 return true 10655 } finally { Opal.pop_exception(); } 10656 } else { throw $err; } 10657 }})(); 10658 } else { 10659 10660 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()}))); 10661 return true; 10662 } 10663 } else { 10664 10665 self.$logger().$error(self.$message_with_context("malformed preprocessor directive - target not permitted: ifeval::" + (target) + "[" + (text) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10666 return true; 10667 } 10668 break; 10669 } if (($eqeq(keyword, "ifeval") || ($not(text)))) { 10670 10671 if ($truthy(skip)) { 10672 self.skipping = true; 10673 } self.conditional_stack['$<<']($hash2(["target", "skip", "skipping"], {"target": target, "skip": skip, "skipping": self.skipping})); 10674 } else if (!($truthy(self.skipping) || ($truthy(skip)))) { 10675 10676 self.$replace_next_line(text.$rstrip()); 10677 self.$unshift(""); 10678 if ($truthy(text['$start_with?']("include::"))) { 10679 self.look_ahead = $rb_minus(self.look_ahead, 1); 10680 } } return true; 10681 }); 10682 10683 $def(self, '$preprocess_include_directive', function $$preprocess_include_directive(target, attrlist) { 10684 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; 10685 10686 10687 doc = self.document; 10688 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?']())))) { 10689 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?']())))) { 10690 10691 $send(self.$logger(), 'info', [], function $$18(){var self = $$18.$$s == null ? this : $$18.$$s; 10692 10693 return self.$message_with_context("include dropped due to missing attribute: include::" + (target) + "[" + (attrlist) + "]", $hash2(["source_location"], {"source_location": self.$cursor()}))}, {$$s: self}); 10694 self.$shift(); 10695 return true; 10696 } else if ($truthy(doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true}))['$[]']("optional-option"))) { 10697 10698 $send(self.$logger(), 'info', [], function $$19(){var self = $$19.$$s == null ? this : $$19.$$s; 10699 10700 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}); 10701 self.$shift(); 10702 return true; 10703 } else { 10704 10705 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()}))); 10706 return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (attrlist) + "]"); 10707 } 10708 } else if (($truthy(self['$include_processors?']()) && ($truthy((ext = $send(self.include_processor_extensions, 'find', [], function $$20(candidate){ 10709 10710 if (candidate == null) candidate = nil; 10711 return candidate.$instance()['$handles?'](expanded_target);})))))) { 10712 10713 self.$shift(); 10714 ext.$process_method()['$[]'](doc, self, expanded_target, doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true}))); 10715 return true; 10716 } else if ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SECURE')))) { 10717 return self.$replace_next_line("link:" + (expanded_target) + "[role=include]") 10718 } else if ($truthy(self.maxdepth)) { 10719 10720 if ($truthy($rb_ge(self.include_stack.$size(), self.maxdepth['$[]']("curr")))) { 10721 10722 self.$logger().$error(self.$message_with_context("maximum include depth of " + (self.maxdepth['$[]']("rel")) + " exceeded", $hash2(["source_location"], {"source_location": self.$cursor()}))); 10723 return nil; 10724 } parsed_attrs = doc.$parse_attributes(attrlist, [], $hash2(["sub_input"], {"sub_input": true})); 10725 $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])); 10726 10727 switch (target_type) { 10728 case "file": 10729 10730 reader = $$$('File').$method("open"); 10731 read_mode = $$('FILE_READ_MODE'); 10732 break; 10733 case "uri": 10734 10735 reader = $$$('OpenURI').$method("open_uri"); 10736 read_mode = $$('URI_READ_MODE'); 10737 break; 10738 default: 10739 return inc_path 10740 } if (!$truthy($$('RUBY_ENGINE_OPAL'))) { 10741 if (($truthy((enc = parsed_attrs['$[]']("encoding"))) && ($truthy((function() { try { 10742 return $$$('Encoding').$find(enc) 10743 } catch ($err) { 10744 if (Opal.rescue($err, [$$('StandardError')])) { 10745 try { 10746 return nil 10747 } finally { Opal.pop_exception(); } 10748 } else { throw $err; } 10749 }})())))) { 10750 10751 (read_mode_params = read_mode.$split(":"))['$[]='](1, enc); 10752 read_mode = read_mode_params.$join(":"); 10753 } 10754 } inc_linenos = (inc_tags = nil); 10755 if ($truthy(attrlist)) { 10756 if ($truthy(parsed_attrs['$key?']("lines"))) { 10757 10758 inc_linenos = []; 10759 $send(self.$split_delimited_value(parsed_attrs['$[]']("lines")), 'each', [], function $$21(linedef){var $c, $d, from = nil, to = nil; 10760 10761 10762 if (linedef == null) linedef = nil; 10763 if ($truthy(linedef['$include?'](".."))) { 10764 10765 $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])); 10766 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())))); 10767 } else { 10768 return inc_linenos['$<<'](linedef.$to_i()) 10769 }}); 10770 inc_linenos = ($truthy(inc_linenos['$empty?']()) ? (nil) : (inc_linenos.$sort().$uniq())); 10771 } else if ($truthy(parsed_attrs['$key?']("tag"))) { 10772 if (!($truthy((tag = parsed_attrs['$[]']("tag"))['$empty?']()) || ($eqeq(tag, "!")))) { 10773 inc_tags = ($truthy(tag['$start_with?']("!")) ? ($hash(tag.$slice(1, tag.$length()), false)) : ($hash(tag, true))); 10774 } 10775 } else if ($truthy(parsed_attrs['$key?']("tags"))) { 10776 10777 inc_tags = $hash2([], {}); 10778 $send(self.$split_delimited_value(parsed_attrs['$[]']("tags")), 'each', [], function $$22(tagdef){var $c; 10779 10780 10781 if (tagdef == null) tagdef = nil; 10782 if (($truthy(tagdef['$empty?']()) || ($eqeq(tagdef, "!")))) { 10783 return nil 10784 } else if ($truthy(tagdef['$start_with?']("!"))) { 10785 return ($c = [tagdef.$slice(1, tagdef.$length()), false], $send(inc_tags, '[]=', $c), $c[$c.length - 1]) 10786 } else { 10787 return ($c = [tagdef, true], $send(inc_tags, '[]=', $c), $c[$c.length - 1]) 10788 }}); 10789 if ($truthy(inc_tags['$empty?']())) { 10790 inc_tags = nil; 10791 } } 10792 } if ($truthy(inc_linenos)) { 10793 10794 $a = [[], nil, 0], (inc_lines = $a[0]), (inc_offset = $a[1]), (inc_lineno = $a[2]); 10795 10796 try { 10797 $send(reader, 'call', [inc_path, read_mode], function $$23(f){var select_remaining = nil; 10798 10799 10800 if (f == null) f = nil; 10801 select_remaining = nil; 10802 return (function(){try { var $t_break = $thrower('break'); return $send(f, 'each_line', [], function $$24(l){var select = nil; 10803 10804 10805 if (l == null) l = nil; 10806 inc_lineno = $rb_plus(inc_lineno, 1); 10807 if (($truthy(select_remaining) || (($eqeqeq($$$('Float'), (select = inc_linenos['$[]'](0))) && ($truthy((select_remaining = select['$infinite?']()))))))) { 10808 10809 inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno)); 10810 return inc_lines['$<<'](l); 10811 } else { 10812 10813 if ($eqeq(select, inc_lineno)) { 10814 10815 inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno)); 10816 inc_lines['$<<'](l); 10817 inc_linenos.$shift(); 10818 }; 10819 if ($truthy(inc_linenos['$empty?']())) { 10820 $t_break.$throw(); 10821 } else { 10822 return nil 10823 }; 10824 };})} catch($e) { 10825 if ($e === $t_break) return $e.$v; 10826 throw $e; 10827 }})();}); 10828 } catch ($err) { 10829 if (Opal.rescue($err, [$$('StandardError')])) { 10830 try { 10831 10832 self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))); 10833 return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]"); 10834 } finally { Opal.pop_exception(); } 10835 } else { throw $err; } 10836 } self.$shift(); 10837 if ($truthy(inc_offset)) { 10838 10839 parsed_attrs['$[]=']("partial-option", ""); 10840 self.$push_include(inc_lines, inc_path, relpath, inc_offset, parsed_attrs); 10841 } } else if ($truthy(inc_tags)) { 10842 10843 $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]); 10844 if ($truthy(inc_tags['$key?']("**"))) { 10845 10846 select = (base_select = inc_tags.$delete("**")); 10847 if ($truthy(inc_tags['$key?']("*"))) { 10848 wildcard = inc_tags.$delete("*"); 10849 } else if (($not(select) && ($eqeq(inc_tags.$values().$first(), false)))) { 10850 wildcard = true; 10851 } } else if ($truthy(inc_tags['$key?']("*"))) { 10852 if ($eqeq(inc_tags.$keys().$first(), "*")) { 10853 select = (base_select = (wildcard = inc_tags.$delete("*"))['$!']()); 10854 } else { 10855 10856 select = (base_select = false); 10857 wildcard = inc_tags.$delete("*"); 10858 } 10859 } else { 10860 select = (base_select = inc_tags['$value?'](true)['$!']()); 10861 } 10862 try { 10863 $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; 10864 10865 10866 if (f == null) f = nil; 10867 $c = ["::", "[]"], (dbl_co = $c[0]), (dbl_sb = $c[1]), $c; 10868 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; 10869 10870 10871 if (l == null) l = nil; 10872 inc_lineno = $rb_plus(inc_lineno, 1); 10873 if ((($truthy(l['$include?'](dbl_co)) && ($truthy(l['$include?'](dbl_sb)))) && ($truthy($$('TagDirectiveRx')['$=~'](l))))) { 10874 10875 this_tag = (($d = $gvars['~']) === nil ? nil : $d['$[]'](2)); 10876 if ($truthy((($d = $gvars['~']) === nil ? nil : $d['$[]'](1)))) { 10877 if ($eqeq(this_tag, active_tag)) { 10878 10879 tag_stack.$pop(); 10880 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; 10881 } else if ($truthy(inc_tags['$key?'](this_tag))) { 10882 10883 include_cursor = self.$create_include_cursor(inc_path, expanded_target, inc_lineno); 10884 if ($truthy((idx = $send(tag_stack, 'rindex', [], function $$27(key){ 10885 10886 if (key == null) key = nil; 10887 return key['$=='](this_tag);}, {$$has_trailing_comma_in_args: true})))) { 10888 10889 if ($eqeq(idx, 0)) { 10890 tag_stack.$shift(); 10891 } else { 10892 10893 tag_stack.$delete_at(idx); 10894 }; 10895 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}))); 10896 } else { 10897 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}))) 10898 }; 10899 } else { 10900 return nil 10901 } 10902 } else if ($truthy(inc_tags['$key?'](this_tag))) { 10903 10904 if ($truthy((select = inc_tags['$[]'](this_tag)))) { 10905 tags_selected['$<<'](this_tag); 10906 }; 10907 return tag_stack['$<<']([(active_tag = this_tag), select, inc_lineno]); 10908 } else if ($not(wildcard['$nil?']())) { 10909 10910 select = (($truthy(active_tag) && ($not(select))) ? (false) : (wildcard)); 10911 return tag_stack['$<<']([(active_tag = this_tag), select, inc_lineno]); 10912 } else { 10913 return nil 10914 }; 10915 } else if ($truthy(select)) { 10916 10917 inc_offset = ($truthy(($ret_or_1 = inc_offset)) ? ($ret_or_1) : (inc_lineno)); 10918 return inc_lines['$<<'](l); 10919 } else { 10920 return nil 10921 };}, {$$s: self});}, {$$s: self}); 10922 } catch ($err) { 10923 if (Opal.rescue($err, [$$('StandardError')])) { 10924 try { 10925 10926 self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))); 10927 return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]"); 10928 } finally { Opal.pop_exception(); } 10929 } else { throw $err; } 10930 } if (!$truthy(tag_stack['$empty?']())) { 10931 $send(tag_stack, 'each', [], function $$28(tag_name, _, tag_lineno){var self = $$28.$$s == null ? this : $$28.$$s; 10932 10933 10934 if (tag_name == null) tag_name = nil; 10935 if (tag_lineno == null) tag_lineno = nil; 10936 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}); 10937 } if (!$truthy((missing_tags = $rb_minus($send(inc_tags, 'keep_if', [], function $$29(_, v){ 10938 if (v == null) v = nil; 10939 return v;}).$keys(), tags_selected.$to_a()))['$empty?']())) { 10940 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()}))); 10941 } self.$shift(); 10942 if ($truthy(inc_offset)) { 10943 10944 if (!(($truthy(base_select) && ($neqeq(wildcard, false))) && ($truthy(inc_tags['$empty?']())))) { 10945 parsed_attrs['$[]=']("partial-option", ""); 10946 } self.$push_include(inc_lines, inc_path, relpath, inc_offset, parsed_attrs); 10947 } } else { 10948 10949 inc_content = nil; 10950 10951 try { 10952 10953 inc_content = $send(reader, 'call', [inc_path, read_mode], function $$30(f){ 10954 10955 if (f == null) f = nil; 10956 return f.$read();}); 10957 self.$shift(); 10958 } catch ($err) { 10959 if (Opal.rescue($err, [$$('StandardError')])) { 10960 try { 10961 10962 self.$logger().$error(self.$message_with_context("include " + (target_type) + " not readable: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))); 10963 return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (expanded_target) + "[" + (attrlist) + "]"); 10964 } finally { Opal.pop_exception(); } 10965 } else { throw $err; } 10966 } self.$push_include(inc_content, inc_path, relpath, 1, parsed_attrs); 10967 } return true; 10968 } else { 10969 return nil 10970 } }); 10971 10972 $def(self, '$resolve_include_path', function $$resolve_include_path(target, attrlist, attributes) { 10973 var $b, self = this, doc = nil, inc_path = nil, relpath = nil; 10974 10975 10976 doc = self.document; 10977 if (($truthy($$('Helpers')['$uriish?'](target)) || ($truthy(($eqeqeq($$$('String'), self.dir) ? (nil) : ((target = "" + (self.dir) + "/" + (target)))))))) { 10978 10979 if (!$truthy(doc['$attr?']("allow-uri-read"))) { 10980 return self.$replace_next_line("link:" + (target) + "[role=include]") 10981 } if ($truthy(doc['$attr?']("cache-uri"))) { 10982 if (!$truthy((($b = $$$('::', 'OpenURI', 'skip_raise')) && ($$$($b, 'Cache', 'skip_raise')) ? 'constant' : nil))) { 10983 $$('Helpers').$require_library("open-uri/cached", "open-uri-cached"); 10984 } 10985 } else if ($not($$('RUBY_ENGINE_OPAL'))) { 10986 $$$('OpenURI'); 10987 } return [$$$('URI').$parse(target), "uri", target]; 10988 } else { 10989 10990 inc_path = doc.$normalize_system_path(target, self.dir, nil, $hash2(["target_name"], {"target_name": "include file"})); 10991 if (!$truthy($$$('File')['$file?'](inc_path))) { 10992 if ($truthy(attributes['$[]']("optional-option"))) { 10993 10994 $send(self.$logger(), 'info', [], function $$31(){var self = $$31.$$s == null ? this : $$31.$$s; 10995 10996 return self.$message_with_context("optional include dropped because include file not found: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))}, {$$s: self}); 10997 self.$shift(); 10998 return true; 10999 } else { 11000 11001 self.$logger().$error(self.$message_with_context("include file not found: " + (inc_path), $hash2(["source_location"], {"source_location": self.$cursor()}))); 11002 return self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (attrlist) + "]"); 11003 } 11004 } relpath = doc.$path_resolver().$relative_path(inc_path, doc.$base_dir()); 11005 return [inc_path, "file", relpath]; 11006 } }); 11007 11008 $def(self, '$pop_include', function $$pop_include() { 11009 var $a, $b, self = this; 11010 11011 if ($truthy(self.include_stack['$empty?']())) { 11012 return nil 11013 } else { 11014 11015 $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])); 11016 self.look_ahead = 0; 11017 return nil; 11018 } 11019 }); 11020 11021 $def(self, '$split_delimited_value', function $$split_delimited_value(val) { 11022 11023 if ($truthy(val['$include?'](","))) { 11024 11025 return val.$split(","); 11026 } else { 11027 11028 return val.$split(";"); 11029 } 11030 }); 11031 11032 $def(self, '$skip_front_matter!', function $PreprocessorReader_skip_front_matter$excl$32(data, increment_linenos) { 11033 var self = this, delim = nil, original_data = nil, front_matter = nil, $ret_or_1 = nil, eof = nil; 11034 11035 11036 if (increment_linenos == null) increment_linenos = true; 11037 if (!$eqeq((delim = data['$[]'](0)), "---")) { 11038 return nil 11039 } original_data = data.$drop(0); 11040 data.$shift(); 11041 front_matter = []; 11042 if ($truthy(increment_linenos)) { 11043 self.lineno = $rb_plus(self.lineno, 1); 11044 } while (!($truthy(($truthy(($ret_or_1 = (eof = data['$empty?']()))) ? ($ret_or_1) : (data['$[]'](0)['$=='](delim)))))) { 11045 11046 front_matter['$<<'](data.$shift()); 11047 if ($truthy(increment_linenos)) { 11048 self.lineno = $rb_plus(self.lineno, 1); 11049 } } if ($truthy(eof)) { 11050 11051 $send(data, 'unshift', $to_a(original_data)); 11052 if ($truthy(increment_linenos)) { 11053 self.lineno = $rb_minus(self.lineno, original_data.$size()); 11054 } return nil; 11055 } data.$shift(); 11056 if ($truthy(increment_linenos)) { 11057 self.lineno = $rb_plus(self.lineno, 1); 11058 } return front_matter; 11059 }, -2); 11060 return $def(self, '$resolve_expr_val', function $$resolve_expr_val(val) { 11061 var self = this, quoted = nil; 11062 11063 11064 if ((($truthy(val['$start_with?']("\"")) && ($truthy(val['$end_with?']("\"")))) || (($truthy(val['$start_with?']("'")) && ($truthy(val['$end_with?']("'"))))))) { 11065 11066 quoted = true; 11067 val = val.$slice(1, $rb_minus(val.$length(), 1)); 11068 } else { 11069 quoted = false; 11070 } if ($truthy(val['$include?']($$('ATTR_REF_HEAD')))) { 11071 val = self.document.$sub_attributes(val, $hash2(["attribute_missing"], {"attribute_missing": "drop"})); 11072 } if ($truthy(quoted)) { 11073 return val 11074 } else if ($truthy(val['$empty?']())) { 11075 return nil 11076 } else if ($eqeq(val, "true")) { 11077 return true 11078 } else if ($eqeq(val, "false")) { 11079 return false 11080 } else if ($truthy(val.$rstrip()['$empty?']())) { 11081 return " " 11082 } else if ($truthy(val['$include?']("."))) { 11083 return val.$to_f() 11084 } else { 11085 return val.$to_i() 11086 } }); 11087 })($nesting[0], $$('Reader'), $nesting); 11088 })($nesting[0], $nesting) 11089}; 11090 11091Opal.modules["asciidoctor/section"] = function(Opal) {/* Generated by Opal 1.7.3 */ 11092 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; 11093 11094 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'); 11095 return (function($base, $parent_nesting) { 11096 var self = $module($base, 'Asciidoctor'); 11097 11098 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 11099 11100 return (function($base, $super, $parent_nesting) { 11101 var self = $klass($base, $super, 'Section'); 11102 11103 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 11104 11105 $proto.document = $proto.next_section_index = $proto.parent = $proto.level = $proto.numeral = $proto.numbered = $proto.sectname = $proto.title = $proto.blocks = nil; 11106 11107 self.$attr_accessor("index"); 11108 self.$attr_accessor("sectname"); 11109 self.$attr_accessor("special"); 11110 self.$attr_accessor("numbered"); 11111 self.$attr_reader("caption"); 11112 11113 $def(self, '$initialize', function $$initialize(parent, level, numbered, opts) { 11114 var $a; $$initialize.$$p || nil; var self = this, $ret_or_1 = nil; 11115 11116 $$initialize.$$p = null; 11117 11118 if (parent == null) parent = nil; 11119 if (level == null) level = nil; 11120 if (numbered == null) numbered = false; 11121 if (opts == null) opts = $hash2([], {}); 11122 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "section", opts], null); 11123 if ($eqeqeq($$('Section'), parent)) { 11124 $a = [($truthy(($ret_or_1 = level)) ? ($ret_or_1) : ($rb_plus(parent.$level(), 1))), parent.$special()], (self.level = $a[0]), (self.special = $a[1]); 11125 } else { 11126 $a = [($truthy(($ret_or_1 = level)) ? ($ret_or_1) : (1)), false], (self.level = $a[0]), (self.special = $a[1]); 11127 } self.numbered = numbered; 11128 return (self.index = 0); 11129 }, -1); 11130 $alias(self, "name", "title"); 11131 11132 $def(self, '$generate_id', function $$generate_id() { 11133 var self = this; 11134 11135 return $$('Section').$generate_id(self.$title(), self.document) 11136 }); 11137 11138 $def(self, '$sections?', function $Section_sections$ques$1() { 11139 var self = this; 11140 11141 return $rb_gt(self.next_section_index, 0) 11142 }); 11143 11144 $def(self, '$sectnum', function $$sectnum(delimiter, append) { 11145 var self = this, $ret_or_1 = nil; 11146 11147 11148 if (delimiter == null) delimiter = "."; 11149 if (append == null) append = nil; 11150 append = ($truthy(($ret_or_1 = append)) ? ($ret_or_1) : (($eqeq(append, false) ? ("") : (delimiter)))); 11151 if (($truthy($rb_gt(self.level, 1)) && ($eqeqeq($$('Section'), self.parent)))) { 11152 return "" + (self.parent.$sectnum(delimiter, delimiter)) + (self.numeral) + (append) 11153 } else { 11154 return "" + (self.numeral) + (append) 11155 } }, -1); 11156 11157 $def(self, '$xreftext', function $$xreftext(xrefstyle) { 11158 var self = this, val = nil, type = nil, quoted_title = nil, signifier = nil; 11159 11160 11161 if (xrefstyle == null) xrefstyle = nil; 11162 if (($truthy((val = self.$reftext())) && ($not(val['$empty?']())))) { 11163 return val 11164 } else if ($truthy(xrefstyle)) { 11165 if ($truthy(self.numbered)) { 11166 11167 switch (xrefstyle) { 11168 case "full": 11169 11170 if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) { 11171 quoted_title = self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title()); 11172 } else { 11173 quoted_title = self.$sub_placeholder(self.$sub_quotes(($truthy(self.document.$compat_mode()) ? ("``%s''") : ("\"`%s`\""))), self.$title()); 11174 } if ($truthy((signifier = self.document.$attributes()['$[]']("" + (type) + "-refsig")))) { 11175 return "" + (signifier) + " " + (self.$sectnum(".", ",")) + " " + (quoted_title) 11176 } else { 11177 return "" + (self.$sectnum(".", ",")) + " " + (quoted_title) 11178 } case "short": 11179 if ($truthy((signifier = self.document.$attributes()['$[]']("" + (self.sectname) + "-refsig")))) { 11180 return "" + (signifier) + " " + (self.$sectnum(".", "")) 11181 } else { 11182 return self.$sectnum(".", "") 11183 } 11184 default: 11185 if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) { 11186 11187 return self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title()); 11188 } else { 11189 return self.$title() 11190 } 11191 } 11192 } else if (($eqeq((type = self.sectname), "chapter") || ($eqeq(type, "appendix")))) { 11193 11194 return self.$sub_placeholder(self.$sub_quotes("_%s_"), self.$title()); 11195 } else { 11196 return self.$title() 11197 } 11198 } else { 11199 return self.$title() 11200 } }, -1); 11201 11202 $def(self, '$<<', function $Section_$lt$lt$2(block) { 11203 var $yield = $Section_$lt$lt$2.$$p || nil, self = this; 11204 11205 $Section_$lt$lt$2.$$p = null; 11206 11207 if ($eqeq(block.$context(), "section")) { 11208 self.$assign_numeral(block); 11209 } return $send2(self, $find_super(self, '<<', $Section_$lt$lt$2, false, true), '<<', [block], $yield); 11210 }); 11211 11212 $def(self, '$to_s', function $$to_s() { 11213 var $yield = $$to_s.$$p || nil, self = this, formal_title = nil; 11214 11215 $$to_s.$$p = null; 11216 if ($truthy(self.title)) { 11217 11218 formal_title = ($truthy(self.numbered) ? ("" + (self.$sectnum()) + " " + (self.title)) : (self.title)); 11219 return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {level: " + (self.level) + ", title: " + (formal_title.$inspect()) + ", blocks: " + (self.blocks.$size()) + "}>"; 11220 } else { 11221 return $send2(self, $find_super(self, 'to_s', $$to_s, false, true), 'to_s', [], $yield) 11222 } 11223 }); 11224 return $defs(self, '$generate_id', function $$generate_id(title, document) { 11225 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; 11226 11227 11228 attrs = document.$attributes(); 11229 pre = ($truthy(($ret_or_1 = attrs['$[]']("idprefix"))) ? ($ret_or_1) : ("_")); 11230 if ($truthy((sep = attrs['$[]']("idseparator")))) { 11231 if (($eqeq(sep.$length(), 1) || (($not((no_sep = sep['$empty?']())) && ($truthy((sep = ($a = ["idseparator", sep.$chr()], $send(attrs, '[]=', $a), $a[$a.length - 1])))))))) { 11232 sep_sub = (($eqeq(sep, "-") || ($eqeq(sep, "."))) ? (" .-") : (" " + (sep) + ".-")); 11233 } 11234 } else { 11235 $a = ["_", " _.-"], (sep = $a[0]), (sep_sub = $a[1]); 11236 } gen_id = "" + (pre) + (title.$downcase().$gsub($$('InvalidSectionIdCharsRx'), "")); 11237 if ($truthy(no_sep)) { 11238 gen_id = gen_id.$delete(" "); 11239 } else { 11240 11241 gen_id = gen_id.$tr_s(sep_sub, sep); 11242 if ($truthy(gen_id['$end_with?'](sep))) { 11243 gen_id = gen_id.$chop(); 11244 } if (($truthy(pre['$empty?']()) && ($truthy(gen_id['$start_with?'](sep))))) { 11245 gen_id = gen_id.$slice(1, gen_id.$length()); 11246 } } if ($truthy(document.$catalog()['$[]']("refs")['$key?'](gen_id))) { 11247 11248 ids = document.$catalog()['$[]']("refs"); 11249 cnt = $$('Compliance').$unique_id_start_index(); 11250 while ($truthy(ids['$[]']((candidate_id = "" + (gen_id) + (sep) + (cnt))))) { 11251 cnt = $rb_plus(cnt, 1); 11252 } return candidate_id; 11253 } else { 11254 return gen_id 11255 } }); 11256 })($nesting[0], $$('AbstractBlock'), $nesting) 11257 })($nesting[0], $nesting) 11258}; 11259 11260Opal.modules["asciidoctor/stylesheets"] = function(Opal) {/* Generated by Opal 1.7.3 */ 11261 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.$$$; 11262 11263 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'); 11264 return (function($base, $parent_nesting) { 11265 var self = $module($base, 'Asciidoctor'); 11266 11267 var $nesting = [self].concat($parent_nesting); 11268 11269 return (function($base, $super, $parent_nesting) { 11270 var self = $klass($base, $super, 'Stylesheets'); 11271 11272 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 11273 11274 $proto.primary_stylesheet_data = nil; 11275 11276 $const_set($nesting[0], 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css"); 11277 $const_set($nesting[0], 'STYLESHEETS_DIR', $$$('File').$join($$('DATA_DIR'), "stylesheets")); 11278 self.__instance__ = self.$new(); 11279 $defs(self, '$instance', $return_ivar("__instance__")); 11280 11281 $def(self, '$primary_stylesheet_name', function $$primary_stylesheet_name() { 11282 11283 return $$('DEFAULT_STYLESHEET_NAME') 11284 }); 11285 11286 $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() { 11287 var self = this, $ret_or_1 = nil; 11288 11289 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()))) 11290 }); 11291 11292 $def(self, '$embed_primary_stylesheet', function $$embed_primary_stylesheet() { 11293 var self = this; 11294 11295 return "<style>\n" + (self.$primary_stylesheet_data()) + "\n" + "</style>" 11296 }); 11297 11298 $def(self, '$write_primary_stylesheet', function $$write_primary_stylesheet(target_dir) { 11299 var self = this; 11300 11301 11302 if (target_dir == null) target_dir = "."; 11303 return $$$('File').$write($$$('File').$join(target_dir, self.$primary_stylesheet_name()), self.$primary_stylesheet_data(), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 11304 }, -1); 11305 11306 $def(self, '$coderay_stylesheet_name', function $$coderay_stylesheet_name() { 11307 11308 return $$('SyntaxHighlighter').$for("coderay").$stylesheet_basename() 11309 }); 11310 11311 $def(self, '$coderay_stylesheet_data', function $$coderay_stylesheet_data() { 11312 11313 return $$('SyntaxHighlighter').$for("coderay").$read_stylesheet() 11314 }); 11315 11316 $def(self, '$embed_coderay_stylesheet', function $$embed_coderay_stylesheet() { 11317 var self = this; 11318 11319 return "<style>\n" + (self.$coderay_stylesheet_data()) + "\n" + "</style>" 11320 }); 11321 11322 $def(self, '$write_coderay_stylesheet', function $$write_coderay_stylesheet(target_dir) { 11323 var self = this; 11324 11325 11326 if (target_dir == null) target_dir = "."; 11327 return $$$('File').$write($$$('File').$join(target_dir, self.$coderay_stylesheet_name()), self.$coderay_stylesheet_data(), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 11328 }, -1); 11329 11330 $def(self, '$pygments_stylesheet_name', function $$pygments_stylesheet_name(style) { 11331 11332 11333 if (style == null) style = nil; 11334 return $$('SyntaxHighlighter').$for("pygments").$stylesheet_basename(style); 11335 }, -1); 11336 11337 $def(self, '$pygments_stylesheet_data', function $$pygments_stylesheet_data(style) { 11338 11339 11340 if (style == null) style = nil; 11341 return $$('SyntaxHighlighter').$for("pygments").$read_stylesheet(style); 11342 }, -1); 11343 11344 $def(self, '$embed_pygments_stylesheet', function $$embed_pygments_stylesheet(style) { 11345 var self = this; 11346 11347 11348 if (style == null) style = nil; 11349 return "<style>\n" + (self.$pygments_stylesheet_data(style)) + "\n" + "</style>"; 11350 }, -1); 11351 return $def(self, '$write_pygments_stylesheet', function $$write_pygments_stylesheet(target_dir, style) { 11352 var self = this; 11353 11354 11355 if (target_dir == null) target_dir = "."; 11356 if (style == null) style = nil; 11357 return $$$('File').$write($$$('File').$join(target_dir, self.$pygments_stylesheet_name(style)), self.$pygments_stylesheet_data(style), $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 11358 }, -1); 11359 })($nesting[0], null, $nesting) 11360 })($nesting[0], $nesting) 11361}; 11362 11363Opal.modules["asciidoctor/table"] = function(Opal) {/* Generated by Opal 1.7.3 */ 11364 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.$$$; 11365 11366 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'); 11367 return (function($base, $parent_nesting) { 11368 var self = $module($base, 'Asciidoctor'); 11369 11370 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 11371 11372 11373 (function($base, $super, $parent_nesting) { 11374 var self = $klass($base, $super, 'Table'); 11375 11376 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 11377 11378 $proto.attributes = $proto.document = $proto.rows = $proto.has_header_option = $proto.columns = nil; 11379 11380 $const_set($nesting[0], 'DEFAULT_PRECISION', 4); 11381 (function($base, $super) { 11382 var self = $klass($base, $super, 'Rows'); 11383 11384 var $proto = self.$$prototype; 11385 11386 $proto.head = $proto.body = $proto.foot = nil; 11387 11388 self.$attr_accessor("head", "foot", "body"); 11389 11390 $def(self, '$initialize', function $$initialize(head, foot, body) { 11391 var self = this; 11392 11393 11394 if (head == null) head = []; 11395 if (foot == null) foot = []; 11396 if (body == null) body = []; 11397 self.head = head; 11398 self.foot = foot; 11399 return (self.body = body); 11400 }, -1); 11401 $alias(self, "[]", "send"); 11402 11403 $def(self, '$by_section', function $$by_section() { 11404 var self = this; 11405 11406 return [["head", self.head], ["body", self.body], ["foot", self.foot]] 11407 }); 11408 return $def(self, '$to_h', function $$to_h() { 11409 var self = this; 11410 11411 return $hash2(["head", "body", "foot"], {"head": self.head, "body": self.body, "foot": self.foot}) 11412 }); 11413 })($nesting[0], null); 11414 self.$attr_accessor("columns"); 11415 self.$attr_accessor("rows"); 11416 self.$attr_accessor("has_header_option"); 11417 self.$attr_reader("caption"); 11418 11419 $def(self, '$initialize', function $$initialize(parent, attributes) { 11420 var $a; $$initialize.$$p || nil; var self = this, pcwidth = nil, pcwidth_intval = nil, abswidth_val = nil; 11421 11422 $$initialize.$$p = null; 11423 11424 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [parent, "table"], null); 11425 self.rows = $$('Rows').$new(); 11426 self.columns = []; 11427 self.has_header_option = false; 11428 if ($truthy((pcwidth = attributes['$[]']("width")))) { 11429 if (($truthy($rb_gt((pcwidth_intval = pcwidth.$to_i()), 100)) || ($truthy($rb_lt(pcwidth_intval, 1))))) { 11430 if (!($eqeq(pcwidth_intval, 0) && (($eqeq(pcwidth, "0") || ($eqeq(pcwidth, "0%")))))) { 11431 pcwidth_intval = 100; 11432 } 11433 } 11434 } else { 11435 pcwidth_intval = 100; 11436 } self.attributes['$[]=']("tablepcwidth", pcwidth_intval); 11437 if ($truthy(self.document.$attributes()['$[]']("pagewidth"))) { 11438 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))); 11439 } if ($truthy(attributes['$[]']("rotate-option"))) { 11440 return ($a = ["orientation", "landscape"], $send(self.attributes, '[]=', $a), $a[$a.length - 1]) 11441 } else { 11442 return nil 11443 } }); 11444 11445 $def(self, '$header_row?', function $Table_header_row$ques$1() { 11446 var self = this, val = nil; 11447 11448 if (($truthy((val = self.has_header_option)) && ($truthy(self.rows.$body()['$empty?']())))) { 11449 return val 11450 } else { 11451 return nil 11452 } 11453 }); 11454 11455 $def(self, '$create_columns', function $$create_columns(colspecs) { 11456 var self = this, cols = nil, autowidth_cols = nil, width_base = nil, num_cols = nil; 11457 11458 11459 cols = []; 11460 autowidth_cols = nil; 11461 width_base = 0; 11462 $send(colspecs, 'each', [], function $$2(colspec){var self = $$2.$$s == null ? this : $$2.$$s, colwidth = nil, $ret_or_1 = nil; 11463 11464 11465 if (colspec == null) colspec = nil; 11466 colwidth = colspec['$[]']("width"); 11467 cols['$<<']($$('Column').$new(self, cols.$size(), colspec)); 11468 if ($truthy($rb_lt(colwidth, 0))) { 11469 return (autowidth_cols = ($truthy(($ret_or_1 = autowidth_cols)) ? ($ret_or_1) : ([])))['$<<'](cols['$[]'](-1)) 11470 } else { 11471 return (width_base = $rb_plus(width_base, colwidth)) 11472 }}, {$$s: self}); 11473 if ($truthy($rb_gt((num_cols = (self.columns = cols).$size()), 0))) { 11474 11475 self.attributes['$[]=']("colcount", num_cols); 11476 if (!($truthy($rb_gt(width_base, 0)) || ($truthy(autowidth_cols)))) { 11477 width_base = nil; 11478 } self.$assign_column_widths(width_base, autowidth_cols); 11479 } return nil; 11480 }); 11481 11482 $def(self, '$assign_column_widths', function $$assign_column_widths(width_base, autowidth_cols) { 11483 var self = this, precision = nil, total_width = nil, col_pcwidth = nil, autowidth = nil, autowidth_attrs = nil; 11484 11485 11486 if (width_base == null) width_base = nil; 11487 if (autowidth_cols == null) autowidth_cols = nil; 11488 precision = $$('DEFAULT_PRECISION'); 11489 total_width = (col_pcwidth = 0); 11490 if ($truthy(width_base)) { 11491 11492 if ($truthy(autowidth_cols)) { 11493 11494 if ($truthy($rb_gt(width_base, 100))) { 11495 11496 autowidth = 0; 11497 self.$logger().$warn("total column width must not exceed 100% when using autowidth columns; got " + (width_base) + "%"); 11498 } else { 11499 11500 autowidth = $rb_divide($rb_minus(100, width_base), autowidth_cols.$size()).$truncate(precision); 11501 if ($eqeq(autowidth.$to_i(), autowidth)) { 11502 autowidth = autowidth.$to_i(); 11503 } width_base = 100; 11504 } autowidth_attrs = $hash2(["width", "autowidth-option"], {"width": autowidth, "autowidth-option": ""}); 11505 $send(autowidth_cols, 'each', [], function $$3(col){ 11506 11507 if (col == null) col = nil; 11508 return col.$update_attributes(autowidth_attrs);}); 11509 } $send(self.columns, 'each', [], function $$4(col){ 11510 11511 if (col == null) col = nil; 11512 return (total_width = $rb_plus(total_width, (col_pcwidth = col.$assign_width(nil, width_base, precision))));}); 11513 } else { 11514 11515 col_pcwidth = $rb_divide(100, self.columns.$size()).$truncate(precision); 11516 if ($eqeq(col_pcwidth.$to_i(), col_pcwidth)) { 11517 col_pcwidth = col_pcwidth.$to_i(); 11518 } $send(self.columns, 'each', [], function $$5(col){ 11519 11520 if (col == null) col = nil; 11521 return (total_width = $rb_plus(total_width, col.$assign_width(col_pcwidth, nil, precision)));}); 11522 } if (!$eqeq(total_width, 100)) { 11523 self.columns['$[]'](-1).$assign_width($rb_plus($rb_minus(100, total_width), col_pcwidth).$round(precision), nil, precision); 11524 } return nil; 11525 }, -1); 11526 return $def(self, '$partition_header_footer', function $$partition_header_footer(attrs) { 11527 var $a, self = this, num_body_rows = nil, body = nil; 11528 11529 11530 num_body_rows = ($a = ["rowcount", (body = self.rows.$body()).$size()], $send(self.attributes, '[]=', $a), $a[$a.length - 1]); 11531 if ($truthy($rb_gt(num_body_rows, 0))) { 11532 if ($truthy(self.has_header_option)) { 11533 11534 self.rows['$head=']([$send(body.$shift(), 'map', [], function $$6(cell){ 11535 11536 if (cell == null) cell = nil; 11537 return cell.$reinitialize(true);})]); 11538 num_body_rows = $rb_minus(num_body_rows, 1); 11539 } else if ($truthy(self.has_header_option['$nil?']())) { 11540 11541 self.has_header_option = false; 11542 body.$unshift($send(body.$shift(), 'map', [], function $$7(cell){ 11543 11544 if (cell == null) cell = nil; 11545 return cell.$reinitialize(false);})); 11546 } 11547 } if (($truthy($rb_gt(num_body_rows, 0)) && ($truthy(attrs['$[]']("footer-option"))))) { 11548 self.rows['$foot=']([body.$pop()]); 11549 } return nil; 11550 }); 11551 })($nesting[0], $$('AbstractBlock'), $nesting); 11552 (function($base, $super) { 11553 var self = $klass($base, $super, 'Column'); 11554 11555 var $proto = self.$$prototype; 11556 11557 $proto.attributes = nil; 11558 11559 self.$attr_accessor("style"); 11560 11561 $def(self, '$initialize', function $$initialize(table, index, attributes) { 11562 $$initialize.$$p || nil; var self = this; 11563 11564 $$initialize.$$p = null; 11565 11566 if (attributes == null) attributes = $hash2([], {}); 11567 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [table, "table_column"], null); 11568 self.style = attributes['$[]']("style"); 11569 attributes['$[]=']("colnumber", $rb_plus(index, 1)); 11570 if ($truthy((attributes['$[]']("width")))) ; else { 11571 attributes['$[]=']("width", 1); 11572 } if ($truthy((attributes['$[]']("halign")))) ; else { 11573 attributes['$[]=']("halign", "left"); 11574 } if ($truthy((attributes['$[]']("valign")))) ; else { 11575 attributes['$[]=']("valign", "top"); 11576 } return self.$update_attributes(attributes); 11577 }, -3); 11578 $alias(self, "table", "parent"); 11579 11580 $def(self, '$assign_width', function $$assign_width(col_pcwidth, width_base, precision) { 11581 var $a, self = this, col_abswidth = nil; 11582 11583 11584 if ($truthy(width_base)) { 11585 11586 col_pcwidth = $rb_divide($rb_times(self.attributes['$[]']("width").$to_f(), 100), width_base).$truncate(precision); 11587 if ($eqeq(col_pcwidth.$to_i(), col_pcwidth)) { 11588 col_pcwidth = col_pcwidth.$to_i(); 11589 } } if ($truthy(self.$parent().$attributes()['$[]']("tableabswidth"))) { 11590 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))); 11591 } return ($a = ["colpcwidth", col_pcwidth], $send(self.attributes, '[]=', $a), $a[$a.length - 1]); 11592 }); 11593 11594 $def(self, '$block?', $return_val(false)); 11595 return $def(self, '$inline?', $return_val(false)); 11596 })($$('Table'), $$('AbstractNode')); 11597 (function($base, $super, $parent_nesting) { 11598 var self = $klass($base, $super, 'Cell'); 11599 11600 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 11601 11602 $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; 11603 11604 $const_set($nesting[0], 'DOUBLE_LF', $rb_times($$('LF'), 2)); 11605 self.$attr_accessor("colspan"); 11606 self.$attr_accessor("rowspan"); 11607 $alias(self, "column", "parent"); 11608 self.$attr_reader("inner_document"); 11609 11610 $def(self, '$initialize', function $$initialize(column, cell_text, attributes, opts) { 11611 var $a; $$initialize.$$p || nil; var 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; 11612 11613 $$initialize.$$p = null; 11614 11615 if (attributes == null) attributes = $hash2([], {}); 11616 if (opts == null) opts = $hash2([], {}); 11617 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [column, "table_cell"], null); 11618 self.cursor = (self.reinitialize_args = nil); 11619 if ($truthy(self.document.$sourcemap())) { 11620 self.source_location = opts['$[]']("cursor").$dup(); 11621 } if ($truthy(column)) { 11622 11623 if ($truthy((in_header_row = column.$table()['$header_row?']()))) { 11624 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))))))))) { 11625 11626 if (($eqeq(cell_style, "asciidoc") || ($eqeq(cell_style, "literal")))) { 11627 self.reinitialize_args = [column, cell_text, ($truthy(($ret_or_1 = attributes)) ? (attributes.$merge()) : ($ret_or_1)), opts]; 11628 } cell_style = nil; 11629 } 11630 } else { 11631 cell_style = column.$style(); 11632 } self.$update_attributes(column.$attributes()); 11633 } if ($truthy(attributes)) { 11634 11635 if ($truthy(attributes['$empty?']())) { 11636 self.colspan = (self.rowspan = nil); 11637 } else { 11638 11639 $a = [attributes.$delete("colspan"), attributes.$delete("rowspan")], (self.colspan = $a[0]), (self.rowspan = $a[1]); 11640 if (!$truthy(in_header_row)) { 11641 cell_style = ($truthy(($ret_or_1 = attributes['$[]']("style"))) ? ($ret_or_1) : (cell_style)); 11642 } self.$update_attributes(attributes); 11643 } 11644 switch (cell_style) { 11645 case "asciidoc": 11646 11647 asciidoc = true; 11648 inner_document_cursor = opts['$[]']("cursor"); 11649 if ($truthy((cell_text = cell_text.$rstrip())['$start_with?']($$('LF')))) { 11650 11651 lines_advanced = 1; 11652 while ($truthy((cell_text = cell_text.$slice(1, cell_text.$length()))['$start_with?']($$('LF')))) { 11653 lines_advanced = $rb_plus(lines_advanced, 1); 11654 } inner_document_cursor.$advance(lines_advanced); 11655 } else { 11656 cell_text = cell_text.$lstrip(); 11657 } break; 11658 case "literal": 11659 11660 literal = true; 11661 cell_text = cell_text.$rstrip(); 11662 while ($truthy(cell_text['$start_with?']($$('LF')))) { 11663 cell_text = cell_text.$slice(1, cell_text.$length()); 11664 } break; 11665 default: 11666 11667 normal_psv = true; 11668 cell_text = ($truthy(cell_text) ? (cell_text.$strip()) : ("")); 11669 } } else { 11670 11671 self.colspan = (self.rowspan = nil); 11672 if ($eqeq(cell_style, "asciidoc")) { 11673 11674 asciidoc = true; 11675 inner_document_cursor = opts['$[]']("cursor"); 11676 } } if ($truthy(asciidoc)) { 11677 11678 parent_doctitle = self.document.$attributes().$delete("doctitle"); 11679 inner_document_lines = cell_text.$split($$('LF'), -1); 11680 if (!$truthy(inner_document_lines['$empty?']())) { 11681 if ($truthy((unprocessed_line1 = inner_document_lines['$[]'](0))['$include?']("::"))) { 11682 11683 preprocessed_lines = $$('PreprocessorReader').$new(self.document, [unprocessed_line1]).$readlines(); 11684 if (!($eqeq(unprocessed_line1, preprocessed_lines['$[]'](0)) && ($truthy($rb_lt(preprocessed_lines.$size(), 2))))) { 11685 11686 inner_document_lines.$shift(); 11687 if (!$truthy(preprocessed_lines['$empty?']())) { 11688 $send(inner_document_lines, 'unshift', $to_a(preprocessed_lines)); 11689 } } } 11690 } self.inner_document = $$('Document').$new(inner_document_lines, $hash2(["standalone", "parent", "cursor"], {"standalone": false, "parent": self.document, "cursor": inner_document_cursor})); 11691 if (!$truthy(parent_doctitle['$nil?']())) { 11692 self.document.$attributes()['$[]=']("doctitle", parent_doctitle); 11693 } self.subs = nil; 11694 } else if ($truthy(literal)) { 11695 11696 self.content_model = "verbatim"; 11697 self.subs = $$('BASIC_SUBS'); 11698 } else { 11699 11700 if ($truthy(normal_psv)) { 11701 if ($truthy(in_header_row)) { 11702 self.cursor = opts['$[]']("cursor"); 11703 } else { 11704 self.$catalog_inline_anchor(cell_text, opts['$[]']("cursor")); 11705 } 11706 } self.content_model = "simple"; 11707 self.subs = $$('NORMAL_SUBS'); 11708 } self.text = cell_text; 11709 return (self.style = cell_style); 11710 }, -3); 11711 11712 $def(self, '$reinitialize', function $$reinitialize(has_header) { 11713 var self = this; 11714 11715 11716 if ($truthy(has_header)) { 11717 self.reinitialize_args = nil; 11718 } else if ($truthy(self.reinitialize_args)) { 11719 return $send($$$($$('Table'), 'Cell'), 'new', $to_a(self.reinitialize_args)) 11720 } else { 11721 self.style = self.attributes['$[]']("style"); 11722 } if ($truthy(self.cursor)) { 11723 self.$catalog_inline_anchor(); 11724 } return self; 11725 }); 11726 11727 $def(self, '$catalog_inline_anchor', function $$catalog_inline_anchor(cell_text, cursor) { 11728 var $a, self = this; 11729 11730 11731 if (cell_text == null) cell_text = self.text; 11732 if (cursor == null) cursor = nil; 11733 if (!$truthy(cursor)) { 11734 $a = [self.cursor, nil], (cursor = $a[0]), (self.cursor = $a[1]); 11735 } if (($truthy(cell_text['$start_with?']("[[")) && ($truthy($$('LeadingInlineAnchorRx')['$=~'](cell_text))))) { 11736 return $$('Parser').$catalog_inline_anchor((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), (($a = $gvars['~']) === nil ? nil : $a['$[]'](2)), self, cursor, self.document) 11737 } else { 11738 return nil 11739 } }, -1); 11740 11741 $def(self, '$text', function $$text() { 11742 var self = this; 11743 11744 return self.$apply_subs(self.text, self.subs) 11745 }); 11746 self.$attr_writer("text"); 11747 11748 $def(self, '$content', function $$content() { 11749 var self = this, cell_style = nil, subbed_text = nil; 11750 11751 if ($eqeq((cell_style = self.style), "asciidoc")) { 11752 return self.inner_document.$convert() 11753 } else if ($truthy(self.text['$include?']($$('DOUBLE_LF')))) { 11754 return $send(self.$text().$split($$('BlankLineRx')), 'map', [], function $$8(para){var self = $$8.$$s == null ? this : $$8.$$s; 11755 11756 11757 if (para == null) para = nil; 11758 if (($truthy(cell_style) && ($neqeq(cell_style, "header")))) { 11759 return $$('Inline').$new(self.$parent(), "quoted", para, $hash2(["type"], {"type": cell_style})).$convert() 11760 } else { 11761 return para 11762 }}, {$$s: self}) 11763 } else if ($truthy((subbed_text = self.$text())['$empty?']())) { 11764 return [] 11765 } else if (($truthy(cell_style) && ($neqeq(cell_style, "header")))) { 11766 return [$$('Inline').$new(self.$parent(), "quoted", subbed_text, $hash2(["type"], {"type": cell_style})).$convert()] 11767 } else { 11768 return [subbed_text] 11769 } 11770 }); 11771 11772 $def(self, '$lines', function $$lines() { 11773 var self = this; 11774 11775 return self.text.$split($$('LF')) 11776 }); 11777 11778 $def(self, '$source', $return_ivar("text")); 11779 11780 $def(self, '$file', function $$file() { 11781 var self = this, $ret_or_1 = nil; 11782 11783 if ($truthy(($ret_or_1 = self.source_location))) { 11784 return self.source_location.$file() 11785 } else { 11786 return $ret_or_1 11787 } 11788 }); 11789 11790 $def(self, '$lineno', function $$lineno() { 11791 var self = this, $ret_or_1 = nil; 11792 11793 if ($truthy(($ret_or_1 = self.source_location))) { 11794 return self.source_location.$lineno() 11795 } else { 11796 return $ret_or_1 11797 } 11798 }); 11799 return $def(self, '$to_s', function $$to_s() { 11800 var $yield = $$to_s.$$p || nil, self = this, $ret_or_1 = nil; 11801 11802 $$to_s.$$p = null; 11803 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) + "]" 11804 }); 11805 })($$('Table'), $$('AbstractBlock'), $nesting); 11806 return (function($base, $super, $parent_nesting) { 11807 var self = $klass($base, $super, 'ParserContext'); 11808 11809 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 11810 11811 $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; 11812 11813 self.$include($$('Logging')); 11814 $const_set($nesting[0], 'FORMATS', ["psv", "csv", "dsv", "tsv"].$to_set()); 11815 $const_set($nesting[0], 'DELIMITERS', $hash2(["psv", "csv", "dsv", "tsv", "!sv"], {"psv": ["|", /\|/], "csv": [",", /,/], "dsv": [":", /:/], "tsv": ["\t", /\t/], "!sv": ["!", /!/]})); 11816 self.$attr_accessor("table"); 11817 self.$attr_accessor("format"); 11818 self.$attr_reader("colcount"); 11819 self.$attr_accessor("buffer"); 11820 self.$attr_reader("delimiter"); 11821 self.$attr_reader("delimiter_re"); 11822 11823 $def(self, '$initialize', function $$initialize(reader, table, attributes) { 11824 var $a, $b, self = this, xsv = nil, sep = nil; 11825 11826 11827 if (attributes == null) attributes = $hash2([], {}); 11828 self.start_cursor_data = (self.reader = reader).$mark(); 11829 self.table = table; 11830 if ($truthy(attributes['$key?']("format"))) { 11831 if ($truthy($$('FORMATS')['$include?']((xsv = attributes['$[]']("format"))))) { 11832 if ($eqeq(xsv, "tsv")) { 11833 self.format = "csv"; 11834 } else if (($eqeq((self.format = xsv), "psv") && ($truthy(table.$document()['$nested?']())))) { 11835 xsv = "!sv"; 11836 } 11837 } else { 11838 11839 self.$logger().$error(self.$message_with_context("illegal table format: " + (xsv), $hash2(["source_location"], {"source_location": reader.$cursor_at_prev_line()}))); 11840 $a = ["psv", ($truthy(table.$document()['$nested?']()) ? ("!sv") : ("psv"))], (self.format = $a[0]), (xsv = $a[1]); 11841 } 11842 } else { 11843 $a = ["psv", ($truthy(table.$document()['$nested?']()) ? ("!sv") : ("psv"))], (self.format = $a[0]), (xsv = $a[1]); 11844 } if ($truthy(attributes['$key?']("separator"))) { 11845 if ($truthy((sep = attributes['$[]']("separator"))['$nil_or_empty?']())) { 11846 $b = $$('DELIMITERS')['$[]'](xsv), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])); 11847 } else if ($eqeq(sep, "\\t")) { 11848 $b = $$('DELIMITERS')['$[]']("tsv"), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])); 11849 } else { 11850 $a = [sep, $regexp([$$$('Regexp').$escape(sep)])], (self.delimiter = $a[0]), (self.delimiter_rx = $a[1]); 11851 } 11852 } else { 11853 $b = $$('DELIMITERS')['$[]'](xsv), $a = $to_ary($b), (self.delimiter = ($a[0] == null ? nil : $a[0])), (self.delimiter_rx = ($a[1] == null ? nil : $a[1])); 11854 } self.colcount = ($truthy(table.$columns()['$empty?']()) ? (-1) : (table.$columns().$size())); 11855 self.buffer = ""; 11856 self.cellspecs = []; 11857 self.cell_open = false; 11858 self.active_rowspans = [0]; 11859 self.column_visits = 0; 11860 self.current_row = []; 11861 return (self.linenum = -1); 11862 }, -3); 11863 11864 $def(self, '$starts_with_delimiter?', function $ParserContext_starts_with_delimiter$ques$9(line) { 11865 var self = this; 11866 11867 return line['$start_with?'](self.delimiter) 11868 }); 11869 11870 $def(self, '$match_delimiter', function $$match_delimiter(line) { 11871 var self = this; 11872 11873 return self.delimiter_rx.$match(line) 11874 }); 11875 11876 $def(self, '$skip_past_delimiter', function $$skip_past_delimiter(pre) { 11877 var self = this; 11878 11879 11880 self.buffer = "" + (self.buffer) + (pre) + (self.delimiter); 11881 return nil; 11882 }); 11883 11884 $def(self, '$skip_past_escaped_delimiter', function $$skip_past_escaped_delimiter(pre) { 11885 var self = this; 11886 11887 11888 self.buffer = "" + (self.buffer) + (pre.$chop()) + (self.delimiter); 11889 return nil; 11890 }); 11891 11892 $def(self, '$buffer_has_unclosed_quotes?', function $ParserContext_buffer_has_unclosed_quotes$ques$10(append, q) { 11893 var self = this, record = nil, qq = nil, trailing_quote = nil, $ret_or_1 = nil; 11894 11895 11896 if (append == null) append = nil; 11897 if (q == null) q = "\""; 11898 if ($eqeq((record = ($truthy(append) ? ($rb_plus(self.buffer, append).$strip()) : (self.buffer.$strip()))), q)) { 11899 return true 11900 } else if ($truthy(record['$start_with?'](q))) { 11901 11902 qq = $rb_plus(q, q); 11903 if ((($truthy((trailing_quote = record['$end_with?'](q))) && ($truthy(record['$end_with?'](qq)))) || ($truthy(record['$start_with?'](qq))))) { 11904 if ($truthy(($ret_or_1 = (record = record.$gsub(qq, ""))['$start_with?'](q)))) { 11905 return record['$end_with?'](q)['$!']() 11906 } else { 11907 return $ret_or_1 11908 } 11909 } else { 11910 return trailing_quote['$!']() 11911 } } else { 11912 return false 11913 } }, -1); 11914 11915 $def(self, '$take_cellspec', function $$take_cellspec() { 11916 var self = this; 11917 11918 return self.cellspecs.$shift() 11919 }); 11920 11921 $def(self, '$push_cellspec', function $$push_cellspec(cellspec) { 11922 var self = this, $ret_or_1 = nil; 11923 11924 11925 if (cellspec == null) cellspec = $hash2([], {}); 11926 self.cellspecs['$<<'](($truthy(($ret_or_1 = cellspec)) ? ($ret_or_1) : ($hash2([], {})))); 11927 return nil; 11928 }, -1); 11929 11930 $def(self, '$keep_cell_open', function $$keep_cell_open() { 11931 var self = this; 11932 11933 11934 self.cell_open = true; 11935 return nil; 11936 }); 11937 11938 $def(self, '$mark_cell_closed', function $$mark_cell_closed() { 11939 var self = this; 11940 11941 11942 self.cell_open = false; 11943 return nil; 11944 }); 11945 11946 $def(self, '$cell_open?', $return_ivar("cell_open")); 11947 11948 $def(self, '$cell_closed?', function $ParserContext_cell_closed$ques$11() { 11949 var self = this; 11950 11951 return self.cell_open['$!']() 11952 }); 11953 11954 $def(self, '$close_open_cell', function $$close_open_cell(next_cellspec) { 11955 var self = this; 11956 11957 11958 if (next_cellspec == null) next_cellspec = $hash2([], {}); 11959 self.$push_cellspec(next_cellspec); 11960 if ($truthy(self['$cell_open?']())) { 11961 self.$close_cell(true); 11962 } self.$advance(); 11963 return nil; 11964 }, -1); 11965 11966 $def(self, '$close_cell', function $$close_cell(eol) {try { var $t_return = $thrower('return'); 11967 var self = this, cell_text = nil, cellspec = nil, repeat = nil, $ret_or_1 = nil, q = nil; 11968 11969 11970 if (eol == null) eol = false; 11971 if ($eqeq(self.format, "psv")) { 11972 11973 cell_text = self.buffer; 11974 self.buffer = ""; 11975 if ($truthy((cellspec = self.$take_cellspec()))) { 11976 repeat = ($truthy(($ret_or_1 = cellspec.$delete("repeatcol"))) ? ($ret_or_1) : (1)); 11977 } else { 11978 11979 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))}))); 11980 cellspec = $hash2([], {}); 11981 repeat = 1; 11982 }; 11983 } else { 11984 11985 cell_text = self.buffer.$strip(); 11986 self.buffer = ""; 11987 cellspec = nil; 11988 repeat = 1; 11989 if ((($eqeq(self.format, "csv") && ($not(cell_text['$empty?']()))) && ($truthy(cell_text['$include?']((q = "\"")))))) { 11990 if (($truthy(cell_text['$start_with?'](q)) && ($truthy(cell_text['$end_with?'](q))))) { 11991 if ($truthy((cell_text = cell_text.$slice(1, $rb_minus(cell_text.$length(), 2))))) { 11992 cell_text = cell_text.$strip().$squeeze(q); 11993 } else { 11994 11995 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()}))); 11996 cell_text = ""; 11997 } 11998 } else { 11999 cell_text = cell_text.$squeeze(q); 12000 } 12001 }; 12002 }; 12003 $send((1), 'upto', [repeat], function $$12(i){var self = $$12.$$s == null ? this : $$12.$$s, column = nil, extra_cols = nil, offset = nil, cell = nil; 12004 if (self.colcount == null) self.colcount = nil; 12005 if (self.table == null) self.table = nil; 12006 if (self.current_row == null) self.current_row = nil; 12007 if (self.reader == null) self.reader = nil; 12008 if (self.column_visits == null) self.column_visits = nil; 12009 if (self.linenum == null) self.linenum = nil; 12010 12011 12012 if (i == null) i = nil; 12013 if ($eqeq(self.colcount, -1)) { 12014 12015 self.table.$columns()['$<<']((column = $$$($$('Table'), 'Column').$new(self.table, $rb_minus($rb_plus(self.table.$columns().$size(), i), 1)))); 12016 if ((($truthy(cellspec) && ($truthy(cellspec['$key?']("colspan")))) && ($truthy($rb_gt((extra_cols = $rb_minus(cellspec['$[]']("colspan").$to_i(), 1)), 0))))) { 12017 12018 offset = self.table.$columns().$size(); 12019 $send(extra_cols, 'times', [], function $$13(j){var self = $$13.$$s == null ? this : $$13.$$s; 12020 if (self.table == null) self.table = nil; 12021 12022 12023 if (j == null) j = nil; 12024 return self.table.$columns()['$<<']($$$($$('Table'), 'Column').$new(self.table, $rb_plus(offset, j)));}, {$$s: self}); 12025 }; 12026 } else if (!$truthy((column = self.table.$columns()['$[]'](self.current_row.$size())))) { 12027 12028 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()}))); 12029 $t_return.$throw(); 12030 }; 12031 cell = $$$($$('Table'), 'Cell').$new(column, cell_text, cellspec, $hash2(["cursor"], {"cursor": self.reader.$cursor_before_mark()})); 12032 self.reader.$mark(); 12033 if (!($not(cell.$rowspan()) || ($eqeq(cell.$rowspan(), 1)))) { 12034 self.$activate_rowspan(cell.$rowspan(), ($truthy(($ret_or_1 = cell.$colspan())) ? ($ret_or_1) : (1))); 12035 }; 12036 self.column_visits = $rb_plus(self.column_visits, ($truthy(($ret_or_1 = cell.$colspan())) ? ($ret_or_1) : (1))); 12037 self.current_row['$<<'](cell); 12038 if (($truthy(self['$end_of_row?']()) && ((($neqeq(self.colcount, -1) || ($truthy($rb_gt(self.linenum, 0)))) || (($truthy(eol) && ($eqeq(i, repeat)))))))) { 12039 return self.$close_row() 12040 } else { 12041 return nil 12042 };}, {$$s: self, $$ret: $t_return}); 12043 self.cell_open = false; 12044 return nil;} catch($e) { 12045 if ($e === $t_return) return $e.$v; 12046 throw $e; 12047 } 12048 }, -1); 12049 self.$private(); 12050 12051 $def(self, '$close_row', function $$close_row() { 12052 var self = this; 12053 12054 12055 self.table.$rows().$body()['$<<'](self.current_row); 12056 if ($eqeq(self.colcount, -1)) { 12057 self.colcount = self.column_visits; 12058 } self.column_visits = 0; 12059 self.current_row = []; 12060 self.active_rowspans.$shift(); 12061 if ($truthy((self.active_rowspans['$[]'](0)))) ; else { 12062 self.active_rowspans['$[]='](0, 0); 12063 } return nil; 12064 }); 12065 12066 $def(self, '$activate_rowspan', function $$activate_rowspan(rowspan, colspan) { 12067 var self = this; 12068 12069 12070 $send((1), 'upto', [$rb_minus(rowspan, 1)], function $$14(i){var $a, self = $$14.$$s == null ? this : $$14.$$s, $ret_or_1 = nil; 12071 if (self.active_rowspans == null) self.active_rowspans = nil; 12072 12073 12074 if (i == null) i = nil; 12075 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}); 12076 return nil; 12077 }); 12078 12079 $def(self, '$end_of_row?', function $ParserContext_end_of_row$ques$15() { 12080 var self = this, $ret_or_1 = nil; 12081 12082 if ($truthy(($ret_or_1 = self.colcount['$=='](-1)))) { 12083 return $ret_or_1 12084 } else { 12085 return self.$effective_column_visits()['$=='](self.colcount) 12086 } 12087 }); 12088 12089 $def(self, '$effective_column_visits', function $$effective_column_visits() { 12090 var self = this; 12091 12092 return $rb_plus(self.column_visits, self.active_rowspans['$[]'](0)) 12093 }); 12094 return $def(self, '$advance', function $$advance() { 12095 var self = this; 12096 12097 return (self.linenum = $rb_plus(self.linenum, 1)) 12098 }); 12099 })($$('Table'), null, $nesting); 12100 })($nesting[0], $nesting) 12101}; 12102 12103Opal.modules["asciidoctor/writer"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12104 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.$$$; 12105 12106 Opal.add_stubs('respond_to?,write,+,chomp,include'); 12107 return (function($base, $parent_nesting) { 12108 var self = $module($base, 'Asciidoctor'); 12109 12110 var $nesting = [self].concat($parent_nesting); 12111 12112 12113 (function($base, $parent_nesting) { 12114 var self = $module($base, 'Writer'); 12115 12116 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12117 12118 return $def(self, '$write', function $$write(output, target) { 12119 12120 12121 if ($truthy(target['$respond_to?']("write"))) { 12122 target.$write($rb_plus(output.$chomp(), $$('LF'))); 12123 } else { 12124 $$$('File').$write(target, output, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 12125 } return nil; 12126 }) 12127 })($nesting[0], $nesting); 12128 return (function($base, $parent_nesting) { 12129 var self = $module($base, 'VoidWriter'); 12130 12131 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12132 12133 12134 self.$include($$('Writer')); 12135 return $def(self, '$write', $return_val(nil)); 12136 })($nesting[0], $nesting); 12137 })($nesting[0], $nesting) 12138}; 12139 12140Opal.modules["asciidoctor/load"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12141 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.$$$; 12142 12143 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'); 12144 return (function($base, $parent_nesting) { 12145 var self = $module($base, 'Asciidoctor'); 12146 12147 var $nesting = [self].concat($parent_nesting); 12148 12149 return (function(self, $parent_nesting) { 12150 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12151 12152 12153 12154 $def(self, '$load', function $$load(input, options) { 12155 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; 12156 12157 12158 if (options == null) options = $hash2([], {}); 12159 try { 12160 12161 options = options.$merge(); 12162 if ($truthy((timings = options['$[]']("timings")))) { 12163 timings.$start("read"); 12164 }; 12165 if (($truthy(options['$key?']("logger")) && ($neqeq((logger = options['$[]']("logger")), $$('LoggerManager').$logger())))) { 12166 $$('LoggerManager')['$logger='](($truthy(($ret_or_1 = logger)) ? ($ret_or_1) : ($$('NullLogger').$new()))); 12167 }; 12168 if ($not((attrs = options['$[]']("attributes")))) { 12169 attrs = $hash2([], {}); 12170 } else if ($eqeqeq($$$('Hash'), attrs)) { 12171 attrs = attrs.$merge(); 12172 } else if (($truthy((($c = $$$('::', 'Java', 'skip_raise')) && ($b = $$$($c, 'JavaUtil', 'skip_raise')) && ($a = $$$($b, 'Map', 'skip_raise')) ? 'constant' : nil)) && ($eqeqeq($$$($$$($$$('Java'), 'JavaUtil'), 'Map'), attrs)))) { 12173 attrs = attrs.$dup(); 12174 } else if ($eqeqeq($$$('Array'), attrs)) { 12175 attrs = $send($hash2([], {}), 'tap', [], function $$1(accum){ 12176 12177 if (accum == null) accum = nil; 12178 return $send(attrs, 'each', [], function $$2(entry){var $d, $e, k = nil, _ = nil, v = nil; 12179 12180 12181 if (entry == null) entry = nil; 12182 $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; 12183 return ($d = [k, v], $send(accum, '[]=', $d), $d[$d.length - 1]);});}); 12184 } else if ($eqeqeq($$$('String'), attrs)) { 12185 attrs = $send($hash2([], {}), 'tap', [], function $$3(accum){ 12186 12187 if (accum == null) accum = nil; 12188 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; 12189 12190 12191 if (entry == null) entry = nil; 12192 $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; 12193 return ($d = [k, v], $send(accum, '[]=', $d), $d[$d.length - 1]);});}); 12194 } else if (($truthy(attrs['$respond_to?']("keys")) && ($truthy(attrs['$respond_to?']("[]"))))) { 12195 attrs = $send($hash2([], {}), 'tap', [], function $$5(accum){ 12196 12197 if (accum == null) accum = nil; 12198 return $send(attrs.$keys(), 'each', [], function $$6(k){var $d; 12199 12200 12201 if (k == null) k = nil; 12202 return ($d = [k, attrs['$[]'](k)], $send(accum, '[]=', $d), $d[$d.length - 1]);});}); 12203 } else { 12204 self.$raise($$$('ArgumentError'), "illegal type for attributes option: " + (attrs.$class().$ancestors().$join(" < "))); 12205 }; 12206 if ($eqeqeq($$$('File'), input)) { 12207 12208 options['$[]=']("input_mtime", ($eqeq($$('RUBY_ENGINE'), "jruby") ? ($$$('Time').$at(input.$mtime().$to_i())) : (input.$mtime()))); 12209 attrs['$[]=']("docfile", (input_path = $$$('File').$absolute_path(input.$path()))); 12210 attrs['$[]=']("docdir", $$$('File').$dirname(input_path)); 12211 attrs['$[]=']("docname", $$('Helpers').$basename(input_path, ($d = ["docfilesuffix", $$('Helpers').$extname(input_path)], $send(attrs, '[]=', $d), $d[$d.length - 1]))); 12212 source = input.$read(); 12213 } else if ($truthy(input['$respond_to?']("read"))) { 12214 12215 try { 12216 input.$rewind(); 12217 } catch ($err) { 12218 if (Opal.rescue($err, [$$('StandardError')])) { 12219 try { 12220 nil; 12221 } finally { Opal.pop_exception(); } 12222 } else { throw $err; } 12223 }; 12224 source = input.$read(); 12225 } else if ($eqeqeq($$$('String'), input)) { 12226 source = input; 12227 } else if ($eqeqeq($$$('Array'), input)) { 12228 source = input.$drop(0); 12229 } else if ($truthy(input)) { 12230 self.$raise($$$('ArgumentError'), "unsupported input type: " + (input.$class())); 12231 }; 12232 if ($truthy(timings)) { 12233 12234 timings.$record("read"); 12235 timings.$start("parse"); 12236 }; 12237 options['$[]=']("attributes", attrs); 12238 doc = ($eqeq(options['$[]']("parse"), false) ? ($$('Document').$new(source, options)) : ($$('Document').$new(source, options).$parse())); 12239 if ($truthy(timings)) { 12240 timings.$record("parse"); 12241 }; 12242 return doc; 12243 } catch ($err) { 12244 if (Opal.rescue($err, [$$('StandardError')])) {(e = $err); 12245 try { 12246 12247 12248 try { 12249 12250 context = "asciidoctor: FAILED: " + (($truthy(($ret_or_1 = attrs['$[]']("docfile"))) ? ($ret_or_1) : ("<stdin>"))) + ": Failed to load AsciiDoc document"; 12251 if ($truthy(e['$respond_to?']("exception"))) { 12252 12253 wrapped_e = e.$exception("" + (context) + " - " + (e.$message())); 12254 wrapped_e.$set_backtrace(e.$backtrace()); 12255 } else { 12256 12257 wrapped_e = e.$class().$new(context, e); 12258 wrapped_e['$stack_trace='](e.$stack_trace()); 12259 }; 12260 } catch ($err) { 12261 if (Opal.rescue($err, [$$('StandardError')])) { 12262 try { 12263 wrapped_e = e; 12264 } finally { Opal.pop_exception(); } 12265 } else { throw $err; } 12266 };; 12267 return self.$raise(wrapped_e); 12268 } finally { Opal.pop_exception(); } 12269 } else { throw $err; } 12270 } }, -2); 12271 return $def(self, '$load_file', function $$load_file(filename, options) { 12272 var self = this; 12273 12274 12275 if (options == null) options = $hash2([], {}); 12276 return $send($$$('File'), 'open', [filename, $$('FILE_READ_MODE')], function $$7(file){var self = $$7.$$s == null ? this : $$7.$$s; 12277 12278 12279 if (file == null) file = nil; 12280 return self.$load(file, options);}, {$$s: self}); 12281 }, -2); 12282 })(Opal.get_singleton_class(self), $nesting) 12283 })($nesting[0], $nesting) 12284}; 12285 12286Opal.modules["asciidoctor/convert"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12287 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.$$$; 12288 12289 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'); 12290 return (function($base, $parent_nesting) { 12291 var self = $module($base, 'Asciidoctor'); 12292 12293 var $nesting = [self].concat($parent_nesting); 12294 12295 return (function(self, $parent_nesting) { 12296 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12297 12298 12299 12300 $def(self, '$convert', function $$convert(input, options) { 12301 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; 12302 12303 12304 if (options == null) options = $hash2([], {}); 12305 (options = options.$merge()).$delete("parse"); 12306 to_dir = options.$delete("to_dir"); 12307 mkdirs = options.$delete("mkdirs"); 12308 if (($eqeqeq(true, ($ret_or_1 = (to_file = options.$delete("to_file")))) || ($eqeqeq(nil, $ret_or_1)))) { 12309 12310 if (!$truthy((write_to_target = to_dir))) { 12311 if ($eqeqeq($$$('File'), input)) { 12312 sibling_path = $$$('File').$absolute_path(input.$path()); 12313 } 12314 } to_file = nil; 12315 } else if ($eqeqeq(false, $ret_or_1)) { 12316 to_file = nil; 12317 } else if ($eqeqeq("/dev/null", $ret_or_1)) { 12318 return self.$load(input, options) 12319 } else if (!$truthy((stream_output = to_file['$respond_to?']("write")))) { 12320 options['$[]=']("to_file", (write_to_target = to_file)); 12321 } if (!$truthy(options['$key?']("standalone"))) { 12322 if (($truthy(sibling_path) || ($truthy(write_to_target)))) { 12323 options['$[]=']("standalone", options.$fetch("header_footer", true)); 12324 } else if ($truthy(options['$key?']("header_footer"))) { 12325 options['$[]=']("standalone", options['$[]']("header_footer")); 12326 } 12327 } if ($truthy(sibling_path)) { 12328 options['$[]=']("to_dir", (outdir = $$$('File').$dirname(sibling_path))); 12329 } else if ($truthy(write_to_target)) { 12330 if ($truthy(to_dir)) { 12331 if ($truthy(to_file)) { 12332 options['$[]=']("to_dir", $$$('File').$dirname($$$('File').$expand_path(to_file, to_dir))); 12333 } else { 12334 options['$[]=']("to_dir", $$$('File').$expand_path(to_dir)); 12335 } 12336 } else if ($truthy(to_file)) { 12337 options['$[]=']("to_dir", $$$('File').$dirname($$$('File').$expand_path(to_file))); 12338 } 12339 } doc = self.$load(input, options); 12340 if ($truthy(sibling_path)) { 12341 12342 outfile = $$$('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix())); 12343 if ($eqeq(outfile, sibling_path)) { 12344 self.$raise($$$('IOError'), "input file and output file cannot be the same: " + (outfile)); 12345 } } else if ($truthy(write_to_target)) { 12346 12347 working_dir = ($truthy(options['$key?']("base_dir")) ? ($$$('File').$expand_path(options['$[]']("base_dir"))) : ($$$('Dir').$pwd())); 12348 jail = ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (working_dir) : (nil)); 12349 if ($truthy(to_dir)) { 12350 12351 outdir = doc.$normalize_system_path(to_dir, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false})); 12352 if ($truthy(to_file)) { 12353 12354 outfile = doc.$normalize_system_path(to_file, outdir, nil, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false})); 12355 outdir = $$$('File').$dirname(outfile); 12356 } else { 12357 outfile = $$$('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix())); 12358 } } else if ($truthy(to_file)) { 12359 12360 outfile = doc.$normalize_system_path(to_file, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false})); 12361 outdir = $$$('File').$dirname(outfile); 12362 } if (($eqeqeq($$$('File'), input) && ($eqeq(outfile, $$$('File').$absolute_path(input.$path()))))) { 12363 self.$raise($$$('IOError'), "input file and output file cannot be the same: " + (outfile)); 12364 } if ($truthy(mkdirs)) { 12365 $$('Helpers').$mkdir_p(outdir); 12366 } else if (!$truthy($$$('File')['$directory?'](outdir))) { 12367 self.$raise($$$('IOError'), "target directory does not exist: " + (to_dir) + " (hint: set :mkdirs option)"); 12368 } } else { 12369 12370 outfile = to_file; 12371 outdir = nil; 12372 } if (($truthy(outfile) && ($not(stream_output)))) { 12373 output = doc.$convert($hash2(["outfile", "outdir"], {"outfile": outfile, "outdir": outdir})); 12374 } else { 12375 output = doc.$convert(); 12376 } if ($truthy(outfile)) { 12377 12378 doc.$write(output, outfile); 12379 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)))))) { 12380 12381 if ($truthy((stylesheet = doc.$attr("stylesheet")))) { 12382 if ($truthy($$('DEFAULT_STYLESHEET_KEYS')['$include?'](stylesheet))) { 12383 copy_asciidoctor_stylesheet = true; 12384 } else if ($not($$('Helpers')['$uriish?'](stylesheet))) { 12385 copy_user_stylesheet = true; 12386 } 12387 } copy_syntax_hl_stylesheet = ($truthy(($ret_or_1 = (syntax_hl = doc.$syntax_highlighter()))) ? (syntax_hl['$write_stylesheet?'](doc)) : ($ret_or_1)); 12388 if ((($truthy(copy_asciidoctor_stylesheet) || ($truthy(copy_user_stylesheet))) || ($truthy(copy_syntax_hl_stylesheet)))) { 12389 12390 stylesoutdir = doc.$normalize_system_path(stylesdir, outdir, ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (outdir) : (nil))); 12391 if ($truthy(mkdirs)) { 12392 $$('Helpers').$mkdir_p(stylesoutdir); 12393 } else if (!$truthy($$$('File')['$directory?'](stylesoutdir))) { 12394 self.$raise($$$('IOError'), "target stylesheet directory does not exist: " + (stylesoutdir) + " (hint: set :mkdirs option)"); 12395 } if ($truthy(copy_asciidoctor_stylesheet)) { 12396 $$('Stylesheets').$instance().$write_primary_stylesheet(stylesoutdir); 12397 } else if ($truthy(copy_user_stylesheet)) { 12398 12399 if (($eqeq((stylesheet_src = doc.$attr("copycss")), "") || ($eqeq(stylesheet_src, true)))) { 12400 stylesheet_src = doc.$normalize_system_path(stylesheet); 12401 } else { 12402 stylesheet_src = doc.$normalize_system_path(stylesheet_src.$to_s()); 12403 } stylesheet_dest = doc.$normalize_system_path(stylesheet, stylesoutdir, ($truthy($rb_ge(doc.$safe(), $$$($$('SafeMode'), 'SAFE'))) ? (outdir) : (nil))); 12404 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"}))))))) { 12405 12406 if (($neqeq((stylesheet_outdir = $$$('File').$dirname(stylesheet_dest)), stylesoutdir) && ($not($$$('File')['$directory?'](stylesheet_outdir))))) { 12407 if ($truthy(mkdirs)) { 12408 $$('Helpers').$mkdir_p(stylesheet_outdir); 12409 } else { 12410 self.$raise($$$('IOError'), "target stylesheet directory does not exist: " + (stylesheet_outdir) + " (hint: set :mkdirs option)"); 12411 } 12412 } $$$('File').$write(stylesheet_dest, stylesheet_data, $hash2(["mode"], {"mode": $$('FILE_WRITE_MODE')})); 12413 } } if ($truthy(copy_syntax_hl_stylesheet)) { 12414 syntax_hl.$write_stylesheet(doc, stylesoutdir); 12415 } } } return doc; 12416 } else { 12417 return output 12418 } }, -2); 12419 12420 $def(self, '$convert_file', function $$convert_file(filename, options) { 12421 var self = this; 12422 12423 12424 if (options == null) options = $hash2([], {}); 12425 return $send($$$('File'), 'open', [filename, $$('FILE_READ_MODE')], function $$1(file){var self = $$1.$$s == null ? this : $$1.$$s; 12426 12427 12428 if (file == null) file = nil; 12429 return self.$convert(file, options);}, {$$s: self}); 12430 }, -2); 12431 $alias(self, "render", "convert"); 12432 return $alias(self, "render_file", "convert_file"); 12433 })(Opal.get_singleton_class(self), $nesting) 12434 })($nesting[0], $nesting) 12435}; 12436 12437Opal.modules["asciidoctor/syntax_highlighter/highlightjs"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12438 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.$$$; 12439 12440 Opal.add_stubs('register_for,merge,proc,[]=,attr,[],==,attr?,join,map,split,lstrip'); 12441 return (function($base, $parent_nesting) { 12442 var self = $module($base, 'Asciidoctor'); 12443 12444 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12445 12446 return (function($base, $super, $parent_nesting) { 12447 var self = $klass($base, $super, 'HighlightJsAdapter'); 12448 12449 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12450 12451 12452 self.$register_for("highlightjs", "highlight.js"); 12453 12454 $def(self, '$initialize', function $$initialize($a) { 12455 var $post_args, args, $yield = $$initialize.$$p || nil, self = this; 12456 12457 $$initialize.$$p = null; 12458 12459 $post_args = $slice(arguments); 12460 args = $post_args; 12461 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', $to_a(args), $yield); 12462 return (self.name = (self.pre_class = "highlightjs")); 12463 }, -1); 12464 12465 $def(self, '$format', function $$format(node, lang, opts) { 12466 $$format.$$p || nil; var self = this; 12467 12468 $$format.$$p = null; 12469 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; 12470 if (code == null) code = nil; 12471 return ($a = ["class", "language-" + (($truthy(($ret_or_1 = lang)) ? ($ret_or_1) : ("none"))) + " hljs"], $send(code, '[]=', $a), $a[$a.length - 1]);})}))], null) 12472 }); 12473 12474 $def(self, '$docinfo?', $return_val(true)); 12475 return $def(self, '$docinfo', function $$docinfo(location, doc, opts) { 12476 var base_url = nil; 12477 12478 12479 base_url = doc.$attr("highlightjsdir", "" + (opts['$[]']("cdn_base_url")) + "/highlight.js/" + ($$('HIGHLIGHT_JS_VERSION'))); 12480 if ($eqeq(location, "head")) { 12481 return "<link rel=\"stylesheet\" href=\"" + (base_url) + "/styles/" + (doc.$attr("highlightjs-theme", "github")) + ".min.css\"" + (opts['$[]']("self_closing_tag_slash")) + ">" 12482 } else { 12483 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){ 12484 12485 if (lang == null) lang = nil; 12486 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>" 12487 } }); 12488 })($$('SyntaxHighlighter'), $$$($$('SyntaxHighlighter'), 'Base'), $nesting) 12489 })($nesting[0], $nesting) 12490}; 12491 12492Opal.modules["asciidoctor/syntax_highlighter"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12493 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.$$$; 12494 12495 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'); 12496 12497 (function($base, $parent_nesting) { 12498 var self = $module($base, 'Asciidoctor'); 12499 12500 var $nesting = [self].concat($parent_nesting); 12501 12502 return (function($base, $parent_nesting) { 12503 var self = $module($base, 'SyntaxHighlighter'); 12504 12505 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12506 12507 12508 self.$attr_reader("name"); 12509 12510 $def(self, '$initialize', function $$initialize(name, backend, opts) { 12511 var self = this; 12512 if (opts == null) opts = $hash2([], {}); 12513 return (self.name = (self.pre_class = name)); 12514 }, -2); 12515 12516 $def(self, '$docinfo?', $return_val(nil)); 12517 12518 $def(self, '$docinfo', function $$docinfo(location, doc, opts) { 12519 var self = this; 12520 12521 return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("docinfo") + " method since #docinfo? returns true") 12522 }); 12523 12524 $def(self, '$highlight?', $return_val(nil)); 12525 12526 $def(self, '$highlight', function $$highlight(node, source, lang, opts) { 12527 var self = this; 12528 12529 return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("highlight") + " method since #highlight? returns true") 12530 }); 12531 12532 $def(self, '$format', function $$format(node, lang, opts) { 12533 var self = this; 12534 12535 return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("format") + " method") 12536 }); 12537 12538 $def(self, '$write_stylesheet?', $return_val(nil)); 12539 12540 $def(self, '$write_stylesheet', function $$write_stylesheet(doc, to_dir) { 12541 var self = this; 12542 12543 return self.$raise($$$('NotImplementedError'), "" + ($$('SyntaxHighlighter')) + " subclass " + (self.$class()) + " must implement the #" + ("write_stylesheet") + " method since #write_stylesheet? returns true") 12544 }); 12545 $defs(self, '$included', function $$included(into) { 12546 12547 return into.$extend($$('Config')) 12548 }); 12549 self.$private_class_method("included"); 12550 (function($base, $parent_nesting) { 12551 var self = $module($base, 'Config'); 12552 12553 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12554 12555 return $def(self, '$register_for', function $$register_for($a) { 12556 var $post_args, names, self = this; 12557 12558 12559 $post_args = $slice(arguments); 12560 names = $post_args; 12561 return $send($$('SyntaxHighlighter'), 'register', [self].concat($to_a($send(names, 'map', [], function $$1(name){ 12562 12563 if (name == null) name = nil; 12564 return name.$to_s();})))); 12565 }, -1) 12566 })($nesting[0], $nesting); 12567 (function($base, $parent_nesting) { 12568 var self = $module($base, 'Factory'); 12569 12570 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12571 12572 12573 12574 $def(self, '$register', function $$register(syntax_highlighter, $a) { 12575 var $post_args, names, self = this; 12576 12577 12578 $post_args = $slice(arguments, 1); 12579 names = $post_args; 12580 return $send(names, 'each', [], function $$2(name){var $b, self = $$2.$$s == null ? this : $$2.$$s; 12581 12582 12583 if (name == null) name = nil; 12584 return ($b = [name, syntax_highlighter], $send(self.$registry(), '[]=', $b), $b[$b.length - 1]);}, {$$s: self}); 12585 }, -2); 12586 12587 $def(self, '$for', function $Factory_for$3(name) { 12588 var self = this; 12589 12590 return self.$registry()['$[]'](name) 12591 }); 12592 12593 $def(self, '$create', function $$create(name, backend, opts) { 12594 var self = this, syntax_hl = nil; 12595 12596 12597 if (backend == null) backend = "html5"; 12598 if (opts == null) opts = $hash2([], {}); 12599 if ($truthy((syntax_hl = self.$for(name)))) { 12600 12601 if ($eqeqeq($Class, syntax_hl)) { 12602 syntax_hl = syntax_hl.$new(name, backend, opts); 12603 } if (!$truthy(syntax_hl.$name())) { 12604 self.$raise($$$('NameError'), "" + (syntax_hl.$class()) + " must specify a value for `name'"); 12605 } return syntax_hl; 12606 } else { 12607 return nil 12608 } }, -2); 12609 self.$private(); 12610 return $def(self, '$registry', function $$registry() { 12611 var self = this; 12612 12613 return self.$raise($$$('NotImplementedError'), "" + ($$('Factory')) + " subclass " + (self.$class()) + " must implement the #" + ("registry") + " method") 12614 }); 12615 })($nesting[0], $nesting); 12616 (function($base, $super, $parent_nesting) { 12617 var self = $klass($base, $super, 'CustomFactory'); 12618 12619 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12620 12621 12622 self.$include($$('Factory')); 12623 12624 $def(self, '$initialize', function $$initialize(seed_registry) { 12625 var self = this, $ret_or_1 = nil; 12626 12627 12628 if (seed_registry == null) seed_registry = nil; 12629 return (self.registry = ($truthy(($ret_or_1 = seed_registry)) ? ($ret_or_1) : ($hash2([], {})))); 12630 }, -1); 12631 self.$private(); 12632 return self.$attr_reader("registry"); 12633 })($nesting[0], null, $nesting); 12634 (function($base, $parent_nesting) { 12635 var self = $module($base, 'DefaultFactory'); 12636 12637 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12638 12639 12640 self.$include($$('Factory')); 12641 $class_variable_set($nesting[0], '@@registry', $hash2([], {})); 12642 self.$private(); 12643 12644 $def(self, '$registry', function $$registry() { 12645 12646 return $class_variable_get($nesting[0], '@@registry', false) 12647 }); 12648 return nil; 12649 })($nesting[0], $nesting); 12650 (function($base, $super, $parent_nesting) { 12651 var self = $klass($base, $super, 'DefaultFactoryProxy'); 12652 12653 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12654 12655 12656 self.$include($$('DefaultFactory')); 12657 return nil; 12658 })($nesting[0], $$('CustomFactory'), $nesting); 12659 (function($base, $super, $parent_nesting) { 12660 var self = $klass($base, $super, 'Base'); 12661 12662 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 12663 12664 $proto.pre_class = nil; 12665 12666 self.$include($$('SyntaxHighlighter')); 12667 return $def(self, '$format', function $$format(node, lang, opts) { 12668 var self = this, class_attr_val = nil, transform = nil, pre = nil, code = nil; 12669 12670 12671 class_attr_val = ($truthy(opts['$[]']("nowrap")) ? ("" + (self.pre_class) + " highlight nowrap") : ("" + (self.pre_class) + " highlight")); 12672 if ($truthy((transform = opts['$[]']("transform")))) { 12673 12674 transform['$[]']((pre = $hash2(["class"], {"class": class_attr_val})), (code = ($truthy(lang) ? ($hash2(["data-lang"], {"data-lang": lang})) : ($hash2([], {}))))); 12675 if ($truthy((lang = code.$delete("data-lang")))) { 12676 code['$[]=']("data-lang", lang); 12677 } return "<pre" + ($send(pre, 'map', [], function $$4(k, v){ 12678 12679 if (k == null) k = nil; 12680 if (v == null) v = nil; 12681 return " " + (k) + "=\"" + (v) + "\"";}).$join()) + "><code" + ($send(code, 'map', [], function $$5(k, v){ 12682 12683 if (k == null) k = nil; 12684 if (v == null) v = nil; 12685 return " " + (k) + "=\"" + (v) + "\"";}).$join()) + ">" + (node.$content()) + "</code></pre>"; 12686 } else { 12687 return "<pre class=\"" + (class_attr_val) + "\"><code" + (($truthy(lang) ? (" data-lang=\"" + (lang) + "\"") : (""))) + ">" + (node.$content()) + "</code></pre>" 12688 } }); 12689 })($nesting[0], null, $nesting); 12690 return self.$extend($$('DefaultFactory')); 12691 })($nesting[0], $nesting) 12692 })($nesting[0], $nesting); 12693 self.$require("asciidoctor/syntax_highlighter.rb"+ '/../' + "syntax_highlighter/highlightjs"); 12694 return nil; 12695}; 12696 12697Opal.modules["asciidoctor/timings"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12698 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.$$$; 12699 12700 Opal.add_stubs('[]=,now,-,delete,reduce,+,[],>,time,puts,sprintf,to_f,read_parse,convert,read_parse_convert,private,==,const_defined?,clock_gettime'); 12701 return (function($base, $parent_nesting) { 12702 var self = $module($base, 'Asciidoctor'); 12703 12704 var $nesting = [self].concat($parent_nesting); 12705 12706 return (function($base, $super, $parent_nesting) { 12707 var self = $klass($base, $super, 'Timings'); 12708 12709 var $a, $b, $c, $d, $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 12710 12711 $proto.timers = $proto.log = nil; 12712 12713 12714 $def(self, '$initialize', function $$initialize() { 12715 var self = this; 12716 12717 12718 self.log = $hash2([], {}); 12719 return (self.timers = $hash2([], {})); 12720 }); 12721 12722 $def(self, '$start', function $$start(key) { 12723 var $a, self = this; 12724 12725 return ($a = [key, self.$now()], $send(self.timers, '[]=', $a), $a[$a.length - 1]) 12726 }); 12727 12728 $def(self, '$record', function $$record(key) { 12729 var $a, self = this; 12730 12731 return ($a = [key, $rb_minus(self.$now(), self.timers.$delete(key))], $send(self.log, '[]=', $a), $a[$a.length - 1]) 12732 }); 12733 12734 $def(self, '$time', function $$time($a) { 12735 var $post_args, keys, self = this, time = nil; 12736 12737 12738 $post_args = $slice(arguments); 12739 keys = $post_args; 12740 time = $send(keys, 'reduce', [0], function $$1(sum, key){var self = $$1.$$s == null ? this : $$1.$$s, $ret_or_1 = nil; 12741 if (self.log == null) self.log = nil; 12742 12743 12744 if (sum == null) sum = nil; 12745 if (key == null) key = nil; 12746 return $rb_plus(sum, ($truthy(($ret_or_1 = self.log['$[]'](key))) ? ($ret_or_1) : (0)));}, {$$s: self}); 12747 if ($truthy($rb_gt(time, 0))) { 12748 return time 12749 } else { 12750 return nil 12751 } }, -1); 12752 12753 $def(self, '$read', function $$read() { 12754 var self = this; 12755 12756 return self.$time("read") 12757 }); 12758 12759 $def(self, '$parse', function $$parse() { 12760 var self = this; 12761 12762 return self.$time("parse") 12763 }); 12764 12765 $def(self, '$read_parse', function $$read_parse() { 12766 var self = this; 12767 12768 return self.$time("read", "parse") 12769 }); 12770 12771 $def(self, '$convert', function $$convert() { 12772 var self = this; 12773 12774 return self.$time("convert") 12775 }); 12776 12777 $def(self, '$read_parse_convert', function $$read_parse_convert() { 12778 var self = this; 12779 12780 return self.$time("read", "parse", "convert") 12781 }); 12782 12783 $def(self, '$write', function $$write() { 12784 var self = this; 12785 12786 return self.$time("write") 12787 }); 12788 12789 $def(self, '$total', function $$total() { 12790 var self = this; 12791 12792 return self.$time("read", "parse", "convert", "write") 12793 }); 12794 12795 $def(self, '$print_report', function $$print_report(to, subject) { 12796 var self = this; 12797 if ($gvars.stdout == null) $gvars.stdout = nil; 12798 12799 12800 if (to == null) to = $gvars.stdout; 12801 if (subject == null) subject = nil; 12802 if ($truthy(subject)) { 12803 to.$puts("Input file: " + (subject)); 12804 } to.$puts(" Time to read and parse source: " + (self.$sprintf("%05.5f", self.$read_parse().$to_f()))); 12805 to.$puts(" Time to convert document: " + (self.$sprintf("%05.5f", self.$convert().$to_f()))); 12806 return to.$puts(" Total time (read, parse and convert): " + (self.$sprintf("%05.5f", self.$read_parse_convert().$to_f()))); 12807 }, -1); 12808 self.$private(); 12809 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")))) { 12810 12811 $const_set($nesting[0], 'CLOCK_ID', $$$($$$('Process'), 'CLOCK_MONOTONIC')); 12812 return $def(self, '$now', function $$now() { 12813 12814 return $$$('Process').$clock_gettime($$('CLOCK_ID')) 12815 }); 12816 } else { 12817 return $def(self, '$now', function $$now() { 12818 12819 return $$$('Time').$now() 12820 }) 12821 } })($nesting[0], null, $nesting) 12822 })($nesting[0], $nesting) 12823}; 12824 12825Opal.modules["asciidoctor/converter/html5"] = function(Opal) {/* Generated by Opal 1.7.3 */ 12826 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.$$$; 12827 12828 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'); 12829 return (function($base, $parent_nesting) { 12830 var self = $module($base, 'Asciidoctor'); 12831 12832 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 12833 12834 return (function($base, $super, $parent_nesting) { 12835 var self = $klass($base, $super, 'Html5Converter'); 12836 12837 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 12838 12839 $proto.void_element_slash = $proto.xml_mode = $proto.refs = $proto.resolving_xref = nil; 12840 12841 self.$register_for("html5"); 12842 $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": ["“", "”"], "single": ["‘", "’"], "mark": ["<mark>", "</mark>", true], "superscript": ["<sup>", "</sup>", true], "subscript": ["<sub>", "</sub>", true], "asciimath": ["\\$", "\\$"], "latexmath": ["\\(", "\\)"]}))['$default='](["", ""]); 12843 $const_set($nesting[0], 'DropAnchorRx', /<(?:a\b[^>]*|\/a)>/); 12844 $const_set($nesting[0], 'StemBreakRx', / *\\\n(?:\\?\n)*|\n\n+/); 12845 12846 $const_set($nesting[0], 'SvgPreambleRx', $regexp(["^", $$('CC_ALL'), "*?(?=<svg[\\s>])"])); 12847 $const_set($nesting[0], 'SvgStartTagRx', /^<svg(?:\s[^>]*)?>/); $const_set($nesting[0], 'DimensionAttributeRx', $regexp(["\\s(?:width|height|style)=([\"'])", $$('CC_ANY'), "*?\\1"])); 12848 12849 $def(self, '$initialize', function $$initialize(backend, opts) { 12850 var self = this, syntax = nil; 12851 12852 12853 if (opts == null) opts = $hash2([], {}); 12854 self.backend = backend; 12855 if ($eqeq(opts['$[]']("htmlsyntax"), "xml")) { 12856 12857 syntax = "xml"; 12858 self.xml_mode = true; 12859 self.void_element_slash = "/"; 12860 } else { 12861 12862 syntax = "html"; 12863 self.xml_mode = nil; 12864 self.void_element_slash = ""; 12865 } return self.$init_backend_traits($hash2(["basebackend", "filetype", "htmlsyntax", "outfilesuffix", "supports_templates"], {"basebackend": "html", "filetype": "html", "htmlsyntax": syntax, "outfilesuffix": ".html", "supports_templates": true})); 12866 }, -2); 12867 12868 $def(self, '$convert', function $$convert(node, transform, opts) { 12869 var $yield = $$convert.$$p || nil, self = this; 12870 12871 $$convert.$$p = null; 12872 12873 if (transform == null) transform = node.$node_name(); 12874 if (opts == null) opts = nil; 12875 12876 switch (transform) { 12877 case "inline_quoted": 12878 return self.$convert_inline_quoted(node) 12879 case "paragraph": 12880 return self.$convert_paragraph(node) 12881 case "inline_anchor": 12882 return self.$convert_inline_anchor(node) 12883 case "section": 12884 return self.$convert_section(node) 12885 case "listing": 12886 return self.$convert_listing(node) 12887 case "literal": 12888 return self.$convert_literal(node) 12889 case "ulist": 12890 return self.$convert_ulist(node) 12891 case "olist": 12892 return self.$convert_olist(node) 12893 case "dlist": 12894 return self.$convert_dlist(node) 12895 case "admonition": 12896 return self.$convert_admonition(node) 12897 case "colist": 12898 return self.$convert_colist(node) 12899 case "embedded": 12900 return self.$convert_embedded(node) 12901 case "example": 12902 return self.$convert_example(node) 12903 case "floating_title": 12904 return self.$convert_floating_title(node) 12905 case "image": 12906 return self.$convert_image(node) 12907 case "inline_break": 12908 return self.$convert_inline_break(node) 12909 case "inline_button": 12910 return self.$convert_inline_button(node) 12911 case "inline_callout": 12912 return self.$convert_inline_callout(node) 12913 case "inline_footnote": 12914 return self.$convert_inline_footnote(node) 12915 case "inline_image": 12916 return self.$convert_inline_image(node) 12917 case "inline_indexterm": 12918 return self.$convert_inline_indexterm(node) 12919 case "inline_kbd": 12920 return self.$convert_inline_kbd(node) 12921 case "inline_menu": 12922 return self.$convert_inline_menu(node) 12923 case "open": 12924 return self.$convert_open(node) 12925 case "page_break": 12926 return self.$convert_page_break(node) 12927 case "preamble": 12928 return self.$convert_preamble(node) 12929 case "quote": 12930 return self.$convert_quote(node) 12931 case "sidebar": 12932 return self.$convert_sidebar(node) 12933 case "stem": 12934 return self.$convert_stem(node) 12935 case "table": 12936 return self.$convert_table(node) 12937 case "thematic_break": 12938 return self.$convert_thematic_break(node) 12939 case "verse": 12940 return self.$convert_verse(node) 12941 case "video": 12942 return self.$convert_video(node) 12943 case "document": 12944 return self.$convert_document(node) 12945 case "toc": 12946 return self.$convert_toc(node) 12947 case "pass": 12948 return self.$convert_pass(node) 12949 case "audio": 12950 return self.$convert_audio(node) 12951 default: 12952 return $send2(self, $find_super(self, 'convert', $$convert, false, true), 'convert', [node, transform, opts], $yield) 12953 } }, -2); 12954 12955 $def(self, '$convert_document', function $$convert_document(node) { 12956 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; 12957 12958 12959 br = "<br" + ((slash = self.void_element_slash)) + ">"; 12960 if (!$truthy((asset_uri_scheme = node.$attr("asset-uri-scheme", "https"))['$empty?']())) { 12961 asset_uri_scheme = "" + (asset_uri_scheme) + ":"; 12962 } cdn_base_url = "" + (asset_uri_scheme) + "//cdnjs.cloudflare.com/ajax/libs"; 12963 linkcss = node['$attr?']("linkcss"); 12964 max_width_attr = ($truthy(node['$attr?']("max-width")) ? (" style=\"max-width: " + (node.$attr("max-width")) + ";\"") : ("")); 12965 result = ["<!DOCTYPE html>"]; 12966 lang_attribute = ($truthy(node['$attr?']("nolang")) ? ("") : (" lang=\"" + (node.$attr("lang", "en")) + "\"")); 12967 result['$<<']("<html" + (($truthy(self.xml_mode) ? (" xmlns=\"http://www.w3.org/1999/xhtml\"") : (""))) + (lang_attribute) + ">"); 12968 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) + ">"); 12969 if ($truthy(node['$attr?']("app-name"))) { 12970 result['$<<']("<meta name=\"application-name\" content=\"" + (node.$attr("app-name")) + "\"" + (slash) + ">"); 12971 } if ($truthy(node['$attr?']("description"))) { 12972 result['$<<']("<meta name=\"description\" content=\"" + (node.$attr("description")) + "\"" + (slash) + ">"); 12973 } if ($truthy(node['$attr?']("keywords"))) { 12974 result['$<<']("<meta name=\"keywords\" content=\"" + (node.$attr("keywords")) + "\"" + (slash) + ">"); 12975 } if ($truthy(node['$attr?']("authors"))) { 12976 result['$<<']("<meta name=\"author\" content=\"" + (($truthy((authors = node.$sub_replacements(node.$attr("authors")))['$include?']("<")) ? (authors.$gsub($$('XmlSanitizeRx'), "")) : (authors))) + "\"" + (slash) + ">"); 12977 } if ($truthy(node['$attr?']("copyright"))) { 12978 result['$<<']("<meta name=\"copyright\" content=\"" + (node.$attr("copyright")) + "\"" + (slash) + ">"); 12979 } if ($truthy(node['$attr?']("favicon"))) { 12980 12981 if ($truthy((icon_href = node.$attr("favicon"))['$empty?']())) { 12982 12983 icon_href = "favicon.ico"; 12984 icon_type = "image/x-icon"; 12985 } else if ($truthy((icon_ext = $$('Helpers').$extname(icon_href, nil)))) { 12986 icon_type = ($eqeq(icon_ext, ".ico") ? ("image/x-icon") : ("image/" + (icon_ext.$slice(1, icon_ext.$length())))); 12987 } else { 12988 icon_type = "image/x-icon"; 12989 } result['$<<']("<link rel=\"icon\" type=\"" + (icon_type) + "\" href=\"" + (icon_href) + "\"" + (slash) + ">"); 12990 } result['$<<']("<title>" + (node.$doctitle($hash2(["sanitize", "use_fallback"], {"sanitize": true, "use_fallback": true}))) + "</title>"); 12991 if ($truthy($$('DEFAULT_STYLESHEET_KEYS')['$include?'](node.$attr("stylesheet")))) { 12992 12993 if ($truthy((webfonts = node.$attr("webfonts")))) { 12994 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) + ">"); 12995 } if ($truthy(linkcss)) { 12996 result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path($$('DEFAULT_STYLESHEET_NAME'), node.$attr("stylesdir", ""), false)) + "\"" + (slash) + ">"); 12997 } else { 12998 result['$<<']("<style>\n" + ($$('Stylesheets').$instance().$primary_stylesheet_data()) + "\n" + "</style>"); 12999 } } else if ($truthy(node['$attr?']("stylesheet"))) { 13000 if ($truthy(linkcss)) { 13001 result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path(node.$attr("stylesheet"), node.$attr("stylesdir", ""))) + "\"" + (slash) + ">"); 13002 } else { 13003 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>"); 13004 } 13005 } if ($truthy(node['$attr?']("icons", "font"))) { 13006 if ($truthy(node['$attr?']("iconfont-remote"))) { 13007 result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$attr("iconfont-cdn", "" + (cdn_base_url) + "/font-awesome/" + ($$('FONT_AWESOME_VERSION')) + "/css/font-awesome.min.css")) + "\"" + (slash) + ">"); 13008 } else { 13009 13010 iconfont_stylesheet = "" + (node.$attr("iconfont-name", "font-awesome")) + ".css"; 13011 result['$<<']("<link rel=\"stylesheet\" href=\"" + (node.$normalize_web_path(iconfont_stylesheet, node.$attr("stylesdir", ""), false)) + "\"" + (slash) + ">"); 13012 } 13013 } if ($truthy((syntax_hl = node.$syntax_highlighter()))) { 13014 result['$<<']((syntax_hl_docinfo_head_idx = result.$size())); 13015 } if (!$truthy((docinfo_content = node.$docinfo())['$empty?']())) { 13016 result['$<<'](docinfo_content); 13017 } result['$<<']("</head>"); 13018 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13019 if (((($truthy((sectioned = node['$sections?']())) && ($truthy(node['$attr?']("toc-class")))) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) { 13020 classes = [node.$doctype(), node.$attr("toc-class"), "toc-" + (node.$attr("toc-position", "header"))]; 13021 } else { 13022 classes = [node.$doctype()]; 13023 } if ($truthy(node['$role?']())) { 13024 classes['$<<'](node.$role()); 13025 } result['$<<']("<body" + (id_attr) + " class=\"" + (classes.$join(" ")) + "\">"); 13026 if (!$truthy((docinfo_content = node.$docinfo("header"))['$empty?']())) { 13027 result['$<<'](docinfo_content); 13028 } if (!$truthy(node.$noheader())) { 13029 13030 result['$<<']("<div id=\"header\"" + (max_width_attr) + ">"); 13031 if ($eqeq(node.$doctype(), "manpage")) { 13032 13033 result['$<<']("<h1>" + (node.$doctitle()) + " Manual Page</h1>"); 13034 if ((($truthy(sectioned) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) { 13035 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>"); 13036 } if ($truthy(node['$attr?']("manpurpose"))) { 13037 result['$<<'](self.$generate_manname_section(node)); 13038 } } else { 13039 13040 if ($truthy(node['$header?']())) { 13041 13042 if (!$truthy(node.$notitle())) { 13043 result['$<<']("<h1>" + (node.$header().$title()) + "</h1>"); 13044 } details = []; 13045 idx = 1; 13046 $send(node.$authors(), 'each', [], function $$1(author){ 13047 13048 if (author == null) author = nil; 13049 details['$<<']("<span id=\"author" + (($truthy($rb_gt(idx, 1)) ? (idx) : (""))) + "\" class=\"author\">" + (node.$sub_replacements(author.$name())) + "</span>" + (br)); 13050 if ($truthy(author.$email())) { 13051 details['$<<']("<span id=\"email" + (($truthy($rb_gt(idx, 1)) ? (idx) : (""))) + "\" class=\"email\">" + (node.$sub_macros(author.$email())) + "</span>" + (br)); 13052 } return (idx = $rb_plus(idx, 1));}); 13053 if ($truthy(node['$attr?']("revnumber"))) { 13054 details['$<<']("<span id=\"revnumber\">" + (($truthy(($ret_or_1 = node.$attr("version-label"))) ? ($ret_or_1) : ("")).$downcase()) + " " + (node.$attr("revnumber")) + (($truthy(node['$attr?']("revdate")) ? (",") : (""))) + "</span>"); 13055 } if ($truthy(node['$attr?']("revdate"))) { 13056 details['$<<']("<span id=\"revdate\">" + (node.$attr("revdate")) + "</span>"); 13057 } if ($truthy(node['$attr?']("revremark"))) { 13058 details['$<<']("" + (br) + "<span id=\"revremark\">" + (node.$attr("revremark")) + "</span>"); 13059 } if (!$truthy(details['$empty?']())) { 13060 13061 result['$<<']("<div class=\"details\">"); 13062 result.$concat(details); 13063 result['$<<']("</div>"); 13064 } } if ((($truthy(sectioned) && ($truthy(node['$attr?']("toc")))) && ($truthy(node['$attr?']("toc-placement", "auto"))))) { 13065 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>"); 13066 } } result['$<<']("</div>"); 13067 } result['$<<']("<div id=\"content\"" + (max_width_attr) + ">\n" + (node.$content()) + "\n" + "</div>"); 13068 if (($truthy(node['$footnotes?']()) && ($not(node['$attr?']("nofootnotes"))))) { 13069 13070 result['$<<']("<div id=\"footnotes\"" + (max_width_attr) + ">\n" + "<hr" + (slash) + ">"); 13071 $send(node.$footnotes(), 'each', [], function $$2(footnote){ 13072 13073 if (footnote == null) footnote = nil; 13074 return result['$<<']("<div class=\"footnote\" id=\"_footnotedef_" + (footnote.$index()) + "\">\n" + "<a href=\"#_footnoteref_" + (footnote.$index()) + "\">" + (footnote.$index()) + "</a>. " + (footnote.$text()) + "\n" + "</div>");}); 13075 result['$<<']("</div>"); 13076 } if (!$truthy(node.$nofooter())) { 13077 13078 result['$<<']("<div id=\"footer\"" + (max_width_attr) + ">"); 13079 result['$<<']("<div id=\"footer-text\">"); 13080 if ($truthy(node['$attr?']("revnumber"))) { 13081 result['$<<']("" + (node.$attr("version-label")) + " " + (node.$attr("revnumber")) + (br)); 13082 } if (($truthy(node['$attr?']("last-update-label")) && ($not(node['$attr?']("reproducible"))))) { 13083 result['$<<']("" + (node.$attr("last-update-label")) + " " + (node.$attr("docdatetime"))); 13084 } result['$<<']("</div>"); 13085 result['$<<']("</div>"); 13086 } if ($truthy(syntax_hl)) { 13087 13088 if ($truthy(syntax_hl['$docinfo?']("head"))) { 13089 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}))); 13090 } else { 13091 result.$delete_at(syntax_hl_docinfo_head_idx); 13092 } if ($truthy(syntax_hl['$docinfo?']("footer"))) { 13093 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}))); 13094 } } if ($truthy(node['$attr?']("stem"))) { 13095 13096 eqnums_val = node.$attr("eqnums", "none"); 13097 if ($truthy(eqnums_val['$empty?']())) { 13098 eqnums_val = "AMS"; 13099 } eqnums_opt = " equationNumbers: { autoNumber: \"" + (eqnums_val) + "\" } "; 13100 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>"); 13101 } if (!$truthy((docinfo_content = node.$docinfo("footer"))['$empty?']())) { 13102 result['$<<'](docinfo_content); 13103 } result['$<<']("</body>"); 13104 result['$<<']("</html>"); 13105 return result.$join($$('LF')); 13106 }); 13107 13108 $def(self, '$convert_embedded', function $$convert_embedded(node) { 13109 var self = this, result = nil, id_attr = nil, toc_p = nil; 13110 13111 13112 result = []; 13113 if ($eqeq(node.$doctype(), "manpage")) { 13114 13115 if (!$truthy(node.$notitle())) { 13116 13117 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13118 result['$<<']("<h1" + (id_attr) + ">" + (node.$doctitle()) + " Manual Page</h1>"); 13119 } if ($truthy(node['$attr?']("manpurpose"))) { 13120 result['$<<'](self.$generate_manname_section(node)); 13121 } } else if (($truthy(node['$header?']()) && ($not(node.$notitle())))) { 13122 13123 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13124 result['$<<']("<h1" + (id_attr) + ">" + (node.$header().$title()) + "</h1>"); 13125 } if (((($truthy(node['$sections?']()) && ($truthy(node['$attr?']("toc")))) && ($neqeq((toc_p = node.$attr("toc-placement")), "macro"))) && ($neqeq(toc_p, "preamble")))) { 13126 result['$<<']("<div id=\"toc\" class=\"toc\">\n" + "<div id=\"toctitle\">" + (node.$attr("toc-title")) + "</div>\n" + (node.$converter().$convert(node, "outline")) + "\n" + "</div>"); 13127 } result['$<<'](node.$content()); 13128 if (($truthy(node['$footnotes?']()) && ($not(node['$attr?']("nofootnotes"))))) { 13129 13130 result['$<<']("<div id=\"footnotes\">\n" + "<hr" + (self.void_element_slash) + ">"); 13131 $send(node.$footnotes(), 'each', [], function $$3(footnote){ 13132 13133 if (footnote == null) footnote = nil; 13134 return result['$<<']("<div class=\"footnote\" id=\"_footnotedef_" + (footnote.$index()) + "\">\n" + "<a href=\"#_footnoteref_" + (footnote.$index()) + "\">" + (footnote.$index()) + "</a>. " + (footnote.$text()) + "\n" + "</div>");}); 13135 result['$<<']("</div>"); 13136 } return result.$join($$('LF')); 13137 }); 13138 13139 $def(self, '$convert_outline', function $$convert_outline(node, opts) { 13140 var self = this, sectnumlevels = nil, $ret_or_1 = nil, $ret_or_2 = nil, toclevels = nil, sections = nil, result = nil; 13141 13142 13143 if (opts == null) opts = $hash2([], {}); 13144 if (!$truthy(node['$sections?']())) { 13145 return nil 13146 } sectnumlevels = ($truthy(($ret_or_1 = opts['$[]']("sectnumlevels"))) ? ($ret_or_1) : (($truthy(($ret_or_2 = node.$document().$attributes()['$[]']("sectnumlevels"))) ? ($ret_or_2) : (3)).$to_i())); 13147 toclevels = ($truthy(($ret_or_1 = opts['$[]']("toclevels"))) ? ($ret_or_1) : (($truthy(($ret_or_2 = node.$document().$attributes()['$[]']("toclevels"))) ? ($ret_or_2) : (2)).$to_i())); 13148 sections = node.$sections(); 13149 result = ["<ul class=\"sectlevel" + (sections['$[]'](0).$level()) + "\">"]; 13150 $send(sections, 'each', [], function $$4(section){var self = $$4.$$s == null ? this : $$4.$$s, slevel = nil, stitle = nil, signifier = nil, child_toc_level = nil; 13151 13152 13153 if (section == null) section = nil; 13154 slevel = section.$level(); 13155 if ($truthy(section.$caption())) { 13156 stitle = section.$captioned_title(); 13157 } else if (($truthy(section.$numbered()) && ($truthy($rb_le(slevel, sectnumlevels))))) { 13158 if (($truthy($rb_lt(slevel, 2)) && ($eqeq(node.$document().$doctype(), "book")))) { 13159 13160 switch (section.$sectname()) { 13161 case "chapter": 13162 stitle = "" + (($truthy((signifier = node.$document().$attributes()['$[]']("chapter-signifier"))) ? ("" + (signifier) + " ") : (""))) + (section.$sectnum()) + " " + (section.$title()); 13163 break; 13164 case "part": 13165 stitle = "" + (($truthy((signifier = node.$document().$attributes()['$[]']("part-signifier"))) ? ("" + (signifier) + " ") : (""))) + (section.$sectnum(nil, ":")) + " " + (section.$title()); 13166 break; 13167 default: 13168 stitle = "" + (section.$sectnum()) + " " + (section.$title()); 13169 } 13170 } else { 13171 stitle = "" + (section.$sectnum()) + " " + (section.$title()); 13172 } 13173 } else { 13174 stitle = section.$title(); 13175 } if ($truthy(stitle['$include?']("<a"))) { 13176 stitle = stitle.$gsub($$('DropAnchorRx'), ""); 13177 } if (($truthy($rb_lt(slevel, toclevels)) && ($truthy((child_toc_level = self.$convert_outline(section, $hash2(["toclevels", "sectnumlevels"], {"toclevels": toclevels, "sectnumlevels": sectnumlevels}))))))) { 13178 13179 result['$<<']("<li><a href=\"#" + (section.$id()) + "\">" + (stitle) + "</a>"); 13180 result['$<<'](child_toc_level); 13181 return result['$<<']("</li>"); 13182 } else { 13183 return result['$<<']("<li><a href=\"#" + (section.$id()) + "\">" + (stitle) + "</a></li>") 13184 }}, {$$s: self}); 13185 result['$<<']("</ul>"); 13186 return result.$join($$('LF')); 13187 }, -2); 13188 13189 $def(self, '$convert_section', function $$convert_section(node) { 13190 var doc_attrs = nil, level = nil, title = nil, $ret_or_1 = nil, signifier = nil, id_attr = nil, id = nil, role = nil; 13191 13192 13193 doc_attrs = node.$document().$attributes(); 13194 level = node.$level(); 13195 if ($truthy(node.$caption())) { 13196 title = node.$captioned_title(); 13197 } else if (($truthy(node.$numbered()) && ($truthy($rb_le(level, ($truthy(($ret_or_1 = doc_attrs['$[]']("sectnumlevels"))) ? ($ret_or_1) : (3)).$to_i()))))) { 13198 if (($truthy($rb_lt(level, 2)) && ($eqeq(node.$document().$doctype(), "book")))) { 13199 13200 switch (node.$sectname()) { 13201 case "chapter": 13202 title = "" + (($truthy((signifier = doc_attrs['$[]']("chapter-signifier"))) ? ("" + (signifier) + " ") : (""))) + (node.$sectnum()) + " " + (node.$title()); 13203 break; 13204 case "part": 13205 title = "" + (($truthy((signifier = doc_attrs['$[]']("part-signifier"))) ? ("" + (signifier) + " ") : (""))) + (node.$sectnum(nil, ":")) + " " + (node.$title()); 13206 break; 13207 default: 13208 title = "" + (node.$sectnum()) + " " + (node.$title()); 13209 } 13210 } else { 13211 title = "" + (node.$sectnum()) + " " + (node.$title()); 13212 } 13213 } else { 13214 title = node.$title(); 13215 } if ($truthy(node.$id())) { 13216 13217 id_attr = " id=\"" + ((id = node.$id())) + "\""; 13218 if ($truthy(doc_attrs['$[]']("sectlinks"))) { 13219 title = "<a class=\"link\" href=\"#" + (id) + "\">" + (title) + "</a>"; 13220 } if ($truthy(doc_attrs['$[]']("sectanchors"))) { 13221 if ($eqeq(doc_attrs['$[]']("sectanchors"), "after")) { 13222 title = "" + (title) + "<a class=\"anchor\" href=\"#" + (id) + "\"></a>"; 13223 } else { 13224 title = "<a class=\"anchor\" href=\"#" + (id) + "\"></a>" + (title); 13225 } 13226 } } else { 13227 id_attr = ""; 13228 } if ($eqeq(level, 0)) { 13229 return "<h1" + (id_attr) + " class=\"sect0" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">" + (title) + "</h1>\n" + (node.$content()) 13230 } else { 13231 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>" 13232 } }); 13233 13234 $def(self, '$convert_admonition', function $$convert_admonition(node) { 13235 var self = this, id_attr = nil, name = nil, title_element = nil, label = nil, role = nil; 13236 13237 13238 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13239 name = node.$attr("name"); 13240 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13241 if ($truthy(node.$document()['$attr?']("icons"))) { 13242 if (($truthy(node.$document()['$attr?']("icons", "font")) && ($not(node['$attr?']("icon"))))) { 13243 label = "<i class=\"fa icon-" + (name) + "\" title=\"" + (node.$attr("textlabel")) + "\"></i>"; 13244 } else { 13245 label = "<img src=\"" + (node.$icon_uri(name)) + "\" alt=\"" + (node.$attr("textlabel")) + "\"" + (self.void_element_slash) + ">"; 13246 } 13247 } else { 13248 label = "<div class=\"title\">" + (node.$attr("textlabel")) + "</div>"; 13249 } 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>"; 13250 }); 13251 13252 $def(self, '$convert_audio', function $$convert_audio(node) { 13253 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; 13254 13255 13256 xml = self.xml_mode; 13257 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13258 classes = ["audioblock", node.$role()].$compact(); 13259 class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13260 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13261 start_t = node.$attr("start"); 13262 end_t = node.$attr("end"); 13263 time_anchor = (($truthy(start_t) || ($truthy(end_t))) ? ("#t=" + (($truthy(($ret_or_1 = start_t)) ? ($ret_or_1) : (""))) + (($truthy(end_t) ? ("," + (end_t)) : ("")))) : ("")); 13264 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>"; 13265 }); 13266 13267 $def(self, '$convert_colist', function $$convert_colist(node) { 13268 var $a, self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, font_icons = nil, num = nil; 13269 13270 13271 result = []; 13272 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13273 classes = ["colist", node.$style(), node.$role()].$compact(); 13274 class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13275 result['$<<']("<div" + (id_attribute) + (class_attribute) + ">"); 13276 if ($truthy(node['$title?']())) { 13277 result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>"); 13278 } if ($truthy(node.$document()['$attr?']("icons"))) { 13279 13280 result['$<<']("<table>"); 13281 $a = [node.$document()['$attr?']("icons", "font"), 0], (font_icons = $a[0]), (num = $a[1]); 13282 $send(node.$items(), 'each', [], function $$5(item){var self = $$5.$$s == null ? this : $$5.$$s, num_label = nil; 13283 if (self.void_element_slash == null) self.void_element_slash = nil; 13284 13285 13286 if (item == null) item = nil; 13287 num = $rb_plus(num, 1); 13288 if ($truthy(font_icons)) { 13289 num_label = "<i class=\"conum\" data-value=\"" + (num) + "\"></i><b>" + (num) + "</b>"; 13290 } else { 13291 num_label = "<img src=\"" + (node.$icon_uri("callouts/" + (num))) + "\" alt=\"" + (num) + "\"" + (self.void_element_slash) + ">"; 13292 } 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}); 13293 result['$<<']("</table>"); 13294 } else { 13295 13296 result['$<<']("<ol>"); 13297 $send(node.$items(), 'each', [], function $$6(item){ 13298 13299 if (item == null) item = nil; 13300 return result['$<<']("<li>\n" + "<p>" + (item.$text()) + "</p>" + (($truthy(item['$blocks?']()) ? ($rb_plus($$('LF'), item.$content())) : (""))) + "\n" + "</li>");}); 13301 result['$<<']("</ol>"); 13302 } result['$<<']("</div>"); 13303 return result.$join($$('LF')); 13304 }); 13305 13306 $def(self, '$convert_dlist', function $$convert_dlist(node) { 13307 var self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, slash = nil, col_style_attribute = nil, dt_style_attribute = nil; 13308 13309 13310 result = []; 13311 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13312 13313 switch (node.$style()) { 13314 case "qanda": 13315 classes = ["qlist", "qanda", node.$role()]; 13316 break; 13317 case "horizontal": 13318 classes = ["hdlist", node.$role()]; 13319 break; 13320 default: 13321 classes = ["dlist", node.$style(), node.$role()]; 13322 } class_attribute = " class=\"" + (classes.$compact().$join(" ")) + "\""; 13323 result['$<<']("<div" + (id_attribute) + (class_attribute) + ">"); 13324 if ($truthy(node['$title?']())) { 13325 result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>"); 13326 } 13327 switch (node.$style()) { 13328 case "qanda": 13329 13330 result['$<<']("<ol>"); 13331 $send(node.$items(), 'each', [], function $$7(terms, dd){ 13332 13333 if (terms == null) terms = nil; 13334 if (dd == null) dd = nil; 13335 result['$<<']("<li>"); 13336 $send(terms, 'each', [], function $$8(dt){ 13337 13338 if (dt == null) dt = nil; 13339 return result['$<<']("<p><em>" + (dt.$text()) + "</em></p>");}); 13340 if ($truthy(dd)) { 13341 13342 if ($truthy(dd['$text?']())) { 13343 result['$<<']("<p>" + (dd.$text()) + "</p>"); 13344 } if ($truthy(dd['$blocks?']())) { 13345 result['$<<'](dd.$content()); 13346 } } return result['$<<']("</li>");}); 13347 result['$<<']("</ol>"); 13348 break; 13349 case "horizontal": 13350 13351 slash = self.void_element_slash; 13352 result['$<<']("<table>"); 13353 if (($truthy(node['$attr?']("labelwidth")) || ($truthy(node['$attr?']("itemwidth"))))) { 13354 13355 result['$<<']("<colgroup>"); 13356 col_style_attribute = ($truthy(node['$attr?']("labelwidth")) ? (" style=\"width: " + (node.$attr("labelwidth").$chomp("%")) + "%;\"") : ("")); 13357 result['$<<']("<col" + (col_style_attribute) + (slash) + ">"); 13358 col_style_attribute = ($truthy(node['$attr?']("itemwidth")) ? (" style=\"width: " + (node.$attr("itemwidth").$chomp("%")) + "%;\"") : ("")); 13359 result['$<<']("<col" + (col_style_attribute) + (slash) + ">"); 13360 result['$<<']("</colgroup>"); 13361 } $send(node.$items(), 'each', [], function $$9(terms, dd){var first_term = nil; 13362 13363 13364 if (terms == null) terms = nil; 13365 if (dd == null) dd = nil; 13366 result['$<<']("<tr>"); 13367 result['$<<']("<td class=\"hdlist1" + (($truthy(node['$option?']("strong")) ? (" strong") : (""))) + "\">"); 13368 first_term = true; 13369 $send(terms, 'each', [], function $$10(dt){ 13370 13371 if (dt == null) dt = nil; 13372 if (!$truthy(first_term)) { 13373 result['$<<']("<br" + (slash) + ">"); 13374 } result['$<<'](dt.$text()); 13375 return (first_term = nil);}); 13376 result['$<<']("</td>"); 13377 result['$<<']("<td class=\"hdlist2\">"); 13378 if ($truthy(dd)) { 13379 13380 if ($truthy(dd['$text?']())) { 13381 result['$<<']("<p>" + (dd.$text()) + "</p>"); 13382 } if ($truthy(dd['$blocks?']())) { 13383 result['$<<'](dd.$content()); 13384 } } result['$<<']("</td>"); 13385 return result['$<<']("</tr>");}); 13386 result['$<<']("</table>"); 13387 break; 13388 default: 13389 13390 result['$<<']("<dl>"); 13391 dt_style_attribute = ($truthy(node.$style()) ? ("") : (" class=\"hdlist1\"")); 13392 $send(node.$items(), 'each', [], function $$11(terms, dd){ 13393 13394 if (terms == null) terms = nil; 13395 if (dd == null) dd = nil; 13396 $send(terms, 'each', [], function $$12(dt){ 13397 13398 if (dt == null) dt = nil; 13399 return result['$<<']("<dt" + (dt_style_attribute) + ">" + (dt.$text()) + "</dt>");}); 13400 if (!$truthy(dd)) { 13401 return nil 13402 } result['$<<']("<dd>"); 13403 if ($truthy(dd['$text?']())) { 13404 result['$<<']("<p>" + (dd.$text()) + "</p>"); 13405 } if ($truthy(dd['$blocks?']())) { 13406 result['$<<'](dd.$content()); 13407 } return result['$<<']("</dd>");}); 13408 result['$<<']("</dl>"); 13409 } result['$<<']("</div>"); 13410 return result.$join($$('LF')); 13411 }); 13412 13413 $def(self, '$convert_example', function $$convert_example(node) { 13414 var id_attribute = nil, class_attribute = nil, summary_element = nil, title_element = nil, role = nil; 13415 13416 13417 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13418 if ($truthy(node['$option?']("collapsible"))) { 13419 13420 class_attribute = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : ("")); 13421 summary_element = ($truthy(node['$title?']()) ? ("<summary class=\"title\">" + (node.$title()) + "</summary>") : ("<summary class=\"title\">Details</summary>")); 13422 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>"; 13423 } else { 13424 13425 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$captioned_title()) + "</div>\n") : ("")); 13426 return "<div" + (id_attribute) + " class=\"exampleblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + (node.$content()) + "\n" + "</div>\n" + "</div>"; 13427 } }); 13428 13429 $def(self, '$convert_floating_title', function $$convert_floating_title(node) { 13430 var tag_name = nil, id_attribute = nil, classes = nil; 13431 13432 13433 tag_name = "h" + ($rb_plus(node.$level(), 1)); 13434 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13435 classes = [node.$style(), node.$role()].$compact(); 13436 return "<" + (tag_name) + (id_attribute) + " class=\"" + (classes.$join(" ")) + "\">" + (node.$title()) + "</" + (tag_name) + ">"; 13437 }); 13438 13439 $def(self, '$convert_image', function $$convert_image(node) { 13440 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; 13441 13442 13443 target = node.$attr("target"); 13444 width_attr = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : ("")); 13445 height_attr = ($truthy(node['$attr?']("height")) ? (" height=\"" + (node.$attr("height")) + "\"") : ("")); 13446 if ((($truthy(node['$attr?']("format", "svg")) || ($truthy(target['$include?'](".svg")))) && ($truthy($rb_lt(node.$document().$safe(), $$$($$('SafeMode'), 'SECURE')))))) { 13447 if ($truthy(node['$option?']("inline"))) { 13448 img = ($truthy(($ret_or_1 = self.$read_svg_contents(node, target))) ? ($ret_or_1) : ("<span class=\"alt\">" + (node.$alt()) + "</span>")); 13449 } else if ($truthy(node['$option?']("interactive"))) { 13450 13451 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>")); 13452 img = "<object type=\"image/svg+xml\" data=\"" + (node.$image_uri(target)) + "\"" + (width_attr) + (height_attr) + ">" + (fallback) + "</object>"; 13453 } else { 13454 img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (width_attr) + (height_attr) + (self.void_element_slash) + ">"; 13455 } 13456 } else { 13457 img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (width_attr) + (height_attr) + (self.void_element_slash) + ">"; 13458 } if ($truthy(node['$attr?']("link"))) { 13459 img = "<a class=\"image\" href=\"" + (node.$attr("link")) + "\"" + (self.$append_link_constraint_attrs(node).$join()) + ">" + (img) + "</a>"; 13460 } id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13461 classes = ["imageblock"]; 13462 if ($truthy(node['$attr?']("float"))) { 13463 classes['$<<'](node.$attr("float")); 13464 } if ($truthy(node['$attr?']("align"))) { 13465 classes['$<<']("text-" + (node.$attr("align"))); 13466 } if ($truthy(node.$role())) { 13467 classes['$<<'](node.$role()); 13468 } class_attr = " class=\"" + (classes.$join(" ")) + "\""; 13469 title_el = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$captioned_title()) + "</div>") : ("")); 13470 return "<div" + (id_attr) + (class_attr) + ">\n" + "<div class=\"content\">\n" + (img) + "\n" + "</div>" + (title_el) + "\n" + "</div>"; 13471 }); 13472 13473 $def(self, '$convert_listing', function $$convert_listing(node) { 13474 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; 13475 13476 13477 nowrap = ($truthy(($ret_or_1 = node['$option?']("nowrap"))) ? ($ret_or_1) : (node.$document()['$attr?']("prewrap")['$!']())); 13478 if ($eqeq(node.$style(), "source")) { 13479 13480 lang = node.$attr("language"); 13481 if ($truthy((syntax_hl = node.$document().$syntax_highlighter()))) { 13482 13483 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([], {}))); 13484 opts['$[]=']("nowrap", nowrap); 13485 } else { 13486 13487 pre_open = "<pre class=\"highlight" + (($truthy(nowrap) ? (" nowrap") : (""))) + "\"><code" + (($truthy(lang) ? (" class=\"language-" + (lang) + "\" data-lang=\"" + (lang) + "\"") : (""))) + ">"; 13488 pre_close = "</code></pre>"; 13489 } } else { 13490 13491 pre_open = "<pre" + (($truthy(nowrap) ? (" class=\"nowrap\"") : (""))) + ">"; 13492 pre_close = "</pre>"; 13493 } id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13494 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$captioned_title()) + "</div>\n") : ("")); 13495 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>"; 13496 }); 13497 13498 $def(self, '$convert_literal', function $$convert_literal(node) { 13499 var id_attribute = nil, title_element = nil, nowrap = nil, $ret_or_1 = nil, role = nil; 13500 13501 13502 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13503 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13504 nowrap = ($truthy(($ret_or_1 = node.$document()['$attr?']("prewrap")['$!']())) ? ($ret_or_1) : (node['$option?']("nowrap"))); 13505 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>"; 13506 }); 13507 13508 $def(self, '$convert_stem', function $$convert_stem(node) { 13509 var $a, $b, self = this, id_attribute = nil, title_element = nil, style = nil, open = nil, close = nil, equation = nil, br = nil, role = nil; 13510 13511 13512 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13513 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13514 $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])); 13515 if ($truthy((equation = node.$content()))) { 13516 13517 if (($eqeq(style, "asciimath") && ($truthy(equation['$include?']($$('LF')))))) { 13518 13519 br = "" + ($$('LF')) + "<br" + (self.void_element_slash) + ">"; 13520 equation = $send(equation, 'gsub', [$$('StemBreakRx')], function $$13(){var $c; 13521 13522 return "" + (close) + ($rb_times(br, $rb_minus((($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$count($$('LF')), 1))) + ($$('LF')) + (open)}); 13523 } if (!($truthy(equation['$start_with?'](open)) && ($truthy(equation['$end_with?'](close))))) { 13524 equation = "" + (open) + (equation) + (close); 13525 } } else { 13526 equation = ""; 13527 } return "<div" + (id_attribute) + " class=\"stemblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_element) + "<div class=\"content\">\n" + (equation) + "\n" + "</div>\n" + "</div>"; 13528 }); 13529 13530 $def(self, '$convert_olist', function $$convert_olist(node) { 13531 var self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, type_attribute = nil, keyword = nil, start_attribute = nil, reversed_attribute = nil; 13532 13533 13534 result = []; 13535 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13536 classes = ["olist", node.$style(), node.$role()].$compact(); 13537 class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13538 result['$<<']("<div" + (id_attribute) + (class_attribute) + ">"); 13539 if ($truthy(node['$title?']())) { 13540 result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>"); 13541 } type_attribute = ($truthy((keyword = node.$list_marker_keyword())) ? (" type=\"" + (keyword) + "\"") : ("")); 13542 start_attribute = ($truthy(node['$attr?']("start")) ? (" start=\"" + (node.$attr("start")) + "\"") : ("")); 13543 reversed_attribute = ($truthy(node['$option?']("reversed")) ? (self.$append_boolean_attribute("reversed", self.xml_mode)) : ("")); 13544 result['$<<']("<ol class=\"" + (node.$style()) + "\"" + (type_attribute) + (start_attribute) + (reversed_attribute) + ">"); 13545 $send(node.$items(), 'each', [], function $$14(item){ 13546 13547 if (item == null) item = nil; 13548 if ($truthy(item.$id())) { 13549 result['$<<']("<li id=\"" + (item.$id()) + "\"" + (($truthy(item.$role()) ? (" class=\"" + (item.$role()) + "\"") : (""))) + ">"); 13550 } else if ($truthy(item.$role())) { 13551 result['$<<']("<li class=\"" + (item.$role()) + "\">"); 13552 } else { 13553 result['$<<']("<li>"); 13554 } result['$<<']("<p>" + (item.$text()) + "</p>"); 13555 if ($truthy(item['$blocks?']())) { 13556 result['$<<'](item.$content()); 13557 } return result['$<<']("</li>");}); 13558 result['$<<']("</ol>"); 13559 result['$<<']("</div>"); 13560 return result.$join($$('LF')); 13561 }); 13562 13563 $def(self, '$convert_open', function $$convert_open(node) { 13564 var self = this, style = nil, id_attr = nil, title_el = nil, role = nil; 13565 13566 if ($eqeq((style = node.$style()), "abstract")) { 13567 if (($eqeq(node.$parent(), node.$document()) && ($eqeq(node.$document().$doctype(), "book")))) { 13568 13569 self.$logger().$warn("abstract block cannot be used in a document without a title when doctype is book. Excluding block content."); 13570 return ""; 13571 } else { 13572 13573 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13574 title_el = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13575 return "<div" + (id_attr) + " class=\"quoteblock abstract" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + (title_el) + "<blockquote>\n" + (node.$content()) + "\n" + "</blockquote>\n" + "</div>"; 13576 } 13577 } else if (($eqeq(style, "partintro") && ((($truthy($rb_gt(node.$level(), 0)) || ($neqeq(node.$parent().$context(), "section"))) || ($neqeq(node.$document().$doctype(), "book")))))) { 13578 13579 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."); 13580 return ""; 13581 } else { 13582 13583 id_attr = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13584 title_el = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13585 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>"; 13586 } 13587 }); 13588 13589 $def(self, '$convert_page_break', $return_val("<div style=\"page-break-after: always;\"></div>")); 13590 13591 $def(self, '$convert_paragraph', function $$convert_paragraph(node) { 13592 var attributes = nil; 13593 13594 13595 if ($truthy(node.$role())) { 13596 attributes = "" + (($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : (""))) + " class=\"paragraph " + (node.$role()) + "\""; 13597 } else if ($truthy(node.$id())) { 13598 attributes = " id=\"" + (node.$id()) + "\" class=\"paragraph\""; 13599 } else { 13600 attributes = " class=\"paragraph\""; 13601 } if ($truthy(node['$title?']())) { 13602 return "<div" + (attributes) + ">\n" + "<div class=\"title\">" + (node.$title()) + "</div>\n" + "<p>" + (node.$content()) + "</p>\n" + "</div>" 13603 } else { 13604 return "<div" + (attributes) + ">\n" + "<p>" + (node.$content()) + "</p>\n" + "</div>" 13605 } }); 13606 $alias(self, "convert_pass", "content_only"); 13607 13608 $def(self, '$convert_preamble', function $$convert_preamble(node) { 13609 var doc = nil, toc = nil; 13610 13611 13612 if ((($truthy((doc = node.$document())['$attr?']("toc-placement", "preamble")) && ($truthy(doc['$sections?']()))) && ($truthy(doc['$attr?']("toc"))))) { 13613 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>"; 13614 } else { 13615 toc = ""; 13616 } return "<div id=\"preamble\">\n" + "<div class=\"sectionbody\">\n" + (node.$content()) + "\n" + "</div>" + (toc) + "\n" + "</div>"; 13617 }); 13618 13619 $def(self, '$convert_quote', function $$convert_quote(node) { 13620 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; 13621 13622 13623 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13624 classes = ["quoteblock", node.$role()].$compact(); 13625 class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13626 title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : ("")); 13627 attribution = ($truthy(node['$attr?']("attribution")) ? (node.$attr("attribution")) : (nil)); 13628 citetitle = ($truthy(node['$attr?']("citetitle")) ? (node.$attr("citetitle")) : (nil)); 13629 if (($truthy(attribution) || ($truthy(citetitle)))) { 13630 13631 cite_element = ($truthy(citetitle) ? ("<cite>" + (citetitle) + "</cite>") : ("")); 13632 attribution_text = ($truthy(attribution) ? ("— " + (attribution) + (($truthy(citetitle) ? ("<br" + (self.void_element_slash) + ">\n") : ("")))) : ("")); 13633 attribution_element = "\n<div class=\"attribution\">\n" + (attribution_text) + (cite_element) + "\n</div>"; 13634 } else { 13635 attribution_element = ""; 13636 } return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<blockquote>\n" + (node.$content()) + "\n" + "</blockquote>" + (attribution_element) + "\n" + "</div>"; 13637 }); 13638 13639 $def(self, '$convert_thematic_break', function $$convert_thematic_break(node) { 13640 var self = this; 13641 13642 return "<hr" + (self.void_element_slash) + ">" 13643 }); 13644 13645 $def(self, '$convert_sidebar', function $$convert_sidebar(node) { 13646 var id_attribute = nil, title_element = nil, role = nil; 13647 13648 13649 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13650 title_element = ($truthy(node['$title?']()) ? ("<div class=\"title\">" + (node.$title()) + "</div>\n") : ("")); 13651 return "<div" + (id_attribute) + " class=\"sidebarblock" + (($truthy((role = node.$role())) ? (" " + (role)) : (""))) + "\">\n" + "<div class=\"content\">\n" + (title_element) + (node.$content()) + "\n" + "</div>\n" + "</div>"; 13652 }); 13653 13654 $def(self, '$convert_table', function $$convert_table(node) { 13655 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; 13656 13657 13658 result = []; 13659 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13660 if ($eqeq((frame = node.$attr("frame", "all", "table-frame")), "topbot")) { 13661 frame = "ends"; 13662 } classes = ["tableblock", "frame-" + (frame), "grid-" + (node.$attr("grid", "all", "table-grid"))]; 13663 if ($truthy((stripes = node.$attr("stripes", nil, "table-stripes")))) { 13664 classes['$<<']("stripes-" + (stripes)); 13665 } style_attribute = ""; 13666 if (($truthy((autowidth = node['$option?']("autowidth"))) && ($not(node['$attr?']("width"))))) { 13667 classes['$<<']("fit-content"); 13668 } else if ($eqeq((tablewidth = node.$attr("tablepcwidth")), 100)) { 13669 classes['$<<']("stretch"); 13670 } else { 13671 style_attribute = " style=\"width: " + (tablewidth) + "%;\""; 13672 } if ($truthy(node['$attr?']("float"))) { 13673 classes['$<<'](node.$attr("float")); 13674 } if ($truthy((role = node.$role()))) { 13675 classes['$<<'](role); 13676 } class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13677 result['$<<']("<table" + (id_attribute) + (class_attribute) + (style_attribute) + ">"); 13678 if ($truthy(node['$title?']())) { 13679 result['$<<']("<caption class=\"title\">" + (node.$captioned_title()) + "</caption>"); 13680 } if ($truthy($rb_gt(node.$attr("rowcount"), 0))) { 13681 13682 slash = self.void_element_slash; 13683 result['$<<']("<colgroup>"); 13684 if ($truthy(autowidth)) { 13685 result = $rb_plus(result, $$('Array').$new(node.$columns().$size(), "<col" + (slash) + ">")); 13686 } else { 13687 $send(node.$columns(), 'each', [], function $$15(col){ 13688 13689 if (col == null) col = nil; 13690 return result['$<<'](($truthy(col['$option?']("autowidth")) ? ("<col" + (slash) + ">") : ("<col style=\"width: " + (col.$attr("colpcwidth")) + "%;\"" + (slash) + ">")));}); 13691 } result['$<<']("</colgroup>"); 13692 $send(node.$rows().$to_h(), 'each', [], function $$16(tsec, rows){ 13693 13694 if (tsec == null) tsec = nil; 13695 if (rows == null) rows = nil; 13696 if ($truthy(rows['$empty?']())) { 13697 return nil 13698 } result['$<<']("<t" + (tsec) + ">"); 13699 $send(rows, 'each', [], function $$17(row){ 13700 13701 if (row == null) row = nil; 13702 result['$<<']("<tr>"); 13703 $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; 13704 13705 13706 if (cell == null) cell = nil; 13707 if ($eqeq(tsec, "head")) { 13708 cell_content = cell.$text(); 13709 } else 13710 switch (cell.$style()) { 13711 case "asciidoc": 13712 cell_content = "<div class=\"content\">" + (cell.$content()) + "</div>"; 13713 break; 13714 case "literal": 13715 cell_content = "<div class=\"literal\"><pre>" + (cell.$text()) + "</pre></div>"; 13716 break; 13717 default: 13718 cell_content = ($truthy((cell_content = cell.$content())['$empty?']()) ? ("") : ("<p class=\"tableblock\">" + (cell_content.$join("</p>\n" + "<p class=\"tableblock\">")) + "</p>")); 13719 } cell_tag_name = (($eqeq(tsec, "head") || ($eqeq(cell.$style(), "header"))) ? ("th") : ("td")); 13720 cell_class_attribute = " class=\"tableblock halign-" + (cell.$attr("halign")) + " valign-" + (cell.$attr("valign")) + "\""; 13721 cell_colspan_attribute = ($truthy(cell.$colspan()) ? (" colspan=\"" + (cell.$colspan()) + "\"") : ("")); 13722 cell_rowspan_attribute = ($truthy(cell.$rowspan()) ? (" rowspan=\"" + (cell.$rowspan()) + "\"") : ("")); 13723 cell_style_attribute = ($truthy(node.$document()['$attr?']("cellbgcolor")) ? (" style=\"background-color: " + (node.$document().$attr("cellbgcolor")) + ";\"") : ("")); 13724 return result['$<<']("<" + (cell_tag_name) + (cell_class_attribute) + (cell_colspan_attribute) + (cell_rowspan_attribute) + (cell_style_attribute) + ">" + (cell_content) + "</" + (cell_tag_name) + ">");}); 13725 return result['$<<']("</tr>");}); 13726 return result['$<<']("</t" + (tsec) + ">");}); 13727 } result['$<<']("</table>"); 13728 return result.$join($$('LF')); 13729 }); 13730 13731 $def(self, '$convert_toc', function $$convert_toc(node) { 13732 var doc = nil, id_attr = nil, title_id_attr = nil, title = nil, levels = nil, role = nil; 13733 13734 13735 if (!(($truthy((doc = node.$document())['$attr?']("toc-placement", "macro")) && ($truthy(doc['$sections?']()))) && ($truthy(doc['$attr?']("toc"))))) { 13736 return "<!-- toc disabled -->" 13737 } if ($truthy(node.$id())) { 13738 13739 id_attr = " id=\"" + (node.$id()) + "\""; 13740 title_id_attr = " id=\"" + (node.$id()) + "title\""; 13741 } else { 13742 13743 id_attr = " id=\"toc\""; 13744 title_id_attr = " id=\"toctitle\""; 13745 } title = ($truthy(node['$title?']()) ? (node.$title()) : (doc.$attr("toc-title"))); 13746 levels = ($truthy(node['$attr?']("levels")) ? (node.$attr("levels").$to_i()) : (nil)); 13747 role = ($truthy(node['$role?']()) ? (node.$role()) : (doc.$attr("toc-class", "toc"))); 13748 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>"; 13749 }); 13750 13751 $def(self, '$convert_ulist', function $$convert_ulist(node) { 13752 var self = this, result = nil, id_attribute = nil, div_classes = nil, marker_checked = nil, marker_unchecked = nil, checklist = nil, ul_class_attribute = nil; 13753 13754 13755 result = []; 13756 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13757 div_classes = ["ulist", node.$style(), node.$role()].$compact(); 13758 marker_checked = (marker_unchecked = ""); 13759 if ($truthy((checklist = node['$option?']("checklist")))) { 13760 13761 div_classes.$unshift(div_classes.$shift(), "checklist"); 13762 ul_class_attribute = " class=\"checklist\""; 13763 if ($truthy(node['$option?']("interactive"))) { 13764 if ($truthy(self.xml_mode)) { 13765 13766 marker_checked = "<input type=\"checkbox\" data-item-complete=\"1\" checked=\"checked\"/> "; 13767 marker_unchecked = "<input type=\"checkbox\" data-item-complete=\"0\"/> "; 13768 } else { 13769 13770 marker_checked = "<input type=\"checkbox\" data-item-complete=\"1\" checked> "; 13771 marker_unchecked = "<input type=\"checkbox\" data-item-complete=\"0\"> "; 13772 } 13773 } else if ($truthy(node.$document()['$attr?']("icons", "font"))) { 13774 13775 marker_checked = "<i class=\"fa fa-check-square-o\"></i> "; 13776 marker_unchecked = "<i class=\"fa fa-square-o\"></i> "; 13777 } else { 13778 13779 marker_checked = "✓ "; 13780 marker_unchecked = "❏ "; 13781 } } else { 13782 ul_class_attribute = ($truthy(node.$style()) ? (" class=\"" + (node.$style()) + "\"") : ("")); 13783 } result['$<<']("<div" + (id_attribute) + " class=\"" + (div_classes.$join(" ")) + "\">"); 13784 if ($truthy(node['$title?']())) { 13785 result['$<<']("<div class=\"title\">" + (node.$title()) + "</div>"); 13786 } result['$<<']("<ul" + (ul_class_attribute) + ">"); 13787 $send(node.$items(), 'each', [], function $$19(item){ 13788 13789 if (item == null) item = nil; 13790 if ($truthy(item.$id())) { 13791 result['$<<']("<li id=\"" + (item.$id()) + "\"" + (($truthy(item.$role()) ? (" class=\"" + (item.$role()) + "\"") : (""))) + ">"); 13792 } else if ($truthy(item.$role())) { 13793 result['$<<']("<li class=\"" + (item.$role()) + "\">"); 13794 } else { 13795 result['$<<']("<li>"); 13796 } if (($truthy(checklist) && ($truthy(item['$attr?']("checkbox"))))) { 13797 result['$<<']("<p>" + (($truthy(item['$attr?']("checked")) ? (marker_checked) : (marker_unchecked))) + (item.$text()) + "</p>"); 13798 } else { 13799 result['$<<']("<p>" + (item.$text()) + "</p>"); 13800 } if ($truthy(item['$blocks?']())) { 13801 result['$<<'](item.$content()); 13802 } return result['$<<']("</li>");}); 13803 result['$<<']("</ul>"); 13804 result['$<<']("</div>"); 13805 return result.$join($$('LF')); 13806 }); 13807 13808 $def(self, '$convert_verse', function $$convert_verse(node) { 13809 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; 13810 13811 13812 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13813 classes = ["verseblock", node.$role()].$compact(); 13814 class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13815 title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : ("")); 13816 attribution = ($truthy(node['$attr?']("attribution")) ? (node.$attr("attribution")) : (nil)); 13817 citetitle = ($truthy(node['$attr?']("citetitle")) ? (node.$attr("citetitle")) : (nil)); 13818 if (($truthy(attribution) || ($truthy(citetitle)))) { 13819 13820 cite_element = ($truthy(citetitle) ? ("<cite>" + (citetitle) + "</cite>") : ("")); 13821 attribution_text = ($truthy(attribution) ? ("— " + (attribution) + (($truthy(citetitle) ? ("<br" + (self.void_element_slash) + ">\n") : ("")))) : ("")); 13822 attribution_element = "\n<div class=\"attribution\">\n" + (attribution_text) + (cite_element) + "\n</div>"; 13823 } else { 13824 attribution_element = ""; 13825 } return "<div" + (id_attribute) + (class_attribute) + ">" + (title_element) + "\n" + "<pre class=\"content\">" + (node.$content()) + "</pre>" + (attribution_element) + "\n" + "</div>"; 13826 }); 13827 13828 $def(self, '$convert_video', function $$convert_video(node) { 13829 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; 13830 13831 13832 xml = self.xml_mode; 13833 id_attribute = ($truthy(node.$id()) ? (" id=\"" + (node.$id()) + "\"") : ("")); 13834 classes = ["videoblock"]; 13835 if ($truthy(node['$attr?']("float"))) { 13836 classes['$<<'](node.$attr("float")); 13837 } if ($truthy(node['$attr?']("align"))) { 13838 classes['$<<']("text-" + (node.$attr("align"))); 13839 } if ($truthy(node.$role())) { 13840 classes['$<<'](node.$role()); 13841 } class_attribute = " class=\"" + (classes.$join(" ")) + "\""; 13842 title_element = ($truthy(node['$title?']()) ? ("\n<div class=\"title\">" + (node.$title()) + "</div>") : ("")); 13843 width_attribute = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : ("")); 13844 height_attribute = ($truthy(node['$attr?']("height")) ? (" height=\"" + (node.$attr("height")) + "\"") : ("")); 13845 13846 switch (node.$attr("poster")) { 13847 case "vimeo": 13848 13849 if (!$truthy((asset_uri_scheme = node.$document().$attr("asset-uri-scheme", "https"))['$empty?']())) { 13850 asset_uri_scheme = "" + (asset_uri_scheme) + ":"; 13851 } start_anchor = ($truthy(node['$attr?']("start")) ? ("#at=" + (node.$attr("start"))) : ("")); 13852 delimiter = ["?"]; 13853 $b = node.$attr("target").$split("/", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (hash = ($a[1] == null ? nil : $a[1])); 13854 hash_param = ($truthy((hash = ($truthy(($ret_or_2 = hash)) ? ($ret_or_2) : (node.$attr("hash"))))) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&"))) + "h=" + (hash)) : ("")); 13855 autoplay_param = ($truthy(node['$option?']("autoplay")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&"))) + "autoplay=1") : ("")); 13856 loop_param = ($truthy(node['$option?']("loop")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&"))) + "loop=1") : ("")); 13857 muted_param = ($truthy(node['$option?']("muted")) ? ("" + (($truthy(($ret_or_2 = delimiter.$pop())) ? ($ret_or_2) : ("&"))) + "muted=1") : ("")); 13858 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>"; 13859 case "youtube": 13860 13861 if (!$truthy((asset_uri_scheme = node.$document().$attr("asset-uri-scheme", "https"))['$empty?']())) { 13862 asset_uri_scheme = "" + (asset_uri_scheme) + ":"; 13863 } rel_param_val = ($truthy(node['$option?']("related")) ? (1) : (0)); 13864 start_param = ($truthy(node['$attr?']("start")) ? ("&start=" + (node.$attr("start"))) : ("")); 13865 end_param = ($truthy(node['$attr?']("end")) ? ("&end=" + (node.$attr("end"))) : ("")); 13866 autoplay_param = ($truthy(node['$option?']("autoplay")) ? ("&autoplay=1") : ("")); 13867 loop_param = ($truthy((has_loop_param = node['$option?']("loop"))) ? ("&loop=1") : ("")); 13868 mute_param = ($truthy(node['$option?']("muted")) ? ("&mute=1") : ("")); 13869 controls_param = ($truthy(node['$option?']("nocontrols")) ? ("&controls=0") : ("")); 13870 if ($truthy(node['$option?']("nofullscreen"))) { 13871 13872 fs_param = "&fs=0"; 13873 fs_attribute = ""; 13874 } else { 13875 13876 fs_param = ""; 13877 fs_attribute = self.$append_boolean_attribute("allowfullscreen", xml); 13878 } modest_param = ($truthy(node['$option?']("modest")) ? ("&modestbranding=1") : ("")); 13879 theme_param = ($truthy(node['$attr?']("theme")) ? ("&theme=" + (node.$attr("theme"))) : ("")); 13880 hl_param = ($truthy(node['$attr?']("lang")) ? ("&hl=" + (node.$attr("lang"))) : ("")); 13881 $b = node.$attr("target").$split("/", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (list = ($a[1] == null ? nil : $a[1])); 13882 if ($truthy((list = ($truthy(($ret_or_2 = list)) ? ($ret_or_2) : (node.$attr("list")))))) { 13883 list_param = "&list=" + (list); 13884 } else { 13885 13886 $b = target.$split(",", 2), $a = $to_ary($b), (target = ($a[0] == null ? nil : $a[0])), (playlist = ($a[1] == null ? nil : $a[1])); 13887 if ($truthy((playlist = ($truthy(($ret_or_2 = playlist)) ? ($ret_or_2) : (node.$attr("playlist")))))) { 13888 list_param = "&playlist=" + (target) + "," + (playlist); 13889 } else { 13890 list_param = ($truthy(has_loop_param) ? ("&playlist=" + (target)) : ("")); 13891 } } 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>"; 13892 default: 13893 13894 poster_attribute = ($truthy((val = node.$attr("poster"))['$nil_or_empty?']()) ? ("") : (" poster=\"" + (node.$media_uri(val)) + "\"")); 13895 preload_attribute = ($truthy((val = node.$attr("preload"))['$nil_or_empty?']()) ? ("") : (" preload=\"" + (val) + "\"")); 13896 start_t = node.$attr("start"); 13897 end_t = node.$attr("end"); 13898 time_anchor = (($truthy(start_t) || ($truthy(end_t))) ? ("#t=" + (($truthy(($ret_or_2 = start_t)) ? ($ret_or_2) : (""))) + (($truthy(end_t) ? ("," + (end_t)) : ("")))) : ("")); 13899 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>"; 13900 } }); 13901 13902 $def(self, '$convert_inline_anchor', function $$convert_inline_anchor(node) { 13903 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; 13904 13905 13906 switch (node.$type()) { 13907 case "xref": 13908 13909 if ($truthy((path = node.$attributes()['$[]']("path")))) { 13910 13911 attrs = self.$append_link_constraint_attrs(node, ($truthy(node.$role()) ? ([" class=\"" + (node.$role()) + "\""]) : ([]))).$join(); 13912 text = ($truthy(($ret_or_2 = node.$text())) ? ($ret_or_2) : (path)); 13913 } else { 13914 13915 attrs = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : ("")); 13916 if (!$truthy((text = node.$text()))) { 13917 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))))))) { 13918 if (($truthy((self.resolving_xref = ($truthy(($ret_or_2 = self.resolving_xref)) ? ($ret_or_2) : ((outer = true))))) && ($truthy(outer)))) { 13919 13920 if ($truthy((text = ref.$xreftext(node.$attr("xrefstyle", nil, true))))) { 13921 if ($truthy(text['$include?']("<a"))) { 13922 text = text.$gsub($$('DropAnchorRx'), ""); 13923 } 13924 } else { 13925 text = ($truthy(top) ? ("[^top]") : ("[" + (refid) + "]")); 13926 } self.resolving_xref = nil; 13927 } else { 13928 text = ($truthy(top) ? ("[^top]") : ("[" + (refid) + "]")); 13929 } 13930 } else { 13931 text = "[" + (refid) + "]"; 13932 } 13933 } } return "<a href=\"" + (node.$target()) + "\"" + (attrs) + ">" + (text) + "</a>"; 13934 case "ref": 13935 return "<a id=\"" + (node.$id()) + "\"></a>" 13936 case "link": 13937 13938 attrs = ($truthy(node.$id()) ? ([" id=\"" + (node.$id()) + "\""]) : ([])); 13939 if ($truthy(node.$role())) { 13940 attrs['$<<'](" class=\"" + (node.$role()) + "\""); 13941 } if ($truthy(node['$attr?']("title"))) { 13942 attrs['$<<'](" title=\"" + (node.$attr("title")) + "\""); 13943 } return "<a href=\"" + (node.$target()) + "\"" + (self.$append_link_constraint_attrs(node, attrs).$join()) + ">" + (node.$text()) + "</a>"; 13944 case "bibref": 13945 return "<a id=\"" + (node.$id()) + "\"></a>[" + (($truthy(($ret_or_2 = node.$reftext())) ? ($ret_or_2) : (node.$id()))) + "]" 13946 default: 13947 13948 self.$logger().$warn("unknown anchor type: " + (node.$type().$inspect())); 13949 return nil; 13950 } 13951 }); 13952 13953 $def(self, '$convert_inline_break', function $$convert_inline_break(node) { 13954 var self = this; 13955 13956 return "" + (node.$text()) + "<br" + (self.void_element_slash) + ">" 13957 }); 13958 13959 $def(self, '$convert_inline_button', function $$convert_inline_button(node) { 13960 13961 return "<b class=\"button\">" + (node.$text()) + "</b>" 13962 }); 13963 13964 $def(self, '$convert_inline_callout', function $$convert_inline_callout(node) { 13965 var self = this, src = nil, guard = nil; 13966 13967 if ($truthy(node.$document()['$attr?']("icons", "font"))) { 13968 return "<i class=\"conum\" data-value=\"" + (node.$text()) + "\"></i><b>(" + (node.$text()) + ")</b>" 13969 } else if ($truthy(node.$document()['$attr?']("icons"))) { 13970 13971 src = node.$icon_uri("callouts/" + (node.$text())); 13972 return "<img src=\"" + (src) + "\" alt=\"" + (node.$text()) + "\"" + (self.void_element_slash) + ">"; 13973 } else if ($eqeqeq($$$('Array'), (guard = node.$attributes()['$[]']("guard")))) { 13974 return "<!--<b class=\"conum\">(" + (node.$text()) + ")</b>-->" 13975 } else { 13976 return "" + (guard) + "<b class=\"conum\">(" + (node.$text()) + ")</b>" 13977 } 13978 }); 13979 13980 $def(self, '$convert_inline_footnote', function $$convert_inline_footnote(node) { 13981 var index = nil, id_attr = nil; 13982 13983 if ($truthy((index = node.$attr("index")))) { 13984 if ($eqeq(node.$type(), "xref")) { 13985 return "<sup class=\"footnoteref\">[<a class=\"footnote\" href=\"#_footnotedef_" + (index) + "\" title=\"View footnote.\">" + (index) + "</a>]</sup>" 13986 } else { 13987 13988 id_attr = ($truthy(node.$id()) ? (" id=\"_footnote_" + (node.$id()) + "\"") : ("")); 13989 return "<sup class=\"footnote\"" + (id_attr) + ">[<a id=\"_footnoteref_" + (index) + "\" class=\"footnote\" href=\"#_footnotedef_" + (index) + "\" title=\"View footnote.\">" + (index) + "</a>]</sup>"; 13990 } 13991 } else if ($eqeq(node.$type(), "xref")) { 13992 return "<sup class=\"footnoteref red\" title=\"Unresolved footnote reference.\">[" + (node.$text()) + "]</sup>" 13993 } else { 13994 return nil 13995 } 13996 }); 13997 13998 $def(self, '$convert_inline_image', function $$convert_inline_image(node) { 13999 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; 14000 14001 14002 target = node.$target(); 14003 if ($eqeq((type = ($truthy(($ret_or_1 = node.$type())) ? ($ret_or_1) : ("image"))), "icon")) { 14004 if ($eqeq((icons = node.$document().$attr("icons")), "font")) { 14005 14006 i_class_attr_val = "fa fa-" + (target); 14007 if ($truthy(node['$attr?']("size"))) { 14008 i_class_attr_val = "" + (i_class_attr_val) + " fa-" + (node.$attr("size")); 14009 } if ($truthy(node['$attr?']("flip"))) { 14010 i_class_attr_val = "" + (i_class_attr_val) + " fa-flip-" + (node.$attr("flip")); 14011 } else if ($truthy(node['$attr?']("rotate"))) { 14012 i_class_attr_val = "" + (i_class_attr_val) + " fa-rotate-" + (node.$attr("rotate")); 14013 } attrs = ($truthy(node['$attr?']("title")) ? (" title=\"" + (node.$attr("title")) + "\"") : ("")); 14014 img = "<i class=\"" + (i_class_attr_val) + "\"" + (attrs) + "></i>"; 14015 } else if ($truthy(icons)) { 14016 14017 attrs = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : ("")); 14018 if ($truthy(node['$attr?']("height"))) { 14019 attrs = "" + (attrs) + " height=\"" + (node.$attr("height")) + "\""; 14020 } if ($truthy(node['$attr?']("title"))) { 14021 attrs = "" + (attrs) + " title=\"" + (node.$attr("title")) + "\""; 14022 } img = "<img src=\"" + (node.$icon_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">"; 14023 } else { 14024 img = "[" + (node.$alt()) + "]"; 14025 } 14026 } else { 14027 14028 attrs = ($truthy(node['$attr?']("width")) ? (" width=\"" + (node.$attr("width")) + "\"") : ("")); 14029 if ($truthy(node['$attr?']("height"))) { 14030 attrs = "" + (attrs) + " height=\"" + (node.$attr("height")) + "\""; 14031 } if ($truthy(node['$attr?']("title"))) { 14032 attrs = "" + (attrs) + " title=\"" + (node.$attr("title")) + "\""; 14033 } if ((($truthy(node['$attr?']("format", "svg")) || ($truthy(target['$include?'](".svg")))) && ($truthy($rb_lt(node.$document().$safe(), $$$($$('SafeMode'), 'SECURE')))))) { 14034 if ($truthy(node['$option?']("inline"))) { 14035 img = ($truthy(($ret_or_1 = self.$read_svg_contents(node, target))) ? ($ret_or_1) : ("<span class=\"alt\">" + (node.$alt()) + "</span>")); 14036 } else if ($truthy(node['$option?']("interactive"))) { 14037 14038 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>")); 14039 img = "<object type=\"image/svg+xml\" data=\"" + (node.$image_uri(target)) + "\"" + (attrs) + ">" + (fallback) + "</object>"; 14040 } else { 14041 img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">"; 14042 } 14043 } else { 14044 img = "<img src=\"" + (node.$image_uri(target)) + "\" alt=\"" + (self.$encode_attribute_value(node.$alt())) + "\"" + (attrs) + (self.void_element_slash) + ">"; 14045 } } if ($truthy(node['$attr?']("link"))) { 14046 img = "<a class=\"image\" href=\"" + (node.$attr("link")) + "\"" + (self.$append_link_constraint_attrs(node).$join()) + ">" + (img) + "</a>"; 14047 } class_attr_val = type; 14048 if ($truthy((role = node.$role()))) { 14049 class_attr_val = ($truthy(node['$attr?']("float")) ? ("" + (class_attr_val) + " " + (node.$attr("float")) + " " + (role)) : ("" + (class_attr_val) + " " + (role))); 14050 } else if ($truthy(node['$attr?']("float"))) { 14051 class_attr_val = "" + (class_attr_val) + " " + (node.$attr("float")); 14052 } return "<span class=\"" + (class_attr_val) + "\">" + (img) + "</span>"; 14053 }); 14054 14055 $def(self, '$convert_inline_indexterm', function $$convert_inline_indexterm(node) { 14056 14057 if ($eqeq(node.$type(), "visible")) { 14058 return node.$text() 14059 } else { 14060 return "" 14061 } 14062 }); 14063 14064 $def(self, '$convert_inline_kbd', function $$convert_inline_kbd(node) { 14065 var keys = nil; 14066 14067 if ($eqeq((keys = node.$attr("keys")).$size(), 1)) { 14068 return "<kbd>" + (keys['$[]'](0)) + "</kbd>" 14069 } else { 14070 return "<span class=\"keyseq\"><kbd>" + (keys.$join("</kbd>+<kbd>")) + "</kbd></span>" 14071 } 14072 }); 14073 14074 $def(self, '$convert_inline_menu', function $$convert_inline_menu(node) { 14075 var caret = nil, submenu_joiner = nil, menu = nil, submenus = nil, menuitem = nil; 14076 14077 14078 caret = ($truthy(node.$document()['$attr?']("icons", "font")) ? (" <i class=\"fa fa-angle-right caret\"></i> ") : (" <b class=\"caret\">›</b> ")); 14079 submenu_joiner = "</b>" + (caret) + "<b class=\"submenu\">"; 14080 menu = node.$attr("menu"); 14081 if ($truthy((submenus = node.$attr("submenus"))['$empty?']())) { 14082 if ($truthy((menuitem = node.$attr("menuitem")))) { 14083 return "<span class=\"menuseq\"><b class=\"menu\">" + (menu) + "</b>" + (caret) + "<b class=\"menuitem\">" + (menuitem) + "</b></span>" 14084 } else { 14085 return "<b class=\"menuref\">" + (menu) + "</b>" 14086 } 14087 } else { 14088 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>" 14089 } }); 14090 14091 $def(self, '$convert_inline_quoted', function $$convert_inline_quoted(node) { 14092 var $a, $b, open = nil, close = nil, tag = nil, class_attr = nil; 14093 14094 14095 $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])); 14096 if ($truthy(node.$id())) { 14097 14098 class_attr = ($truthy(node.$role()) ? (" class=\"" + (node.$role()) + "\"") : ("")); 14099 if ($truthy(tag)) { 14100 return "" + (open.$chop()) + " id=\"" + (node.$id()) + "\"" + (class_attr) + ">" + (node.$text()) + (close) 14101 } else { 14102 return "<span id=\"" + (node.$id()) + "\"" + (class_attr) + ">" + (open) + (node.$text()) + (close) + "</span>" 14103 } } else if ($truthy(node.$role())) { 14104 if ($truthy(tag)) { 14105 return "" + (open.$chop()) + " class=\"" + (node.$role()) + "\">" + (node.$text()) + (close) 14106 } else { 14107 return "<span class=\"" + (node.$role()) + "\">" + (open) + (node.$text()) + (close) + "</span>" 14108 } 14109 } else { 14110 return "" + (open) + (node.$text()) + (close) 14111 } }); 14112 14113 $def(self, '$read_svg_contents', function $$read_svg_contents(node, target) { 14114 var svg = nil, old_start_tag = nil, new_start_tag = nil, start_tag_match = nil; 14115 14116 14117 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}))))) { 14118 14119 if ($truthy(svg['$empty?']())) { 14120 return nil 14121 } if (!$truthy(svg['$start_with?']("<svg"))) { 14122 svg = svg.$sub($$('SvgPreambleRx'), ""); 14123 } old_start_tag = (new_start_tag = (start_tag_match = nil)); 14124 $send(["width", "height"], 'each', [], function $$20(dim){var $ret_or_1 = nil, $ret_or_2 = nil; 14125 14126 14127 if (dim == null) dim = nil; 14128 if (!$truthy(node['$attr?'](dim))) { 14129 return nil 14130 } if (!$truthy(new_start_tag)) { 14131 14132 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")) { 14133 return nil 14134 } new_start_tag = (old_start_tag = start_tag_match['$[]'](0)).$gsub($$('DimensionAttributeRx'), ""); 14135 } return (new_start_tag = "" + (new_start_tag.$chop()) + " " + (dim) + "=\"" + (node.$attr(dim)) + "\">");}); 14136 if ($truthy(new_start_tag)) { 14137 svg = "" + (new_start_tag) + (svg['$[]'](Opal.Range.$new(old_start_tag.$length(), -1, false))); 14138 } } return svg; 14139 }); 14140 self.$private(); 14141 14142 $def(self, '$append_boolean_attribute', function $$append_boolean_attribute(name, xml) { 14143 14144 if ($truthy(xml)) { 14145 return " " + (name) + "=\"" + (name) + "\"" 14146 } else { 14147 return " " + (name) 14148 } 14149 }); 14150 14151 $def(self, '$append_link_constraint_attrs', function $$append_link_constraint_attrs(node, attrs) { 14152 var rel = nil, window = nil; 14153 14154 14155 if (attrs == null) attrs = []; 14156 if ($truthy(node['$option?']("nofollow"))) { 14157 rel = "nofollow"; 14158 } if ($truthy((window = node.$attributes()['$[]']("window")))) { 14159 14160 attrs['$<<'](" target=\"" + (window) + "\""); 14161 if (($eqeq(window, "_blank") || ($truthy(node['$option?']("noopener"))))) { 14162 attrs['$<<'](($truthy(rel) ? (" rel=\"" + (rel) + " noopener\"") : (" rel=\"noopener\""))); 14163 } } else if ($truthy(rel)) { 14164 attrs['$<<'](" rel=\"" + (rel) + "\""); 14165 } return attrs; 14166 }, -2); 14167 14168 $def(self, '$encode_attribute_value', function $$encode_attribute_value(val) { 14169 14170 if ($truthy(val['$include?']("\""))) { 14171 14172 return val.$gsub("\"", """); 14173 } else { 14174 return val 14175 } 14176 }); 14177 14178 $def(self, '$generate_manname_section', function $$generate_manname_section(node) { 14179 var manname_title = nil, next_section_title = nil, next_section = nil, manname_id_attr = nil, manname_id = nil; 14180 14181 14182 manname_title = node.$attr("manname-title", "Name"); 14183 if (($truthy((next_section = node.$sections()['$[]'](0))) && ($eqeq((next_section_title = next_section.$title()), next_section_title.$upcase())))) { 14184 manname_title = manname_title.$upcase(); 14185 } manname_id_attr = ($truthy((manname_id = node.$attr("manname-id"))) ? (" id=\"" + (manname_id) + "\"") : ("")); 14186 return "<h2" + (manname_id_attr) + ">" + (manname_title) + "</h2>\n" + "<div class=\"sectionbody\">\n" + "<p>" + (node.$attr("mannames").$join(", ")) + " - " + (node.$attr("manpurpose")) + "</p>\n" + "</div>"; 14187 }); 14188 14189 $def(self, '$get_root_document', function $$get_root_document(node) { 14190 14191 14192 while ($truthy((node = node.$document())['$nested?']())) { 14193 node = node.$parent_document(); 14194 } return node; 14195 }); 14196 14197 $def(self, '$method_missing', function $$method_missing(id, $a) { 14198 var $post_args, args, $yield = $$method_missing.$$p || nil, self = this, name = nil; 14199 14200 $$method_missing.$$p = null; 14201 14202 $post_args = $slice(arguments, 1); 14203 args = $post_args; 14204 if (($not((name = id.$to_s())['$start_with?']("convert_")) && ($truthy(self['$handles?'](name))))) { 14205 14206 return $send(self, 'send', ["convert_" + (name)].concat($to_a(args))); 14207 } else { 14208 return $send2(self, $find_super(self, 'method_missing', $$method_missing, false, true), 'method_missing', [id].concat($to_a(args)), $yield) 14209 } }, -2); 14210 return $def(self, '$respond_to_missing?', function $Html5Converter_respond_to_missing$ques$21(id, $a) { 14211 var self = this, $ret_or_1 = nil, name = nil; 14212 14213 14214 $slice(arguments, 1); 14215 if ($truthy(($ret_or_1 = (name = id.$to_s())['$start_with?']("convert_")['$!']()))) { 14216 14217 return self['$handles?'](name); 14218 } else { 14219 return $ret_or_1 14220 } }, -2); 14221 })($$('Converter'), $$$($$('Converter'), 'Base'), $nesting) 14222 })($nesting[0], $nesting) 14223}; 14224 14225Opal.modules["asciidoctor/extensions"] = function(Opal) {/* Generated by Opal 1.7.3 */ 14226 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.$$$; 14227 14228 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'); 14229 return (function($base, $parent_nesting) { 14230 var self = $module($base, 'Asciidoctor'); 14231 14232 var $nesting = [self].concat($parent_nesting); 14233 14234 return (function($base, $parent_nesting) { 14235 var self = $module($base, 'Extensions'); 14236 14237 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14238 14239 14240 (function($base, $super, $parent_nesting) { 14241 var self = $klass($base, $super, 'Processor'); 14242 14243 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14244 14245 $proto.config = nil; 14246 14247 (function(self, $parent_nesting) { 14248 14249 14250 14251 $def(self, '$config', function $$config() { 14252 var self = this, $ret_or_1 = nil; 14253 if (self.config == null) self.config = nil; 14254 14255 return (self.config = ($truthy(($ret_or_1 = self.config)) ? ($ret_or_1) : ($hash2([], {})))) 14256 }); 14257 14258 $def(self, '$option', function $$option(key, default_value) { 14259 var $a, self = this; 14260 14261 return ($a = [key, default_value], $send(self.$config(), '[]=', $a), $a[$a.length - 1]) 14262 }); 14263 14264 $def(self, '$enable_dsl', function $$enable_dsl() { 14265 var self = this; 14266 14267 if ($truthy(self['$const_defined?']("DSL"))) { 14268 if ($truthy(self['$singleton_class?']())) { 14269 return self.$include(self.$const_get("DSL")) 14270 } else { 14271 return self.$extend(self.$const_get("DSL")) 14272 } 14273 } else { 14274 return nil 14275 } 14276 }); 14277 return $alias(self, "use_dsl", "enable_dsl"); 14278 })(Opal.get_singleton_class(self)); 14279 self.$attr_reader("config"); 14280 14281 $def(self, '$initialize', function $$initialize(config) { 14282 var self = this; 14283 14284 14285 if (config == null) config = $hash2([], {}); 14286 return (self.config = self.$class().$config().$merge(config)); 14287 }, -1); 14288 14289 $def(self, '$update_config', function $$update_config(config) { 14290 var self = this; 14291 14292 return self.config.$update(config) 14293 }); 14294 14295 $def(self, '$process', function $$process($a) { 14296 var self = this; 14297 14298 14299 $slice(arguments); 14300 return self.$raise($$$('NotImplementedError'), "" + ($$('Processor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method"); 14301 }, -1); 14302 14303 $def(self, '$create_section', function $$create_section(parent, title, attrs, opts) { 14304 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; 14305 14306 14307 if (opts == null) opts = $hash2([], {}); 14308 doc = parent.$document(); 14309 book = (doctype = doc.$doctype())['$==']("book"); 14310 level = ($truthy(($ret_or_1 = opts['$[]']("level"))) ? ($ret_or_1) : ($rb_plus(parent.$level(), 1))); 14311 if ($truthy((style = attrs.$delete("style")))) { 14312 if (($truthy(book) && ($eqeq(style, "abstract")))) { 14313 $a = ["chapter", 1], (sectname = $a[0]), (level = $a[1]); 14314 } else { 14315 14316 $a = [style, true], (sectname = $a[0]), (special = $a[1]); 14317 if ($eqeq(level, 0)) { 14318 level = 1; 14319 } } 14320 } else if ($truthy(book)) { 14321 sectname = ($eqeq(level, 0) ? ("part") : (($truthy($rb_gt(level, 1)) ? ("section") : ("chapter")))); 14322 } else if (($eqeq(doctype, "manpage") && ($eqeq(title.$casecmp("synopsis"), 0)))) { 14323 $a = ["synopsis", true], (sectname = $a[0]), (special = $a[1]); 14324 } else { 14325 sectname = "section"; 14326 } sect = $$('Section').$new(parent, level); 14327 $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]); 14328 if ($truthy(special)) { 14329 14330 sect['$special='](true); 14331 if ($truthy(opts.$fetch("numbered", style['$==']("appendix")))) { 14332 sect['$numbered='](true); 14333 } else if (($not(opts['$key?']("numbered")) && ($truthy(doc['$attr?']("sectnums", "all"))))) { 14334 sect['$numbered=']((($truthy(book) && ($eqeq(level, 1))) ? ("chapter") : (true))); 14335 } } else if ($truthy($rb_gt(level, 0))) { 14336 if ($truthy(opts.$fetch("numbered", doc['$attr?']("sectnums")))) { 14337 sect['$numbered='](($truthy(sect.$special()) ? (($truthy(($ret_or_1 = parent.$numbered())) || ($ret_or_1))) : (true))); 14338 } 14339 } else if ($truthy(opts.$fetch("numbered", ($truthy(($ret_or_1 = book)) ? (doc['$attr?']("partnums")) : ($ret_or_1))))) { 14340 sect['$numbered='](true); 14341 } if ($eqeq((id = attrs['$[]']("id")), false)) { 14342 attrs.$delete("id"); 14343 } else { 14344 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])); 14345 } sect.$update_attributes(attrs); 14346 return sect; 14347 }, -4); 14348 14349 $def(self, '$create_block', function $$create_block(parent, context, source, attrs, opts) { 14350 14351 14352 if (opts == null) opts = $hash2([], {}); 14353 return $$('Block').$new(parent, context, $hash2(["source", "attributes"], {"source": source, "attributes": attrs}).$merge(opts)); 14354 }, -5); 14355 14356 $def(self, '$create_list', function $$create_list(parent, context, attrs) { 14357 var list = nil; 14358 14359 14360 if (attrs == null) attrs = nil; 14361 list = $$('List').$new(parent, context); 14362 if ($truthy(attrs)) { 14363 list.$update_attributes(attrs); 14364 } return list; 14365 }, -3); 14366 14367 $def(self, '$create_list_item', function $$create_list_item(parent, text) { 14368 14369 14370 if (text == null) text = nil; 14371 return $$('ListItem').$new(parent, text); 14372 }, -2); 14373 14374 $def(self, '$create_image_block', function $$create_image_block(parent, attrs, opts) { 14375 var $a, self = this, target = nil, title = nil, block = nil; 14376 14377 14378 if (opts == null) opts = $hash2([], {}); 14379 if (!$truthy((target = attrs['$[]']("target")))) { 14380 self.$raise($$$('ArgumentError'), "Unable to create an image block, target attribute is required"); 14381 } if ($truthy((attrs['$[]']("alt")))) ; else { 14382 attrs['$[]=']("alt", ($a = ["default-alt", $$('Helpers').$basename(target, true).$tr("_-", " ")], $send(attrs, '[]=', $a), $a[$a.length - 1])); 14383 } title = ($truthy(attrs['$key?']("title")) ? (attrs.$delete("title")) : (nil)); 14384 block = self.$create_block(parent, "image", nil, attrs, opts); 14385 if ($truthy(title)) { 14386 14387 block['$title='](title); 14388 block.$assign_caption(attrs.$delete("caption"), "figure"); 14389 } return block; 14390 }, -3); 14391 14392 $def(self, '$create_inline', function $$create_inline(parent, context, text, opts) { 14393 14394 14395 if (opts == null) opts = $hash2([], {}); 14396 return $$('Inline').$new(parent, context, text, ($eqeq(context, "quoted") ? ($hash2(["type"], {"type": "unquoted"}).$merge(opts)) : (opts))); 14397 }, -4); 14398 14399 $def(self, '$parse_content', function $$parse_content(parent, content, attributes) { 14400 var reader = nil; 14401 14402 14403 if (attributes == null) attributes = nil; 14404 reader = ($eqeqeq($$('Reader'), content) ? (content) : ($$('Reader').$new(content))); 14405 $$('Parser').$parse_blocks(reader, parent, attributes); 14406 return parent; 14407 }, -3); 14408 14409 $def(self, '$parse_attributes', function $$parse_attributes(block, attrlist, opts) { 14410 var $ret_or_1 = nil; 14411 14412 14413 if (opts == null) opts = $hash2([], {}); 14414 if ($truthy(($truthy(attrlist) ? (attrlist['$empty?']()) : (true)))) { 14415 return $hash2([], {}) 14416 } if (($truthy(opts['$[]']("sub_attributes")) && ($truthy(attrlist['$include?']($$('ATTR_REF_HEAD')))))) { 14417 attrlist = block.$sub_attributes(attrlist); 14418 } return $$('AttributeList').$new(attrlist).$parse(($truthy(($ret_or_1 = opts['$[]']("positional_attributes"))) ? ($ret_or_1) : ([]))); 14419 }, -3); 14420 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; 14421 14422 14423 if (method_name == null) method_name = nil; 14424 if (delegate_method_name == null) delegate_method_name = nil; 14425 if (context == null) context = nil; 14426 return $send(self, 'define_method', [method_name], function $$2($a){var $post_args, args, self = $$2.$$s == null ? this : $$2.$$s; 14427 14428 14429 $post_args = $slice(arguments); 14430 args = $post_args; 14431 args.$unshift(args.$shift(), context); 14432 return $send(self, 'send', [delegate_method_name].concat($to_a(args)));}, {$$arity: -1, $$s: self});}, {$$s: self}); 14433 })($nesting[0], null, $nesting); 14434 (function($base) { 14435 var self = $module($base, 'ProcessorDsl'); 14436 14437 14438 14439 14440 $def(self, '$option', function $$option(key, value) { 14441 var $a, self = this; 14442 14443 return ($a = [key, value], $send(self.$config(), '[]=', $a), $a[$a.length - 1]) 14444 }); 14445 14446 $def(self, '$process', function $$process($a) { 14447 var block = $$process.$$p || nil, $post_args, args, $b, self = this, context = nil; 14448 if (self.process_block == null) self.process_block = nil; 14449 14450 $$process.$$p = null; 14451 $post_args = $slice(arguments); 14452 args = $post_args; 14453 if ((block !== nil)) { 14454 14455 if (!$truthy(args['$empty?']())) { 14456 self.$raise($$$('ArgumentError'), "wrong number of arguments (given " + (args.$size()) + ", expected 0)"); 14457 } if (!($truthy(block.$binding()) && ($eqeq(self, block.$binding().$receiver())))) { 14458 14459 context = self; 14460 $send(block, 'define_singleton_method', ["call"], function $$3($b){var $post_args, m_args; 14461 14462 14463 $post_args = $slice(arguments); 14464 m_args = $post_args; 14465 return $send(context, 'instance_exec', $to_a(m_args), block.$to_proc());}, -1); 14466 } return (self.process_block = block); 14467 } else if ($truthy((($b = self['process_block'], $b != null && $b !== nil) ? 'instance-variable' : nil))) { 14468 return $send(self.process_block, 'call', $to_a(args)) 14469 } else { 14470 return self.$raise($$$('NotImplementedError'), "" + (self.$class()) + " #" + ("process") + " method called before being registered") 14471 } }, -1); 14472 return $def(self, '$process_block_given?', function $ProcessorDsl_process_block_given$ques$4() { 14473 var $a, self = this; 14474 14475 return (($a = self['process_block'], $a != null && $a !== nil) ? 'instance-variable' : nil) 14476 }); 14477 })($nesting[0]); 14478 (function($base, $parent_nesting) { 14479 var self = $module($base, 'DocumentProcessorDsl'); 14480 14481 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14482 14483 14484 self.$include($$('ProcessorDsl')); 14485 return $def(self, '$prefer', function $$prefer() { 14486 var self = this; 14487 14488 return self.$option("position", ">>") 14489 }); 14490 })($nesting[0], $nesting); 14491 (function($base, $parent_nesting) { 14492 var self = $module($base, 'SyntaxProcessorDsl'); 14493 14494 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14495 14496 14497 self.$include($$('ProcessorDsl')); 14498 14499 $def(self, '$named', function $$named(value) { 14500 var self = this; 14501 14502 if ($eqeqeq($$('Processor'), self)) { 14503 return (self.name = value) 14504 } else { 14505 return self.$option("name", value) 14506 } 14507 }); 14508 14509 $def(self, '$content_model', function $$content_model(value) { 14510 var self = this; 14511 14512 return self.$option("content_model", value) 14513 }); 14514 $alias(self, "parse_content_as", "content_model"); 14515 14516 $def(self, '$positional_attributes', function $$positional_attributes($a) { 14517 var $post_args, value, self = this; 14518 14519 14520 $post_args = $slice(arguments); 14521 value = $post_args; 14522 return self.$option("positional_attrs", value.$flatten()); 14523 }, -1); 14524 $alias(self, "name_positional_attributes", "positional_attributes"); 14525 $alias(self, "positional_attrs", "positional_attributes"); 14526 14527 $def(self, '$default_attributes', function $$default_attributes(value) { 14528 var self = this; 14529 14530 return self.$option("default_attrs", value) 14531 }); 14532 $alias(self, "default_attrs", "default_attributes"); 14533 14534 $def(self, '$resolve_attributes', function $$resolve_attributes($a) { 14535 var $post_args, args, $b, self = this, $ret_or_1 = nil, names = nil, defaults = nil; 14536 14537 14538 $post_args = $slice(arguments); 14539 args = $post_args; 14540 if (!$truthy($rb_gt(args.$size(), 1))) { 14541 if ($truthy((args = args.$fetch(0, true))['$respond_to?']("to_sym"))) { 14542 args = [args]; 14543 } 14544 } if ($eqeqeq(true, ($ret_or_1 = args))) { 14545 14546 self.$option("positional_attrs", []); 14547 return self.$option("default_attrs", $hash2([], {})); 14548 } else if ($eqeqeq($$$('Array'), $ret_or_1)) { 14549 14550 $b = [[], $hash2([], {})], (names = $b[0]), (defaults = $b[1]); 14551 $send(args, 'each', [], function $$5(arg){var $c, $d, name = nil, value = nil, idx = nil; 14552 14553 14554 if (arg == null) arg = nil; 14555 if ($truthy((arg = arg.$to_s())['$include?']("="))) { 14556 14557 $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])); 14558 if ($truthy(name['$include?'](":"))) { 14559 14560 $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])); 14561 idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i())); 14562 names['$[]='](idx, name); 14563 } return ($c = [name, value], $send(defaults, '[]=', $c), $c[$c.length - 1]); 14564 } else if ($truthy(arg['$include?'](":"))) { 14565 14566 $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])); 14567 idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i())); 14568 return ($c = [idx, name], $send(names, '[]=', $c), $c[$c.length - 1]); 14569 } else { 14570 return names['$<<'](arg) 14571 }}); 14572 self.$option("positional_attrs", names.$compact()); 14573 return self.$option("default_attrs", defaults); 14574 } else if ($eqeqeq($$$('Hash'), $ret_or_1)) { 14575 14576 $b = [[], $hash2([], {})], (names = $b[0]), (defaults = $b[1]); 14577 $send(args, 'each', [], function $$6(key, val){var $c, $d, name = nil, idx = nil; 14578 14579 14580 if (key == null) key = nil; 14581 if (val == null) val = nil; 14582 if ($truthy((name = key.$to_s())['$include?'](":"))) { 14583 14584 $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])); 14585 idx = ($eqeq(idx, "@") ? (names.$size()) : (idx.$to_i())); 14586 names['$[]='](idx, name); 14587 } if ($truthy(val)) { 14588 return ($c = [name, val], $send(defaults, '[]=', $c), $c[$c.length - 1]) 14589 } else { 14590 return nil 14591 }}); 14592 self.$option("positional_attrs", names.$compact()); 14593 return self.$option("default_attrs", defaults); 14594 } else { 14595 return self.$raise($$$('ArgumentError'), "unsupported attributes specification for macro: " + (args.$inspect())) 14596 } }, -1); 14597 return $alias(self, "resolves_attributes", "resolve_attributes"); 14598 })($nesting[0], $nesting); 14599 (function($base, $super, $parent_nesting) { 14600 var self = $klass($base, $super, 'Preprocessor'); 14601 14602 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14603 14604 return $def(self, '$process', function $$process(document, reader) { 14605 var self = this; 14606 14607 return self.$raise($$$('NotImplementedError'), "" + ($$('Preprocessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14608 }) 14609 })($nesting[0], $$('Processor'), $nesting); 14610 $const_set($$('Preprocessor'), 'DSL', $$('DocumentProcessorDsl')); 14611 (function($base, $super, $parent_nesting) { 14612 var self = $klass($base, $super, 'TreeProcessor'); 14613 14614 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14615 14616 return $def(self, '$process', function $$process(document) { 14617 var self = this; 14618 14619 return self.$raise($$$('NotImplementedError'), "" + ($$('TreeProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14620 }) 14621 })($nesting[0], $$('Processor'), $nesting); 14622 $const_set($$('TreeProcessor'), 'DSL', $$('DocumentProcessorDsl')); 14623 $const_set($nesting[0], 'Treeprocessor', $$('TreeProcessor')); 14624 (function($base, $super, $parent_nesting) { 14625 var self = $klass($base, $super, 'Postprocessor'); 14626 14627 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14628 14629 return $def(self, '$process', function $$process(document, output) { 14630 var self = this; 14631 14632 return self.$raise($$$('NotImplementedError'), "" + ($$('Postprocessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14633 }) 14634 })($nesting[0], $$('Processor'), $nesting); 14635 $const_set($$('Postprocessor'), 'DSL', $$('DocumentProcessorDsl')); 14636 (function($base, $super, $parent_nesting) { 14637 var self = $klass($base, $super, 'IncludeProcessor'); 14638 14639 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14640 14641 14642 14643 $def(self, '$process', function $$process(document, reader, target, attributes) { 14644 var self = this; 14645 14646 return self.$raise($$$('NotImplementedError'), "" + ($$('IncludeProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14647 }); 14648 return $def(self, '$handles?', $return_val(true)); 14649 })($nesting[0], $$('Processor'), $nesting); 14650 (function($base, $parent_nesting) { 14651 var self = $module($base, 'IncludeProcessorDsl'); 14652 14653 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14654 14655 14656 self.$include($$('DocumentProcessorDsl')); 14657 return $def(self, '$handles?', function $IncludeProcessorDsl_handles$ques$7($a) { 14658 var block = $IncludeProcessorDsl_handles$ques$7.$$p || nil, $post_args, args, $b, self = this; 14659 if (self.handles_block == null) self.handles_block = nil; 14660 14661 $IncludeProcessorDsl_handles$ques$7.$$p = null; 14662 $post_args = $slice(arguments); 14663 args = $post_args; 14664 if ((block !== nil)) { 14665 14666 if (!$truthy(args['$empty?']())) { 14667 self.$raise($$$('ArgumentError'), "wrong number of arguments (given " + (args.$size()) + ", expected 0)"); 14668 } return (self.handles_block = block); 14669 } else if ($truthy((($b = self['handles_block'], $b != null && $b !== nil) ? 'instance-variable' : nil))) { 14670 return self.handles_block.$call(args['$[]'](0)) 14671 } else { 14672 return true 14673 } }, -1); 14674 })($nesting[0], $nesting); 14675 $const_set($$('IncludeProcessor'), 'DSL', $$('IncludeProcessorDsl')); 14676 (function($base, $super, $parent_nesting) { 14677 var self = $klass($base, $super, 'DocinfoProcessor'); 14678 14679 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14680 14681 $proto.config = nil; 14682 14683 14684 $def(self, '$initialize', function $$initialize(config) { 14685 var $a; $$initialize.$$p || nil; var self = this, $ret_or_1 = nil; 14686 14687 $$initialize.$$p = null; 14688 14689 if (config == null) config = $hash2([], {}); 14690 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null); 14691 if ($truthy(($ret_or_1 = self.config['$[]']("location")))) { 14692 return $ret_or_1 14693 } else { 14694 return ($a = ["location", "head"], $send(self.config, '[]=', $a), $a[$a.length - 1]) 14695 } }, -1); 14696 return $def(self, '$process', function $$process(document) { 14697 var self = this; 14698 14699 return self.$raise($$$('NotImplementedError'), "" + ($$('DocinfoProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14700 }); 14701 })($nesting[0], $$('Processor'), $nesting); 14702 (function($base, $parent_nesting) { 14703 var self = $module($base, 'DocinfoProcessorDsl'); 14704 14705 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14706 14707 14708 self.$include($$('DocumentProcessorDsl')); 14709 return $def(self, '$at_location', function $$at_location(value) { 14710 var self = this; 14711 14712 return self.$option("location", value) 14713 }); 14714 })($nesting[0], $nesting); 14715 $const_set($$('DocinfoProcessor'), 'DSL', $$('DocinfoProcessorDsl')); 14716 (function($base, $super, $parent_nesting) { 14717 var self = $klass($base, $super, 'BlockProcessor'); 14718 14719 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14720 14721 $proto.config = nil; 14722 14723 self.$attr_accessor("name"); 14724 14725 $def(self, '$initialize', function $$initialize(name, config) { 14726 var $a; $$initialize.$$p || nil; var self = this, $ret_or_1 = nil; 14727 14728 $$initialize.$$p = null; 14729 14730 if (name == null) name = nil; 14731 if (config == null) config = $hash2([], {}); 14732 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null); 14733 self.name = ($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.config['$[]']("name"))); 14734 if ($eqeqeq($NilClass, ($ret_or_1 = self.config['$[]']("contexts")))) { 14735 if ($truthy((self.config['$[]']("contexts")))) ; else { 14736 self.config['$[]=']("contexts", ["open", "paragraph"].$to_set()); 14737 } 14738 } else if ($eqeqeq($$$('Symbol'), $ret_or_1)) { 14739 self.config['$[]=']("contexts", [self.config['$[]']("contexts")].$to_set()); 14740 } else { 14741 self.config['$[]=']("contexts", self.config['$[]']("contexts").$to_set()); 14742 } if ($truthy(($ret_or_1 = self.config['$[]']("content_model")))) { 14743 return $ret_or_1 14744 } else { 14745 return ($a = ["content_model", "compound"], $send(self.config, '[]=', $a), $a[$a.length - 1]) 14746 } }, -1); 14747 return $def(self, '$process', function $$process(parent, reader, attributes) { 14748 var self = this; 14749 14750 return self.$raise($$$('NotImplementedError'), "" + ($$('BlockProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14751 }); 14752 })($nesting[0], $$('Processor'), $nesting); 14753 (function($base, $parent_nesting) { 14754 var self = $module($base, 'BlockProcessorDsl'); 14755 14756 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14757 14758 14759 self.$include($$('SyntaxProcessorDsl')); 14760 14761 $def(self, '$contexts', function $$contexts($a) { 14762 var $post_args, value, self = this; 14763 14764 14765 $post_args = $slice(arguments); 14766 value = $post_args; 14767 return self.$option("contexts", value.$flatten().$to_set()); 14768 }, -1); 14769 $alias(self, "on_contexts", "contexts"); 14770 $alias(self, "on_context", "contexts"); 14771 return $alias(self, "bind_to", "contexts"); 14772 })($nesting[0], $nesting); 14773 $const_set($$('BlockProcessor'), 'DSL', $$('BlockProcessorDsl')); 14774 (function($base, $super, $parent_nesting) { 14775 var self = $klass($base, $super, 'MacroProcessor'); 14776 14777 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14778 14779 $proto.config = nil; 14780 14781 self.$attr_accessor("name"); 14782 14783 $def(self, '$initialize', function $$initialize(name, config) { 14784 var $a; $$initialize.$$p || nil; var self = this, $ret_or_1 = nil; 14785 14786 $$initialize.$$p = null; 14787 14788 if (name == null) name = nil; 14789 if (config == null) config = $hash2([], {}); 14790 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [config], null); 14791 self.name = ($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.config['$[]']("name"))); 14792 if ($truthy(($ret_or_1 = self.config['$[]']("content_model")))) { 14793 return $ret_or_1 14794 } else { 14795 return ($a = ["content_model", "attributes"], $send(self.config, '[]=', $a), $a[$a.length - 1]) 14796 } }, -1); 14797 return $def(self, '$process', function $$process(parent, target, attributes) { 14798 var self = this; 14799 14800 return self.$raise($$$('NotImplementedError'), "" + ($$('MacroProcessor')) + " subclass " + (self.$class()) + " must implement the #" + ("process") + " method") 14801 }); 14802 })($nesting[0], $$('Processor'), $nesting); 14803 (function($base, $parent_nesting) { 14804 var self = $module($base, 'MacroProcessorDsl'); 14805 14806 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14807 14808 14809 self.$include($$('SyntaxProcessorDsl')); 14810 14811 $def(self, '$resolve_attributes', function $$resolve_attributes($a) { 14812 var $post_args, args, $yield = $$resolve_attributes.$$p || nil, self = this; 14813 14814 $$resolve_attributes.$$p = null; 14815 14816 $post_args = $slice(arguments); 14817 args = $post_args; 14818 if (($eqeq(args.$size(), 1) && ($not(args['$[]'](0))))) { 14819 return self.$option("content_model", "text") 14820 } else { 14821 14822 $send2(self, $find_super(self, 'resolve_attributes', $$resolve_attributes, false, true), 'resolve_attributes', $to_a(args), $yield); 14823 return self.$option("content_model", "attributes"); 14824 } }, -1); 14825 return $alias(self, "resolves_attributes", "resolve_attributes"); 14826 })($nesting[0], $nesting); 14827 (function($base, $super, $parent_nesting) { 14828 var self = $klass($base, $super, 'BlockMacroProcessor'); 14829 14830 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14831 14832 $proto.name = nil; 14833 return $def(self, '$name', function $$name() { 14834 var self = this; 14835 14836 14837 if (!$truthy($$('MacroNameRx')['$match?'](self.name.$to_s()))) { 14838 self.$raise($$$('ArgumentError'), "invalid name for block macro: " + (self.name)); 14839 } return self.name; 14840 }) 14841 })($nesting[0], $$('MacroProcessor'), $nesting); 14842 $const_set($$('BlockMacroProcessor'), 'DSL', $$('MacroProcessorDsl')); 14843 (function($base, $super, $parent_nesting) { 14844 var self = $klass($base, $super, 'InlineMacroProcessor'); 14845 14846 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14847 14848 $proto.config = $proto.name = nil; 14849 14850 $class_variable_set($nesting[0], '@@rx_cache', $hash2([], {})); 14851 14852 $def(self, '$regexp', function $$regexp() { 14853 var $a, self = this, $ret_or_1 = nil; 14854 14855 if ($truthy(($ret_or_1 = self.config['$[]']("regexp")))) { 14856 return $ret_or_1 14857 } else { 14858 return ($a = ["regexp", self.$resolve_regexp(self.name.$to_s(), self.config['$[]']("format"))], $send(self.config, '[]=', $a), $a[$a.length - 1]) 14859 } 14860 }); 14861 return $def(self, '$resolve_regexp', function $$resolve_regexp(name, format) { 14862 var $a, self = this, $ret_or_1 = nil; 14863 14864 14865 if (!$truthy($$('MacroNameRx')['$match?'](name))) { 14866 self.$raise($$$('ArgumentError'), "invalid name for inline macro: " + (name)); 14867 } if ($truthy(($ret_or_1 = $class_variable_get($nesting[0], '@@rx_cache', false)['$[]']([name, format])))) { 14868 return $ret_or_1 14869 } else { 14870 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]) 14871 } }); 14872 })($nesting[0], $$('MacroProcessor'), $nesting); 14873 (function($base, $parent_nesting) { 14874 var self = $module($base, 'InlineMacroProcessorDsl'); 14875 14876 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14877 14878 14879 self.$include($$('MacroProcessorDsl')); 14880 14881 $def(self, '$format', function $$format(value) { 14882 var self = this; 14883 14884 return self.$option("format", value) 14885 }); 14886 $alias(self, "match_format", "format"); 14887 $alias(self, "using_format", "format"); 14888 return $def(self, '$match', function $$match(value) { 14889 var self = this; 14890 14891 return self.$option("regexp", value) 14892 }); 14893 })($nesting[0], $nesting); 14894 $const_set($$('InlineMacroProcessor'), 'DSL', $$('InlineMacroProcessorDsl')); 14895 (function($base, $super) { 14896 var self = $klass($base, $super, 'Extension'); 14897 14898 14899 14900 self.$attr_reader("kind"); 14901 self.$attr_reader("config"); 14902 self.$attr_reader("instance"); 14903 return $def(self, '$initialize', function $$initialize(kind, instance, config) { 14904 var self = this; 14905 14906 14907 self.kind = kind; 14908 self.instance = instance; 14909 return (self.config = config); 14910 }); 14911 })($nesting[0], null); 14912 (function($base, $super) { 14913 var self = $klass($base, $super, 'ProcessorExtension'); 14914 14915 14916 14917 self.$attr_reader("process_method"); 14918 return $def(self, '$initialize', function $$initialize(kind, instance, process_method) { 14919 $$initialize.$$p || nil; var self = this, $ret_or_1 = nil; 14920 14921 $$initialize.$$p = null; 14922 14923 if (process_method == null) process_method = nil; 14924 $send2(self, $find_super(self, 'initialize', $$initialize, false, true), 'initialize', [kind, instance, instance.$config()], null); 14925 return (self.process_method = ($truthy(($ret_or_1 = process_method)) ? ($ret_or_1) : (instance.$method("process")))); 14926 }, -3); 14927 })($nesting[0], $$('Extension')); 14928 (function($base, $super, $parent_nesting) { 14929 var self = $klass($base, $super, 'Group'); 14930 14931 var $nesting = [self].concat($parent_nesting); 14932 14933 14934 (function(self, $parent_nesting) { 14935 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 14936 14937 return $def(self, '$register', function $$register(name) { 14938 var self = this; 14939 14940 14941 if (name == null) name = nil; 14942 return $$('Extensions').$register(name, self); 14943 }, -1) 14944 })(Opal.get_singleton_class(self), $nesting); 14945 return $def(self, '$activate', function $$activate(registry) { 14946 var self = this; 14947 14948 return self.$raise($$$('NotImplementedError')) 14949 }); 14950 })($nesting[0], null, $nesting); 14951 (function($base, $super, $parent_nesting) { 14952 var self = $klass($base, $super, 'Registry'); 14953 14954 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 14955 14956 $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; 14957 14958 self.$attr_reader("document"); 14959 self.$attr_reader("groups"); 14960 14961 $def(self, '$initialize', function $$initialize(groups) { 14962 var self = this; 14963 14964 14965 if (groups == null) groups = $hash2([], {}); 14966 self.groups = groups; 14967 self.$reset(); 14968 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))))))); 14969 return (self.document = nil); 14970 }, -1); 14971 14972 $def(self, '$activate', function $$activate(document) { 14973 var self = this, ext_groups = nil; 14974 14975 14976 if ($truthy(self.document)) { 14977 self.$reset(); 14978 } self.document = document; 14979 if (!$truthy((ext_groups = $rb_plus($$('Extensions').$groups().$values(), self.groups.$values()))['$empty?']())) { 14980 $send(ext_groups, 'each', [], function $$8(group){var self = $$8.$$s == null ? this : $$8.$$s, $ret_or_1 = nil; 14981 14982 14983 if (group == null) group = nil; 14984 if ($eqeqeq($$$('Proc'), ($ret_or_1 = group))) { 14985 14986 switch (group.$arity()) { 14987 case 0: 14988 case -1: 14989 return $send(self, 'instance_exec', [], group.$to_proc()) 14990 case 1: 14991 return group.$call(self) 14992 default: 14993 return nil 14994 } 14995 } else if ($eqeqeq($Class, $ret_or_1)) { 14996 return group.$new().$activate(self) 14997 } else { 14998 return group.$activate(self) 14999 }}, {$$s: self}); 15000 } return self; 15001 }); 15002 15003 $def(self, '$preprocessor', function $$preprocessor($a) { 15004 var block = $$preprocessor.$$p || nil, $post_args, args, self = this; 15005 15006 $$preprocessor.$$p = null; 15007 $post_args = $slice(arguments); 15008 args = $post_args; 15009 return $send(self, 'add_document_processor', ["preprocessor", args], block.$to_proc()); 15010 }, -1); 15011 15012 $def(self, '$preprocessors?', function $Registry_preprocessors$ques$9() { 15013 var self = this; 15014 15015 return self.preprocessor_extensions['$!']()['$!']() 15016 }); 15017 15018 $def(self, '$preprocessors', $return_ivar("preprocessor_extensions")); 15019 15020 $def(self, '$tree_processor', function $$tree_processor($a) { 15021 var block = $$tree_processor.$$p || nil, $post_args, args, self = this; 15022 15023 $$tree_processor.$$p = null; 15024 $post_args = $slice(arguments); 15025 args = $post_args; 15026 return $send(self, 'add_document_processor', ["tree_processor", args], block.$to_proc()); 15027 }, -1); 15028 15029 $def(self, '$tree_processors?', function $Registry_tree_processors$ques$10() { 15030 var self = this; 15031 15032 return self.tree_processor_extensions['$!']()['$!']() 15033 }); 15034 15035 $def(self, '$tree_processors', $return_ivar("tree_processor_extensions")); 15036 $alias(self, "treeprocessor", "tree_processor"); 15037 $alias(self, "treeprocessors?", "tree_processors?"); 15038 $alias(self, "treeprocessors", "tree_processors"); 15039 15040 $def(self, '$postprocessor', function $$postprocessor($a) { 15041 var block = $$postprocessor.$$p || nil, $post_args, args, self = this; 15042 15043 $$postprocessor.$$p = null; 15044 $post_args = $slice(arguments); 15045 args = $post_args; 15046 return $send(self, 'add_document_processor', ["postprocessor", args], block.$to_proc()); 15047 }, -1); 15048 15049 $def(self, '$postprocessors?', function $Registry_postprocessors$ques$11() { 15050 var self = this; 15051 15052 return self.postprocessor_extensions['$!']()['$!']() 15053 }); 15054 15055 $def(self, '$postprocessors', $return_ivar("postprocessor_extensions")); 15056 15057 $def(self, '$include_processor', function $$include_processor($a) { 15058 var block = $$include_processor.$$p || nil, $post_args, args, self = this; 15059 15060 $$include_processor.$$p = null; 15061 $post_args = $slice(arguments); 15062 args = $post_args; 15063 return $send(self, 'add_document_processor', ["include_processor", args], block.$to_proc()); 15064 }, -1); 15065 15066 $def(self, '$include_processors?', function $Registry_include_processors$ques$12() { 15067 var self = this; 15068 15069 return self.include_processor_extensions['$!']()['$!']() 15070 }); 15071 15072 $def(self, '$include_processors', $return_ivar("include_processor_extensions")); 15073 15074 $def(self, '$docinfo_processor', function $$docinfo_processor($a) { 15075 var block = $$docinfo_processor.$$p || nil, $post_args, args, self = this; 15076 15077 $$docinfo_processor.$$p = null; 15078 $post_args = $slice(arguments); 15079 args = $post_args; 15080 return $send(self, 'add_document_processor', ["docinfo_processor", args], block.$to_proc()); 15081 }, -1); 15082 15083 $def(self, '$docinfo_processors?', function $Registry_docinfo_processors$ques$13(location) { 15084 var self = this; 15085 15086 15087 if (location == null) location = nil; 15088 if ($truthy(self.docinfo_processor_extensions)) { 15089 if ($truthy(location)) { 15090 return $send(self.docinfo_processor_extensions, 'any?', [], function $$14(ext){ 15091 15092 if (ext == null) ext = nil; 15093 return ext.$config()['$[]']("location")['$=='](location);}) 15094 } else { 15095 return true 15096 } 15097 } else { 15098 return false 15099 } }, -1); 15100 15101 $def(self, '$docinfo_processors', function $$docinfo_processors(location) { 15102 var self = this; 15103 15104 15105 if (location == null) location = nil; 15106 if ($truthy(self.docinfo_processor_extensions)) { 15107 if ($truthy(location)) { 15108 return $send(self.docinfo_processor_extensions, 'select', [], function $$15(ext){ 15109 15110 if (ext == null) ext = nil; 15111 return ext.$config()['$[]']("location")['$=='](location);}) 15112 } else { 15113 return self.docinfo_processor_extensions 15114 } 15115 } else { 15116 return nil 15117 } }, -1); 15118 15119 $def(self, '$block', function $$block($a) { 15120 var block = $$block.$$p || nil, $post_args, args, self = this; 15121 15122 $$block.$$p = null; 15123 $post_args = $slice(arguments); 15124 args = $post_args; 15125 return $send(self, 'add_syntax_processor', ["block", args], block.$to_proc()); 15126 }, -1); 15127 15128 $def(self, '$blocks?', function $Registry_blocks$ques$16() { 15129 var self = this; 15130 15131 return self.block_extensions['$!']()['$!']() 15132 }); 15133 15134 $def(self, '$registered_for_block?', function $Registry_registered_for_block$ques$17(name, context) { 15135 var self = this, ext = nil; 15136 15137 if ($truthy((ext = self.block_extensions['$[]'](name.$to_sym())))) { 15138 if ($truthy(ext.$config()['$[]']("contexts")['$include?'](context))) { 15139 return ext 15140 } else { 15141 return false 15142 } 15143 } else { 15144 return false 15145 } 15146 }); 15147 15148 $def(self, '$find_block_extension', function $$find_block_extension(name) { 15149 var self = this; 15150 15151 return self.block_extensions['$[]'](name.$to_sym()) 15152 }); 15153 15154 $def(self, '$block_macro', function $$block_macro($a) { 15155 var block = $$block_macro.$$p || nil, $post_args, args, self = this; 15156 15157 $$block_macro.$$p = null; 15158 $post_args = $slice(arguments); 15159 args = $post_args; 15160 return $send(self, 'add_syntax_processor', ["block_macro", args], block.$to_proc()); 15161 }, -1); 15162 15163 $def(self, '$block_macros?', function $Registry_block_macros$ques$18() { 15164 var self = this; 15165 15166 return self.block_macro_extensions['$!']()['$!']() 15167 }); 15168 15169 $def(self, '$registered_for_block_macro?', function $Registry_registered_for_block_macro$ques$19(name) { 15170 var self = this, ext = nil; 15171 15172 if ($truthy((ext = self.block_macro_extensions['$[]'](name.$to_sym())))) { 15173 return ext 15174 } else { 15175 return false 15176 } 15177 }); 15178 15179 $def(self, '$find_block_macro_extension', function $$find_block_macro_extension(name) { 15180 var self = this; 15181 15182 return self.block_macro_extensions['$[]'](name.$to_sym()) 15183 }); 15184 15185 $def(self, '$inline_macro', function $$inline_macro($a) { 15186 var block = $$inline_macro.$$p || nil, $post_args, args, self = this; 15187 15188 $$inline_macro.$$p = null; 15189 $post_args = $slice(arguments); 15190 args = $post_args; 15191 return $send(self, 'add_syntax_processor', ["inline_macro", args], block.$to_proc()); 15192 }, -1); 15193 15194 $def(self, '$inline_macros?', function $Registry_inline_macros$ques$20() { 15195 var self = this; 15196 15197 return self.inline_macro_extensions['$!']()['$!']() 15198 }); 15199 15200 $def(self, '$registered_for_inline_macro?', function $Registry_registered_for_inline_macro$ques$21(name) { 15201 var self = this, ext = nil; 15202 15203 if ($truthy((ext = self.inline_macro_extensions['$[]'](name.$to_sym())))) { 15204 return ext 15205 } else { 15206 return false 15207 } 15208 }); 15209 15210 $def(self, '$find_inline_macro_extension', function $$find_inline_macro_extension(name) { 15211 var self = this; 15212 15213 return self.inline_macro_extensions['$[]'](name.$to_sym()) 15214 }); 15215 15216 $def(self, '$inline_macros', function $$inline_macros() { 15217 var self = this; 15218 15219 return self.inline_macro_extensions.$values() 15220 }); 15221 15222 $def(self, '$prefer', function $$prefer($a) { 15223 var block = $$prefer.$$p || nil, $post_args, args, self = this, extension = nil, arg0 = nil, extensions_store = nil; 15224 15225 $$prefer.$$p = null; 15226 $post_args = $slice(arguments); 15227 args = $post_args; 15228 extension = ($eqeqeq($$('ProcessorExtension'), (arg0 = args.$shift())) ? (arg0) : ($send(self, 'send', [arg0].concat($to_a(args)), block.$to_proc()))); 15229 extensions_store = self.$instance_variable_get(((("@") + (extension.$kind())) + "_extensions").$to_sym()); 15230 extensions_store.$unshift(extensions_store.$delete(extension)); 15231 return extension; 15232 }, -1); 15233 self.$private(); 15234 15235 $def(self, '$add_document_processor', function $$add_document_processor(kind, args) { 15236 var block = $$add_document_processor.$$p || nil, $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; 15237 15238 $$add_document_processor.$$p = null; 15239 kind_name = kind.$to_s().$tr("_", " "); 15240 kind_class_symbol = $send(kind_name.$split(), 'map', [], function $$22(it){ 15241 15242 if (it == null) it = nil; 15243 return it.$capitalize();}).$join().$to_sym(); 15244 kind_class = $$('Extensions').$const_get(kind_class_symbol, false); 15245 kind_java_class = ($truthy((($$$('::', 'AsciidoctorJ', 'skip_raise')) ? 'constant' : nil)) ? ($$$($$$('AsciidoctorJ'), 'Extensions').$const_get(kind_class_symbol, false)) : (nil)); 15246 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(), []))); 15247 if ((block !== nil)) { 15248 15249 config = self.$resolve_args(args, 1); 15250 (processor = kind_class.$new(config)).$singleton_class().$enable_dsl(); 15251 if ($eqeq(block.$arity(), 0)) { 15252 $send(processor, 'instance_exec', [], block.$to_proc()); 15253 } else { 15254 Opal.yield1(block, processor); 15255 } if (!$truthy(processor['$process_block_given?']())) { 15256 self.$raise($$$('NoMethodError'), "No block specified to process " + (kind_name) + " extension at " + (block.$source_location().$join(":"))); 15257 } processor.$freeze(); 15258 extension = $$('ProcessorExtension').$new(kind, processor); 15259 } else { 15260 15261 $c = self.$resolve_args(args, 2), $b = $to_ary($c), (processor = ($b[0] == null ? nil : $b[0])), (config = ($b[1] == null ? nil : $b[1])); 15262 if ($truthy((processor_class = $$('Helpers').$resolve_class(processor)))) { 15263 15264 if (!($truthy($rb_lt(processor_class, kind_class)) || (($truthy(kind_java_class) && ($truthy($rb_lt(processor_class, kind_java_class))))))) { 15265 self.$raise($$$('ArgumentError'), "Invalid type for " + (kind_name) + " extension: " + (processor)); 15266 } processor_instance = processor_class.$new(config); 15267 processor_instance.$freeze(); 15268 extension = $$('ProcessorExtension').$new(kind, processor_instance); 15269 } else if (($eqeqeq(kind_class, processor) || (($truthy(kind_java_class) && ($eqeqeq(kind_java_class, processor)))))) { 15270 15271 processor.$update_config(config); 15272 processor.$freeze(); 15273 extension = $$('ProcessorExtension').$new(kind, processor); 15274 } else { 15275 self.$raise($$$('ArgumentError'), "Invalid arguments specified for registering " + (kind_name) + " extension: " + (args)); 15276 } } if ($eqeq(extension.$config()['$[]']("position"), ">>")) { 15277 15278 kind_store.$unshift(extension); 15279 } else { 15280 15281 kind_store['$<<'](extension); 15282 } return extension; 15283 }); 15284 15285 $def(self, '$add_syntax_processor', function $$add_syntax_processor(kind, args) { 15286 var block = $$add_syntax_processor.$$p || nil, $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; 15287 15288 $$add_syntax_processor.$$p = null; 15289 kind_name = kind.$to_s().$tr("_", " "); 15290 kind_class_symbol = $send(kind_name.$split(), 'map', [], function $$23(it){ 15291 15292 if (it == null) it = nil; 15293 return it.$capitalize();})['$<<']("Processor").$join().$to_sym(); 15294 kind_class = $$('Extensions').$const_get(kind_class_symbol, false); 15295 kind_java_class = ($truthy((($$$('::', 'AsciidoctorJ', 'skip_raise')) ? 'constant' : nil)) ? ($$$($$$('AsciidoctorJ'), 'Extensions').$const_get(kind_class_symbol, false)) : (nil)); 15296 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([], {})))); 15297 if ((block !== nil)) { 15298 15299 $c = self.$resolve_args(args, 2), $b = $to_ary($c), (name = ($b[0] == null ? nil : $b[0])), (config = ($b[1] == null ? nil : $b[1])); 15300 (processor = kind_class.$new(self.$as_symbol(name), config)).$singleton_class().$enable_dsl(); 15301 if ($eqeq(block.$arity(), 0)) { 15302 $send(processor, 'instance_exec', [], block.$to_proc()); 15303 } else { 15304 Opal.yield1(block, processor); 15305 } if (!$truthy((name = self.$as_symbol(processor.$name())))) { 15306 self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension at " + (block.$source_location().$join(":"))); 15307 } if (!$truthy(processor['$process_block_given?']())) { 15308 self.$raise($$$('NoMethodError'), "No block specified to process " + (kind_name) + " extension at " + (block.$source_location().$join(":"))); 15309 } processor.$freeze(); 15310 return ($b = [name, $$('ProcessorExtension').$new(kind, processor)], $send(kind_store, '[]=', $b), $b[$b.length - 1]); 15311 } else { 15312 15313 $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])); 15314 if ($truthy((processor_class = $$('Helpers').$resolve_class(processor)))) { 15315 15316 if (!($truthy($rb_lt(processor_class, kind_class)) || (($truthy(kind_java_class) && ($truthy($rb_lt(processor_class, kind_java_class))))))) { 15317 self.$raise($$$('ArgumentError'), "Class specified for " + (kind_name) + " extension does not inherit from " + (kind_class) + ": " + (processor)); 15318 } processor_instance = processor_class.$new(self.$as_symbol(name), config); 15319 if (!$truthy((name = self.$as_symbol(processor_instance.$name())))) { 15320 self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension: " + (processor)); 15321 } processor_instance.$freeze(); 15322 return ($b = [name, $$('ProcessorExtension').$new(kind, processor_instance)], $send(kind_store, '[]=', $b), $b[$b.length - 1]); 15323 } else if (($eqeqeq(kind_class, processor) || (($truthy(kind_java_class) && ($eqeqeq(kind_java_class, processor)))))) { 15324 15325 processor.$update_config(config); 15326 if (!$truthy((name = ($truthy(name) ? (($b = [self.$as_symbol(name)], $send(processor, 'name=', $b), $b[$b.length - 1])) : (self.$as_symbol(processor.$name())))))) { 15327 self.$raise($$$('ArgumentError'), "No name specified for " + (kind_name) + " extension: " + (processor)); 15328 } processor.$freeze(); 15329 return ($b = [name, $$('ProcessorExtension').$new(kind, processor)], $send(kind_store, '[]=', $b), $b[$b.length - 1]); 15330 } else { 15331 return self.$raise($$$('ArgumentError'), "Invalid arguments specified for registering " + (kind_name) + " extension: " + (args)) 15332 } } }); 15333 15334 $def(self, '$reset', function $$reset() { 15335 var self = this; 15336 15337 15338 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))))))); 15339 return (self.document = nil); 15340 }); 15341 15342 $def(self, '$resolve_args', function $$resolve_args(args, expect) { 15343 var opts = nil, missing = nil; 15344 15345 15346 opts = ($eqeqeq($$$('Hash'), args['$[]'](-1)) ? (args.$pop()) : ($hash2([], {}))); 15347 if ($eqeq(expect, 1)) { 15348 return opts 15349 } if ($truthy($rb_gt((missing = $rb_minus($rb_minus(expect, 1), args.$size())), 0))) { 15350 args = $rb_plus(args, $$$('Array').$new(missing)); 15351 } else if ($truthy($rb_lt(missing, 0))) { 15352 args.$pop(missing['$-@']()); 15353 } args['$<<'](opts); 15354 return args; 15355 }); 15356 return $def(self, '$as_symbol', function $$as_symbol(name) { 15357 15358 if ($truthy(name)) { 15359 return name.$to_sym() 15360 } else { 15361 return nil 15362 } 15363 }); 15364 })($nesting[0], null, $nesting); 15365 return (function(self, $parent_nesting) { 15366 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 15367 15368 15369 15370 $def(self, '$generate_name', function $$generate_name() { 15371 var self = this; 15372 15373 return "extgrp" + (self.$next_auto_id()) 15374 }); 15375 15376 $def(self, '$next_auto_id', function $$next_auto_id() { 15377 var self = this, $ret_or_1 = nil; 15378 if (self.auto_id == null) self.auto_id = nil; 15379 15380 15381 self.auto_id = ($truthy(($ret_or_1 = self.auto_id)) ? ($ret_or_1) : (-1)); 15382 return (self.auto_id = $rb_plus(self.auto_id, 1)); 15383 }); 15384 15385 $def(self, '$groups', function $$groups() { 15386 var self = this, $ret_or_1 = nil; 15387 if (self.groups == null) self.groups = nil; 15388 15389 return (self.groups = ($truthy(($ret_or_1 = self.groups)) ? ($ret_or_1) : ($hash2([], {})))) 15390 }); 15391 15392 $def(self, '$create', function $$create(name) { 15393 var block = $$create.$$p || nil, self = this, $ret_or_1 = nil; 15394 15395 $$create.$$p = null; 15396 if (name == null) name = nil; 15397 if ((block !== nil)) { 15398 return $$('Registry').$new($hash(($truthy(($ret_or_1 = name)) ? ($ret_or_1) : (self.$generate_name())), block)) 15399 } else { 15400 return $$('Registry').$new() 15401 } }, -1); 15402 15403 $def(self, '$register', function $$register($a) { 15404 var block = $$register.$$p || nil, $post_args, args, $b, self = this, argc = nil, resolved_group = nil, group = nil, $ret_or_1 = nil, name = nil; 15405 15406 $$register.$$p = null; 15407 $post_args = $slice(arguments); 15408 args = $post_args; 15409 argc = args.$size(); 15410 if ((block !== nil)) { 15411 resolved_group = block; 15412 } else if ($truthy((group = args.$pop()))) { 15413 resolved_group = ($truthy(($ret_or_1 = $$('Helpers').$resolve_class(group))) ? ($ret_or_1) : (group)); 15414 } else { 15415 self.$raise($$$('ArgumentError'), "Extension group to register not specified"); 15416 } name = ($truthy(($ret_or_1 = args.$pop())) ? ($ret_or_1) : (self.$generate_name())); 15417 if (!$truthy(args['$empty?']())) { 15418 self.$raise($$$('ArgumentError'), "Wrong number of arguments (" + (argc) + " for 1..2)"); 15419 } return ($b = [name.$to_sym(), resolved_group], $send(self.$groups(), '[]=', $b), $b[$b.length - 1]); 15420 }, -1); 15421 15422 $def(self, '$unregister_all', function $$unregister_all() { 15423 var self = this; 15424 15425 15426 self.groups = $hash2([], {}); 15427 return nil; 15428 }); 15429 return $def(self, '$unregister', function $$unregister($a) { 15430 var $post_args, names, self = this; 15431 15432 15433 $post_args = $slice(arguments); 15434 names = $post_args; 15435 $send(names, 'each_with_object', [self.$groups()], function $$24(group, catalog){ 15436 15437 if (group == null) group = nil; 15438 if (catalog == null) catalog = nil; 15439 return catalog.$delete(group.$to_sym());}); 15440 return nil; 15441 }, -1); 15442 })(Opal.get_singleton_class(self), $nesting); 15443 })($nesting[0], $nesting) 15444 })($nesting[0], $nesting); 15445}; 15446 15447Opal.modules["asciidoctor/js/asciidoctor_ext/stylesheet"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15448 var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; 15449 15450 Opal.add_stubs('rstrip,read,join'); 15451 return (function($base, $parent_nesting) { 15452 var self = $module($base, 'Asciidoctor'); 15453 15454 var $nesting = [self].concat($parent_nesting); 15455 15456 return (function($base, $super) { 15457 var self = $klass($base, $super, 'Stylesheets'); 15458 15459 var $proto = self.$$prototype; 15460 15461 $proto.primary_stylesheet_data = nil; 15462 return $def(self, '$primary_stylesheet_data', function $$primary_stylesheet_data() { 15463 var self = this, $ret_or_1 = nil; 15464 15465 return (self.primary_stylesheet_data = ($truthy(($ret_or_1 = self.primary_stylesheet_data)) ? ($ret_or_1) : ($$$('IO').$read($$$('File').$join("css", "asciidoctor.css")).$rstrip()))) 15466 }) 15467 })($nesting[0], null) 15468 })($nesting[0], $nesting) 15469}; 15470 15471Opal.modules["asciidoctor/js/asciidoctor_ext/document"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15472 var $module = Opal.module, $klass = Opal.klass, $def = Opal.def, $nesting = []; Opal.nil; 15473 15474 return (function($base, $parent_nesting) { 15475 var self = $module($base, 'Asciidoctor'); 15476 15477 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 15478 15479 return (function($base, $super) { 15480 var self = $klass($base, $super, 'Document'); 15481 15482 15483 return $def(self, '$fill_datetime_attributes', function $$fill_datetime_attributes(attrs, input_mtime) { 15484 15485 15486 var $truthy = Opal.truthy; 15487 var $falsy = Opal.falsy; 15488 var nil = Opal.nil; 15489 var utc_offset; 15490 var source_date_epoch; 15491 var localdate; 15492 var localyear; 15493 var localtime; 15494 var localdatetime; 15495 var docdate; 15496 var doctime; 15497 15498 var getYear = function (time, utc_offset) { 15499 return utc_offset === 0 ? time.getUTCFullYear() : time.getFullYear() 15500 }; 15501 var getMonth = function (time, utc_offset) { 15502 return utc_offset === 0 ? time.getUTCMonth() : time.getMonth() 15503 }; 15504 var getDay = function (time, utc_offset) { 15505 return utc_offset === 0 ? time.getUTCDate() : time.getDate() 15506 }; 15507 var getHours = function (time, utc_offset) { 15508 return utc_offset === 0 ? time.getUTCHours() : time.getHours() 15509 }; 15510 15511 var now = new Date(); 15512 // See https://reproducible-builds.org/specs/source-date-epoch/ 15513 if (Opal.const_get_qualified('::', 'ENV')['$key?']('SOURCE_DATE_EPOCH')) { 15514 now.setTime(parseInt(Opal.const_get_qualified('::', 'ENV')['$[]']('SOURCE_DATE_EPOCH')) * 1000); 15515 source_date_epoch = now; 15516 utc_offset = 0; // utc 15517 } else { 15518 utc_offset = -now.getTimezoneOffset() / 60; // local date 15519 } 15520 // localdate and localyear 15521 if ($truthy((localdate = attrs['$[]']('localdate')))) { 15522 if ($falsy(localyear = attrs['$[]']('localyear'))) { 15523 localyear = localdate.indexOf('-') === 4 ? localdate.substring(0, 4) : nil; 15524 attrs['$[]=']('localyear', localyear); 15525 } 15526 } else { 15527 var now_year = getYear(now, utc_offset).toString(); 15528 var now_month = ('0' + (getMonth(now, utc_offset) + 1)).slice(-2); 15529 var now_day = ('0' + getDay(now, utc_offset)).slice(-2); 15530 localdate = now_year + '-' + now_month + '-' + now_day; 15531 attrs['$[]=']('localdate', localdate); 15532 localyear = now_year; 15533 attrs['$[]=']('localyear', now_year); 15534 } 15535 // localtime 15536 if ($falsy((localtime = attrs['$[]']('localtime')))) { 15537 var hours = ('0' + (getHours(now, utc_offset))).slice(-2); 15538 var minutes = ('0' + (now.getMinutes())).slice(-2); 15539 var seconds = ('0' + (now.getSeconds())).slice(-2); 15540 var utc_offset_format; 15541 if (utc_offset === 0) { 15542 utc_offset_format = 'UTC'; 15543 } else if (utc_offset > 0) { 15544 utc_offset_format = ('+0' + (utc_offset * 100)).slice(-5); 15545 } else { 15546 utc_offset_format = ('-0' + (-utc_offset * 100)).slice(-5); 15547 } 15548 localtime = hours + ':' + minutes + ':' + seconds + ' ' + utc_offset_format; 15549 attrs['$[]=']('localtime', localtime); 15550 } 15551 // localdatetime 15552 if ($falsy((localdatetime = attrs['$[]']('localdatetime')))) { 15553 localdatetime = localdate + ' ' + localtime; 15554 attrs['$[]=']('localdatetime', localdatetime); 15555 } 15556 15557 // docdate, doctime and docdatetime should default to localdate, localtime and localdatetime if not otherwise set 15558 if ($truthy(source_date_epoch)) { 15559 input_mtime = source_date_epoch; 15560 } else if ($truthy(input_mtime)) { 15561 utc_offset = -input_mtime.getTimezoneOffset() / 60; 15562 } else { 15563 input_mtime = now; 15564 } 15565 15566 // docdate and docyear 15567 if ($truthy(docdate = attrs['$[]']('docdate'))) { 15568 attrs['$[]=']('docyear', docdate.indexOf('-') === 4 ? docdate.substring(0, 4) : nil); 15569 } else { 15570 var mtime_year = getYear(input_mtime, utc_offset).toString(); 15571 var mtime_month = ('0' + (getMonth(input_mtime, utc_offset) + 1)).slice(-2); 15572 var mtime_day = ('0' + (getDay(input_mtime, utc_offset))).slice(-2); 15573 docdate = mtime_year + '-' + mtime_month + '-' + mtime_day; 15574 attrs['$[]=']('docdate', docdate); 15575 if ($falsy(attrs['$[]']('docyear'))) { 15576 attrs['$[]=']('docyear', mtime_year); 15577 } 15578 } 15579 // doctime 15580 if ($falsy(doctime = attrs['$[]']('doctime'))) { 15581 var mtime_hours = ('0' + (getHours(input_mtime, utc_offset))).slice(-2); 15582 var mtime_minutes = ('0' + (input_mtime.getMinutes())).slice(-2); 15583 var mtime_seconds = ('0' + (input_mtime.getSeconds())).slice(-2); 15584 var utc_offset_format; 15585 if (utc_offset === 0) { 15586 utc_offset_format = 'UTC'; 15587 } else if (utc_offset > 0) { 15588 utc_offset_format = ('+0' + (utc_offset * 100)).slice(-5); 15589 } else { 15590 utc_offset_format = ('-0' + (-utc_offset * 100)).slice(-5); 15591 } 15592 doctime = mtime_hours + ':' + mtime_minutes + ':' + mtime_seconds + ' ' + utc_offset_format; 15593 attrs['$[]=']('doctime', doctime); 15594 } 15595 // docdatetime 15596 if ($falsy(attrs['$[]']('docdatetime'))) { 15597 attrs['$[]=']('docdatetime', docdate + ' ' + doctime); 15598 } 15599 return nil 15600 15601 }) 15602 })($nesting[0], $$('AbstractBlock')) 15603 })($nesting[0], $nesting) 15604}; 15605 15606Opal.modules["asciidoctor/js/asciidoctor_ext/substitutors"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15607 var $module = Opal.module, $def = Opal.def, $nesting = []; Opal.nil; 15608 15609 return (function($base, $parent_nesting) { 15610 var self = $module($base, 'Asciidoctor'); 15611 15612 var $nesting = [self].concat($parent_nesting); 15613 15614 return (function($base) { 15615 var self = $module($base, 'Substitutors'); 15616 15617 15618 return $def(self, '$sub_placeholder', function $$sub_placeholder(format_string, replacement) { 15619 15620 return format_string.replace('%s', replacement); 15621 }) 15622 })($nesting[0]) 15623 })($nesting[0], $nesting) 15624}; 15625 15626Opal.modules["asciidoctor/js/asciidoctor_ext/parser"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15627 var $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $defs = Opal.defs, $nesting = []; Opal.nil; 15628 15629 return (function($base, $parent_nesting) { 15630 var self = $module($base, 'Asciidoctor'); 15631 15632 var $nesting = [self].concat($parent_nesting); 15633 15634 return (function($base, $super) { 15635 var self = $klass($base, $super, 'Parser'); 15636 15637 15638 if ($truthy(String.prototype.repeat)) { 15639 return $defs(self, '$uniform?', function $Parser_uniform$ques$1(str, chr, len) { 15640 15641 return chr.repeat(len) === str; 15642 }) 15643 } else { 15644 return $defs(self, '$uniform?', function $Parser_uniform$ques$2(str, chr, len) { 15645 15646 return Array.apply(null, { length: len }).map(function () { return chr }).join('') === str; 15647 }) 15648 } 15649 })($nesting[0], null) 15650 })($nesting[0], $nesting) 15651}; 15652 15653Opal.modules["asciidoctor/js/asciidoctor_ext/syntax_highlighter"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15654 var $module = Opal.module, $truthy = Opal.truthy, $def = Opal.def, $nesting = [], nil = Opal.nil; 15655 15656 Opal.add_stubs('key?,registry,[],include?,include,empty?,debug,logger,join,keys'); 15657 return (function($base, $parent_nesting) { 15658 var self = $module($base, 'Asciidoctor'); 15659 15660 var $nesting = [self].concat($parent_nesting); 15661 15662 return (function($base, $parent_nesting) { 15663 var self = $module($base, 'SyntaxHighlighter'); 15664 15665 var $nesting = [self].concat($parent_nesting); 15666 15667 return (function($base, $parent_nesting) { 15668 var self = $module($base, 'Factory'); 15669 15670 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); 15671 15672 return $def(self, '$for', function $Factory_for$1(name) { 15673 var self = this; 15674 15675 if ($truthy(self.$registry()['$key?'](name))) { 15676 return self.$registry()['$[]'](name) 15677 } else { 15678 15679 if (!$truthy(self['$include?']($$('Logging')))) { 15680 self.$include($$('Logging')); 15681 } if ($truthy(self.$registry()['$empty?']())) { 15682 self.$logger().$debug("no syntax highlighter available, functionality disabled."); 15683 } else { 15684 self.$logger().$debug("syntax highlighter named '" + (name) + "' is not available, must be one of: '" + (self.$registry().$keys().$join("', '")) + "'."); 15685 } return nil; 15686 } 15687 }) 15688 })($nesting[0], $nesting) 15689 })($nesting[0], $nesting) 15690 })($nesting[0], $nesting) 15691}; 15692 15693Opal.modules["asciidoctor/js/asciidoctor_ext"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15694 var self = Opal.top; Opal.nil; 15695 15696 Opal.add_stubs('require'); 15697 15698 self.$require("asciidoctor/js/asciidoctor_ext/stylesheet"); 15699 self.$require("asciidoctor/js/asciidoctor_ext/document"); 15700 self.$require("asciidoctor/js/asciidoctor_ext/substitutors"); 15701 self.$require("asciidoctor/js/asciidoctor_ext/parser"); 15702 self.$require("asciidoctor/js/asciidoctor_ext/syntax_highlighter"); 15703 15704// Load specific runtime 15705self.$require("asciidoctor/js/asciidoctor_ext/node"); 15706}; 15707 15708Opal.modules["asciidoctor/js/opal_ext/logger"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15709 var $klass = Opal.klass, $def = Opal.def, $truthy = Opal.truthy, $rb_lt = Opal.rb_lt, $nesting = [], nil = Opal.nil; 15710 15711 Opal.add_stubs('chr,rjust,message_as_string,<,write,call,[]'); 15712 return (function($base, $super, $parent_nesting) { 15713 var self = $klass($base, $super, 'Logger'); 15714 15715 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; 15716 15717 $proto.level = $proto.progname = $proto.pipe = $proto.formatter = nil; 15718 15719 (function($base, $super) { 15720 var self = $klass($base, $super, 'Formatter'); 15721 15722 15723 return $def(self, '$call', function $$call(severity, time, progname, msg) { 15724 var self = this, time_format = nil; 15725 15726 15727 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); 15728 return "" + (severity.$chr()) + ", [" + (time_format) + "] " + (severity.$rjust(5)) + " -- " + (progname) + ": " + (self.$message_as_string(msg)); 15729 }) 15730 })($nesting[0], null); 15731 return $def(self, '$add', function $$add(severity, message, progname) { 15732 var block = $$add.$$p || nil, self = this, $ret_or_1 = nil; 15733 15734 $$add.$$p = null; 15735 if (message == null) message = nil; 15736 if (progname == null) progname = nil; 15737 if ($truthy($rb_lt((severity = ($truthy(($ret_or_1 = severity)) ? ($ret_or_1) : ($$('UNKNOWN')))), self.level))) { 15738 return true 15739 } progname = ($truthy(($ret_or_1 = progname)) ? ($ret_or_1) : (self.progname)); 15740 if (!$truthy(message)) { 15741 if ((block !== nil)) { 15742 message = Opal.yieldX(block, []); 15743 } else { 15744 15745 message = progname; 15746 progname = self.progname; 15747 } 15748 } self.pipe.$write(self.formatter.$call(($truthy(($ret_or_1 = $$('SEVERITY_LABELS')['$[]'](severity))) ? ($ret_or_1) : ("ANY")), new Date(), progname, message)); 15749 return true; 15750 }, -2); 15751 })($nesting[0], null, $nesting) 15752}; 15753 15754Opal.modules["asciidoctor/js/postscript"] = function(Opal) {/* Generated by Opal 1.7.3 */ 15755 var self = Opal.top; Opal.nil; 15756 15757 Opal.add_stubs('require'); 15758 15759 self.$require("asciidoctor/converter/composite"); 15760 self.$require("asciidoctor/converter/html5"); 15761 self.$require("asciidoctor/extensions"); 15762 self.$require("asciidoctor/js/asciidoctor_ext"); 15763 return self.$require("asciidoctor/js/opal_ext/logger"); 15764}; 15765 15766Opal.queue(function(Opal) {/* Generated by Opal 1.7.3 */ 15767 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.$$$; 15768 15769 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'); 15770 15771 self.$require("set"); 15772 self.$require("asciidoctor/js"); 15773 (function($base, $parent_nesting) { 15774 var self = $module($base, 'Asciidoctor'); 15775 15776 var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $ret_or_1 = nil; 15777 15778 15779 $const_set($nesting[0], 'RUBY_ENGINE_OPAL', $const_set($nesting[0], 'RUBY_ENGINE', $$$('RUBY_ENGINE'))['$==']("opal")); 15780 (function($base, $parent_nesting) { 15781 var self = $module($base, 'SafeMode'); 15782 15783 var $nesting = [self].concat($parent_nesting); 15784 15785 15786 $const_set($nesting[0], 'UNSAFE', 0); 15787 $const_set($nesting[0], 'SAFE', 1); 15788 $const_set($nesting[0], 'SERVER', 10); 15789 $const_set($nesting[0], 'SECURE', 20); 15790 self.names_by_value = $send($send(self.$constants(false), 'map', [], function $SafeMode$1(sym){var self = $SafeMode$1.$$s == null ? this : $SafeMode$1.$$s; 15791 15792 15793 if (sym == null) sym = nil; 15794 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; 15795 15796 15797 if ($mlhs_tmp1 == null) $mlhs_tmp1 = nil; 15798 if ($mlhs_tmp2 == null) $mlhs_tmp2 = nil; 15799 $b = $mlhs_tmp1, $a = $to_ary($b), (a = ($a[0] == null ? nil : $a[0])); 15800 $b = $mlhs_tmp2, $a = $to_ary($b), (b = ($a[0] == null ? nil : $a[0])); 15801 return a['$<=>'](b);}, {$$has_top_level_mlhs_arg: true}).$to_h(); 15802 $defs(self, '$value_for_name', function $$value_for_name(name) { 15803 var self = this; 15804 15805 return self.$const_get(name.$upcase(), false) 15806 }); 15807 $defs(self, '$name_for_value', function $$name_for_value(value) { 15808 var self = this; 15809 if (self.names_by_value == null) self.names_by_value = nil; 15810 15811 return self.names_by_value['$[]'](value) 15812 }); 15813 return $defs(self, '$names', function $$names() { 15814 var self = this; 15815 if (self.names_by_value == null) self.names_by_value = nil; 15816 15817 return self.names_by_value.$values() 15818 }); 15819 })($nesting[0], $nesting); 15820 (function($base, $parent_nesting) { 15821 var self = $module($base, 'Compliance'); 15822 15823 15824 self.keys = $$$('Set').$new(); 15825 (function(self, $parent_nesting) { 15826 15827 15828 self.$attr_reader("keys"); 15829 return $def(self, '$define', function $$define(key, value) { 15830 var self = this; 15831 if (self.keys == null) self.keys = nil; 15832 15833 15834 self.$instance_variable_set("@" + (key), value); 15835 self.$singleton_class().$send("attr_accessor", key); 15836 self.keys['$<<'](key); 15837 return nil; 15838 }); 15839 })(Opal.get_singleton_class(self)); 15840 self.$define("block_terminates_paragraph", true); 15841 self.$define("strict_verbatim_paragraphs", true); 15842 self.$define("underline_style_section_titles", true); 15843 self.$define("unwrap_standalone_preamble", true); 15844 self.$define("attribute_missing", "skip"); 15845 self.$define("attribute_undefined", "drop-line"); 15846 self.$define("shorthand_property_syntax", true); 15847 self.$define("natural_xrefs", true); 15848 self.$define("unique_id_start_index", 2); 15849 return self.$define("markdown_syntax", true); 15850 })($nesting[0]); 15851 if (!$truthy((($$('ROOT_DIR', 'skip_raise')) ? 'constant' : nil))) { 15852 $const_set($nesting[0], 'ROOT_DIR', $$$('File').$dirname($$$('File').$absolute_path("."))); 15853 } $const_set($nesting[0], 'LIB_DIR', $$$('File').$join($$('ROOT_DIR'), "lib")); 15854 $const_set($nesting[0], 'DATA_DIR', $$$('File').$join($$('ROOT_DIR'), "data")); 15855 $const_set($nesting[0], 'USER_HOME', (function() { try { 15856 return $$$('Dir').$home() 15857 } catch ($err) { 15858 if (Opal.rescue($err, [$$('StandardError')])) { 15859 try { 15860 15861 if ($truthy(($ret_or_1 = $$$('ENV')['$[]']("HOME")))) { 15862 return $ret_or_1 15863 } else { 15864 return $$$('Dir').$pwd() 15865 }; 15866 } finally { Opal.pop_exception(); } 15867 } else { throw $err; } 15868 }})()); 15869 $const_set($nesting[0], 'LF', "\n"); 15870 $const_set($nesting[0], 'NULL', "\x00"); 15871 $const_set($nesting[0], 'TAB', "\t"); 15872 $const_set($nesting[0], 'MAX_INT', 9007199254740991); 15873 $const_set($nesting[0], 'UTF_8', $$$($$$('Encoding'), 'UTF_8')); 15874 $const_set($nesting[0], 'BOM_BYTES_UTF_8', [239, 187, 191]); 15875 $const_set($nesting[0], 'BOM_BYTES_UTF_16LE', [255, 254]); 15876 $const_set($nesting[0], 'BOM_BYTES_UTF_16BE', [254, 255]); 15877 $const_set($nesting[0], 'FILE_READ_MODE', ($truthy($$('RUBY_ENGINE_OPAL')) ? ("r") : ("rb:utf-8:utf-8"))); 15878 $const_set($nesting[0], 'URI_READ_MODE', $$('FILE_READ_MODE')); 15879 $const_set($nesting[0], 'FILE_WRITE_MODE', ($truthy($$('RUBY_ENGINE_OPAL')) ? ("w") : ("w:utf-8"))); 15880 $const_set($nesting[0], 'DEFAULT_DOCTYPE', "article"); 15881 $const_set($nesting[0], 'DEFAULT_BACKEND', "html5"); 15882 $const_set($nesting[0], 'DEFAULT_STYLESHEET_KEYS', ["", "DEFAULT"].$to_set()); 15883 $const_set($nesting[0], 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css"); 15884 $const_set($nesting[0], 'BACKEND_ALIASES', $hash2(["html", "docbook"], {"html": "html5", "docbook": "docbook5"})); 15885 $const_set($nesting[0], 'DEFAULT_PAGE_WIDTHS', $hash2(["docbook"], {"docbook": 425})); 15886 $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"})); 15887 $const_set($nesting[0], 'ASCIIDOC_EXTENSIONS', $hash2([".adoc", ".asciidoc", ".asc", ".ad", ".txt"], {".adoc": true, ".asciidoc": true, ".asc": true, ".ad": true, ".txt": true})); 15888 $const_set($nesting[0], 'SETEXT_SECTION_LEVELS', $hash2(["=", "-", "~", "^", "+"], {"=": 0, "-": 1, "~": 2, "^": 3, "+": 4})); 15889 $const_set($nesting[0], 'ADMONITION_STYLES', ["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"].$to_set()); 15890 $const_set($nesting[0], 'ADMONITION_STYLE_HEADS', $send($$$('Set').$new(), 'tap', [], function $Asciidoctor$3(accum){ 15891 15892 if (accum == null) accum = nil; 15893 return $send($$('ADMONITION_STYLES'), 'each', [], function $$4(s){ 15894 15895 if (s == null) s = nil; 15896 return accum['$<<'](s.$chr());});})); 15897 $const_set($nesting[0], 'PARAGRAPH_STYLES', ["comment", "example", "literal", "listing", "normal", "open", "pass", "quote", "sidebar", "source", "verse", "abstract", "partintro"].$to_set()); 15898 $const_set($nesting[0], 'VERBATIM_STYLES', ["literal", "listing", "source", "verse"].$to_set()); 15899 $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()]})); 15900 $const_set($nesting[0], 'DELIMITED_BLOCK_HEADS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$5(accum){ 15901 15902 if (accum == null) accum = nil; 15903 return $send($$('DELIMITED_BLOCKS'), 'each_key', [], function $$6(k){var $b; 15904 15905 15906 if (k == null) k = nil; 15907 return ($b = [k.$slice(0, 2), true], $send(accum, '[]=', $b), $b[$b.length - 1]);});})); 15908 $const_set($nesting[0], 'DELIMITED_BLOCK_TAILS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$7(accum){ 15909 15910 if (accum == null) accum = nil; 15911 return $send($$('DELIMITED_BLOCKS'), 'each_key', [], function $$8(k){var $b; 15912 15913 15914 if (k == null) k = nil; 15915 if ($eqeq(k.$length(), 4)) { 15916 return ($b = [k, k['$[]']($rb_minus(k.$length(), 1))], $send(accum, '[]=', $b), $b[$b.length - 1]) 15917 } else { 15918 return nil 15919 }});})); 15920 $const_set($nesting[0], 'CAPTION_ATTRIBUTE_NAMES', $hash2(["example", "figure", "listing", "table"], {"example": "example-caption", "figure": "figure-caption", "listing": "listing-caption", "table": "table-caption"})); 15921 $const_set($nesting[0], 'LAYOUT_BREAK_CHARS', $hash2(["'", "<"], {"'": "thematic_break", "<": "page_break"})); 15922 $const_set($nesting[0], 'MARKDOWN_THEMATIC_BREAK_CHARS', $hash2(["-", "*", "_"], {"-": "thematic_break", "*": "thematic_break", "_": "thematic_break"})); 15923 $const_set($nesting[0], 'HYBRID_LAYOUT_BREAK_CHARS', $$('LAYOUT_BREAK_CHARS').$merge($$('MARKDOWN_THEMATIC_BREAK_CHARS'))); 15924 $const_set($nesting[0], 'NESTABLE_LIST_CONTEXTS', ["ulist", "olist", "dlist"]); 15925 $const_set($nesting[0], 'ORDERED_LIST_STYLES', ["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"]); 15926 $const_set($nesting[0], 'ORDERED_LIST_KEYWORDS', $hash2(["loweralpha", "lowerroman", "upperalpha", "upperroman"], {"loweralpha": "a", "lowerroman": "i", "upperalpha": "A", "upperroman": "I"})); 15927 $const_set($nesting[0], 'ATTR_REF_HEAD', "{"); 15928 $const_set($nesting[0], 'LIST_CONTINUATION', "+"); 15929 $const_set($nesting[0], 'HARD_LINE_BREAK', " +"); 15930 $const_set($nesting[0], 'LINE_CONTINUATION', " \\"); 15931 $const_set($nesting[0], 'LINE_CONTINUATION_LEGACY', " +"); 15932 $const_set($nesting[0], 'BLOCK_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\[", "\\]"]})); 15933 $const_set($nesting[0], 'INLINE_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\(", "\\)"]})); 15934 $const_set($nesting[0], 'STEM_TYPE_ALIASES', $hash2(["latexmath", "latex", "tex"], {"latexmath": "latexmath", "latex": "latexmath", "tex": "latexmath"}))['$default=']("asciimath"); 15935 $const_set($nesting[0], 'FONT_AWESOME_VERSION', "4.7.0"); 15936 $const_set($nesting[0], 'HIGHLIGHT_JS_VERSION', "9.18.3"); 15937 $const_set($nesting[0], 'MATHJAX_VERSION', "2.7.9"); 15938 $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"})); 15939 $const_set($nesting[0], 'FLEXIBLE_ATTRIBUTES', ["sectnums"]); 15940 $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": "+", "backslash": "\\", "backtick": "`", "blank": "", "empty": "", "sp": " ", "two-colons": "::", "two-semicolons": ";;", "nbsp": " ", "deg": "°", "zwsp": "​", "quot": """, "apos": "'", "lsquo": "‘", "rsquo": "’", "ldquo": "“", "rdquo": "”", "wj": "⁠", "brvbar": "¦", "pp": "++", "cpp": "C++", "amp": "&", "lt": "<", "gt": ">"})); 15941 $const_set($nesting[0], 'QUOTE_SUBS', $send($hash2([], {}), 'tap', [], function $Asciidoctor$9(accum){var normal = nil, compat = nil; 15942 15943 15944 if (accum == null) accum = nil; 15945 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+?)~/]])); 15946 accum['$[]='](true, (compat = normal.$drop(0))); 15947 compat['$[]='](2, ["double", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?``(\\S|\\S", $$('CC_ALL'), "*?\\S)''(?!", $$('CG_WORD'), ")"], 'm')]); 15948 compat['$[]='](3, ["single", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?`(\\S|\\S", $$('CC_ALL'), "*?\\S)'(?!", $$('CG_WORD'), ")"], 'm')]); 15949 compat['$[]='](4, ["monospaced", "unconstrained", $regexp(["\\\\?(?:\\[([^\\]]+)\\])?\\+\\+(", $$('CC_ALL'), "+?)\\+\\+"], 'm')]); 15950 compat['$[]='](5, ["monospaced", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?\\+(\\S|\\S", $$('CC_ALL'), "*?\\S)\\+(?!", $$('CG_WORD'), ")"], 'm')]); 15951 return compat.$insert(3, ["emphasis", "constrained", $regexp(["(^|[^", $$('CC_WORD'), ";:}])(?:\\[([^\\]]+)\\])?'(\\S|\\S", $$('CC_ALL'), "*?\\S)'(?!", $$('CG_WORD'), ")"], 'm')]);})); 15952 $const_set($nesting[0], 'REPLACEMENTS', [[/\\?\(C\)/, "©", "none"], [/\\?\(R\)/, "®", "none"], [/\\?\(TM\)/, "™", "none"], [/(?: |\n|^|\\)--(?: |\n|$)/, " — ", "none"], [$regexp(["(", $$('CG_WORD'), ")\\\\?--(?=", $$('CG_WORD'), ")"]), "—​", "leading"], [/\\?\.\.\./, "…​", "none"], [/\\?`'/, "’", "none"], [$regexp(["(", $$('CG_ALNUM'), ")\\\\?'(?=", $$('CG_ALPHA'), ")"]), "’", "leading"], [/\\?->/, "→", "none"], [/\\?=>/, "⇒", "none"], [/\\?<-/, "←", "none"], [/\\?<=/, "⇐", "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"]]); 15953 return nil; 15954 })($nesting[0], $nesting); 15955 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/core_ext"); 15956 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/helpers"); 15957 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/logging"); 15958 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/rx"); 15959 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/substitutors"); 15960 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/version"); 15961 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/abstract_node"); 15962 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/abstract_block"); 15963 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/attribute_list"); 15964 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/block"); 15965 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/callouts"); 15966 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/converter"); 15967 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/document"); 15968 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/inline"); 15969 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/list"); 15970 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/parser"); 15971 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/path_resolver"); 15972 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/reader"); 15973 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/section"); 15974 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/stylesheets"); 15975 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/table"); 15976 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/writer"); 15977 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/load"); 15978 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/convert"); 15979 15980 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/syntax_highlighter"); 15981 self.$require("asciidoctor.rb"+ '/../' + "asciidoctor/timings"); 15982 return self.$require("asciidoctor/js/postscript");}); 15983 15984 15985/* global Opal */ 15986 15987/** 15988 * Convert a JSON to an (Opal) Hash. 15989 * @private 15990 */ 15991const toHash = function (object) { 15992 return object && !object.$$is_hash ? Opal.hash2(Object.keys(object), object) : object 15993}; 15994 15995/** 15996 * Convert an (Opal) Hash to JSON. 15997 * @private 15998 */ 15999const fromHash = function (hash) { 16000 const object = {}; 16001 if (hash) { 16002 const stringMap = hash.$$smap; 16003 for (const key in stringMap) { 16004 const value = stringMap[key]; 16005 object[key] = value === Opal.nil ? undefined : value; 16006 } 16007 const numericMap = hash.$$map; 16008 if (numericMap) { 16009 const positional = []; 16010 for (const key in numericMap) { 16011 const entry = numericMap[key]; 16012 const value = entry.value; 16013 const index = entry.key - 1; 16014 positional[index] = value === Opal.nil ? undefined : value; 16015 } 16016 if (positional.length > 0) { 16017 object.$positional = positional; 16018 } 16019 } 16020 } 16021 return object 16022}; 16023 16024const fromHashKeys = function (hash) { 16025 const object = {}; 16026 if (hash) { 16027 const data = hash.$$keys; 16028 for (const key in data) { 16029 const value = data[key].value; 16030 object[key.toString()] = value === Opal.nil ? undefined : value; 16031 } 16032 } 16033 return object 16034}; 16035 16036/** 16037 * @private 16038 */ 16039const prepareOptions = function (options) { 16040 options = toHash(options); 16041 if (options) { 16042 const converter = options['$[]']('converter'); 16043 if (converter && converter !== Opal.nil) { 16044 options['$[]=']('converter', bridgeConverter(converter)); 16045 } 16046 const attrs = options['$[]']('attributes'); 16047 if (attrs && typeof attrs === 'object' && attrs.constructor.name === 'Object') { 16048 options = options.$dup(); 16049 options['$[]=']('attributes', toHash(attrs)); 16050 } 16051 } 16052 return options 16053}; 16054 16055const bridgeConverter = function (converter) { 16056 const buildBackendTraitsFromObject = function (obj) { 16057 return Object.assign({}, 16058 obj.basebackend ? { basebackend: obj.basebackend } : {}, 16059 obj.outfilesuffix ? { outfilesuffix: obj.outfilesuffix } : {}, 16060 obj.filetype ? { filetype: obj.filetype } : {}, 16061 obj.htmlsyntax ? { htmlsyntax: obj.htmlsyntax } : {}, 16062 obj.supports_templates ? { supports_templates: obj.supports_templates } : {} 16063 ) 16064 }; 16065 const assignBackendTraitsToInstance = function (obj, instance) { 16066 if (obj.backend_traits) { 16067 instance.backend_traits = toHash(obj.backend_traits); 16068 } else if (obj.backendTraits) { 16069 instance.backend_traits = toHash(obj.backendTraits); 16070 } else if (obj.basebackend || obj.outfilesuffix || obj.filetype || obj.htmlsyntax || obj.supports_templates) { 16071 instance.backend_traits = toHash(buildBackendTraitsFromObject(obj)); 16072 } 16073 }; 16074 const bridgeHandlesMethodToInstance = function (obj, instance) { 16075 bridgeMethodToInstance(obj, instance, '$handles?', 'handles', function () { 16076 return true 16077 }); 16078 }; 16079 const bridgeComposedMethodToInstance = function (obj, instance) { 16080 bridgeMethodToInstance(obj, instance, '$composed', 'composed'); 16081 }; 16082 const bridgeEqEqMethodToInstance = function (obj, instance) { 16083 bridgeMethodToInstance(obj, instance, '$==', '==', function (other) { 16084 return instance === other 16085 }); 16086 }; 16087 const bridgeSendMethodToInstance = function (obj, instance) { 16088 bridgeMethodToInstance(obj, instance, '$send', 'send', function (symbol) { 16089 const [, ...args] = Array.from(arguments); 16090 const func = instance['$' + symbol]; 16091 if (func) { 16092 return func.apply(instance, args) 16093 } 16094 throw new Error(`undefined method \`${symbol}\` for \`${instance.toString()}\``) 16095 }); 16096 }; 16097 const bridgeMethodToInstance = function (obj, instance, methodName, functionName, defaultImplementation) { 16098 if (typeof obj[methodName] === 'undefined') { 16099 if (typeof obj[functionName] === 'function') { 16100 instance[methodName] = obj[functionName]; 16101 } else if (defaultImplementation) { 16102 instance[methodName] = defaultImplementation; 16103 } 16104 } 16105 }; 16106 const addRespondToMethod = function (instance) { 16107 if (typeof instance['$respond_to?'] !== 'function') { 16108 instance['$respond_to?'] = function (name) { 16109 return typeof this[name] === 'function' 16110 }; 16111 } 16112 }; 16113 if (typeof converter === 'function') { 16114 // Class 16115 const object = initializeClass(ConverterBase, converter.constructor.name, { 16116 initialize: function (backend, opts) { 16117 const self = this; 16118 const result = new converter(backend, opts); // eslint-disable-line 16119 Object.assign(this, result); 16120 assignBackendTraitsToInstance(result, self); 16121 const propertyNames = Object.getOwnPropertyNames(converter.prototype); 16122 for (let i = 0; i < propertyNames.length; i++) { 16123 const propertyName = propertyNames[i]; 16124 if (propertyName !== 'constructor') { 16125 self[propertyName] = result[propertyName]; 16126 } 16127 } 16128 if (typeof result.$convert === 'undefined' && typeof result.convert === 'function') { 16129 self.$convert = result.convert; 16130 } 16131 bridgeHandlesMethodToInstance(result, self); 16132 bridgeComposedMethodToInstance(result, self); 16133 addRespondToMethod(self); 16134 self.super(backend, opts); 16135 } 16136 }); 16137 object.$extend(ConverterBackendTraits); 16138 return object 16139 } 16140 if (typeof converter === 'object') { 16141 // Instance 16142 if (typeof converter.$convert === 'undefined' && typeof converter.convert === 'function') { 16143 converter.$convert = converter.convert; 16144 } 16145 assignBackendTraitsToInstance(converter, converter); 16146 if (converter.backend_traits) { 16147 // "extends" ConverterBackendTraits 16148 const converterBackendTraitsFunctionNames = [ 16149 'basebackend', 16150 'filetype', 16151 'htmlsyntax', 16152 'outfilesuffix', 16153 'supports_templates', 16154 'supports_templates?', 16155 'init_backend_traits', 16156 'backend_traits' 16157 ]; 16158 for (const functionName of converterBackendTraitsFunctionNames) { 16159 converter['$' + functionName] = ConverterBackendTraits.prototype['$' + functionName]; 16160 } 16161 converter.$$meta = ConverterBackendTraits; 16162 } 16163 bridgeHandlesMethodToInstance(converter, converter); 16164 bridgeComposedMethodToInstance(converter, converter); 16165 bridgeEqEqMethodToInstance(converter, converter); 16166 bridgeSendMethodToInstance(converter, converter); 16167 addRespondToMethod(converter); 16168 return converter 16169 } 16170 return converter 16171}; 16172 16173function initializeClass (superClass, className, functions, defaultFunctions, argProxyFunctions) { 16174 const scope = Opal.klass(Opal.Object, superClass, className, function () { }); 16175 let postConstructFunction; 16176 let initializeFunction; 16177 let constructorFunction; 16178 const defaultFunctionsOverridden = {}; 16179 for (const functionName in functions) { 16180 if (Object.prototype.hasOwnProperty.call(functions, functionName)) { 16181 (function (functionName) { 16182 const userFunction = functions[functionName]; 16183 if (functionName === 'postConstruct') { 16184 postConstructFunction = userFunction; 16185 } else if (functionName === 'initialize') { 16186 initializeFunction = userFunction; 16187 } else if (functionName === 'constructor') { 16188 constructorFunction = userFunction; 16189 } else { 16190 if (defaultFunctions && Object.prototype.hasOwnProperty.call(defaultFunctions, functionName)) { 16191 defaultFunctionsOverridden[functionName] = true; 16192 } 16193 let $function; 16194 Opal.def(scope, '$' + functionName, ($function = function () { 16195 let args; 16196 if (argProxyFunctions && Object.prototype.hasOwnProperty.call(argProxyFunctions, functionName)) { 16197 args = argProxyFunctions[functionName](arguments); 16198 } else { 16199 args = arguments; 16200 } 16201 // append Ruby block as the final argument 16202 const $block = $function.$$p; 16203 if ($block) { 16204 args[args.length] = function () { return Opal.yield1($block) }; 16205 args.length += 1; 16206 $function.$$p = null; 16207 } 16208 return userFunction.apply(this, args) 16209 })); 16210 } 16211 }(functionName)); 16212 } 16213 } 16214 let initialize; 16215 if (typeof constructorFunction === 'function') { 16216 initialize = function () { 16217 const args = Array.from(arguments); 16218 for (let i = 0; i < args.length; i++) { 16219 // convert all (Opal) Hash arguments to JSON. 16220 if (typeof args[i] === 'object' && '$$smap' in args[i]) { 16221 args[i] = fromHash(args[i]); 16222 } 16223 } 16224 args.unshift(null); 16225 const result = new (Function.prototype.bind.apply(constructorFunction, args)); // eslint-disable-line 16226 Object.assign(this, result); 16227 if (typeof postConstructFunction === 'function') { 16228 postConstructFunction.bind(this)(); 16229 } 16230 }; 16231 } else if (typeof initializeFunction === 'function') { 16232 initialize = function () { 16233 const args = Array.from(arguments); 16234 for (let i = 0; i < args.length; i++) { 16235 // convert all (Opal) Hash arguments to JSON. 16236 if (typeof args[i] === 'object' && '$$smap' in args[i]) { 16237 args[i] = fromHash(args[i]); 16238 } 16239 } 16240 initializeFunction.apply(this, args); 16241 if (typeof postConstructFunction === 'function') { 16242 postConstructFunction.bind(this)(); 16243 } 16244 }; 16245 } else { 16246 initialize = function () { 16247 Opal.send(this, Opal.find_super_dispatcher(this, 'initialize', initialize)); 16248 if (typeof postConstructFunction === 'function') { 16249 postConstructFunction.bind(this)(); 16250 } 16251 }; 16252 } 16253 Opal.def(scope, '$initialize', initialize); 16254 let $superFunction; 16255 Opal.def(scope, 'super', ($superFunction = function (func) { 16256 if (typeof func === 'function') { 16257 Opal.send(this, Opal.find_super_dispatcher(this, func.name, func)); 16258 } else { 16259 // Bind the initialize function to super(); 16260 const argumentsList = Array.from(arguments); 16261 for (let i = 0; i < argumentsList.length; i++) { 16262 // convert all (Opal) Hash arguments to JSON. 16263 if (typeof argumentsList[i] === 'object') { 16264 argumentsList[i] = toHash(argumentsList[i]); 16265 } 16266 } 16267 Opal.send(this, Opal.find_super_dispatcher(this, 'initialize', initialize), argumentsList); 16268 } 16269 })); 16270 for (const functionName in functions) { 16271 $superFunction[functionName] = function () { 16272 const argumentsList = Array.from(arguments); 16273 for (let i = 0; i < argumentsList.length; i++) { 16274 // convert all (Opal) Hash arguments to JSON. 16275 if (typeof argumentsList[i] === 'object' && typeof argumentsList[i].constructor === 'function' && argumentsList[i].constructor.name === 'Object') { 16276 argumentsList[i] = toHash(argumentsList[i]); 16277 } 16278 } 16279 const self = scope.$$prototype; 16280 return Opal.send(self, Opal.find_super_dispatcher(self, functionName, self[`$${functionName}`]), argumentsList) 16281 }; 16282 } 16283 if (defaultFunctions) { 16284 for (const defaultFunctionName in defaultFunctions) { 16285 if (Object.prototype.hasOwnProperty.call(defaultFunctions, defaultFunctionName) && !Object.prototype.hasOwnProperty.call(defaultFunctionsOverridden, defaultFunctionName)) { 16286 (function (defaultFunctionName) { 16287 const defaultFunction = defaultFunctions[defaultFunctionName]; 16288 Opal.def(scope, '$' + defaultFunctionName, function () { 16289 return defaultFunction.apply(this, arguments) 16290 }); 16291 }(defaultFunctionName)); 16292 } 16293 } 16294 } 16295 return scope 16296} 16297 16298// Asciidoctor API 16299 16300/** 16301 * @namespace 16302 * @description 16303 * The main application interface (API) for Asciidoctor. 16304 * This API provides methods to parse AsciiDoc content and convert it to various output formats using built-in or third-party converters. 16305 * 16306 * An AsciiDoc document can be as simple as a single line of content, 16307 * though it more commonly starts with a document header that declares the document title and document attribute definitions. 16308 * The document header is then followed by zero or more section titles, optionally nested, to organize the paragraphs, blocks, lists, etc. of the document. 16309 * 16310 * By default, the processor converts the AsciiDoc document to HTML 5 using a built-in converter. 16311 * However, this behavior can be changed by specifying a different backend (e.g., +docbook+). 16312 * A backend is a keyword for an output format (e.g., DocBook). 16313 * That keyword, in turn, is used to select a converter, which carries out the request to convert the document to that format. 16314 * 16315 * @example 16316 * asciidoctor.convertFile('document.adoc', { 'safe': 'safe' }) // Convert an AsciiDoc file 16317 * 16318 * asciidoctor.convert("I'm using *Asciidoctor* version {asciidoctor-version}.", { 'safe': 'safe' }) // Convert an AsciiDoc string 16319 * 16320 * const doc = asciidoctor.loadFile('document.adoc', { 'safe': 'safe' }) // Parse an AsciiDoc file into a document object 16321 * 16322 * const doc = asciidoctor.load("= Document Title\n\nfirst paragraph\n\nsecond paragraph", { 'safe': 'safe' }) // Parse an AsciiDoc string into a document object 16323 */ 16324const Asciidoctor = Opal.Asciidoctor.$$class; 16325 16326/** 16327 * Get Asciidoctor core version number. 16328 * 16329 * @returns {string} - the version number of Asciidoctor core. 16330 * @memberof Asciidoctor 16331 */ 16332Asciidoctor.prototype.getCoreVersion = function () { 16333 return this.$$const.VERSION 16334}; 16335 16336/** 16337 * Get Asciidoctor.js runtime environment information. 16338 * 16339 * @returns {Object} - the runtime environment including the ioModule, the platform, the engine and the framework. 16340 * @memberof Asciidoctor 16341 */ 16342Asciidoctor.prototype.getRuntime = function () { 16343 return { 16344 ioModule: Opal.const_get_qualified('::', 'JAVASCRIPT_IO_MODULE'), 16345 platform: Opal.const_get_qualified('::', 'JAVASCRIPT_PLATFORM'), 16346 engine: Opal.const_get_qualified('::', 'JAVASCRIPT_ENGINE'), 16347 framework: Opal.const_get_qualified('::', 'JAVASCRIPT_FRAMEWORK') 16348 } 16349}; 16350 16351/** 16352 * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format. 16353 * 16354 * Accepts input as a Buffer or String. 16355 * 16356 * @param {string|Buffer} input - AsciiDoc input as String or Buffer 16357 * @param {Object} options - a JSON of options to control processing (default: {}) 16358 * @returns {string|Document} - the {@link Document} object if the converted String is written to a file, 16359 * otherwise the converted String 16360 * @example 16361 * const input = `= Hello, AsciiDoc! 16362 * Guillaume Grossetie <ggrossetie@example.com> 16363 * 16364 * An introduction to http://asciidoc.org[AsciiDoc]. 16365 * 16366 * == First Section 16367 * 16368 * * item 1 16369 * * item 2` 16370 * 16371 * const html = asciidoctor.convert(input) 16372 * @memberof Asciidoctor 16373 */ 16374Asciidoctor.prototype.convert = function (input, options) { 16375 if (typeof input === 'object' && input.constructor.name === 'Buffer') { 16376 input = input.toString('utf8'); 16377 } 16378 const toFile = options && options.to_file; 16379 if (typeof toFile === 'object' && toFile.constructor.name === 'Writable' && typeof toFile.write === 'function') { 16380 toFile['$respond_to?'] = (name) => name === 'write'; 16381 toFile.$object_id = () => ''; 16382 toFile.$write = function (data) { 16383 this.write(data); 16384 }; 16385 } 16386 const opts = prepareOptions(options); 16387 const result = this.$convert(input, opts); 16388 if (typeof toFile === 'object' && toFile.constructor.name === 'Writable' && typeof toFile.end === 'function') { 16389 toFile.end(); 16390 } 16391 return result === Opal.nil ? '' : result 16392}; 16393 16394/** 16395 * Parse the AsciiDoc source input into an {@link Document} and convert it to the specified backend format. 16396 * 16397 * @param {string} filename - source filename 16398 * @param {Object} options - a JSON of options to control processing (default: {}) 16399 * @returns {string|Document} - the {@link Document} object if the converted String is written to a file, 16400 * otherwise the converted String 16401 * @example 16402 * const html = asciidoctor.convertFile('./document.adoc') 16403 * @memberof Asciidoctor 16404 */ 16405Asciidoctor.prototype.convertFile = function (filename, options) { 16406 return this.$convert_file(filename, prepareOptions(options)) 16407}; 16408 16409/** 16410 * Parse the AsciiDoc source input into an {@link Document} 16411 * 16412 * Accepts input as a Buffer or String. 16413 * 16414 * @param {string|Buffer} input - AsciiDoc input as String or Buffer 16415 * @param {Object} options - a JSON of options to control processing (default: {}) 16416 * @returns {Document} - the {@link Document} object 16417 * @memberof Asciidoctor 16418 */ 16419Asciidoctor.prototype.load = function (input, options) { 16420 if (typeof input === 'object' && input.constructor.name === 'Buffer') { 16421 input = input.toString('utf8'); 16422 } 16423 return this.$load(input, prepareOptions(options)) 16424}; 16425 16426/** 16427 * Parse the contents of the AsciiDoc source file into an {@link Document} 16428 * 16429 * @param {string} filename - source filename 16430 * @param {Object} options - a JSON of options to control processing (default: {}) 16431 * @returns {Document} - the {@link Document} object 16432 * @memberof Asciidoctor 16433 */ 16434Asciidoctor.prototype.loadFile = function (filename, options) { 16435 return this.$load_file(filename, prepareOptions(options)) 16436}; 16437 16438// AbstractBlock API 16439 16440/** 16441 * @namespace 16442 * @extends AbstractNode 16443 */ 16444const AbstractBlock = Opal.Asciidoctor.AbstractBlock; 16445 16446/** 16447 * Describes the type of content this block accepts and how it should be converted. 16448 * @returns {string} - the type of content this block accepts. 16449 * @memberof AbstractBlock 16450 */ 16451AbstractBlock.prototype.getContentModel = function () { 16452 const contentModel = this.content_model; 16453 return contentModel === Opal.nil ? undefined : contentModel 16454}; 16455 16456/** 16457 * Set the type of content this block accepts. Acceptable values are: 16458 * - compound - this block contains other blocks 16459 * - simple - this block holds a paragraph of prose that receives normal substitutions 16460 * - verbatim - this block holds verbatim text (displayed "as is") that receives verbatim substitutions 16461 * - raw - this block holds unprocessed content passed directly to the output with no substitutions applied 16462 * - empty - this block has no content 16463 * @param {string} contentModel - type of content, one of: compound, simple, verbatim, raw or empty. 16464 * @memberof AbstractBlock 16465 */ 16466AbstractBlock.prototype.setContentModel = function (contentModel) { 16467 this.content_model = contentModel; 16468}; 16469 16470/** 16471 * Append a block to this block's list of child blocks. 16472 * @param {AbstractBlock} block - the block to append 16473 * @returns {AbstractBlock} - the parent block to which this block was appended. 16474 * @memberof AbstractBlock 16475 */ 16476AbstractBlock.prototype.append = function (block) { 16477 this.$append(block); 16478 return this 16479}; 16480 16481/** 16482 * Get the String title of this Block with title substitutions applied 16483 * 16484 * The following substitutions are applied to block and section titles: 16485 * 16486 * <code>specialcharacters</code>, <code>quotes</code>, <code>replacements</code>, <code>macros</code>, <code>attributes</code> and <code>post_replacements</code> 16487 * 16488 * @returns {string} - the converted String title for this Block, or undefined if the title is not set. 16489 * @example 16490 * block.title // "Foo 3^ # {two-colons} Bar(1)" 16491 * block.getTitle(); // "Foo 3^ # :: Bar(1)" 16492 * @memberof AbstractBlock 16493 */ 16494AbstractBlock.prototype.getTitle = function () { 16495 const title = this.$title(); 16496 return title === Opal.nil ? undefined : title 16497}; 16498 16499/** 16500 * Set the String block title. 16501 * 16502 * @param {string} title - The block title 16503 * @returns {string} - the new String title assigned to this Block. 16504 * @memberof AbstractBlock 16505 */ 16506AbstractBlock.prototype.setTitle = function (title) { 16507 title = typeof title === 'undefined' ? Opal.nil : title; 16508 return this['$title='](title) 16509}; 16510 16511/** 16512 * Generate and assign caption to block if not already assigned. 16513 * 16514 * If the block has a title and a caption prefix is available for this block, 16515 * then build a caption from this information, assign it a number and store it 16516 * to the caption attribute on the block. 16517 * 16518 * If a caption has already been assigned to this block, do nothing. 16519 * 16520 * The parts of a complete caption are: `<prefix> <number>. <title>` 16521 * This partial caption represents the part the precedes the title. 16522 * 16523 * @param {string} value - the String caption to assign to this block or nil to use document attribute. 16524 * @param {string} captionContext - the String context to use when resolving caption-related attributes. 16525 * If not provided, the name of the context for this block is used. Only certain contexts allow the caption to be looked up. 16526 * 16527 * @memberof AbstractBlock 16528 */ 16529AbstractBlock.prototype.assignCaption = function (value, captionContext) { 16530 value = typeof value === 'undefined' ? Opal.nil : value; 16531 captionContext = typeof captionContext === 'undefined' ? null : captionContext; 16532 this.$assign_caption(value, captionContext); 16533}; 16534 16535/** 16536 * Convenience method that returns the interpreted title of the Block 16537 * with the caption prepended. 16538 * Concatenates the value of this Block's caption instance variable and the 16539 * return value of this Block's title method. No space is added between the 16540 * two values. If the Block does not have a caption, the interpreted title is 16541 * returned. 16542 * 16543 * @returns {string} - the converted String title prefixed with the caption, or just the converted String title if no caption is set 16544 * @memberof AbstractBlock 16545 */ 16546AbstractBlock.prototype.getCaptionedTitle = function () { 16547 return this.$captioned_title() 16548}; 16549 16550/** 16551 * Get the style (block type qualifier) for this block. 16552 * 16553 * @returns {string} - the style for this block 16554 * @memberof AbstractBlock 16555 */ 16556AbstractBlock.prototype.getStyle = function () { 16557 const style = this.style; 16558 return style === Opal.nil ? undefined : style 16559}; 16560 16561/** 16562 * Set the style for this block. 16563 * 16564 * @param {string} style - Style 16565 * @memberof AbstractBlock 16566 */ 16567AbstractBlock.prototype.setStyle = function (style) { 16568 this.style = style; 16569}; 16570 16571/** 16572 * Get the location in the AsciiDoc source where this block begins. 16573 * 16574 * @returns {Cursor} - the location in the AsciiDoc source where this block begins 16575 * @memberof AbstractBlock 16576 */ 16577AbstractBlock.prototype.getSourceLocation = function () { 16578 const sourceLocation = this.source_location; 16579 if (sourceLocation === Opal.nil) { 16580 return undefined 16581 } 16582 sourceLocation.getFile = function () { 16583 const file = this.file; 16584 return file === Opal.nil ? undefined : file 16585 }; 16586 sourceLocation.getDirectory = function () { 16587 const dir = this.dir; 16588 return dir === Opal.nil ? undefined : dir 16589 }; 16590 sourceLocation.getPath = function () { 16591 const path = this.path; 16592 return path === Opal.nil ? undefined : path 16593 }; 16594 sourceLocation.getLineNumber = function () { 16595 const lineno = this.lineno; 16596 return lineno === Opal.nil ? undefined : lineno 16597 }; 16598 return sourceLocation 16599}; 16600 16601/** 16602 * Get the caption for this block. 16603 * 16604 * @returns {string} - the caption for this block 16605 * @memberof AbstractBlock 16606 */ 16607AbstractBlock.prototype.getCaption = function () { 16608 const caption = this.$caption(); 16609 return caption === Opal.nil ? undefined : caption 16610}; 16611 16612/** 16613 * Set the caption for this block. 16614 * 16615 * @param {string} caption - Caption 16616 * @memberof AbstractBlock 16617 */ 16618AbstractBlock.prototype.setCaption = function (caption) { 16619 this.caption = typeof caption === 'undefined' ? Opal.nil : caption; 16620}; 16621 16622/** 16623 * Get the level of this section or the section level in which this block resides. 16624 * 16625 * @returns {number} - the level (Integer) of this section 16626 * @memberof AbstractBlock 16627 */ 16628AbstractBlock.prototype.getLevel = function () { 16629 const level = this.level; 16630 return level === Opal.nil ? undefined : level 16631}; 16632 16633/** 16634 * Get the substitution keywords to be applied to the contents of this block. 16635 * 16636 * @returns {Array<string>} - the list of {string} substitution keywords associated with this block. 16637 * @memberof AbstractBlock 16638 */ 16639AbstractBlock.prototype.getSubstitutions = function () { 16640 return this.subs 16641}; 16642 16643/** 16644 * Check whether a given substitution keyword is present in the substitutions for this block. 16645 * 16646 * @returns {boolean} - whether the substitution is present on this block. 16647 * @memberof AbstractBlock 16648 */ 16649AbstractBlock.prototype.hasSubstitution = function (substitution) { 16650 return this['$sub?'](substitution) 16651}; 16652 16653/** 16654 * Remove the specified substitution keyword from the list of substitutions for this block. 16655 * 16656 * @memberof AbstractBlock 16657 */ 16658AbstractBlock.prototype.removeSubstitution = function (substitution) { 16659 this.$remove_sub(substitution); 16660}; 16661 16662/** 16663 * Checks if the {@link AbstractBlock} contains any child blocks. 16664 * 16665 * @returns {boolean} - whether the {@link AbstractBlock} has child blocks. 16666 * @memberof AbstractBlock 16667 */ 16668AbstractBlock.prototype.hasBlocks = function () { 16669 return this.blocks.length > 0 16670}; 16671 16672/** 16673 * Get the list of {@link AbstractBlock} sub-blocks for this block. 16674 * 16675 * @returns {Array<AbstractBlock>} - a list of {@link AbstractBlock} sub-blocks 16676 * @memberof AbstractBlock 16677 */ 16678AbstractBlock.prototype.getBlocks = function () { 16679 return this.blocks 16680}; 16681 16682/** 16683 * Get the converted result of the child blocks by converting the children appropriate to content model that this block supports. 16684 * 16685 * @returns {string} - the converted result of the child blocks 16686 * @memberof AbstractBlock 16687 */ 16688AbstractBlock.prototype.getContent = function () { 16689 const content = this.$content(); 16690 return content === Opal.nil ? undefined : content 16691}; 16692 16693/** 16694 * Get the converted content for this block. 16695 * If the block has child blocks, the content method should cause them to be converted 16696 * and returned as content that can be included in the parent block's template. 16697 * 16698 * @returns {string} - the converted String content for this block 16699 * @memberof AbstractBlock 16700 */ 16701AbstractBlock.prototype.convert = function () { 16702 return this.$convert() 16703}; 16704 16705/** 16706 * Query for all descendant block-level nodes in the document tree 16707 * that match the specified selector (context, style, id, and/or role). 16708 * If a function block is given, it's used as an additional filter. 16709 * If no selector or function block is supplied, all block-level nodes in the tree are returned. 16710 * @param {Object} [selector] 16711 * @param {function} [block] 16712 * @example 16713 * doc.findBy({'context': 'section'}); 16714 * // => { level: 0, title: "Hello, AsciiDoc!", blocks: 0 } 16715 * // => { level: 1, title: "First Section", blocks: 1 } 16716 * 16717 * doc.findBy({'context': 'section'}, function (section) { return section.getLevel() === 1; }); 16718 * // => { level: 1, title: "First Section", blocks: 1 } 16719 * 16720 * doc.findBy({'context': 'listing', 'style': 'source'}); 16721 * // => { context: :listing, content_model: :verbatim, style: "source", lines: 1 } 16722 * 16723 * @returns {Array<AbstractBlock>} - a list of block-level nodes that match the filter or an empty list if no matches are found 16724 * @memberof AbstractBlock 16725 */ 16726AbstractBlock.prototype.findBy = function (selector, block) { 16727 if (typeof block === 'undefined' && typeof selector === 'function') { 16728 return Opal.send(this, 'find_by', null, selector) 16729 } else if (typeof block === 'function') { 16730 return Opal.send(this, 'find_by', [toHash(selector)], block) 16731 } else { 16732 return this.$find_by(toHash(selector)) 16733 } 16734}; 16735 16736/** 16737 * Get the source line number where this block started. 16738 * @returns {number} - the source line number where this block started 16739 * @memberof AbstractBlock 16740 */ 16741AbstractBlock.prototype.getLineNumber = function () { 16742 const lineno = this.$lineno(); 16743 return lineno === Opal.nil ? undefined : lineno 16744}; 16745 16746/** 16747 * Check whether this block has any child Section objects. 16748 * Only applies to Document and Section instances. 16749 * @returns {boolean} - true if this block has child Section objects, otherwise false 16750 * @memberof AbstractBlock 16751 */ 16752AbstractBlock.prototype.hasSections = function () { 16753 // REMIND: call directly the underlying method "$sections?" 16754 // once https://github.com/asciidoctor/asciidoctor/pull/3591 is merged and a new version is released. 16755 // return this['$sections?']() 16756 return this.next_section_index !== Opal.nil && this.next_section_index > 0 16757}; 16758 16759/** 16760 * Get the Array of child Section objects. 16761 * Only applies to Document and Section instances. 16762 * @memberof AbstractBlock 16763 * @returns {Array<Section>} - an {Array} of {@link Section} objects 16764 */ 16765AbstractBlock.prototype.getSections = function () { 16766 return this.$sections() 16767}; 16768 16769/** 16770 * Get the numeral of this block (if section, relative to parent, otherwise absolute). 16771 * Only assigned to section if automatic section numbering is enabled. 16772 * Only assigned to formal block (block with title) if corresponding caption attribute is present. 16773 * If the section is an appendix, the numeral is a letter (starting with A). 16774 * @returns {string} - the numeral 16775 * @memberof AbstractBlock 16776 */ 16777AbstractBlock.prototype.getNumeral = function () { 16778 const numeral = this.$numeral(); 16779 return numeral === Opal.nil ? undefined : numeral 16780}; 16781 16782/** 16783 * Set the numeral of this block. 16784 * @param {string} value - The numeral value 16785 * @memberof AbstractBlock 16786 */ 16787AbstractBlock.prototype.setNumeral = function (value) { 16788 this['$numeral='](value); 16789}; 16790 16791/** 16792 * A convenience method that checks whether the title of this block is defined. 16793 * 16794 * @returns {boolean} - a {boolean} indicating whether this block has a title. 16795 * @memberof AbstractBlock 16796 */ 16797AbstractBlock.prototype.hasTitle = function () { 16798 return this['$title?']() 16799}; 16800 16801/** 16802 * Returns the converted alt text for this block image. 16803 * @returns {string} - the {string} value of the alt attribute with XML special character and replacement substitutions applied. 16804 * @memberof AbstractBlock 16805 */ 16806AbstractBlock.prototype.getAlt = function () { 16807 return this.$alt() 16808}; 16809 16810// Section API 16811 16812/** 16813 * @description 16814 * Methods for managing sections of AsciiDoc content in a document. 16815 * 16816 * @example 16817 * <pre> 16818 * section = asciidoctor.Section.create() 16819 * section.setTitle('Section 1') 16820 * section.setId('sect1') 16821 * section.getBlocks().length // 0 16822 * section.getId() // "sect1" 16823 * section.append(newBlock) 16824 * section.getBlocks().length // 1 16825 * </pre> 16826 * @namespace 16827 * @extends AbstractBlock 16828 */ 16829const Section = Opal.Asciidoctor.Section; 16830 16831/** 16832 * Create a {Section} object. 16833 * @param {AbstractBlock} [parent] - The parent AbstractBlock. If set, must be a Document or Section object (default: undefined) 16834 * @param {number} [level] - The Integer level of this section (default: 1 more than parent level or 1 if parent not defined) 16835 * @param {boolean} [numbered] - A Boolean indicating whether numbering is enabled for this Section (default: false) 16836 * @param {Object} [opts] - An optional JSON of options (default: {}) 16837 * @returns {Section} - a new {Section} object 16838 * @memberof Section 16839 */ 16840Section.create = function (parent, level, numbered, opts) { 16841 if (opts && opts.attributes) { 16842 opts.attributes = toHash(opts.attributes); 16843 } 16844 return this.$new(parent, level, numbered, toHash(opts)) 16845}; 16846 16847/** 16848 * Set the level of this section or the section level in which this block resides. 16849 * @param {number} level - Level (Integer) 16850 * @memberof AbstractBlock 16851 */ 16852Section.prototype.setLevel = function (level) { 16853 this.level = level; 16854}; 16855 16856/** 16857 * Get the 0-based index order of this section within the parent block. 16858 * @returns {number} 16859 * @memberof Section 16860 */ 16861Section.prototype.getIndex = function () { 16862 return this.index 16863}; 16864 16865/** 16866 * Set the 0-based index order of this section within the parent block. 16867 * @param {string} index - The index order of this section 16868 * @memberof Section 16869 */ 16870Section.prototype.setIndex = function (index) { 16871 this.index = index; 16872}; 16873 16874/** 16875 * Get the section name of this section. 16876 * @returns {string|undefined} 16877 * @memberof Section 16878 */ 16879Section.prototype.getSectionName = function () { 16880 const sectname = this.sectname; 16881 return sectname === Opal.nil ? undefined : sectname 16882}; 16883 16884/** 16885 * Set the section name of this section. 16886 * @param {string} value - The section name 16887 * @memberof Section 16888 */ 16889Section.prototype.setSectionName = function (value) { 16890 this.sectname = value; 16891}; 16892 16893/** 16894 * Get the section numeral of this section. 16895 * @returns {string} 16896 * @memberof Section 16897 */ 16898Section.prototype.getSectionNumeral = function () { 16899 return this.$sectnum() 16900}; 16901 16902Section.prototype.getSectionNumber = Section.prototype.getSectionNumeral; 16903 16904/** 16905 * Get the flag to indicate whether this is a special section or a child of one. 16906 * @returns {boolean} 16907 * @memberof Section 16908 */ 16909Section.prototype.isSpecial = function () { 16910 return this.special 16911}; 16912 16913/** 16914 * Set the flag to indicate whether this is a special section or a child of one. 16915 * @param {boolean} value - A flag to indicated if this is a special section 16916 * @memberof Section 16917 */ 16918Section.prototype.setSpecial = function (value) { 16919 this.special = value; 16920}; 16921 16922/** 16923 * Get the state of the numbered attribute at this section (need to preserve for creating TOC). 16924 * @returns {boolean} 16925 * @memberof Section 16926 */ 16927Section.prototype.isNumbered = function () { 16928 return this.numbered 16929}; 16930 16931/** 16932 * Get the caption for this section (only relevant for appendices). 16933 * @returns {string} 16934 * @memberof Section 16935 */ 16936Section.prototype.getCaption = function () { 16937 const value = this.caption; 16938 return value === Opal.nil ? undefined : value 16939}; 16940 16941/** 16942 * Get the name of the Section (title) 16943 * @returns {string} 16944 * @see {@link AbstractBlock#getTitle} 16945 * @memberof Section 16946 */ 16947Section.prototype.getName = function () { 16948 return this.getTitle() 16949}; 16950 16951/** 16952 * @description 16953 * Methods for managing AsciiDoc content blocks. 16954 * 16955 * @example 16956 * block = asciidoctor.Block.create(parent, 'paragraph', {source: '_This_ is a <test>'}) 16957 * block.getContent() 16958 * // "<em>This</em> is a <test>" 16959 * 16960 * @namespace 16961 * @extends AbstractBlock 16962 */ 16963const Block = Opal.Asciidoctor.Block; 16964 16965/** 16966 * Create a {Block} object. 16967 * @param {AbstractBlock} parent - The parent {AbstractBlock} with a compound content model to which this {Block} will be appended. 16968 * @param {string} context - The context name for the type of content (e.g., "paragraph"). 16969 * @param {Object} [opts] - a JSON of options to customize block initialization: (default: {}) 16970 * @param {string} opts.content_model - indicates whether blocks can be nested in this {Block} ("compound"), 16971 * otherwise how the lines should be processed ("simple", "verbatim", "raw", "empty"). (default: "simple") 16972 * @param {Object} opts.attributes - a JSON of attributes (key/value pairs) to assign to this {Block}. (default: {}) 16973 * @param {string|Array<string>} opts.source - a String or {Array} of raw source for this {Block}. (default: undefined) 16974 * 16975 * IMPORTANT: If you don't specify the `subs` option, you must explicitly call the `commit_subs` method to resolve and assign the substitutions 16976 * to this block (which are resolved from the `subs` attribute, if specified, or the default substitutions based on this block's context). 16977 * If you want to use the default subs for a block, pass the option `subs: "default"`. 16978 * You can override the default subs using the `default_subs` option. 16979 * 16980 * @returns {Block} - a new {Block} object 16981 * @memberof Block 16982 */ 16983Block.create = function (parent, context, opts) { 16984 if (opts && opts.attributes) { 16985 opts.attributes = toHash(opts.attributes); 16986 } 16987 return this.$new(parent, context, toHash(opts)) 16988}; 16989 16990/** 16991 * Get the source of this block. 16992 * @returns {string} - the String source of this block. 16993 * @memberof Block 16994 */ 16995Block.prototype.getSource = function () { 16996 return this.$source() 16997}; 16998 16999/** 17000 * Get the source lines of this block. 17001 * @returns {Array<string>} - the String {Array} of source lines for this block. 17002 * @memberof Block 17003 */ 17004Block.prototype.getSourceLines = function () { 17005 return this.lines 17006}; 17007 17008// AbstractNode API 17009 17010/** 17011 * @namespace 17012 * @description 17013 * An abstract base class that provides state and methods for managing a node of AsciiDoc content. 17014 * The state and methods on this class are common to all content segments in an AsciiDoc document. 17015 */ 17016const AbstractNode = Opal.Asciidoctor.AbstractNode; 17017 17018/** 17019 * Apply the specified substitutions to the text. 17020 * If no substitutions are specified, the following substitutions are applied: 17021 * <code>specialcharacters</code>, <code>quotes</code>, <code>attributes</code>, <code>replacements</code>, <code>macros</code>, and <code>post_replacements</code>. 17022 * 17023 * @param {string|Array<string>} text - The String or String Array of text to process; must not be undefined. 17024 * @param {Array<string>} [subs] - The substitutions to perform; must be an Array or undefined. 17025 * @returns {string|Array<string>} - a String or String Array to match the type of the text argument with substitutions applied. 17026 * @memberof AbstractNode 17027 */ 17028AbstractNode.prototype.applySubstitutions = function (text, subs) { 17029 return this.$apply_subs(text, subs) 17030}; 17031 17032/** 17033 * Resolve the list of comma-delimited subs against the possible options. 17034 * 17035 * @param {string} subs - The comma-delimited String of substitution names or aliases. 17036 * @param {string} [type] - A String representing the context for which the subs are being resolved (default: 'block'). 17037 * @param {Array<string>} [defaults] - An Array of substitutions to start with when computing incremental substitutions (default: undefined). 17038 * @param {string} [subject] - The String to use in log messages to communicate the subject for which subs are being resolved (default: undefined) 17039 * 17040 * @returns {Array<string>} - An Array of Strings representing the substitution operation or nothing if no subs are found. 17041 * @memberof AbstractNode 17042 */ 17043AbstractNode.prototype.resolveSubstitutions = function (subs, type, defaults, subject) { 17044 if (typeof type === 'undefined') { 17045 type = 'block'; 17046 } 17047 if (typeof defaults === 'undefined') { 17048 defaults = Opal.nil; 17049 } 17050 if (typeof subject === 'undefined') { 17051 subject = Opal.nil; 17052 } 17053 const value = this.$resolve_subs(subs, type, defaults, subject); 17054 return value === Opal.nil ? undefined : value 17055}; 17056 17057/** 17058 * Call {@link AbstractNode#resolveSubstitutions} for the 'block' type. 17059 * 17060 * @see {@link AbstractNode#resolveSubstitutions} 17061 */ 17062AbstractNode.prototype.resolveBlockSubstitutions = function (subs, defaults, subject) { 17063 return this.resolveSubstitutions(subs, 'block', defaults, subject) 17064}; 17065 17066/** 17067 * Call {@link AbstractNode#resolveSubstitutions} for the 'inline' type with the subject set as passthrough macro. 17068 * 17069 * @see {@link AbstractNode#resolveSubstitutions} 17070 */ 17071AbstractNode.prototype.resolvePassSubstitutions = function (subs) { 17072 return this.resolveSubstitutions(subs, 'inline', undefined, 'passthrough macro') 17073}; 17074 17075/** 17076 * @returns {string} - the String name of this node 17077 * @memberof AbstractNode 17078 */ 17079AbstractNode.prototype.getNodeName = function () { 17080 return this.node_name 17081}; 17082 17083/** 17084 * @returns {Object} - the JSON of attributes for this node 17085 * @memberof AbstractNode 17086 */ 17087AbstractNode.prototype.getAttributes = function () { 17088 return fromHash(this.attributes) 17089}; 17090 17091/** 17092 * Get the value of the specified attribute. 17093 * 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. 17094 * 17095 * Look for the specified attribute in the attributes on this node and return the value of the attribute, if found. 17096 * 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. 17097 * Otherwise, return the default value (default: undefined). 17098 * 17099 * @param {string} name - The String of the attribute to resolve. 17100 * @param {*} [defaultValue] - The {Object} value to return if the attribute is not found (default: undefined). 17101 * @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). 17102 * 17103 * @returns {*} - the {Object} value (typically a String) of the attribute or defaultValue if the attribute is not found. 17104 * @memberof AbstractNode 17105 */ 17106AbstractNode.prototype.getAttribute = function (name, defaultValue, fallbackName) { 17107 const value = this.$attr(name, defaultValue, fallbackName); 17108 return value === Opal.nil ? undefined : value 17109}; 17110 17111/** 17112 * Check whether the specified attribute is present on this node. 17113 * 17114 * @param {string} name - The String of the attribute to resolve. 17115 * @returns {boolean} - true if the attribute is present, otherwise false 17116 * @memberof AbstractNode 17117 */ 17118AbstractNode.prototype.hasAttribute = function (name) { 17119 return name in this.attributes.$$smap 17120}; 17121 17122/** 17123 * Check if the specified attribute is defined using the same logic as {AbstractNode#getAttribute}, optionally performing acomparison with the expected value if specified. 17124 * 17125 * Look for the specified attribute in the attributes on this node. 17126 * 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. 17127 * In either case, if the attribute is found, and the comparison value is truthy, return whether the two values match. 17128 * Otherwise, return whether the attribute was found. 17129 * 17130 * @param {string} name - The String name of the attribute to resolve. 17131 * @param {*} [expectedValue] - The expected Object value of the attribute (default: undefined). 17132 * @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). 17133 * 17134 * @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. 17135 * @memberof AbstractNode 17136 */ 17137AbstractNode.prototype.isAttribute = function (name, expectedValue, fallbackName) { 17138 return this['$attr?'](name, expectedValue, fallbackName) 17139}; 17140 17141/** 17142 * Assign the value to the attribute name for the current node. 17143 * 17144 * @param {string} name - The String attribute name to assign 17145 * @param {*} value - The Object value to assign to the attribute (default: '') 17146 * @param {boolean} overwrite - A Boolean indicating whether to assign the attribute if currently present in the attributes JSON (default: true) 17147 * 17148 * @returns {boolean} - a Boolean indicating whether the assignment was performed 17149 * @memberof AbstractNode 17150 */ 17151AbstractNode.prototype.setAttribute = function (name, value, overwrite) { 17152 if (typeof overwrite === 'undefined') overwrite = true; 17153 return this.$set_attr(name, value, overwrite) 17154}; 17155 17156/** 17157 * Remove the attribute from the current node. 17158 * @param {string} name - The String attribute name to remove 17159 * @returns {string} - the previous {string} value, or undefined if the attribute was not present. 17160 * @memberof AbstractNode 17161 */ 17162AbstractNode.prototype.removeAttribute = function (name) { 17163 const value = this.$remove_attr(name); 17164 return value === Opal.nil ? undefined : value 17165}; 17166 17167/** 17168 * Get the {@link Document} to which this node belongs. 17169 * 17170 * @returns {Document} - the {@link Document} object to which this node belongs. 17171 * @memberof AbstractNode 17172 */ 17173AbstractNode.prototype.getDocument = function () { 17174 return this.document 17175}; 17176 17177/** 17178 * Get the {@link AbstractNode} to which this node is attached. 17179 * 17180 * @memberof AbstractNode 17181 * @returns {AbstractNode} - the {@link AbstractNode} object to which this node is attached, 17182 * or undefined if this node has no parent. 17183 */ 17184AbstractNode.prototype.getParent = function () { 17185 const parent = this.parent; 17186 return parent === Opal.nil ? undefined : parent 17187}; 17188 17189/** 17190 * @returns {boolean} - true if this {AbstractNode} is an instance of {Inline} 17191 * @memberof AbstractNode 17192 */ 17193AbstractNode.prototype.isInline = function () { 17194 return this['$inline?']() 17195}; 17196 17197/** 17198 * @returns {boolean} - true if this {AbstractNode} is an instance of {Block} 17199 * @memberof AbstractNode 17200 */ 17201AbstractNode.prototype.isBlock = function () { 17202 return this['$block?']() 17203}; 17204 17205/** 17206 * 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. 17207 * 17208 * @param {string} expectedValue - The expected String value of the role (optional, default: undefined) 17209 * 17210 * @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. 17211 * @memberof AbstractNode 17212 */ 17213AbstractNode.prototype.isRole = function (expectedValue) { 17214 return this['$role?'](expectedValue) 17215}; 17216 17217/** 17218 * Retrieves the space-separated String role for this node. 17219 * 17220 * @returns {string} - the role as a space-separated String. 17221 * @memberof AbstractNode 17222 */ 17223AbstractNode.prototype.getRole = function () { 17224 const role = this.$role(); 17225 return role === Opal.nil ? undefined : role 17226}; 17227 17228/** 17229 * Sets the value of the role attribute on this node. 17230 * 17231 * @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 17232 * 17233 * @returns {string} - the value of the role attribute 17234 * @memberof AbstractNode 17235 */ 17236AbstractNode.prototype.setRole = function (names) { 17237 if (Array.isArray(names) || (typeof names === 'string' && arguments.length === 1)) { 17238 return this['$role='](names) 17239 } 17240 return this['$role='](Array.from(arguments)) 17241}; 17242 17243/** 17244 * Checks if the specified role is present in the list of roles for this node. 17245 * 17246 * @param {string} name - The String name of the role to find. 17247 * 17248 * @returns {boolean} - a Boolean indicating whether this node has the specified role. 17249 * @memberof AbstractNode 17250 */ 17251AbstractNode.prototype.hasRole = function (name) { 17252 return this['$has_role?'](name) 17253}; 17254 17255/** 17256 * Retrieves the String role names for this node as an Array. 17257 * 17258 * @returns {Array<string>} - the role names as a String {Array}, which is empty if the role attribute is absent on this node. 17259 * @memberof AbstractNode 17260 */ 17261AbstractNode.prototype.getRoles = function () { 17262 return this.$roles() 17263}; 17264 17265/** 17266 * Adds the given role directly to this node. 17267 * 17268 * @param {string} name - The name of the role to add 17269 * 17270 * @returns {boolean} - a Boolean indicating whether the role was added. 17271 * @memberof AbstractNode 17272 */ 17273AbstractNode.prototype.addRole = function (name) { 17274 return this.$add_role(name) 17275}; 17276 17277/** 17278 * Public: Removes the given role directly from this node. 17279 * 17280 * @param {string} name - The name of the role to remove 17281 * 17282 * @returns {boolean} - a Boolean indicating whether the role was removed. 17283 * @memberof AbstractNode 17284 */ 17285AbstractNode.prototype.removeRole = function (name) { 17286 return this.$remove_role(name) 17287}; 17288 17289/** 17290 * A convenience method that checks if the reftext attribute is defined. 17291 * @returns {boolean} - A Boolean indicating whether the reftext attribute is defined 17292 * @memberof AbstractNode 17293 */ 17294AbstractNode.prototype.isReftext = function () { 17295 return this['$reftext?']() 17296}; 17297 17298/** 17299 * A convenience method that returns the value of the reftext attribute with substitutions applied. 17300 * @returns {string|undefined} - the value of the reftext attribute with substitutions applied. 17301 * @memberof AbstractNode 17302 */ 17303AbstractNode.prototype.getReftext = function () { 17304 const reftext = this.$reftext(); 17305 return reftext === Opal.nil ? undefined : reftext 17306}; 17307 17308/** 17309 * @returns {string} - Get the context name for this node 17310 * @memberof AbstractNode 17311 */ 17312AbstractNode.prototype.getContext = function () { 17313 const context = this.context; 17314 // Automatically convert Opal pseudo-symbol to String 17315 return typeof context === 'string' ? context : context.toString() 17316}; 17317 17318/** 17319 * @returns {string} - the String id of this node 17320 * @memberof AbstractNode 17321 */ 17322AbstractNode.prototype.getId = function () { 17323 const id = this.id; 17324 return id === Opal.nil ? undefined : id 17325}; 17326 17327/** 17328 * @param {string} id - the String id of this node 17329 * @memberof AbstractNode 17330 */ 17331AbstractNode.prototype.setId = function (id) { 17332 this.id = id; 17333}; 17334 17335/** 17336 * A convenience method to check if the specified option attribute is enabled on the current node. 17337 * Check if the option is enabled. This method simply checks to see if the <name>-option attribute is defined on the current node. 17338 * 17339 * @param {string} name - the String name of the option 17340 * 17341 * @return {boolean} - a Boolean indicating whether the option has been specified 17342 * @memberof AbstractNode 17343 */ 17344AbstractNode.prototype.isOption = function (name) { 17345 return this['$option?'](name) 17346}; 17347 17348/** 17349 * Set the specified option on this node. 17350 * This method sets the specified option on this node by setting the <name>-option attribute. 17351 * 17352 * @param {string} name - the String name of the option 17353 * 17354 * @memberof AbstractNode 17355 */ 17356AbstractNode.prototype.setOption = function (name) { 17357 return this.$set_option(name) 17358}; 17359 17360/** 17361 * @memberof AbstractNode 17362 */ 17363AbstractNode.prototype.getIconUri = function (name) { 17364 return this.$icon_uri(name) 17365}; 17366 17367/** 17368 * @memberof AbstractNode 17369 */ 17370AbstractNode.prototype.getMediaUri = function (target, assetDirKey) { 17371 return this.$media_uri(target, assetDirKey) 17372}; 17373 17374/** 17375 * @memberof AbstractNode 17376 */ 17377AbstractNode.prototype.getImageUri = function (targetImage, assetDirKey) { 17378 return this.$image_uri(targetImage, assetDirKey) 17379}; 17380 17381/** 17382 * Get the {Converter} instance being used to convert the current {Document}. 17383 * @returns {Object} 17384 * @memberof AbstractNode 17385 */ 17386AbstractNode.prototype.getConverter = function () { 17387 return this.$converter() 17388}; 17389 17390/** 17391 * @memberof AbstractNode 17392 */ 17393AbstractNode.prototype.readContents = function (target, options) { 17394 return this.$read_contents(target, toHash(options)) 17395}; 17396 17397/** 17398 * Read the contents of the file at the specified path. 17399 * This method assumes that the path is safe to read. 17400 * It checks that the file is readable before attempting to read it. 17401 * 17402 * @param path - the {string} path from which to read the contents 17403 * @param {Object} options - a JSON {Object} of options to control processing (default: {}) 17404 * @param {boolean} options.warn_on_failure - a {boolean} that controls whether a warning is issued if the file cannot be read (default: false) 17405 * @param {boolean} options.normalize - a {boolean} that controls whether the lines are normalized and coerced to UTF-8 (default: false) 17406 * 17407 * @returns {string} - the String content of the file at the specified path, or undefined if the file does not exist. 17408 * @memberof AbstractNode 17409 */ 17410AbstractNode.prototype.readAsset = function (path, options) { 17411 const result = this.$read_asset(path, toHash(options)); 17412 return result === Opal.nil ? undefined : result 17413}; 17414 17415/** 17416 * @memberof AbstractNode 17417 */ 17418AbstractNode.prototype.normalizeWebPath = function (target, start, preserveTargetUri) { 17419 return this.$normalize_web_path(target, start, preserveTargetUri) 17420}; 17421 17422/** 17423 * @memberof AbstractNode 17424 */ 17425AbstractNode.prototype.normalizeSystemPath = function (target, start, jail, options) { 17426 return this.$normalize_system_path(target, start, jail, toHash(options)) 17427}; 17428 17429/** 17430 * @memberof AbstractNode 17431 */ 17432AbstractNode.prototype.normalizeAssetPath = function (assetRef, assetName, autoCorrect) { 17433 return this.$normalize_asset_path(assetRef, assetName, autoCorrect) 17434}; 17435 17436// Document API 17437 17438/** 17439 * The {@link Document} class represents a parsed AsciiDoc document. 17440 * 17441 * Document is the root node of a parsed AsciiDoc document.<br/> 17442 * It provides an abstract syntax tree (AST) that represents the structure of the AsciiDoc document 17443 * from which the Document object was parsed. 17444 * 17445 * Although the constructor can be used to create an empty document object, 17446 * more commonly, you'll load the document object from AsciiDoc source 17447 * using the primary API methods on {@link Asciidoctor}. 17448 * When using one of these APIs, you almost always want to set the safe mode to 'safe' (or 'unsafe') 17449 * to enable all of Asciidoctor's features. 17450 * 17451 * <pre> 17452 * const doc = Asciidoctor.load('= Hello, AsciiDoc!', { 'safe': 'safe' }) 17453 * // => Asciidoctor::Document { doctype: "article", doctitle: "Hello, AsciiDoc!", blocks: 0 } 17454 * </pre> 17455 * 17456 * Instances of this class can be used to extract information from the document or alter its structure. 17457 * As such, the Document object is most often used in extensions and by integrations. 17458 * 17459 * The most basic usage of the Document object is to retrieve the document's title. 17460 * 17461 * <pre> 17462 * const source = '= Document Title' 17463 * const doc = asciidoctor.load(source, { 'safe': 'safe' }) 17464 * console.log(doc.getTitle()) // 'Document Title' 17465 * </pre> 17466 * 17467 * You can also use the Document object to access document attributes defined in the header, such as the author and doctype. 17468 * @namespace 17469 * @extends AbstractBlock 17470 */ 17471const Document = Opal.Asciidoctor.Document; 17472 17473/** 17474 * Append a content Block to this Document. 17475 * If the child block is a Section, assign an index to it. 17476 * @param {AbstractBlock} block - the child Block to append to this parent Block 17477 * @returns {AbstractBlock} - the parent block to which this block was appended. 17478 * @memberof Document 17479 */ 17480Document.prototype.append = function (block) { 17481 this['$<<'](block); 17482 return this 17483}; 17484 17485/** 17486 * Returns the SyntaxHighlighter associated with this document. 17487 * 17488 * @returns {SyntaxHighlighter} - the SyntaxHighlighter associated with this document. 17489 * @memberof Document 17490 */ 17491Document.prototype.getSyntaxHighlighter = function () { 17492 const syntaxHighlighter = this.syntax_highlighter; 17493 // eslint-disable-next-line no-proto 17494 const prototype = syntaxHighlighter.__proto__; 17495 if (prototype) { 17496 if (typeof prototype['$highlight?'] === 'function') { 17497 prototype.handlesHighlighting = function () { 17498 const value = prototype['$highlight?'](); 17499 return value === Opal.nil ? false : value 17500 }; 17501 } 17502 if (typeof prototype['$docinfo?'] === 'function') { 17503 prototype.hasDocinfo = prototype['$docinfo?']; 17504 } 17505 if (typeof prototype.$format === 'function') { 17506 prototype.format = function (node, lang, opts) { 17507 return this.$format(node, lang, toHash(opts)) 17508 }; 17509 } 17510 if (typeof prototype.$docinfo === 'function') { 17511 prototype.docinfo = function (location, doc, opts) { 17512 return this.$docinfo(location, doc, toHash(opts)) 17513 }; 17514 } 17515 } 17516 return syntaxHighlighter 17517}; 17518 17519/** 17520 * Returns a JSON {Object} of references captured by the processor. 17521 * 17522 * @returns {Object} - a JSON {Object} of {AbstractNode} in the document. 17523 * @memberof Document 17524 */ 17525Document.prototype.getRefs = function () { 17526 return fromHash(this.catalog.$$smap.refs) 17527}; 17528 17529/** 17530 * Returns an {Array} of {Document/ImageReference} captured by the processor. 17531 * 17532 * @returns {Array<ImageReference>} - an {Array} of {Document/ImageReference} in the document. 17533 * Will return an empty array if the option "catalog_assets: true" was not defined on the processor. 17534 * @memberof Document 17535 */ 17536Document.prototype.getImages = function () { 17537 return this.catalog.$$smap.images 17538}; 17539 17540/** 17541 * Returns an {Array} of links captured by the processor. 17542 * 17543 * @returns {Array<string>} - an {Array} of links in the document. 17544 * Will return an empty array if: 17545 * - the function was called before the document was converted 17546 * - the option "catalog_assets: true" was not defined on the processor 17547 * @memberof Document 17548 */ 17549Document.prototype.getLinks = function () { 17550 return this.catalog.$$smap.links 17551}; 17552 17553/** 17554 * @returns {boolean} - true if the document has footnotes otherwise false 17555 * @memberof Document 17556 */ 17557Document.prototype.hasFootnotes = function () { 17558 return this['$footnotes?']() 17559}; 17560 17561/** 17562 * Returns an {Array} of {Document/Footnote} captured by the processor. 17563 * 17564 * @returns {Array<Footnote>} - an {Array} of {Document/Footnote} in the document. 17565 * Will return an empty array if the function was called before the document was converted. 17566 * @memberof Document 17567 */ 17568Document.prototype.getFootnotes = function () { 17569 return this.$footnotes() 17570}; 17571 17572/** 17573 * Returns the level-0 {Section} (i.e. the document title). 17574 * Only stores the title, not the header attributes. 17575 * 17576 * @returns {string} - the level-0 {Section}. 17577 * @memberof Document 17578 */ 17579Document.prototype.getHeader = function () { 17580 return this.header 17581}; 17582 17583/** 17584 * @memberof Document 17585 */ 17586Document.prototype.setAttribute = function (name, value) { 17587 return this.$set_attribute(name, value) 17588}; 17589 17590/** 17591 17592 * @memberof Document 17593 */ 17594Document.prototype.removeAttribute = function (name) { 17595 this.attributes.$delete(name); 17596 this.attribute_overrides.$delete(name); 17597}; 17598 17599/** 17600 * Convert the AsciiDoc document using the templates loaded by the Converter. 17601 * If a "template_dir" is not specified, or a template is missing, the converter will fall back to using the appropriate built-in template. 17602 * 17603 * @param {Object} [options] - a JSON of options to control processing (default: {}) 17604 * 17605 * @returns {string} 17606 * @memberof Document 17607 */ 17608Document.prototype.convert = function (options) { 17609 const result = this.$convert(toHash(options)); 17610 return result === Opal.nil ? '' : result 17611}; 17612 17613/** 17614 * Write the output to the specified file. 17615 * 17616 * If the converter responds to "write", delegate the work of writing the file to that method. 17617 * Otherwise, write the output the specified file. 17618 * 17619 * @param {string} output 17620 * @param {string} target 17621 * 17622 * @memberof Document 17623 */ 17624Document.prototype.write = function (output, target) { 17625 return this.$write(output, target) 17626}; 17627 17628/** 17629 * @returns {string} - the full name of the author as a String 17630 * @memberof Document 17631 */ 17632Document.prototype.getAuthor = function () { 17633 return this.$author() 17634}; 17635 17636/** 17637 * @returns {string} 17638 * @memberof Document 17639 */ 17640Document.prototype.getSource = function () { 17641 return this.$source() 17642}; 17643 17644/** 17645 * @returns {Array<string>} 17646 * @memberof Document 17647 */ 17648Document.prototype.getSourceLines = function () { 17649 return this.$source_lines() 17650}; 17651 17652/** 17653 * @returns {boolean} 17654 * @memberof Document 17655 */ 17656Document.prototype.isNested = function () { 17657 return this['$nested?']() 17658}; 17659 17660/** 17661 * @returns {boolean} 17662 * @memberof Document 17663 */ 17664Document.prototype.isEmbedded = function () { 17665 return this['$embedded?']() 17666}; 17667 17668/** 17669 * @returns {boolean} 17670 * @memberof Document 17671 */ 17672Document.prototype.hasExtensions = function () { 17673 return this['$extensions?']() 17674}; 17675 17676/** 17677 * Get the value of the doctype attribute for this document. 17678 * @returns {string} 17679 * @memberof Document 17680 */ 17681Document.prototype.getDoctype = function () { 17682 return this.doctype 17683}; 17684 17685/** 17686 * Get the value of the backend attribute for this document. 17687 * @returns {string} 17688 * @memberof Document 17689 */ 17690Document.prototype.getBackend = function () { 17691 return this.backend 17692}; 17693 17694/** 17695 * @returns {boolean} 17696 * @memberof Document 17697 */ 17698Document.prototype.isBasebackend = function (base) { 17699 return this['$basebackend?'](base) 17700}; 17701 17702/** 17703 * Get the title explicitly defined in the document attributes. 17704 * @returns {string} 17705 * @see {@link AbstractNode#getAttributes} 17706 * @memberof Document 17707 */ 17708Document.prototype.getTitle = function () { 17709 const title = this.$title(); 17710 return title === Opal.nil ? undefined : title 17711}; 17712 17713/** 17714 * Set the title on the document header 17715 * 17716 * Set the title of the document header to the specified value. 17717 * If the header does not exist, it is first created. 17718 * 17719 * @param {string} title - the String title to assign as the title of the document header 17720 * 17721 * @returns {string} - the new String title assigned to the document header 17722 * @memberof Document 17723 */ 17724Document.prototype.setTitle = function (title) { 17725 return this['$title='](title) 17726}; 17727 17728/** 17729 * @returns {Document/Title} - a {@link Document/Title} 17730 * @memberof Document 17731 */ 17732Document.prototype.getDocumentTitle = function (options) { 17733 const doctitle = this.$doctitle(toHash(options)); 17734 return doctitle === Opal.nil ? undefined : doctitle 17735}; 17736 17737/** 17738 * @see {@link Document#getDocumentTitle} 17739 * @memberof Document 17740 */ 17741Document.prototype.getDoctitle = Document.prototype.getDocumentTitle; 17742 17743/** 17744 * Get the document catalog JSON object. 17745 * @returns {Object} 17746 * @memberof Document 17747 */ 17748Document.prototype.getCatalog = function () { 17749 return fromHash(this.catalog) 17750}; 17751 17752/** 17753 * 17754 * @returns {Object} 17755 * @see Document#getCatalog 17756 * @memberof Document 17757 */ 17758Document.prototype.getReferences = Document.prototype.getCatalog; 17759 17760/** 17761 * Get the document revision date from document header (document attribute <code>revdate</code>). 17762 * @returns {string} 17763 * @memberof Document 17764 */ 17765Document.prototype.getRevisionDate = function () { 17766 return this.getAttribute('revdate') 17767}; 17768 17769/** 17770 * @see Document#getRevisionDate 17771 * @returns {string} 17772 * @memberof Document 17773 */ 17774Document.prototype.getRevdate = function () { 17775 return this.getRevisionDate() 17776}; 17777 17778/** 17779 * Get the document revision number from document header (document attribute <code>revnumber</code>). 17780 * @returns {string} 17781 * @memberof Document 17782 */ 17783Document.prototype.getRevisionNumber = function () { 17784 return this.getAttribute('revnumber') 17785}; 17786 17787/** 17788 * Get the document revision remark from document header (document attribute <code>revremark</code>). 17789 * @returns {string} 17790 * @memberof Document 17791 */ 17792Document.prototype.getRevisionRemark = function () { 17793 return this.getAttribute('revremark') 17794}; 17795 17796/** 17797 * Assign a value to the specified attribute in the document header. 17798 * 17799 * The assignment will be visible when the header attributes are restored, 17800 * typically between processor phases (e.g., between parse and convert). 17801 * 17802 * @param {string} name - The {string} attribute name to assign 17803 * @param {Object} value - The {Object} value to assign to the attribute (default: '') 17804 * @param {boolean} overwrite - A {boolean} indicating whether to assign the attribute 17805 * if already present in the attributes Hash (default: true) 17806 * 17807 * @returns {boolean} - true if the assignment was performed otherwise false 17808 * @memberof Document 17809 */ 17810Document.prototype.setHeaderAttribute = function (name, value, overwrite) { 17811 if (typeof overwrite === 'undefined') overwrite = true; 17812 if (typeof value === 'undefined') value = ''; 17813 return this.$set_header_attribute(name, value, overwrite) 17814}; 17815 17816/** 17817 * Convenience method to retrieve the authors of this document as an {Array} of {Document/Author} objects. 17818 * 17819 * This method is backed by the author-related attributes on the document. 17820 * 17821 * @returns {Array<Author>} - an {Array} of {Document/Author} objects. 17822 * @memberof Document 17823 */ 17824Document.prototype.getAuthors = function () { 17825 return this.$authors() 17826}; 17827 17828// Document.Footnote API 17829 17830/** 17831 * @namespace 17832 * @module Document/Footnote 17833 */ 17834const Footnote = Document.Footnote; 17835 17836/** 17837 * @returns {number} - the footnote's index 17838 * @memberof Document/Footnote 17839 */ 17840Footnote.prototype.getIndex = function () { 17841 const index = this.$$data.index; 17842 return index === Opal.nil ? undefined : index 17843}; 17844 17845/** 17846 * @returns {number} - the footnote's id 17847 * @memberof Document/Footnote 17848 */ 17849Footnote.prototype.getId = function () { 17850 const id = this.$$data.id; 17851 return id === Opal.nil ? undefined : id 17852}; 17853 17854/** 17855 * @returns {string} - the footnote's text 17856 * @memberof Document/Footnote 17857 */ 17858Footnote.prototype.getText = function () { 17859 const text = this.$$data.text; 17860 return text === Opal.nil ? undefined : text 17861}; 17862 17863// Document.ImageReference API 17864 17865/** 17866 * @class 17867 * @module Document/ImageReference 17868 */ 17869const ImageReference = Document.ImageReference; 17870 17871/** 17872 * @returns {string} - the image's target 17873 * @memberof Document/ImageReference 17874 */ 17875ImageReference.prototype.getTarget = function () { 17876 return this.$$data.target 17877}; 17878 17879/** 17880 * @returns {string} - the image's directory (imagesdir attribute) 17881 * @memberof Document/ImageReference 17882 */ 17883ImageReference.prototype.getImagesDirectory = function () { 17884 const value = this.$$data.imagesdir; 17885 return value === Opal.nil ? undefined : value 17886}; 17887 17888// Document.Author API 17889 17890/** 17891 * The Author class represents information about an author extracted from document attributes. 17892 * @namespace 17893 * @module Document/Author 17894 */ 17895const Author = Document.Author; 17896 17897/** 17898 * @returns {string} - the author's full name 17899 * @memberof Document/Author 17900 */ 17901Author.prototype.getName = function () { 17902 const name = this.$$data.name; 17903 return name === Opal.nil ? undefined : name 17904}; 17905 17906/** 17907 * @returns {string} - the author's first name 17908 * @memberof Document/Author 17909 */ 17910Author.prototype.getFirstName = function () { 17911 const firstName = this.$$data.firstname; 17912 return firstName === Opal.nil ? undefined : firstName 17913}; 17914 17915/** 17916 * @returns {string} - the author's middle name (or undefined if the author has no middle name) 17917 * @memberof Document/Author 17918 */ 17919Author.prototype.getMiddleName = function () { 17920 const middleName = this.$$data.middlename; 17921 return middleName === Opal.nil ? undefined : middleName 17922}; 17923 17924/** 17925 * @returns {string} - the author's last name 17926 * @memberof Document/Author 17927 */ 17928Author.prototype.getLastName = function () { 17929 const lastName = this.$$data.lastname; 17930 return lastName === Opal.nil ? undefined : lastName 17931}; 17932 17933/** 17934 * @returns {string} - the author's initials (by default based on the author's name) 17935 * @memberof Document/Author 17936 */ 17937Author.prototype.getInitials = function () { 17938 const initials = this.$$data.initials; 17939 return initials === Opal.nil ? undefined : initials 17940}; 17941 17942/** 17943 * @returns {string} - the author's email 17944 * @memberof Document/Author 17945 */ 17946Author.prototype.getEmail = function () { 17947 const email = this.$$data.email; 17948 return email === Opal.nil ? undefined : email 17949}; 17950 17951// private constructor 17952Document.RevisionInfo = function (date, number, remark) { 17953 this.date = date; 17954 this.number = number; 17955 this.remark = remark; 17956}; 17957 17958/** 17959 * @class 17960 * @namespace 17961 * @module Document/RevisionInfo 17962 */ 17963const RevisionInfo = Document.RevisionInfo; 17964 17965/** 17966 * Get the document revision date from document header (document attribute <code>revdate</code>). 17967 * @returns {string} 17968 * @memberof Document/RevisionInfo 17969 */ 17970RevisionInfo.prototype.getDate = function () { 17971 return this.date 17972}; 17973 17974/** 17975 * Get the document revision number from document header (document attribute <code>revnumber</code>). 17976 * @returns {string} 17977 * @memberof Document/RevisionInfo 17978 */ 17979RevisionInfo.prototype.getNumber = function () { 17980 return this.number 17981}; 17982 17983/** 17984 * Get the document revision remark from document header (document attribute <code>revremark</code>). 17985 * A short summary of changes in this document revision. 17986 * @returns {string} 17987 * @memberof Document/RevisionInfo 17988 */ 17989RevisionInfo.prototype.getRemark = function () { 17990 return this.remark 17991}; 17992 17993/** 17994 * @returns {boolean} - true if the revision info is empty (ie. not defined), otherwise false 17995 * @memberof Document/RevisionInfo 17996 */ 17997RevisionInfo.prototype.isEmpty = function () { 17998 return this.date === undefined && this.number === undefined && this.remark === undefined 17999}; 18000 18001// SafeMode API 18002 18003/** 18004 * @namespace 18005 */ 18006const SafeMode = Opal.Asciidoctor.SafeMode; 18007 18008/** 18009 * @param {string} name - the name of the security level 18010 * @returns {number} - the integer value of the corresponding security level 18011 */ 18012SafeMode.getValueForName = function (name) { 18013 return this.$value_for_name(name) 18014}; 18015 18016/** 18017 * @param {number} value - the integer value of the security level 18018 * @returns {string} - the name of the corresponding security level 18019 */ 18020SafeMode.getNameForValue = function (value) { 18021 const name = this.$name_for_value(value); 18022 return name === Opal.nil ? undefined : name 18023}; 18024 18025/** 18026 * @returns {Array<string>} - the String {Array} of security levels 18027 */ 18028SafeMode.getNames = function () { 18029 return this.$names() 18030}; 18031 18032// Callouts API 18033 18034/** 18035 * Maintains a catalog of callouts and their associations. 18036 * @namespace 18037 */ 18038const Callouts = Opal.Asciidoctor.Callouts; 18039 18040/** 18041 * Create a new Callouts. 18042 * @returns {Callouts} - a new Callouts 18043 * @memberof Callouts 18044 */ 18045Callouts.create = function () { 18046 return this.$new() 18047}; 18048 18049/** 18050 * Register a new callout for the given list item ordinal. 18051 * 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. 18052 * 18053 * @param {number} ordinal - the Integer ordinal (1-based) of the list item to which this callout is to be associated 18054 * @returns {string} - The unique String id of this callout 18055 * @example 18056 * callouts = asciidoctor.Callouts.create() 18057 * callouts.register(1) 18058 * // => "CO1-1" 18059 * callouts.nextList() 18060 * callouts.register(2) 18061 * // => "CO2-1" 18062 * @memberof Callouts 18063 */ 18064 18065Callouts.prototype.register = function (ordinal) { 18066 return this.$register(ordinal) 18067}; 18068/** 18069 * Get the next callout index in the document. 18070 * 18071 * Reads the next callout index in the document and advances the pointer. 18072 * This method is used during conversion to retrieve the unique id of the callout that was generated during parsing. 18073 * 18074 * @returns {string} - The unique String id of the next callout in the document 18075 * @memberof Callouts 18076 */ 18077Callouts.prototype.readNextId = function () { 18078 return this.$read_next_id() 18079}; 18080 18081/** 18082 * et a space-separated list of callout ids for the specified list item. 18083 * @param {number} ordinal - the Integer ordinal (1-based) of the list item for which to retrieve the callouts 18084 * @returns {string} - a space-separated String of callout ids associated with the specified list item 18085 * @memberof Callouts 18086 */ 18087Callouts.prototype.getCalloutIds = function (ordinal) { 18088 return this.$callout_ids(ordinal) 18089}; 18090 18091/** 18092 * @memberof Callouts 18093 */ 18094Callouts.prototype.getLists = function () { 18095 const lists = this.lists; 18096 if (lists && lists.length > 0) { 18097 for (let i = 0; i < lists.length; i++) { 18098 const list = lists[i]; 18099 if (list && list.length > 0) { 18100 for (let j = 0; j < list.length; j++) { 18101 if (typeof list[j] === 'object' && '$$smap' in list[j]) { 18102 list[j] = fromHash(list[j]); 18103 } 18104 } 18105 } 18106 } 18107 } 18108 return lists 18109}; 18110 18111/** 18112 * @memberof Callouts 18113 */ 18114Callouts.prototype.getListIndex = function () { 18115 return this.list_index 18116}; 18117 18118/** 18119 * The current list for which callouts are being collected. 18120 * @returns {Array} - The Array of callouts at the position of the list index pointer 18121 * @memberof Callouts 18122 */ 18123Callouts.prototype.getCurrentList = function () { 18124 const currentList = this.$current_list(); 18125 if (currentList && currentList.length > 0) { 18126 for (let i = 0; i < currentList.length; i++) { 18127 if (typeof currentList[i] === 'object' && '$$smap' in currentList[i]) { 18128 currentList[i] = fromHash(currentList[i]); 18129 } 18130 } 18131 } 18132 return currentList 18133}; 18134 18135/** 18136 * Advance to the next callout list in the document. 18137 * @memberof Callouts 18138 */ 18139Callouts.prototype.nextList = function () { 18140 return this.$nextList() 18141}; 18142 18143/** 18144 * Rewind the list index pointer, intended to be used when switching from the parsing to conversion phase. 18145 * @memberof Callouts 18146 */ 18147Callouts.prototype.rewind = function () { 18148 return this.$rewind() 18149}; 18150 18151/** 18152 * @returns {Document/RevisionInfo} - a {@link Document/RevisionInfo} 18153 * @memberof Document 18154 */ 18155Document.prototype.getRevisionInfo = function () { 18156 return new Document.RevisionInfo(this.getRevisionDate(), this.getRevisionNumber(), this.getRevisionRemark()) 18157}; 18158 18159/** 18160 * @returns {boolean} - true if the document contains revision info, otherwise false 18161 * @memberof Document 18162 */ 18163Document.prototype.hasRevisionInfo = function () { 18164 const revisionInfo = this.getRevisionInfo(); 18165 return !revisionInfo.isEmpty() 18166}; 18167 18168/** 18169 * @returns {boolean} 18170 * @memberof Document 18171 */ 18172Document.prototype.getNotitle = function () { 18173 return this.$notitle() 18174}; 18175 18176/** 18177 * @returns {boolean} 18178 * @memberof Document 18179 */ 18180Document.prototype.getNoheader = function () { 18181 return this.$noheader() 18182}; 18183 18184/** 18185 * @returns {boolean} 18186 * @memberof Document 18187 */ 18188Document.prototype.getNofooter = function () { 18189 return this.$nofooter() 18190}; 18191 18192/** 18193 * @returns {boolean} 18194 * @memberof Document 18195 */ 18196Document.prototype.hasHeader = function () { 18197 return this['$header?']() 18198}; 18199 18200/** 18201 * Replay attribute assignments at the block level. 18202 * 18203 * <i>This method belongs to an internal API that deals with how attributes are managed by the processor.</i> 18204 * If you understand why this group of methods are necessary, and what they do, feel free to use them. 18205 * <strong>However, keep in mind they are subject to change at any time.</strong> 18206 * 18207 * @param {Object} blockAttributes - A JSON of attributes 18208 * @memberof Document 18209 */ 18210Document.prototype.playbackAttributes = function (blockAttributes) { 18211 blockAttributes = toHash(blockAttributes); 18212 if (blockAttributes) { 18213 const attrEntries = blockAttributes['$[]']('attribute_entries'); 18214 if (attrEntries && Array.isArray(attrEntries)) { 18215 const result = []; 18216 for (let i = 0; i < attrEntries.length; i++) { 18217 const attrEntryObject = attrEntries[i]; 18218 if (attrEntryObject && typeof attrEntryObject === 'object' && attrEntryObject.constructor.name === 'Object') { 18219 attrEntryObject.$name = function () { 18220 return this.name 18221 }; 18222 attrEntryObject.$value = function () { 18223 return this.value 18224 }; 18225 attrEntryObject.$negate = function () { 18226 return this.negate 18227 }; 18228 } 18229 result.push(attrEntryObject); 18230 } 18231 blockAttributes['$[]=']('attribute_entries', result); 18232 } 18233 } 18234 this.$playback_attributes(blockAttributes); 18235}; 18236 18237/** 18238 * Delete the specified attribute from the document if the name is not locked. 18239 * If the attribute is locked, false is returned. 18240 * Otherwise, the attribute is deleted. 18241 * 18242 * @param {string} name - the String attribute name 18243 * 18244 * @returns {boolean} - true if the attribute was deleted, false if it was not because it's locked 18245 * @memberof Document 18246 */ 18247Document.prototype.deleteAttribute = function (name) { 18248 return this.$delete_attribute(name) 18249}; 18250 18251/** 18252 * Determine if the attribute has been locked by being assigned in document options. 18253 * 18254 * @param {string} key - The attribute key to check 18255 * 18256 * @returns {boolean} - true if the attribute is locked, false otherwise 18257 * @memberof Document 18258 */ 18259Document.prototype.isAttributeLocked = function (key) { 18260 return this['$attribute_locked?'](key) 18261}; 18262 18263/** 18264 * Restore the attributes to the previously saved state (attributes in header). 18265 * 18266 * @memberof Document 18267 */ 18268Document.prototype.restoreAttributes = function () { 18269 return this.$restore_attributes() 18270}; 18271 18272/** 18273 * Parse the AsciiDoc source stored in the {Reader} into an abstract syntax tree. 18274 * 18275 * If the data parameter is not nil, create a new {PreprocessorReader} and assigned it to the reader property of this object. 18276 * Otherwise, continue with the reader that was created when the {Document} was instantiated. 18277 * Pass the reader to {Parser.parse} to parse the source data into an abstract syntax tree. 18278 * 18279 * If parsing has already been performed, this method returns without performing any processing. 18280 * 18281 * @param {string|Array<string>} [data] - The optional replacement AsciiDoc source data as a String or String Array. (default: undefined) 18282 * 18283 * @returns {Document} - this {Document} 18284 * @memberof Document 18285 */ 18286Document.prototype.parse = function (data) { 18287 return this.$parse(data) 18288}; 18289 18290/** 18291 * Read the docinfo file(s) for inclusion in the document template 18292 * 18293 * If the docinfo1 attribute is set, read the docinfo.ext file. 18294 * If the docinfo attribute is set, read the doc-name.docinfo.ext file. 18295 * If the docinfo2 attribute is set, read both files in that order. 18296 * 18297 * @param {string} docinfoLocation - The Symbol location of the docinfo (e.g., head, footer, etc). (default: head) 18298 * @param {string|undefined} suffix - The suffix of the docinfo file(s). 18299 * If not set, the extension will be set to the outfilesuffix. (default: undefined) 18300 * 18301 * @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. 18302 * @memberof Document 18303 */ 18304Document.prototype.getDocinfo = function (docinfoLocation, suffix) { 18305 return this.$docinfo(docinfoLocation, suffix) 18306}; 18307 18308/** 18309 * @param {string} [docinfoLocation] - A {string} for checking docinfo extensions at a given location (head or footer) (default: head) 18310 * @returns {boolean} 18311 * @memberof Document 18312 */ 18313Document.prototype.hasDocinfoProcessors = function (docinfoLocation) { 18314 return this['$docinfo_processors?'](docinfoLocation) 18315}; 18316 18317/** 18318 * Increment the specified counter and store it in the block's attributes. 18319 * 18320 * @param {string} counterName - the String name of the counter attribute 18321 * @param {Block} block - the {Block} on which to save the counter 18322 * 18323 * @returns {number} - the next number in the sequence for the specified counter 18324 * @memberof Document 18325 */ 18326Document.prototype.incrementAndStoreCounter = function (counterName, block) { 18327 return this.$increment_and_store_counter(counterName, block) 18328}; 18329 18330/** 18331 * @deprecated Please use {Document#incrementAndStoreCounter} method. 18332 * @memberof Document 18333 */ 18334Document.prototype.counterIncrement = Document.prototype.incrementAndStoreCounter; 18335 18336/** 18337 * Get the named counter and take the next number in the sequence. 18338 * 18339 * @param {string} name - the String name of the counter 18340 * @param {string|number} seed - the initial value as a String or Integer 18341 * 18342 * @returns {number} the next number in the sequence for the specified counter 18343 * @memberof Document 18344 */ 18345Document.prototype.counter = function (name, seed) { 18346 return this.$counter(name, seed) 18347}; 18348 18349/** 18350 * A read-only integer value indicating the level of security that should be enforced while processing this document. 18351 * The value must be set in the Document constructor using the "safe" option. 18352 * 18353 * A value of 0 (UNSAFE) disables any of the security features enforced by Asciidoctor. 18354 * 18355 * A value of 1 (SAFE) closely parallels safe mode in AsciiDoc. 18356 * 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. 18357 * 18358 * A value of 10 (SERVER) disallows the document from setting attributes that would affect the conversion of the document, 18359 * in addition to all the security features of SafeMode.SAFE. 18360 * For instance, this level forbids changing the backend or source-highlighter using an attribute defined in the source document header. 18361 * This is the most fundamental level of security for server deployments (hence the name). 18362 * 18363 * 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, 18364 * in addition to all the security features of SafeMode.SECURE. 18365 * In particular, it disallows use of the include::[] directive and the embedding of binary content (data uri), stylesheets and JavaScripts referenced by the document. 18366 * (Asciidoctor and trusted extensions may still be allowed to embed trusted content into the document). 18367 * 18368 * Since Asciidoctor is aiming for wide adoption, 20 (SECURE) is the default value and is recommended for server deployments. 18369 * 18370 * A value of 100 (PARANOID) is planned to disallow the use of passthrough macros and prevents the document from setting any known attributes, 18371 * in addition to all the security features of SafeMode.SECURE. 18372 * Please note that this level is not currently implemented (and therefore not enforced)! 18373 * 18374 * @returns {number} - An integer value indicating the level of security 18375 * @memberof Document 18376 */ 18377Document.prototype.getSafe = function () { 18378 return this.safe 18379}; 18380 18381/** 18382 * Get the Boolean AsciiDoc compatibility mode. 18383 * Enabling this attribute activates the following syntax changes: 18384 * 18385 * * single quotes as constrained emphasis formatting marks 18386 * * single backticks parsed as inline literal, formatted as monospace 18387 * * single plus parsed as constrained, monospaced inline formatting 18388 * * double plus parsed as constrained, monospaced inline formatting 18389 * 18390 * @returns {boolean} 18391 * @memberof Document 18392 */ 18393Document.prototype.getCompatMode = function () { 18394 return this.compat_mode 18395}; 18396 18397/** 18398 * Get the Boolean flag that indicates whether source map information should be tracked by the parser. 18399 * @returns {boolean} 18400 * @memberof Document 18401 */ 18402Document.prototype.getSourcemap = function () { 18403 const sourcemap = this.sourcemap; 18404 return sourcemap === Opal.nil ? false : sourcemap 18405}; 18406 18407/** 18408 * Set the Boolean flag that indicates whether source map information should be tracked by the parser. 18409 * @param {boolean} value 18410 * @memberof Document 18411 */ 18412Document.prototype.setSourcemap = function (value) { 18413 this.sourcemap = value; 18414}; 18415 18416/** 18417 * Get the JSON of document counters. 18418 * @returns {Object} 18419 * @memberof Document 18420 */ 18421Document.prototype.getCounters = function () { 18422 return fromHash(this.counters) 18423}; 18424 18425/** 18426 * @returns {Object} 18427 * @memberof Document 18428 */ 18429Document.prototype.getCallouts = function () { 18430 return this.$callouts() 18431}; 18432 18433/** 18434 * Get the String base directory for converting this document. 18435 * 18436 * Defaults to directory of the source file. 18437 * If the source is a string, defaults to the current directory. 18438 * @returns {string} 18439 * @memberof Document 18440 */ 18441Document.prototype.getBaseDir = function () { 18442 return this.base_dir 18443}; 18444 18445/** 18446 * Get the JSON of resolved options used to initialize this {Document}. 18447 * @returns {Object} 18448 * @memberof Document 18449 */ 18450Document.prototype.getOptions = function () { 18451 return fromHash(this.options) 18452}; 18453 18454/** 18455 * Get the outfilesuffix defined at the end of the header. 18456 * @returns {string} 18457 * @memberof Document 18458 */ 18459Document.prototype.getOutfilesuffix = function () { 18460 return this.outfilesuffix 18461}; 18462 18463/** 18464 * Get a reference to the parent Document of this nested document. 18465 * @returns {Document|undefined} 18466 * @memberof Document 18467 */ 18468Document.prototype.getParentDocument = function () { 18469 const parentDocument = this.parent_document; 18470 return parentDocument === Opal.nil ? undefined : parentDocument 18471}; 18472 18473/** 18474 * Get the {Reader} associated with this document. 18475 * @returns {Object} 18476 * @memberof Document 18477 */ 18478Document.prototype.getReader = function () { 18479 return this.reader 18480}; 18481 18482/** 18483 * Get the {Converter} instance being used to convert the current {Document}. 18484 * @returns {Object} 18485 * @memberof Document 18486 */ 18487Document.prototype.getConverter = function () { 18488 return this.converter 18489}; 18490 18491/** 18492 * Get the activated {Extensions.Registry} associated with this document. 18493 * @returns {Extensions/Registry} 18494 * @memberof Document 18495 */ 18496Document.prototype.getExtensions = function () { 18497 const extensions = this.extensions; 18498 return extensions === Opal.nil ? undefined : extensions 18499}; 18500 18501// Document.Title API 18502 18503/** 18504 * A partitioned title (i.e., title & subtitle). 18505 * @namespace 18506 * @module Document/Title 18507 */ 18508const Title = Document.Title; 18509 18510/** 18511 * @returns {string} 18512 * @memberof Document/Title 18513 */ 18514Title.prototype.getMain = function () { 18515 return this.main 18516}; 18517 18518/** 18519 * @returns {string} 18520 * @memberof Document/Title 18521 */ 18522Title.prototype.getCombined = function () { 18523 return this.combined 18524}; 18525 18526/** 18527 * @returns {string} 18528 * @memberof Document/Title 18529 */ 18530Title.prototype.getSubtitle = function () { 18531 const subtitle = this.subtitle; 18532 return subtitle === Opal.nil ? undefined : subtitle 18533}; 18534 18535/** 18536 * @returns {boolean} 18537 * @memberof Document/Title 18538 */ 18539Title.prototype.isSanitized = function () { 18540 const sanitized = this['$sanitized?'](); 18541 return sanitized === Opal.nil ? false : sanitized 18542}; 18543 18544/** 18545 * @returns {boolean} 18546 * @memberof Document/Title 18547 */ 18548Title.prototype.hasSubtitle = function () { 18549 return this['$subtitle?']() 18550}; 18551 18552// Inline API 18553 18554/** 18555 * Methods for managing inline elements in AsciiDoc block. 18556 * @namespace 18557 * @extends AbstractNode 18558 */ 18559const Inline = Opal.Asciidoctor.Inline; 18560 18561/** 18562 * Create a new Inline element. 18563 * @param {AbstractBlock} parent 18564 * @param {string} context 18565 * @param {string|undefined} text 18566 * @param {Object|undefined} opts 18567 * @returns {Inline} - a new Inline element 18568 * @memberof Inline 18569 */ 18570Inline.create = function (parent, context, text, opts) { 18571 return this.$new(parent, context, text, prepareOptions(opts)) 18572}; 18573 18574/** 18575 * Get the converted content for this inline node. 18576 * 18577 * @returns {string} - the converted String content for this inline node 18578 * @memberof Inline 18579 */ 18580Inline.prototype.convert = function () { 18581 return this.$convert() 18582}; 18583 18584/** 18585 * Get the converted String text of this Inline node, if applicable. 18586 * 18587 * @returns {string|undefined} - the converted String text for this Inline node, or undefined if not applicable for this node. 18588 * @memberof Inline 18589 */ 18590Inline.prototype.getText = function () { 18591 const text = this.$text(); 18592 return text === Opal.nil ? undefined : text 18593}; 18594 18595/** 18596 * Get the String sub-type (aka qualifier) of this Inline node. 18597 * 18598 * This value is used to distinguish different variations of the same node 18599 * category, such as different types of anchors. 18600 * 18601 * @returns {string} - the string sub-type of this Inline node. 18602 * @memberof Inline 18603 */ 18604Inline.prototype.getType = function () { 18605 return this.$type() 18606}; 18607 18608/** 18609 * Get the primary String target of this Inline node. 18610 * 18611 * @returns {string|undefined} - the string target of this Inline node. 18612 * @memberof Inline 18613 */ 18614Inline.prototype.getTarget = function () { 18615 const target = this.$target(); 18616 return target === Opal.nil ? undefined : target 18617}; 18618 18619/** 18620 * Returns the converted alt text for this inline image. 18621 * 18622 * @returns {string} - the String value of the alt attribute. 18623 * @memberof Inline 18624 */ 18625Inline.prototype.getAlt = function () { 18626 return this.$alt() 18627}; 18628 18629// List API 18630 18631/** 18632 * Methods for managing AsciiDoc lists (ordered, unordered and description lists). 18633 * @namespace 18634 * @extends AbstractBlock 18635 */ 18636const List = Opal.Asciidoctor.List; 18637 18638/** 18639 * Checks if the {@link List} contains any child {@link ListItem}. 18640 * 18641 * @memberof List 18642 * @returns {boolean} - whether the {@link List} has child {@link ListItem}. 18643 */ 18644List.prototype.hasItems = function () { 18645 return this['$items?']() 18646}; 18647 18648/** 18649 * Get the Array of {@link ListItem} nodes for this {@link List}. 18650 * 18651 * @returns {Array<ListItem>} - an Array of {@link ListItem} nodes. 18652 * @memberof List 18653 */ 18654List.prototype.getItems = function () { 18655 return this.blocks 18656}; 18657 18658// ListItem API 18659 18660/** 18661 * Methods for managing items for AsciiDoc olists, ulist, and dlists. 18662 * 18663 * 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]. 18664 * If a description is not set, then the second entry in the tuple is nil. 18665 * @namespace 18666 * @extends AbstractBlock 18667 */ 18668const ListItem = Opal.Asciidoctor.ListItem; 18669 18670/** 18671 * Get the converted String text of this {@link ListItem} node. 18672 * 18673 * @returns {string} - the converted String text for this {@link ListItem} node. 18674 * @memberof ListItem 18675 */ 18676ListItem.prototype.getText = function () { 18677 return this.$text() 18678}; 18679 18680/** 18681 * Set the String source text of this {@link ListItem} node. 18682 * 18683 * @returns {string} - the new String text assigned to this {@link ListItem} 18684 * @memberof ListItem 18685 */ 18686ListItem.prototype.setText = function (text) { 18687 return this['$text='](text) 18688}; 18689 18690/** 18691 * A convenience method that checks whether the text of this {@link ListItem} is not blank (i.e. not undefined or empty string). 18692 * 18693 * @returns {boolean} - whether the text is not blank 18694 * @memberof ListItem 18695 */ 18696ListItem.prototype.hasText = function () { 18697 return this['$text?']() 18698}; 18699 18700/** 18701 * Get the {string} used to mark this {@link ListItem}. 18702 * 18703 * @returns {string} 18704 * @memberof ListItem 18705 */ 18706ListItem.prototype.getMarker = function () { 18707 return this.marker 18708}; 18709 18710/** 18711 * Set the {string} used to mark this {@link ListItem}. 18712 * 18713 * @param {string} marker - the {string} used to mark this {@link ListItem} 18714 * @memberof ListItem 18715 */ 18716ListItem.prototype.setMarker = function (marker) { 18717 this.marker = marker; 18718}; 18719 18720/** 18721 * Get the {@link List} to which this {@link ListItem} is attached. 18722 * 18723 * @returns {List} - the {@link List} object to which this {@link ListItem} is attached, 18724 * or undefined if this node has no parent. 18725 * @memberof ListItem 18726 */ 18727ListItem.prototype.getList = function () { 18728 return this.$list() 18729}; 18730 18731/** 18732 * @see {@link ListItem#getList} 18733 * @memberof ListItem 18734 */ 18735ListItem.prototype.getParent = ListItem.prototype.getList; 18736 18737// Reader API 18738 18739/** @namespace */ 18740const Reader = Opal.Asciidoctor.Reader; 18741 18742/** 18743 * Push source onto the front of the reader and switch the context based on the file, document-relative path and line information given. 18744 * 18745 * This method is typically used in an IncludeProcessor to add source read from the target specified. 18746 * 18747 * @param {string} data 18748 * @param {string|undefined} file 18749 * @param {string|undefined} path 18750 * @param {number} lineno - The line number 18751 * @param {Object} attributes - a JSON of attributes 18752 * @returns {Reader} - this {Reader} object. 18753 * @memberof Reader 18754 */ 18755Reader.prototype.pushInclude = function (data, file, path, lineno, attributes) { 18756 return this.$push_include(data, file, path, lineno, toHash(attributes)) 18757}; 18758 18759/** 18760 * Get the current location of the reader's cursor, which encapsulates the file, dir, path, and lineno of the file being read. 18761 * 18762 * @returns {Cursor} 18763 * @memberof Reader 18764 */ 18765Reader.prototype.getCursor = function () { 18766 return this.$cursor() 18767}; 18768 18769/** 18770 * Get the remaining unprocessed lines, without consuming them, as an {Array} of {string}. 18771 * 18772 * Lines will not be consumed from the Reader (ie. you will be able to read these lines again). 18773 * 18774 * @returns {Array<string>} - the remaining unprocessed lines as an {Array} of {string}. 18775 * @memberof Reader 18776 */ 18777Reader.prototype.getLines = function () { 18778 return this.$lines() 18779}; 18780 18781/** 18782 * Get the remaining unprocessed lines, without consuming them, as a {string}. 18783 * 18784 * Lines will not be consumed from the Reader (ie. you will be able to read these lines again). 18785 * 18786 * @returns {string} - the remaining unprocessed lines as a {string} (joined by linefeed characters). 18787 * @memberof Reader 18788 */ 18789Reader.prototype.getString = function () { 18790 return this.$string() 18791}; 18792 18793/** 18794 * Check whether there are any lines left to read. 18795 * If a previous call to this method resulted in a value of false, immediately returned the cached value. 18796 * Otherwise, delegate to peekLine to determine if there is a next line available. 18797 * 18798 * @returns {boolean} - true if there are more lines, false if there are not. 18799 * @memberof Reader 18800 */ 18801Reader.prototype.hasMoreLines = function () { 18802 return this['$has_more_lines?']() 18803}; 18804 18805/** 18806 * Check whether this reader is empty (contains no lines). 18807 * 18808 * @returns {boolean} - true if there are no more lines to peek, otherwise false. 18809 * @memberof Reader 18810 */ 18811Reader.prototype.isEmpty = function () { 18812 return this['$empty?']() 18813}; 18814 18815/** 18816 * Peek at the next line. 18817 * Processes the line if not already marked as processed, but does not consume it (ie. you will be able to read this line again). 18818 * 18819 * This method will probe the reader for more lines. 18820 * If there is a next line that has not previously been visited, the line is passed to the Reader#processLine method to be initialized. 18821 * This call gives sub-classes the opportunity to do preprocessing. 18822 * 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. 18823 * 18824 * If hasMoreLines is called immediately before peekLine, the direct flag is implicitly true (since the line is flagged as visited). 18825 * 18826 * @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) 18827 * @returns {string} - the next line as a {string} if there are lines remaining. 18828 * @memberof Reader 18829 */ 18830Reader.prototype.peekLine = function (direct) { 18831 direct = direct || false; 18832 const line = this.$peek_line(direct); 18833 return line === Opal.nil ? undefined : line 18834}; 18835 18836/** 18837 * Consume, preprocess, and return the next line. 18838 * 18839 * Line will be consumed from the Reader (ie. you won't be able to read this line again). 18840 * 18841 * @returns {string} - the next line as a {string} if data is present. 18842 * @memberof Reader 18843 */ 18844Reader.prototype.readLine = function () { 18845 const line = this.$read_line(); 18846 return line === Opal.nil ? undefined : line 18847}; 18848 18849/** 18850 * Consume, preprocess, and return the remaining lines. 18851 * 18852 * This method calls Reader#readLine repeatedly until all lines are consumed and returns the lines as an {Array} of {string}. 18853 * This method differs from Reader#getLines in that it processes each line in turn, hence triggering any preprocessors implemented in sub-classes. 18854 * 18855 * Lines will be consumed from the Reader (ie. you won't be able to read these lines again). 18856 * 18857 * @returns {Array<string>} - the lines read as an {Array} of {string}. 18858 * @memberof Reader 18859 */ 18860Reader.prototype.readLines = function () { 18861 return this.$read_lines() 18862}; 18863 18864/** 18865 * Consume, preprocess, and return the remaining lines joined as a {string}. 18866 * 18867 * Delegates to Reader#readLines, then joins the result. 18868 * 18869 * Lines will be consumed from the Reader (ie. you won't be able to read these lines again). 18870 * 18871 * @returns {string} - the lines read joined as a {string} 18872 * @memberof Reader 18873 */ 18874Reader.prototype.read = function () { 18875 return this.$read() 18876}; 18877 18878/** 18879 * Advance to the next line by discarding the line at the front of the stack. 18880 * 18881 * @returns {boolean} - a Boolean indicating whether there was a line to discard. 18882 * @memberof Reader 18883 */ 18884Reader.prototype.advance = function () { 18885 return this.$advance() 18886}; 18887 18888// Cursor API 18889 18890/** @namespace */ 18891const Cursor = Opal.Asciidoctor.Reader.Cursor; 18892 18893/** 18894 * Get the file associated to the cursor. 18895 * @returns {string|undefined} 18896 * @memberof Cursor 18897 */ 18898Cursor.prototype.getFile = function () { 18899 const file = this.file; 18900 return file === Opal.nil ? undefined : file 18901}; 18902 18903/** 18904 * Get the directory associated to the cursor. 18905 * @returns {string|undefined} - the directory associated to the cursor 18906 * @memberof Cursor 18907 */ 18908Cursor.prototype.getDirectory = function () { 18909 const dir = this.dir; 18910 return dir === Opal.nil ? undefined : dir 18911}; 18912 18913/** 18914 * Get the path associated to the cursor. 18915 * @returns {string|undefined} - the path associated to the cursor (or '<stdin>') 18916 * @memberof Cursor 18917 */ 18918Cursor.prototype.getPath = function () { 18919 const path = this.path; 18920 return path === Opal.nil ? undefined : path 18921}; 18922 18923/** 18924 * Get the line number of the cursor. 18925 * @returns {number|undefined} - the line number of the cursor 18926 * @memberof Cursor 18927 */ 18928Cursor.prototype.getLineNumber = function () { 18929 return this.lineno 18930}; 18931 18932// Logger API (available in Asciidoctor 1.5.7+) 18933 18934function initializeLoggerFormatterClass (className, functions) { 18935 const superclass = Opal.const_get_qualified(Opal.Logger, 'Formatter'); 18936 return initializeClass(superclass, className, functions, {}, { 18937 call: function (args) { 18938 for (let i = 0; i < args.length; i++) { 18939 // convert all (Opal) Hash arguments to JSON. 18940 if (typeof args[i] === 'object' && '$$smap' in args[i]) { 18941 args[i] = fromHash(args[i]); 18942 } 18943 } 18944 return args 18945 } 18946 }) 18947} 18948 18949function initializeLoggerClass (className, functions) { 18950 const superClass = Opal.const_get_qualified(Opal.Asciidoctor, 'Logger'); 18951 return initializeClass(superClass, className, functions, {}, { 18952 add: function (args) { 18953 if (args.length >= 2 && typeof args[2] === 'object' && '$$smap' in args[2]) { 18954 const message = args[2]; 18955 const messageObject = fromHash(message); 18956 messageObject.getText = function () { 18957 return this.text 18958 }; 18959 messageObject.getSourceLocation = function () { 18960 return this.source_location 18961 }; 18962 messageObject.$inspect = function () { 18963 const sourceLocation = this.getSourceLocation(); 18964 if (sourceLocation) { 18965 return sourceLocation.getPath() + ': line ' + sourceLocation.getLineNumber() + ': ' + this.getText() 18966 } else { 18967 return this.getText() 18968 } 18969 }; 18970 args[2] = messageObject; 18971 } 18972 if (args.length >= 1) { 18973 args[1] = args[1] === Opal.nil ? undefined : args[1]; 18974 } 18975 return args 18976 } 18977 }) 18978} 18979 18980/** 18981 * @namespace 18982 */ 18983const LoggerManager = Opal.const_get_qualified(Opal.Asciidoctor, 'LoggerManager', true); 18984 18985// Alias 18986Opal.Asciidoctor.LoggerManager = LoggerManager; 18987 18988/** 18989 * @memberof LoggerManager 18990 */ 18991LoggerManager.getLogger = function () { 18992 return this.$logger() 18993}; 18994 18995/** 18996 * @memberof LoggerManager 18997 */ 18998LoggerManager.setLogger = function (logger) { 18999 this['$logger='](logger); 19000}; 19001 19002/** 19003 * @memberof LoggerManager 19004 */ 19005LoggerManager.newLogger = function (name, functions) { 19006 return initializeLoggerClass(name, functions).$new() 19007}; 19008 19009/** 19010 * @memberof LoggerManager 19011 */ 19012LoggerManager.newFormatter = function (name, functions) { 19013 return initializeLoggerFormatterClass(name, functions).$new() 19014}; 19015 19016/** 19017 * @namespace 19018 */ 19019const LoggerSeverity = Opal.const_get_qualified(Opal.Logger, 'Severity', true); 19020 19021// Alias 19022Opal.Asciidoctor.LoggerSeverity = LoggerSeverity; 19023 19024/** 19025 * @memberof LoggerSeverity 19026 */ 19027LoggerSeverity.get = function (severity) { 19028 return LoggerSeverity.$constants()[severity] 19029}; 19030 19031/** 19032 * @namespace 19033 */ 19034const LoggerFormatter = Opal.const_get_qualified(Opal.Logger, 'Formatter', true); 19035 19036// Alias 19037Opal.Asciidoctor.LoggerFormatter = LoggerFormatter; 19038 19039/** 19040 * @memberof LoggerFormatter 19041 */ 19042LoggerFormatter.prototype.call = function (severity, time, programName, message) { 19043 return this.$call(LoggerSeverity.get(severity), time, programName, message) 19044}; 19045 19046/** 19047 * @namespace 19048 */ 19049const MemoryLogger = Opal.const_get_qualified(Opal.Asciidoctor, 'MemoryLogger', true); 19050 19051// Alias 19052Opal.Asciidoctor.MemoryLogger = MemoryLogger; 19053 19054/** 19055 * Create a new MemoryLogger. 19056 * @returns {MemoryLogger} - a MemoryLogger 19057 * @memberof MemoryLogger 19058 */ 19059MemoryLogger.create = function () { 19060 return this.$new() 19061}; 19062 19063/** 19064 * @returns {Array<Object>} - a list of messages 19065 * @memberof MemoryLogger 19066 */ 19067MemoryLogger.prototype.getMessages = function () { 19068 const messages = this.messages; 19069 const result = []; 19070 for (let i = 0; i < messages.length; i++) { 19071 const message = messages[i]; 19072 const messageObject = fromHash(message); 19073 if (typeof messageObject.message === 'string') { 19074 messageObject.getText = function () { 19075 return this.message 19076 }; 19077 } else { 19078 // also convert the message attribute 19079 messageObject.message = fromHash(messageObject.message); 19080 messageObject.getText = function () { 19081 return this.message.text 19082 }; 19083 } 19084 messageObject.getSeverity = function () { 19085 return this.severity.toString() 19086 }; 19087 messageObject.getSourceLocation = function () { 19088 return this.message.source_location 19089 }; 19090 result.push(messageObject); 19091 } 19092 return result 19093}; 19094 19095const Logging = Opal.const_get_qualified(Opal.Asciidoctor, 'Logging', true); 19096 19097Opal.Asciidoctor.Logging = Logging; 19098 19099Logging.getLogger = function () { 19100 return LoggerManager.$logger() 19101}; 19102 19103Logging.createLogMessage = function (text, context) { 19104 return Logging.prototype.$message_with_context(text, toHash(context)) 19105}; 19106 19107// alias 19108 19109/** 19110 * @memberof Reader 19111 */ 19112Reader.prototype.getLogger = Logging.getLogger; 19113/** 19114 * @memberof Reader 19115 */ 19116Reader.prototype.createLogMessage = Logging.createLogMessage; 19117 19118/** 19119 * @memberof AbstractNode 19120 */ 19121AbstractNode.prototype.getLogger = Logging.getLogger; 19122/** 19123 * @memberof AbstractNode 19124 */ 19125AbstractNode.prototype.createLogMessage = Logging.createLogMessage; 19126 19127/** 19128 * @namespace 19129 */ 19130const Logger = Opal.const_get_qualified(Opal.Asciidoctor, 'Logger', true); 19131 19132// Alias 19133Opal.Asciidoctor.Logger = Logger; 19134 19135/** 19136 * @returns {number|undefined} - the maximum severity 19137 * @memberof Logger 19138 */ 19139Logger.prototype.getMaxSeverity = function () { 19140 const result = this.max_severity; 19141 return result === Opal.nil ? undefined : result 19142}; 19143/** 19144 * @returns {LoggerFormatter} - the formatter 19145 * @memberof Logger 19146 */ 19147Logger.prototype.getFormatter = function () { 19148 return this.formatter 19149}; 19150/** 19151 * @param {LoggerFormatter} formatter - the formatter 19152 * @memberof Logger 19153 */ 19154Logger.prototype.setFormatter = function (formatter) { 19155 this.formatter = formatter; 19156}; 19157/** 19158 * @returns {number} - the logging severity threshold 19159 * @memberof Logger 19160 */ 19161Logger.prototype.getLevel = function () { 19162 return this.level 19163}; 19164/** 19165 * @param {number} level - the logging severity threshold 19166 * @memberof Logger 19167 */ 19168Logger.prototype.setLevel = function (level) { 19169 this.level = level; 19170}; 19171/** 19172 * @returns {string} - the program name 19173 * @memberof Logger 19174 */ 19175Logger.prototype.getProgramName = function () { 19176 return this.progname 19177}; 19178/** 19179 * @param {string} programName - the program name 19180 * @memberof Logger 19181 */ 19182Logger.prototype.setProgramName = function (programName) { 19183 this.progname = programName; 19184}; 19185 19186const RubyLogger = Opal.const_get_qualified('::', 'Logger'); 19187 19188const log = function (logger, level, message) { 19189 logger['$' + level](message); 19190}; 19191RubyLogger.prototype.add = function (severity, message, programName) { 19192 const severityValue = typeof severity === 'string' ? LoggerSeverity[severity.toUpperCase()] : severity; 19193 this.$add(severityValue, message, programName); 19194}; 19195RubyLogger.prototype.log = RubyLogger.prototype.add; 19196RubyLogger.prototype.debug = function (message) { 19197 log(this, 'debug', message); 19198}; 19199RubyLogger.prototype.info = function (message) { 19200 log(this, 'info', message); 19201}; 19202RubyLogger.prototype.warn = function (message) { 19203 log(this, 'warn', message); 19204}; 19205RubyLogger.prototype.error = function (message) { 19206 log(this, 'error', message); 19207}; 19208RubyLogger.prototype.fatal = function (message) { 19209 log(this, 'fatal', message); 19210}; 19211RubyLogger.prototype.isDebugEnabled = function () { 19212 return this['$debug?']() 19213}; 19214RubyLogger.prototype.isInfoEnabled = function () { 19215 return this['$info?']() 19216}; 19217RubyLogger.prototype.isWarnEnabled = function () { 19218 return this['$warn?']() 19219}; 19220RubyLogger.prototype.isErrorEnabled = function () { 19221 return this['$error?']() 19222}; 19223RubyLogger.prototype.isFatalEnabled = function () { 19224 return this['$fatal?']() 19225}; 19226 19227/** 19228 * @namespace 19229 */ 19230const NullLogger = Opal.const_get_qualified(Opal.Asciidoctor, 'NullLogger', true); 19231 19232// Alias 19233Opal.Asciidoctor.NullLogger = NullLogger; 19234 19235/** 19236 * Create a new NullLogger. 19237 * @returns {NullLogger} - a NullLogger 19238 * @memberof NullLogger 19239 */ 19240NullLogger.create = function () { 19241 return this.$new() 19242}; 19243 19244/** 19245 * @returns {number|undefined} - the maximum severity 19246 * @memberof NullLogger 19247 */ 19248NullLogger.prototype.getMaxSeverity = function () { 19249 return this.max_severity 19250}; 19251 19252// Alias 19253Opal.Asciidoctor.StopIteration = Opal.StopIteration; 19254 19255/** 19256 * @namespace 19257 */ 19258const Timings = Opal.const_get_qualified(Opal.Asciidoctor, 'Timings', true); 19259 19260// Alias 19261Opal.Asciidoctor.Timings = Timings; 19262 19263/** 19264 * Create a new Timings. 19265 * @returns {Timings} - a Timings 19266 * @memberof Timings 19267 */ 19268Timings.create = function () { 19269 return this.$new() 19270}; 19271 19272/** 19273 * Print a report to the specified output. 19274 * The report will include: 19275 * - the time to read and parse source 19276 * - the time to convert document 19277 * - the total time (read, parse and convert) 19278 * @param {RubyLogger|console|Object} [to] - an optional output (by default stdout) 19279 * @param {string} [subject] - an optional subject (usually the file name) 19280 * @memberof Timings 19281 */ 19282Timings.prototype.printReport = function (to, subject) { 19283 let outputFunction; 19284 if (to) { 19285 if (typeof to.$add === 'function') { 19286 outputFunction = function (message) { 19287 to.$add(1, message); 19288 }; 19289 } else if (typeof to.log === 'function') { 19290 outputFunction = to.log; 19291 } else if (typeof to.write === 'function') { 19292 outputFunction = function (message) { 19293 to.write(message, 'utf-8'); 19294 }; 19295 } else { 19296 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)') 19297 } 19298 } else { 19299 outputFunction = function (message) { 19300 Opal.gvars.stdout.$write(message); 19301 }; 19302 } 19303 if (subject) { 19304 outputFunction('Input file: ' + subject); 19305 } 19306 outputFunction(' Time to read and parse source: ' + this.$read_parse().toFixed(2)); 19307 outputFunction(' Time to convert document: ' + this.$convert().toFixed(2)); 19308 outputFunction(' Total time (read, parse and convert): ' + this.$read_parse_convert().toFixed(2)); 19309}; 19310 19311/** 19312 * @namespace 19313 * @description 19314 * This API is experimental and subject to change. 19315 * 19316 * A pluggable adapter for integrating a syntax (aka code) highlighter into AsciiDoc processing. 19317 * 19318 * There are two types of syntax highlighter adapters. The first performs syntax highlighting during the convert phase. 19319 * This adapter type must define a "handlesHighlighting" method that returns true. 19320 * The companion "highlight" method will then be called to handle the "specialcharacters" substitution for source blocks. 19321 * 19322 * The second assumes syntax highlighting is performed on the client (e.g., when the HTML document is loaded). 19323 * This adapter type must define a "hasDocinfo" method that returns true. 19324 * The companion "docinfo" method will then be called to insert markup into the output document. 19325 * The docinfo functionality is available to both adapter types. 19326 * 19327 * Asciidoctor.js provides several a built-in adapter for highlight.js. 19328 * Additional adapters can be registered using SyntaxHighlighter.register. 19329 */ 19330const SyntaxHighlighter = Opal.const_get_qualified(Opal.Asciidoctor, 'SyntaxHighlighter', true); 19331 19332// Alias 19333Opal.Asciidoctor.SyntaxHighlighter = SyntaxHighlighter; 19334 19335/** 19336 * Associates the syntax highlighter class or object with the specified names. 19337 * 19338 * @description This API is experimental and subject to change. 19339 * 19340 * @param {string|Array} names - A {string} name or an {Array} of {string} names 19341 * @param functions - A list of functions representing a {SyntaxHighlighter} or a {SyntaxHighlighter} class to instantiate 19342 * @memberof SyntaxHighlighter 19343 */ 19344SyntaxHighlighter.register = function (names, functions) { 19345 const name = typeof names === 'string' ? names : names[0]; 19346 if (typeof functions === 'function') { 19347 const classObject = functions; 19348 const prototype = classObject.prototype; 19349 const properties = Object.getOwnPropertyNames(prototype); 19350 functions = {}; 19351 for (const propertyIdx in properties) { 19352 const propertyName = properties[propertyIdx]; 19353 functions[propertyName] = prototype[propertyName]; 19354 } 19355 } 19356 const scope = initializeClass(SyntaxHighlighterBase, name, functions, {}, { 19357 format: function (args) { 19358 if (args.length >= 2 && typeof args[2] === 'object' && '$$smap' in args[2]) { 19359 args[2] = fromHash(args[2]); 19360 } 19361 if (args.length >= 1) { 19362 args[1] = args[1] === Opal.nil ? undefined : args[1]; 19363 } 19364 return args 19365 }, 19366 highlight: function (args) { 19367 if (args.length >= 3 && typeof args[3] === 'object' && '$$smap' in args[3]) { 19368 let opts = args[3]; 19369 opts = fromHash(opts); 19370 for (const key in opts) { 19371 const value = opts[key]; 19372 if (key === 'callouts') { 19373 const callouts = fromHashKeys(value); 19374 for (const idx in callouts) { 19375 const callout = callouts[idx]; 19376 for (let i = 0; i < callout.length; i++) { 19377 const items = callout[i]; 19378 for (let j = 0; j < items.length; j++) { 19379 items[j] = items[j] === Opal.nil ? undefined : items[j]; 19380 } 19381 } 19382 } 19383 opts[key] = callouts; 19384 } else { 19385 opts[key] = value === Opal.nil ? undefined : value; 19386 } 19387 } 19388 args[3] = opts; 19389 } 19390 if (args.length >= 2) { 19391 args[2] = args[2] === Opal.nil ? undefined : args[2]; 19392 } 19393 return args 19394 } 19395 }); 19396 for (const functionName in functions) { 19397 if (Object.prototype.hasOwnProperty.call(functions, functionName)) { 19398 (function (functionName) { 19399 const userFunction = functions[functionName]; 19400 if (functionName === 'handlesHighlighting') { 19401 Opal.def(scope, '$highlight?', function () { 19402 return userFunction.call() 19403 }); 19404 } else if (functionName === 'hasDocinfo') { 19405 Opal.def(scope, '$docinfo?', function (location) { 19406 return userFunction.apply(this, [location]) 19407 }); 19408 } 19409 }(functionName)); 19410 } 19411 } 19412 Opal.def(scope, '$name', function () { 19413 return name 19414 }); 19415 SyntaxHighlighter.$register(scope, names); 19416 return scope 19417}; 19418 19419/** 19420 * Retrieves the syntax highlighter class or object registered for the specified name. 19421 * 19422 * @description This API is experimental and subject to change. 19423 * 19424 * @param {string} name - The {string} name of the syntax highlighter to retrieve. 19425 * @returns {SyntaxHighlighter} - the {SyntaxHighlighter} registered for this name. 19426 * @memberof SyntaxHighlighter 19427 */ 19428SyntaxHighlighter.get = function (name) { 19429 const result = SyntaxHighlighter.$for(name); 19430 return result === Opal.nil ? undefined : result 19431}; 19432 19433/** 19434 * @deprecated Please use {SyntaxHighlighter#get} method as "for" is a reserved keyword. 19435 */ 19436SyntaxHighlighter.for = SyntaxHighlighter.get; 19437 19438/** 19439 * @namespace 19440 */ 19441const SyntaxHighlighterBase = Opal.const_get_qualified(SyntaxHighlighter, 'Base', true); 19442 19443// Alias 19444Opal.Asciidoctor.SyntaxHighlighterBase = SyntaxHighlighterBase; 19445 19446/** 19447 * Statically register the current class in the registry for the specified names. 19448 * 19449 * @description This API is experimental and subject to change. 19450 * 19451 * @param {string|Array<string>} names - A {string} name or an {Array} of {string} names 19452 * @memberof SyntaxHighlighterBase 19453 */ 19454SyntaxHighlighterBase.prototype.registerFor = function (names) { 19455 SyntaxHighlighter.$register(this, names); 19456}; 19457 19458// Table API 19459 19460/** 19461 * Methods for managing AsciiDoc tables. 19462 * @namespace 19463 * @extends AbstractBlock 19464 */ 19465const Table = Opal.Asciidoctor.Table; 19466 19467/** 19468 * Create a new Table element. 19469 * @param {AbstractBlock} parent 19470 * @param {Object|undefined} attributes 19471 * @returns {Table} - a new {Table} object 19472 */ 19473Table.create = function (parent, attributes) { 19474 return this.$new(parent, toHash(attributes)) 19475}; 19476 19477/** 19478 * Get the caption of the table. 19479 * @returns {string} 19480 * @memberof Table 19481 */ 19482Table.prototype.getCaption = function () { 19483 return this.caption 19484}; 19485 19486/** 19487 * Get the rows of this table. 19488 * @returns {Table.Rows} - an {Table.Rows} object with the members "head", "body" and "foot" 19489 * @memberof Table 19490 */ 19491Table.prototype.getRows = function () { 19492 return this.rows 19493}; 19494 19495/** 19496 * Get the columns of this table. 19497 * @returns {Array<Column>} 19498 * @memberof Table 19499 */ 19500Table.prototype.getColumns = function () { 19501 return this.columns 19502}; 19503 19504/** 19505 * Get the head rows of this table. 19506 * @returns {Array<Array<Cell>>} - an Array of Array of Cell 19507 * @memberof Table 19508 */ 19509Table.prototype.getHeadRows = function () { 19510 return this.rows.head 19511}; 19512 19513/** 19514 * Check if the table has a head rows. 19515 * @returns {boolean} 19516 * @memberof Table 19517 */ 19518Table.prototype.hasHeadRows = function () { 19519 return this.rows !== Opal.nil && this.rows.head.length > 0 19520}; 19521 19522/** 19523 * Get the body rows of this table. 19524 * @returns {Array<Array<Cell>>} - an Array of Array of Cell 19525 * @memberof Table 19526 */ 19527Table.prototype.getBodyRows = function () { 19528 return this.rows.body 19529}; 19530 19531/** 19532 * Check if the table has a body rows. 19533 * @returns {boolean} 19534 */ 19535Table.prototype.hasBodyRows = function () { 19536 return this.rows !== Opal.nil && this.rows.body.length > 0 19537}; 19538 19539/** 19540 * Get the foot rows of this table. 19541 * @returns {Array<Array<Cell>>} - an Array of Array of Cell 19542 * @memberof Table 19543 */ 19544Table.prototype.getFootRows = function () { 19545 return this.rows.foot 19546}; 19547 19548/** 19549 * Check if the table has a foot rows. 19550 * @returns {boolean} 19551 */ 19552Table.prototype.hasFootRows = function () { 19553 return this.rows !== Opal.nil && this.rows.foot.length > 0 19554}; 19555 19556/** 19557 * Check if the table has a header option set. 19558 * @returns {boolean} 19559 * @memberof Table 19560 */ 19561Table.prototype.hasHeaderOption = function () { 19562 return this.has_header_option 19563}; 19564 19565/** 19566 * Check if the table has the footer option set. 19567 * @returns {boolean} 19568 * @memberof Table 19569 */ 19570Table.prototype.hasFooterOption = function () { 19571 return this.isOption('footer') 19572}; 19573 19574/** 19575 * Check if the table has the autowidth option set. 19576 * @returns {boolean} 19577 * @memberof Table 19578 */ 19579Table.prototype.hasAutowidthOption = function () { 19580 return this.isOption('autowidth') 19581}; 19582 19583/** 19584 * Get the number of rows in the table. 19585 * Please note that the header and footer rows are also counted. 19586 * @returns {number|undefined} 19587 * @memberof Table 19588 */ 19589Table.prototype.getRowCount = function () { 19590 return this.getAttribute('rowcount') 19591}; 19592 19593/** 19594 * Set the number of rows in the table. 19595 * Please note that the header and footer rows are also counted. 19596 * @param {number} value - the value 19597 * @memberof Table 19598 */ 19599Table.prototype.setRowCount = function (value) { 19600 this.setAttribute('rowcount', value); 19601}; 19602 19603/** 19604 * Get the number of columns in the table. 19605 * @returns {number|undefined} 19606 * @memberof Table 19607 */ 19608Table.prototype.getColumnCount = function () { 19609 return this.getAttribute('colcount') 19610}; 19611 19612/** 19613 * Set the number of columns in the table. 19614 * @param {number} value - the value 19615 * @memberof Table 19616 */ 19617Table.prototype.setColumnCount = function (value) { 19618 this.setAttribute('colcount', value); 19619}; 19620 19621// Rows 19622 19623/** 19624 * @namespace 19625 */ 19626const Rows = Opal.Asciidoctor.Table.Rows; 19627 19628/** 19629 * Create a new Rows element. 19630 * @param {array<array<Cell>>} head 19631 * @param {array<array<Cell>>} foot 19632 * @param {array<array<Cell>>} body 19633 * @returns Rows 19634 */ 19635Rows.create = function (head, foot, body) { 19636 return this.$new(head, foot, body) 19637}; 19638 19639/** 19640 * Get head rows. 19641 * @returns {array<array<Cell>>} 19642 */ 19643Rows.prototype.getHead = function () { 19644 return this.head 19645}; 19646 19647/** 19648 * Get foot rows. 19649 * @returns {array<array<Cell>>} 19650 */ 19651Rows.prototype.getFoot = function () { 19652 return this.foot 19653}; 19654 19655/** 19656 * Get body rows. 19657 * @returns {array<array<Cell>>} 19658 */ 19659Rows.prototype.getBody = function () { 19660 return this.body 19661}; 19662 19663/** 19664 * Retrieve the rows grouped by section as a nested Array. 19665 * 19666 * Creates a 2-dimensional array of two element entries. 19667 * The first element is the section name as a string. 19668 * The second element is the Array of rows in that section. 19669 * The entries are in document order (head, foot, body). 19670 * @returns {[[string, array<array<Cell>>], [string, array<array<Cell>>], [string, array<array<Cell>>]]} 19671 */ 19672Rows.prototype.bySection = function () { 19673 return [['head', this.head], ['body', this.body], ['foot', this.foot]] 19674}; 19675 19676// Table Column 19677 19678/** 19679 * Methods to manage the columns of an AsciiDoc table. 19680 * In particular, it keeps track of the column specs. 19681 * @namespace 19682 * @extends AbstractNode 19683 */ 19684const Column = Opal.Asciidoctor.Table.Column; 19685 19686/** 19687 * Create a new Column element. 19688 * @param {Table} table 19689 * @param {number} index 19690 * @param {Object|undefined} attributes 19691 * @returns Column 19692 */ 19693Column.create = function (table, index, attributes) { 19694 return this.$new(table, index, toHash(attributes)) 19695}; 19696 19697/** 19698 * Get the column number of this cell. 19699 * @returns {number|undefined} 19700 * @memberof Column 19701 */ 19702Column.prototype.getColumnNumber = function () { 19703 return this.getAttribute('colnumber') 19704}; 19705 19706/** 19707 * Get the width of this cell. 19708 * @returns {string|undefined} 19709 * @memberof Column 19710 */ 19711Column.prototype.getWidth = function () { 19712 return this.getAttribute('width') 19713}; 19714 19715/** 19716 * Get the horizontal align of this cell. 19717 * @returns {string|undefined} 19718 * @memberof Column 19719 */ 19720Column.prototype.getHorizontalAlign = function () { 19721 return this.getAttribute('halign') 19722}; 19723 19724/** 19725 * Get the vertical align of this cell. 19726 * @returns {string|undefined} 19727 * @memberof Column 19728 */ 19729Column.prototype.getVerticalAlign = function () { 19730 return this.getAttribute('valign') 19731}; 19732 19733/** 19734 * Get the style of this cell. 19735 * @returns {string} 19736 * @memberof Column 19737 */ 19738Column.prototype.getStyle = function () { 19739 const style = this.style; 19740 return style === Opal.nil ? undefined : style 19741}; 19742 19743// Table Cell 19744 19745/** 19746 * Methods for managing the cells in an AsciiDoc table. 19747 * @namespace 19748 * @extends AbstractBlock 19749 */ 19750const Cell = Opal.Asciidoctor.Table.Cell; 19751 19752/** 19753 * Create a new Cell element 19754 * @param {Column} column 19755 * @param {string} cellText 19756 * @param {Object|undefined} attributes 19757 * @param {Object|undefined} opts 19758 * @returns {Cell} 19759 */ 19760Cell.create = function (column, cellText, attributes, opts) { 19761 return this.$new(column, cellText, toHash(attributes), toHash(opts)) 19762}; 19763 19764/** 19765 * Get the column span of this {@link Cell} node. 19766 * @returns {number} - An Integer of the number of columns this cell will span (default: undefined) 19767 * @memberof Cell 19768 */ 19769Cell.prototype.getColumnSpan = function () { 19770 const colspan = this.colspan; 19771 return colspan === Opal.nil ? undefined : colspan 19772}; 19773 19774/** 19775 * Set the column span of this {@link Cell} node. 19776 * @param {number} value 19777 * @returns {number} - The new colspan value 19778 * @memberof Cell 19779 */ 19780Cell.prototype.setColumnSpan = function (value) { 19781 return this['$colspan='](value) 19782}; 19783 19784/** 19785 * Get the row span of this {@link Cell} node 19786 * @returns {number|undefined} - An Integer of the number of rows this cell will span (default: undefined) 19787 * @memberof Cell 19788 */ 19789Cell.prototype.getRowSpan = function () { 19790 const rowspan = this.rowspan; 19791 return rowspan === Opal.nil ? undefined : rowspan 19792}; 19793 19794/** 19795 * Set the row span of this {@link Cell} node 19796 * @param {number} value 19797 * @returns {number} - The new rowspan value 19798 * @memberof Cell 19799 */ 19800Cell.prototype.setRowSpan = function (value) { 19801 return this['$rowspan='](value) 19802}; 19803 19804/** 19805 * Get the content of the cell. 19806 * This method should not be used for cells in the head row or that have the literal style. 19807 * @returns {string} 19808 * @memberof Cell 19809 */ 19810Cell.prototype.getContent = function () { 19811 return this.$content() 19812}; 19813 19814/** 19815 * Get the text of the cell. 19816 * @returns {string} 19817 * @memberof Cell 19818 */ 19819Cell.prototype.getText = function () { 19820 return this.$text() 19821}; 19822 19823/** 19824 * Get the source of the cell. 19825 * @returns {string} 19826 * @memberof Cell 19827 */ 19828Cell.prototype.getSource = function () { 19829 return this.$source() 19830}; 19831 19832/** 19833 * Get the lines of the cell. 19834 * @returns {Array<string>} 19835 * @memberof Cell 19836 */ 19837Cell.prototype.getLines = function () { 19838 return this.$lines() 19839}; 19840 19841/** 19842 * Get the line number of the cell. 19843 * @returns {number|undefined} 19844 * @memberof Cell 19845 */ 19846Cell.prototype.getLineNumber = function () { 19847 const lineno = this.$lineno(); 19848 return lineno === Opal.nil ? undefined : lineno 19849}; 19850 19851/** 19852 * Get the source file of the cell. 19853 * @returns {string|undefined} 19854 * @memberof Cell 19855 */ 19856Cell.prototype.getFile = function () { 19857 const file = this.$file(); 19858 return file === Opal.nil ? undefined : file 19859}; 19860 19861/** 19862 * Get the style of the cell. 19863 * @returns {string|undefined} 19864 * @memberof Cell 19865 */ 19866Cell.prototype.getStyle = function () { 19867 const style = this.$style(); 19868 return style === Opal.nil ? undefined : style 19869}; 19870 19871/** 19872 * Get the column of this cell. 19873 * @returns {Column|undefined} 19874 * @memberof Cell 19875 */ 19876Cell.prototype.getColumn = function () { 19877 const column = this.$column(); 19878 return column === Opal.nil ? undefined : column 19879}; 19880 19881/** 19882 * Get the width of this cell. 19883 * @returns {string|undefined} 19884 * @memberof Cell 19885 */ 19886Cell.prototype.getWidth = function () { 19887 return this.getAttribute('width') 19888}; 19889 19890/** 19891 * Get the column width in percentage of this cell. 19892 * @returns {string|undefined} 19893 * @memberof Cell 19894 */ 19895Cell.prototype.getColumnPercentageWidth = function () { 19896 return this.getAttribute('colpcwidth') 19897}; 19898 19899/** 19900 * Get the nested {Document} of this cell when style is 'asciidoc'. 19901 * @returns {Document|undefined} - the nested {Document} 19902 * @memberof Cell 19903 */ 19904Cell.prototype.getInnerDocument = function () { 19905 const innerDocument = this.inner_document; 19906 return innerDocument === Opal.nil ? undefined : innerDocument 19907}; 19908 19909// Templates 19910 19911/** 19912 * @description 19913 * This API is experimental and subject to change. 19914 * 19915 * Please note that this API is currently only available in a Node environment. 19916 * We recommend to use a custom converter if you are running in the browser. 19917 * 19918 * @namespace 19919 * @module Converter/TemplateConverter 19920 */ 19921const TemplateConverter = Opal.Asciidoctor.Converter.TemplateConverter; 19922 19923if (TemplateConverter) { 19924 // Alias 19925 Opal.Asciidoctor.TemplateConverter = TemplateConverter; 19926 19927 /** 19928 * Create a new TemplateConverter. 19929 * @param {string} backend - the backend name 19930 * @param templateDirectories - a list of template directories 19931 * @param {Object} opts - a JSON of options 19932 * @param {string} opts.template_engine - the name of the template engine 19933 * @param {Object} [opts.template_cache] - an optional template cache 19934 * @param {Object} [opts.template_cache.scans] - a JSON of template objects keyed by template name keyed by path patterns 19935 * @param {Object} [opts.template_cache.templates] - a JSON of template objects keyed by file paths 19936 * @returns {TemplateConverter} 19937 * @memberof Converter/TemplateConverter 19938 */ 19939 TemplateConverter.create = function (backend, templateDirectories, opts) { 19940 if (opts && opts.template_cache) { 19941 opts.template_cache = toHash(opts.template_cache); 19942 } 19943 this.$new(backend, templateDirectories, toHash(opts)); 19944 }; 19945 19946 /** 19947 * @returns {Object} - The global cache 19948 * @memberof Converter/TemplateConverter 19949 */ 19950 TemplateConverter.getCache = function () { 19951 const caches = fromHash(this.caches); 19952 if (caches) { 19953 if (caches.scans) { 19954 caches.scans = fromHash(caches.scans); 19955 for (const key in caches.scans) { 19956 caches.scans[key] = fromHash(caches.scans[key]); 19957 } 19958 } 19959 if (caches.templates) { 19960 caches.templates = fromHash(caches.templates); 19961 } 19962 } 19963 return caches 19964 }; 19965 19966 /** 19967 * Clear the global cache. 19968 * @memberof Converter/TemplateConverter 19969 */ 19970 TemplateConverter.clearCache = function () { 19971 this.$clear_caches(); 19972 }; 19973 19974 /** 19975 * Convert an {AbstractNode} to the backend format using the named template. 19976 * 19977 * Looks for a template that matches the value of the template name or, 19978 * if the template name is not specified, the value of the {@see AbstractNode.getNodeName} function. 19979 * 19980 * @param {AbstractNode} node - the AbstractNode to convert 19981 * @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) 19982 * @param {Object} opts - an optional JSON that is passed as local variables to the template. (optional, default: undefined) 19983 * @returns {string} - The {string} result from rendering the template 19984 * @memberof Converter/TemplateConverter 19985 */ 19986 TemplateConverter.prototype.convert = function (node, templateName, opts) { 19987 return this.$convert(node, templateName, toHash(opts)) 19988 }; 19989 19990 /** 19991 * Checks whether there is a template registered with the specified name. 19992 * 19993 * @param {string} name - the {string} template name 19994 * @returns {boolean} - a {boolean} that indicates whether a template is registered for the specified template name. 19995 * @memberof Converter/TemplateConverter 19996 */ 19997 TemplateConverter.prototype.handles = function (name) { 19998 return this['$handles?'](name) 19999 }; 20000 20001 /** 20002 * Converts the {AbstractNode} using only its converted content. 20003 * 20004 * @param {AbstractNode} node 20005 * @returns {string} - the converted {string} content. 20006 * @memberof Converter/TemplateConverter 20007 */ 20008 TemplateConverter.prototype.getContentOnly = function (node) { 20009 return this.$content_only(node) 20010 }; 20011 20012 /** 20013 * Skips conversion of the {AbstractNode}. 20014 * 20015 * @param {AbstractNode} node 20016 * @memberof Converter/TemplateConverter 20017 */ 20018 TemplateConverter.prototype.skip = function (node) { 20019 this.$skip(node); 20020 }; 20021 20022 /** 20023 * Retrieves the templates that this converter manages. 20024 * 20025 * @returns {Object} - a JSON of template objects keyed by template name 20026 * @memberof Converter/TemplateConverter 20027 */ 20028 TemplateConverter.prototype.getTemplates = function () { 20029 return fromHash(this.$templates()) 20030 }; 20031 20032 /** 20033 * Registers a template with this converter. 20034 * 20035 * @param {string} name - the {string} template name 20036 * @param {Object} template - the template object to register 20037 * @returns {Object} - the template object 20038 * @memberof Converter/TemplateConverter 20039 */ 20040 TemplateConverter.prototype.register = function (name, template) { 20041 return this.$register(name, template) 20042 }; 20043 20044 /** 20045 * @namespace 20046 * @description 20047 * This API is experimental and subject to change. 20048 * 20049 * Please note that this API is currently only available in a Node environment. 20050 * We recommend to use a custom converter if you are running in the browser. 20051 * 20052 * A pluggable adapter for integrating a template engine into the built-in template converter. 20053 */ 20054 const TemplateEngine = {}; 20055 TemplateEngine.registry = {}; 20056 20057 // Alias 20058 Opal.Asciidoctor.TemplateEngine = TemplateEngine; 20059 20060 /** 20061 * Register a template engine adapter for the given names. 20062 * @param {string|Array} names - a {string} name or an {Array} of {string} names 20063 * @param {Object} templateEngineAdapter - a template engine adapter instance 20064 * @example 20065 * const fs = require('fs') 20066 * class DotTemplateEngineAdapter { 20067 * constructor () { 20068 * this.doT = require('dot') 20069 * } 20070 * compile (file, _) { 20071 * const templateFn = this.doT.template(fs.readFileSync(file, 'utf8')) 20072 * return { 20073 * render: templateFn 20074 * } 20075 * } 20076 * } 20077 * asciidoctor.TemplateEngine.register('dot, new DotTemplateEngineAdapter()) 20078 * @memberof TemplateEngine 20079 */ 20080 TemplateEngine.register = function (names, templateEngineAdapter) { 20081 if (typeof names === 'string') { 20082 this.registry[names] = templateEngineAdapter; 20083 } else { 20084 // array 20085 for (let i = 0; i < names.length; i++) { 20086 const name = names[i]; 20087 this.registry[name] = templateEngineAdapter; 20088 } 20089 } 20090 }; 20091} 20092 20093/** 20094 * @namespace 20095 * @module Converter/CompositeConverter 20096 */ 20097const CompositeConverter = Opal.Asciidoctor.Converter.CompositeConverter; 20098 20099if (CompositeConverter) { 20100 // Alias 20101 Opal.Asciidoctor.CompositeConverter = CompositeConverter; 20102 20103 /** 20104 * Delegates to the first converter that identifies itself as the handler for the given transform. 20105 * The optional Hash is passed as the last option to the delegate's convert method. 20106 * 20107 * @param node - the AbstractNode to convert 20108 * @param [transform] - the optional {string} transform, or the name of the node if no transform is specified. (optional, default: undefined) 20109 * @param [opts] - an optional JSON that is passed as local variables to the template. (optional, default: undefined) 20110 * @returns The {string} result from the delegate's convert method 20111 * @memberof Converter/CompositeConverter 20112 */ 20113 CompositeConverter.prototype.convert = function (node, transform, opts) { 20114 return this.$convert(node, transform, toHash(opts)) 20115 }; 20116 20117 /** 20118 * Converts the {AbstractNode} using only its converted content. 20119 * 20120 * @param {AbstractNode} node 20121 * @returns {string} - the converted {string} content. 20122 * @memberof Converter/CompositeConverter 20123 */ 20124 CompositeConverter.prototype.getContentOnly = function (node) { 20125 return this.$content_only(node) 20126 }; 20127 20128 /** 20129 * Skips conversion of the {AbstractNode}. 20130 * 20131 * @param {AbstractNode} node 20132 * @memberof Converter/CompositeConverter 20133 */ 20134 CompositeConverter.prototype.skip = function (node) { 20135 this.$skip(node); 20136 }; 20137 20138 /** 20139 * Get the Array of Converter objects in the chain. 20140 * @returns {[Converter]} 20141 * @memberof Converter/CompositeConverter 20142 */ 20143 CompositeConverter.prototype.getConverters = function () { 20144 return this.converters 20145 }; 20146 20147 /** 20148 * Retrieve the converter for the specified transform. 20149 * @param transform 20150 * @returns {Converter|undefined} 20151 * @memberof Converter/CompositeConverter 20152 */ 20153 CompositeConverter.prototype.getConverter = function (transform) { 20154 const converter = this.$converter_for(transform); 20155 return converter === Opal.nil ? undefined : converter 20156 }; 20157 20158 /** 20159 * Find the converter for the specified transform. 20160 * Throw an exception if no converter is found. 20161 * 20162 * @param transform 20163 * @returns {Converter} - the matching converter 20164 * @throws Error if no converter is found 20165 * @memberof Converter/CompositeConverter 20166 */ 20167 CompositeConverter.prototype.findConverter = function (transform) { 20168 return this.$find_converter(transform) 20169 }; 20170} 20171 20172// Converter API 20173 20174/** 20175 * @namespace 20176 * @module Converter 20177 */ 20178const Converter = Opal.const_get_qualified(Opal.Asciidoctor, 'Converter'); 20179 20180// Alias 20181Opal.Asciidoctor.Converter = Converter; 20182 20183/** 20184 * Convert the specified node. 20185 * 20186 * @param {AbstractNode} node - the AbstractNode to convert 20187 * @param {string} transform - an optional String transform that hints at 20188 * which transformation should be applied to this node. 20189 * @param {Object} opts - a JSON of options that provide additional hints about how to convert the node (default: {}) 20190 * @returns the {Object} result of the conversion, typically a {string}. 20191 * @memberof Converter 20192 */ 20193Converter.prototype.convert = function (node, transform, opts) { 20194 return this.$convert(node, transform, toHash(opts)) 20195}; 20196 20197/** 20198 * Create an instance of the converter bound to the specified backend. 20199 * 20200 * @param {string} backend - look for a converter bound to this keyword. 20201 * @param {Object} opts - a JSON of options to pass to the converter (default: {}) 20202 * @returns {Converter} - a converter instance for converting nodes in an Asciidoctor AST. 20203 * @memberof Converter 20204 */ 20205Converter.create = function (backend, opts) { 20206 return this.$create(backend, toHash(opts)) 20207}; 20208 20209// Converter Factory API 20210 20211/** 20212 * @namespace 20213 * @module Converter/Factory 20214 */ 20215const ConverterFactory = Opal.Asciidoctor.Converter.Factory; 20216 20217const ConverterBase = Opal.Asciidoctor.Converter.Base; 20218 20219// Alias 20220Opal.Asciidoctor.ConverterFactory = ConverterFactory; 20221 20222const ConverterBackendTraits = Opal.Asciidoctor.Converter.BackendTraits; 20223 20224// Alias 20225Opal.Asciidoctor.ConverterBackendTraits = ConverterBackendTraits; 20226 20227/** 20228 * Register a custom converter in the global converter factory to handle conversion to the specified backends. 20229 * If the backend value is an asterisk, the converter is used to handle any backend that does not have an explicit converter. 20230 * 20231 * @param converter - The Converter instance to register 20232 * @param backends {Array} - A {string} {Array} of backend names that this converter should be registered to handle (optional, default: ['*']) 20233 * @return {*} - Returns nothing 20234 * @memberof Converter/Factory 20235 */ 20236ConverterFactory.register = function (converter, backends) { 20237 const args = [bridgeConverter(converter)].concat(backends); 20238 return Converter.$register.apply(Converter, args) 20239}; 20240 20241/** 20242 * Retrieves the singleton instance of the converter factory. 20243 * 20244 * @param {boolean} initialize - instantiate the singleton if it has not yet 20245 * been instantiated. If this value is false and the singleton has not yet been 20246 * instantiated, this method returns a fresh instance. 20247 * @returns {Converter/Factory} an instance of the converter factory. 20248 * @memberof Converter/Factory 20249 */ 20250ConverterFactory.getDefault = function (initialize) { 20251 return this.$default(initialize) 20252}; 20253 20254/** 20255 * Create an instance of the converter bound to the specified backend. 20256 * 20257 * @param {string} backend - look for a converter bound to this keyword. 20258 * @param {Object} opts - a JSON of options to pass to the converter (default: {}) 20259 * @returns {Converter} - a converter instance for converting nodes in an Asciidoctor AST. 20260 * @memberof Converter/Factory 20261 */ 20262ConverterFactory.prototype.create = function (backend, opts) { 20263 return this.$create(backend, toHash(opts)) 20264}; 20265 20266/** 20267 * Get the converter registry. 20268 * @returns the registry of converter instances or classes keyed by backend name 20269 * @memberof Converter/Factory 20270 */ 20271ConverterFactory.getRegistry = function () { 20272 return fromHash(Converter.$registry()) 20273}; 20274 20275/** 20276 * Lookup the custom converter registered with this factory to handle the specified backend. 20277 * 20278 * @param {string} backend - The {string} backend name. 20279 * @returns the {Converter} class or instance registered to convert the specified backend or undefined if no match is found. 20280 * @memberof Converter/Factory 20281 */ 20282ConverterFactory.for = function (backend) { 20283 const converter = Converter.$for(backend); 20284 return converter === Opal.nil ? undefined : converter 20285}; 20286 20287/* 20288 * Unregister any custom converter classes that are registered with this factory. 20289 * Intended for testing only! 20290 */ 20291ConverterFactory.unregisterAll = function () { 20292 const internalRegistry = Converter.DefaultFactory.$$cvars['@@registry']; 20293 Converter.DefaultFactory.$$cvars['@@registry'] = toHash({ html5: internalRegistry['$[]']('html5') }); 20294}; 20295 20296// Built-in converter 20297 20298/** 20299 * @namespace 20300 * @module Converter/Html5Converter 20301 */ 20302const Html5Converter = Opal.Asciidoctor.Converter.Html5Converter; 20303 20304// Alias 20305Opal.Asciidoctor.Html5Converter = Html5Converter; 20306 20307/** 20308 * Create a new Html5Converter. 20309 * @returns {Html5Converter} - a Html5Converter 20310 * @memberof Converter/Html5Converter 20311 */ 20312Html5Converter.create = function () { 20313 return this.$new() 20314}; 20315 20316/** 20317 * Converts an {AbstractNode} using the given transform. 20318 * This method must be implemented by a concrete converter class. 20319 * 20320 * @param {AbstractNode} node - The concrete instance of AbstractNode to convert. 20321 * @param {string} [transform] - An optional String transform that hints at which transformation should be applied to this node. 20322 * If a transform is not given, the transform is often derived from the value of the {AbstractNode#getNodeName} property. (optional, default: undefined) 20323 * @param {Object} [opts]- An optional JSON of options hints about how to convert the node. (optional, default: undefined) 20324 * 20325 * @returns {string} - the String result. 20326 * @memberof Converter/Html5Converter 20327 */ 20328Html5Converter.prototype.convert = function (node, transform, opts) { 20329 return this.$convert(node, transform, opts) 20330}; 20331 20332/* global Opal, fromHash, toHash, initializeClass */ 20333// Extensions API 20334 20335/** 20336 * @private 20337 */ 20338const toBlock = function (block) { 20339 // arity is a mandatory field 20340 block.$$arity = block.length; 20341 return block 20342}; 20343 20344const registerExtension = function (registry, type, processor, name) { 20345 if (typeof processor === 'object' || processor.$$is_class) { 20346 // processor is an instance or a class 20347 return registry['$' + type](processor, name) 20348 } else { 20349 // processor is a function/lambda 20350 return Opal.send(registry, type, name && [name], toBlock(processor)) 20351 } 20352}; 20353 20354/** 20355 * @namespace 20356 * @description 20357 * Extensions provide a way to participate in the parsing and converting 20358 * phases of the AsciiDoc processor or extend the AsciiDoc syntax. 20359 * 20360 * The various extensions participate in AsciiDoc processing as follows: 20361 * 20362 * 1. After the source lines are normalized, {{@link Extensions/Preprocessor}}s modify or replace 20363 * the source lines before parsing begins. {{@link Extensions/IncludeProcessor}}s are used to 20364 * process include directives for targets which they claim to handle. 20365 * 2. The Parser parses the block-level content into an abstract syntax tree. 20366 * Custom blocks and block macros are processed by associated {{@link Extensions/BlockProcessor}}s 20367 * and {{@link Extensions/BlockMacroProcessor}}s, respectively. 20368 * 3. {{@link Extensions/TreeProcessor}}s are run on the abstract syntax tree. 20369 * 4. Conversion of the document begins, at which point inline markup is processed 20370 * and converted. Custom inline macros are processed by associated {InlineMacroProcessor}s. 20371 * 5. {{@link Extensions/Postprocessor}}s modify or replace the converted document. 20372 * 6. The output is written to the output stream. 20373 * 20374 * Extensions may be registered globally using the {Extensions.register} method 20375 * or added to a custom {Registry} instance and passed as an option to a single 20376 * Asciidoctor processor. 20377 * 20378 * @example 20379 * asciidoctor.Extensions.register(function () { 20380 * this.block(function () { 20381 * const self = this 20382 * self.named('shout') 20383 * self.onContext('paragraph') 20384 * self.process(function (parent, reader) { 20385 * const lines = reader.getLines().map(function (l) { return l.toUpperCase(); }) 20386 * return self.createBlock(parent, 'paragraph', lines) 20387 * }) 20388 * }) 20389 * }) 20390 */ 20391const Extensions = Opal.const_get_qualified(Opal.Asciidoctor, 'Extensions'); 20392 20393// Alias 20394Opal.Asciidoctor.Extensions = Extensions; 20395 20396/** 20397 * Create a new {@link Extensions/Registry}. 20398 * @param {string} name 20399 * @param {function} block 20400 * @memberof Extensions 20401 * @returns {Extensions/Registry} - returns a {@link Extensions/Registry} 20402 */ 20403Extensions.create = function (name, block) { 20404 if (typeof name === 'function' && typeof block === 'undefined') { 20405 return Opal.send(this, 'create', null, toBlock(name)) 20406 } else if (typeof block === 'function') { 20407 return Opal.send(this, 'create', [name], toBlock(block)) 20408 } else { 20409 return this.$create() 20410 } 20411}; 20412 20413/** 20414 * @memberof Extensions 20415 */ 20416Extensions.register = function (name, block) { 20417 if (typeof name === 'function' && typeof block === 'undefined') { 20418 return Opal.send(this, 'register', null, toBlock(name)) 20419 } else { 20420 return Opal.send(this, 'register', [name], toBlock(block)) 20421 } 20422}; 20423 20424/** 20425 * Get statically-registered extension groups. 20426 * @memberof Extensions 20427 */ 20428Extensions.getGroups = function () { 20429 return fromHash(this.$groups()) 20430}; 20431 20432/** 20433 * Unregister all statically-registered extension groups. 20434 * @memberof Extensions 20435 */ 20436Extensions.unregisterAll = function () { 20437 this.$unregister_all(); 20438}; 20439 20440/** 20441 * Unregister the specified statically-registered extension groups. 20442 * 20443 * NOTE Opal cannot delete an entry from a Hash that is indexed by symbol, so 20444 * we have to resort to using low-level operations in this method. 20445 * 20446 * @memberof Extensions 20447 */ 20448Extensions.unregister = function () { 20449 const names = Array.prototype.concat.apply([], arguments); 20450 const groups = this.$groups(); 20451 const groupNameIdx = {}; 20452 let i = 0; 20453 const groupSymbolNames = groups.$$keys; 20454 for (; i < groupSymbolNames.length; i++) { 20455 const groupSymbolName = groupSymbolNames[i]; 20456 groupNameIdx[groupSymbolName.toString()] = groupSymbolName; 20457 } 20458 for (let j = 0; j < names.length; j++) { 20459 const groupStringName = names[j]; 20460 if (groupStringName in groupNameIdx) Opal.hash_delete(groups, groupNameIdx[groupStringName]); 20461 } 20462}; 20463 20464/** 20465 * @namespace 20466 * @module Extensions/Registry 20467 */ 20468const Registry = Extensions.Registry; 20469 20470/** 20471 * @memberof Extensions/Registry 20472 */ 20473Registry.prototype.getGroups = Extensions.getGroups; 20474 20475/** 20476 * @memberof Extensions/Registry 20477 */ 20478Registry.prototype.unregisterAll = function () { 20479 this.groups = Opal.hash(); 20480}; 20481 20482/** 20483 * @memberof Extensions/Registry 20484 */ 20485Registry.prototype.unregister = Extensions.unregister; 20486 20487/** 20488 * @memberof Extensions/Registry 20489 */ 20490Registry.prototype.prefer = function (name, processor) { 20491 if (arguments.length === 1) { 20492 processor = name; 20493 name = null; 20494 } 20495 if (typeof processor === 'object' || processor.$$is_class) { 20496 // processor is an instance or a class 20497 return this.$prefer(name, processor) 20498 } else { 20499 // processor is a function/lambda 20500 return Opal.send(this, 'prefer', name && [name], toBlock(processor)) 20501 } 20502}; 20503 20504/** 20505 * @memberof Extensions/Registry 20506 */ 20507Registry.prototype.block = function (name, processor) { 20508 if (arguments.length === 1) { 20509 processor = name; 20510 name = null; 20511 } 20512 return registerExtension(this, 'block', processor, name) 20513}; 20514 20515/** 20516 * @memberof Extensions/Registry 20517 */ 20518Registry.prototype.inlineMacro = function (name, processor) { 20519 if (arguments.length === 1) { 20520 processor = name; 20521 name = null; 20522 } 20523 return registerExtension(this, 'inline_macro', processor, name) 20524}; 20525 20526/** 20527 * @memberof Extensions/Registry 20528 */ 20529Registry.prototype.includeProcessor = function (name, processor) { 20530 if (arguments.length === 1) { 20531 processor = name; 20532 name = null; 20533 } 20534 return registerExtension(this, 'include_processor', processor, name) 20535}; 20536 20537/** 20538 * @memberof Extensions/Registry 20539 */ 20540Registry.prototype.blockMacro = function (name, processor) { 20541 if (arguments.length === 1) { 20542 processor = name; 20543 name = null; 20544 } 20545 return registerExtension(this, 'block_macro', processor, name) 20546}; 20547 20548/** 20549 * @memberof Extensions/Registry 20550 */ 20551Registry.prototype.treeProcessor = function (name, processor) { 20552 if (arguments.length === 1) { 20553 processor = name; 20554 name = null; 20555 } 20556 return registerExtension(this, 'tree_processor', processor, name) 20557}; 20558 20559/** 20560 * @memberof Extensions/Registry 20561 */ 20562Registry.prototype.postprocessor = function (name, processor) { 20563 if (arguments.length === 1) { 20564 processor = name; 20565 name = null; 20566 } 20567 return registerExtension(this, 'postprocessor', processor, name) 20568}; 20569 20570/** 20571 * @memberof Extensions/Registry 20572 */ 20573Registry.prototype.preprocessor = function (name, processor) { 20574 if (arguments.length === 1) { 20575 processor = name; 20576 name = null; 20577 } 20578 return registerExtension(this, 'preprocessor', processor, name) 20579}; 20580 20581/** 20582 * @memberof Extensions/Registry 20583 */ 20584Registry.prototype.docinfoProcessor = function (name, processor) { 20585 if (arguments.length === 1) { 20586 processor = name; 20587 name = null; 20588 } 20589 return registerExtension(this, 'docinfo_processor', processor, name) 20590}; 20591 20592/** 20593 * Checks whether any {{@link Extensions/Preprocessor}} extensions have been registered. 20594 * 20595 * @memberof Extensions/Registry 20596 * @returns a {boolean} indicating whether any {{@link Extensions/Preprocessor}} extensions are registered. 20597 */ 20598Registry.prototype.hasPreprocessors = function () { 20599 return this['$preprocessors?']() 20600}; 20601 20602/** 20603 * Checks whether any {{@link Extensions/TreeProcessor}} extensions have been registered. 20604 * 20605 * @memberof Extensions/Registry 20606 * @returns a {boolean} indicating whether any {{@link Extensions/TreeProcessor}} extensions are registered. 20607 */ 20608Registry.prototype.hasTreeProcessors = function () { 20609 return this['$tree_processors?']() 20610}; 20611 20612/** 20613 * Checks whether any {{@link Extensions/IncludeProcessor}} extensions have been registered. 20614 * 20615 * @memberof Extensions/Registry 20616 * @returns a {boolean} indicating whether any {{@link Extensions/IncludeProcessor}} extensions are registered. 20617 */ 20618Registry.prototype.hasIncludeProcessors = function () { 20619 return this['$include_processors?']() 20620}; 20621 20622/** 20623 * Checks whether any {{@link Extensions/Postprocessor}} extensions have been registered. 20624 * 20625 * @memberof Extensions/Registry 20626 * @returns a {boolean} indicating whether any {{@link Extensions/Postprocessor}} extensions are registered. 20627 */ 20628Registry.prototype.hasPostprocessors = function () { 20629 return this['$postprocessors?']() 20630}; 20631 20632/** 20633 * Checks whether any {{@link Extensions/DocinfoProcessor}} extensions have been registered. 20634 * 20635 * @memberof Extensions/Registry 20636 * @param location - A {string} for selecting docinfo extensions at a given location (head or footer) (default: undefined) 20637 * @returns a {boolean} indicating whether any {{@link Extensions/DocinfoProcessor}} extensions are registered. 20638 */ 20639Registry.prototype.hasDocinfoProcessors = function (location) { 20640 return this['$docinfo_processors?'](location) 20641}; 20642 20643/** 20644 * Checks whether any {{@link Extensions/BlockProcessor}} extensions have been registered. 20645 * 20646 * @memberof Extensions/Registry 20647 * @returns a {boolean} indicating whether any {{@link Extensions/BlockProcessor}} extensions are registered. 20648 */ 20649Registry.prototype.hasBlocks = function () { 20650 return this['$blocks?']() 20651}; 20652 20653/** 20654 * Checks whether any {{@link Extensions/BlockMacroProcessor}} extensions have been registered. 20655 * 20656 * @memberof Extensions/Registry 20657 * @returns a {boolean} indicating whether any {{@link Extensions/BlockMacroProcessor}} extensions are registered. 20658 */ 20659Registry.prototype.hasBlockMacros = function () { 20660 return this['$block_macros?']() 20661}; 20662 20663/** 20664 * Checks whether any {{@link Extensions/InlineMacroProcessor}} extensions have been registered. 20665 * 20666 * @memberof Extensions/Registry 20667 * @returns a {boolean} indicating whether any {{@link Extensions/InlineMacroProcessor}} extensions are registered. 20668 */ 20669Registry.prototype.hasInlineMacros = function () { 20670 return this['$inline_macros?']() 20671}; 20672 20673/** 20674 * Retrieves the Extension proxy objects for all the {{@link Extensions/Preprocessor}} instances stored in this registry. 20675 * 20676 * @memberof Extensions/Registry 20677 * @returns an {array} of Extension proxy objects. 20678 */ 20679Registry.prototype.getPreprocessors = function () { 20680 return this.$preprocessors() 20681}; 20682 20683/** 20684 * Retrieves the Extension proxy objects for all the {{@link Extensions/TreeProcessor}} instances stored in this registry. 20685 * 20686 * @memberof Extensions/Registry 20687 * @returns an {array} of Extension proxy objects. 20688 */ 20689Registry.prototype.getTreeProcessors = function () { 20690 return this.$tree_processors() 20691}; 20692 20693/** 20694 * Retrieves the Extension proxy objects for all the {{@link Extensions/IncludeProcessor}} instances stored in this registry. 20695 * 20696 * @memberof Extensions/Registry 20697 * @returns an {array} of Extension proxy objects. 20698 */ 20699Registry.prototype.getIncludeProcessors = function () { 20700 return this.$include_processors() 20701}; 20702 20703/** 20704 * Retrieves the Extension proxy objects for all the {{@link Extensions/Postprocessor}} instances stored in this registry. 20705 * 20706 * @memberof Extensions/Registry 20707 * @returns an {array} of Extension proxy objects. 20708 */ 20709Registry.prototype.getPostprocessors = function () { 20710 return this.$postprocessors() 20711}; 20712 20713/** 20714 * Retrieves the Extension proxy objects for all the {{@link Extensions/DocinfoProcessor}} instances stored in this registry. 20715 * 20716 * @memberof Extensions/Registry 20717 * @param location - A {string} for selecting docinfo extensions at a given location (head or footer) (default: undefined) 20718 * @returns an {array} of Extension proxy objects. 20719 */ 20720Registry.prototype.getDocinfoProcessors = function (location) { 20721 return this.$docinfo_processors(location) 20722}; 20723 20724/** 20725 * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockProcessor}} instances stored in this registry. 20726 * 20727 * @memberof Extensions/Registry 20728 * @returns an {array} of Extension proxy objects. 20729 */ 20730Registry.prototype.getBlocks = function () { 20731 return this.block_extensions.$values() 20732}; 20733 20734/** 20735 * Retrieves the Extension proxy objects for all the {{@link Extensions/BlockMacroProcessor}} instances stored in this registry. 20736 * 20737 * @memberof Extensions/Registry 20738 * @returns an {array} of Extension proxy objects. 20739 */ 20740Registry.prototype.getBlockMacros = function () { 20741 return this.block_macro_extensions.$values() 20742}; 20743 20744/** 20745 * Retrieves the Extension proxy objects for all the {{@link Extensions/InlineMacroProcessor}} instances stored in this registry. 20746 * 20747 * @memberof Extensions/Registry 20748 * @returns an {array} of Extension proxy objects. 20749 */ 20750Registry.prototype.getInlineMacros = function () { 20751 return this.$inline_macros() 20752}; 20753 20754/** 20755 * Get any {{@link Extensions/InlineMacroProcessor}} extensions are registered to handle the specified inline macro name. 20756 * 20757 * @param name - the {string} inline macro name 20758 * @memberof Extensions/Registry 20759 * @returns the Extension proxy object for the {{@link Extensions/InlineMacroProcessor}} that matches the inline macro name or undefined if no match is found. 20760 */ 20761Registry.prototype.getInlineMacroFor = function (name) { 20762 const result = this['$registered_for_inline_macro?'](name); 20763 return result === false ? undefined : result 20764}; 20765 20766/** 20767 * Get any {{@link Extensions/BlockProcessor}} extensions are registered to handle the specified block name appearing on the specified context. 20768 * @param name - the {string} block name 20769 * @param context - the context of the block: paragraph, open... (optional) 20770 * @memberof Extensions/Registry 20771 * @returns the Extension proxy object for the {{@link Extensions/BlockProcessor}} that matches the block name and context or undefined if no match is found. 20772 */ 20773Registry.prototype.getBlockFor = function (name, context) { 20774 if (typeof context === 'undefined') { 20775 const ext = this.$find_block_extension(name); 20776 return ext === Opal.nil ? undefined : ext 20777 } 20778 const result = this['$registered_for_block?'](name, context); 20779 return result === false ? undefined : result 20780}; 20781 20782/** 20783 * Get any {{@link Extensions/BlockMacroProcessor}} extensions are registered to handle the specified macro name. 20784 * 20785 * @param name - the {string} macro name 20786 * @memberof Extensions/Registry 20787 * @returns the Extension proxy object for the {{@link Extensions/BlockMacroProcessor}} that matches the macro name or undefined if no match is found. 20788 */ 20789Registry.prototype.getBlockMacroFor = function (name) { 20790 const result = this['$registered_for_block_macro?'](name); 20791 return result === false ? undefined : result 20792}; 20793 20794/** 20795 * @namespace 20796 * @module Extensions/Processor 20797 */ 20798const Processor = Extensions.Processor; 20799 20800/** 20801 * The extension will be added to the beginning of the list for that extension type. (default is append). 20802 * @memberof Extensions/Processor 20803 * @deprecated Please use the <code>prefer</pre> function on the {@link Extensions/Registry}, 20804 * the {@link Extensions/IncludeProcessor}, 20805 * the {@link Extensions/TreeProcessor}, 20806 * the {@link Extensions/Postprocessor}, 20807 * the {@link Extensions/Preprocessor} 20808 * or the {@link Extensions/DocinfoProcessor} 20809 */ 20810Processor.prototype.prepend = function () { 20811 this.$option('position', '>>'); 20812}; 20813 20814/** 20815 * @memberof Extensions/Processor 20816 */ 20817Processor.prototype.process = function (block) { 20818 const handler = { 20819 apply: function (target, thisArg, argumentsList) { 20820 for (let i = 0; i < argumentsList.length; i++) { 20821 // convert all (Opal) Hash arguments to JSON. 20822 if (typeof argumentsList[i] === 'object' && '$$smap' in argumentsList[i]) { 20823 argumentsList[i] = fromHash(argumentsList[i]); 20824 } 20825 } 20826 return target.apply(thisArg, argumentsList) 20827 } 20828 }; 20829 const blockProxy = new Proxy(block, handler); 20830 return Opal.send(this, 'process', null, toBlock(blockProxy)) 20831}; 20832 20833/** 20834 * @param {string} name 20835 * @memberof Extensions/Processor 20836 */ 20837Processor.prototype.named = function (name) { 20838 return this.$named(name) 20839}; 20840 20841/** 20842 * Creates a block and links it to the specified parent. 20843 * 20844 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20845 * @param {string} context 20846 * @param {string|Array<string>} source 20847 * @param {Object|undefined} attrs - A JSON of attributes 20848 * @param {Object|undefined} opts - A JSON of options 20849 * @return {Block} 20850 * @memberof Extensions/Processor 20851 */ 20852Processor.prototype.createBlock = function (parent, context, source, attrs, opts) { 20853 return this.$create_block(parent, context, source, toHash(attrs), toHash(opts)) 20854}; 20855 20856/** 20857 * Creates a list block node and links it to the specified parent. 20858 * 20859 * @param parent - The parent Block (Block, Section, or Document) of this new list block. 20860 * @param {string} context - The list context (e.g., ulist, olist, colist, dlist) 20861 * @param {Object} attrs - An object of attributes to set on this list block 20862 * @returns {List} 20863 * @memberof Extensions/Processor 20864 */ 20865Processor.prototype.createList = function (parent, context, attrs) { 20866 return this.$create_list(parent, context, toHash(attrs)) 20867}; 20868 20869/** 20870 * Creates a list item node and links it to the specified parent. 20871 * 20872 * @param {List} parent - The parent {List} of this new list item block. 20873 * @param {string} text - The text of the list item. 20874 * @returns {ListItem} 20875 * @memberof Extensions/Processor 20876 */ 20877Processor.prototype.createListItem = function (parent, text) { 20878 return this.$create_list_item(parent, text) 20879}; 20880 20881/** 20882 * Creates an image block node and links it to the specified parent. 20883 * @param {Block|Section|Document} parent - The parent Block of this new image block. 20884 * @param {Object} attrs - A JSON of attributes 20885 * @param {string} attrs.target - the target attribute to set the source of the image. 20886 * @param {string} attrs.alt - the alt attribute to specify an alternative text for the image. 20887 * @param {Object} opts - A JSON of options 20888 * @returns {Block} 20889 * @memberof Extensions/Processor 20890 */ 20891Processor.prototype.createImageBlock = function (parent, attrs, opts) { 20892 return this.$create_image_block(parent, toHash(attrs), toHash(opts)) 20893}; 20894 20895/** 20896 * Creates a paragraph block and links it to the specified parent. 20897 * 20898 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20899 * @param {string|Array<string>} source - The source 20900 * @param {Object|undefined} attrs - An object of attributes to set on this block 20901 * @param {Object|undefined} opts - An object of options to set on this block 20902 * @returns {Block} - a paragraph {Block} 20903 * @memberof Extensions/Processor 20904 */ 20905Processor.prototype.createParagraph = function (parent, source, attrs, opts) { 20906 return this.$create_paragraph(parent, source, toHash(attrs), toHash(opts)) 20907}; 20908 20909/** 20910 * Creates an open block and links it to the specified parent. 20911 * 20912 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20913 * @param {string|Array<string>} source - The source 20914 * @param {Object|undefined} attrs - An object of attributes to set on this block 20915 * @param {Object|undefined} opts - An object of options to set on this block 20916 * @returns {Block} - an open {Block} 20917 * @memberof Extensions/Processor 20918 */ 20919Processor.prototype.createOpenBlock = function (parent, source, attrs, opts) { 20920 return this.$create_open_block(parent, source, toHash(attrs), toHash(opts)) 20921}; 20922 20923/** 20924 * Creates an example block and links it to the specified parent. 20925 * 20926 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20927 * @param {string|Array<string>} source - The source 20928 * @param {Object|undefined} attrs - An object of attributes to set on this block 20929 * @param {Object|undefined} opts - An object of options to set on this block 20930 * @returns {Block} - an example {Block} 20931 * @memberof Extensions/Processor 20932 */ 20933Processor.prototype.createExampleBlock = function (parent, source, attrs, opts) { 20934 return this.$create_example_block(parent, source, toHash(attrs), toHash(opts)) 20935}; 20936 20937/** 20938 * Creates a literal block and links it to the specified parent. 20939 * 20940 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20941 * @param {string|Array<string>} source - The source 20942 * @param {Object|undefined} attrs - An object of attributes to set on this block 20943 * @param {Object|undefined} opts - An object of options to set on this block 20944 * @returns {Block} - a literal {Block} 20945 * @memberof Extensions/Processor 20946 */ 20947Processor.prototype.createPassBlock = function (parent, source, attrs, opts) { 20948 return this.$create_pass_block(parent, source, toHash(attrs), toHash(opts)) 20949}; 20950 20951/** 20952 * Creates a listing block and links it to the specified parent. 20953 * 20954 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20955 * @param {string|Array<string>} source - The source 20956 * @param {Object|undefined} attrs - An object of attributes to set on this block 20957 * @param {Object|undefined} opts - An object of options to set on this block 20958 * @returns {Block} - a listing {Block} 20959 * @memberof Extensions/Processor 20960 */ 20961Processor.prototype.createListingBlock = function (parent, source, attrs, opts) { 20962 return this.$create_listing_block(parent, source, toHash(attrs), toHash(opts)) 20963}; 20964 20965/** 20966 * Creates a literal block and links it to the specified parent. 20967 * 20968 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20969 * @param {string|Array<string>} source - The source 20970 * @param {Object|undefined} attrs - An object of attributes to set on this block 20971 * @param {Object|undefined} opts - An object of options to set on this block 20972 * @returns {Block} - a literal {Block} 20973 * @memberof Extensions/Processor 20974 */ 20975Processor.prototype.createLiteralBlock = function (parent, source, attrs, opts) { 20976 return this.$create_literal_block(parent, source, toHash(attrs), toHash(opts)) 20977}; 20978 20979/** 20980 * Creates an inline anchor and links it to the specified parent. 20981 * 20982 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20983 * @param {string} text - The text 20984 * @param {Object|undefined} opts - An object of options to set on this block 20985 * @returns {Inline} - an {Inline} anchor 20986 * @memberof Extensions/Processor 20987 */ 20988Processor.prototype.createAnchor = function (parent, text, opts) { 20989 if (opts && opts.attributes) { 20990 opts.attributes = toHash(opts.attributes); 20991 } 20992 return this.$create_anchor(parent, text, toHash(opts)) 20993}; 20994 20995/** 20996 * Creates an inline pass and links it to the specified parent. 20997 * 20998 * @param {Block|Section|Document} parent - The parent Block (Block, Section, or Document) of this new block. 20999 * @param {string} text - The text 21000 * @param {Object|undefined} opts - An object of options to set on this block 21001 * @returns {Inline} - an {Inline} pass 21002 * @memberof Extensions/Processor 21003 */ 21004Processor.prototype.createInlinePass = function (parent, text, opts) { 21005 if (opts && opts.attributes) { 21006 opts.attributes = toHash(opts.attributes); 21007 } 21008 return this.$create_inline_pass(parent, text, toHash(opts)) 21009}; 21010 21011/** 21012 * Creates an inline node and links it to the specified parent. 21013 * 21014 * @param {Block|Section|Document} parent - The parent Block of this new inline node. 21015 * @param {string} context - The context name 21016 * @param {string} text - The text 21017 * @param {Object|undefined} opts - A JSON of options 21018 * @returns {Inline} - an {Inline} node 21019 * @memberof Extensions/Processor 21020 */ 21021Processor.prototype.createInline = function (parent, context, text, opts) { 21022 if (opts && opts.attributes) { 21023 opts.attributes = toHash(opts.attributes); 21024 } 21025 return this.$create_inline(parent, context, text, toHash(opts)) 21026}; 21027 21028/** 21029 * Parses blocks in the content and attaches the block to the parent. 21030 * @param {AbstractBlock} parent - the parent block 21031 * @param {string|Array<string>} content - the content 21032 * @param {Object|undefined} attrs - an object of attributes 21033 * @returns {AbstractNode} - The parent node into which the blocks are parsed. 21034 * @memberof Extensions/Processor 21035 */ 21036Processor.prototype.parseContent = function (parent, content, attrs) { 21037 return this.$parse_content(parent, content, toHash(attrs)) 21038}; 21039 21040/** 21041 * Parses the attrlist String into a JSON of attributes 21042 * @param {AbstractBlock} block - the current AbstractBlock or the parent AbstractBlock if there is no current block (used for applying subs) 21043 * @param {string} attrlist - the list of attributes as a String 21044 * @param {Object|undefined} opts - an optional JSON of options to control processing: 21045 * - positional_attributes: an Array of attribute names to map positional arguments to (optional, default: []) 21046 * - sub_attributes: enables attribute substitution on the attrlist argument (optional, default: false) 21047 * 21048 * @returns - a JSON of parsed attributes 21049 * @memberof Extensions/Processor 21050 */ 21051Processor.prototype.parseAttributes = function (block, attrlist, opts) { 21052 if (opts && opts.attributes) { 21053 opts.attributes = toHash(opts.attributes); 21054 } 21055 return fromHash(this.$parse_attributes(block, attrlist, toHash(opts))) 21056}; 21057 21058/** 21059 * @param {string|Array<string>} value - Name of a positional attribute or an Array of positional attribute names 21060 * @memberof Extensions/Processor 21061 */ 21062Processor.prototype.positionalAttributes = function (value) { 21063 return this.$positional_attrs(value) 21064}; 21065 21066/** 21067 * Specify how to resolve attributes. 21068 * 21069 * @param {string|Array<string>|Object|boolean} [value] - A specification to resolve attributes. 21070 * @memberof Extensions/Processor 21071 */ 21072Processor.prototype.resolveAttributes = function (value) { 21073 if (typeof value === 'object' && !Array.isArray(value)) { 21074 return this.$resolves_attributes(toHash(value)) 21075 } 21076 if (arguments.length > 1) { 21077 return this.$resolves_attributes(Array.prototype.slice.call(arguments)) 21078 } 21079 if (typeof value === 'undefined') { 21080 // Convert to nil otherwise an exception is thrown at: 21081 // https://github.com/asciidoctor/asciidoctor/blob/0bcb4addc17b307f62975aad203fb556a1bcd8a5/lib/asciidoctor/extensions.rb#L583 21082 // 21083 // if args.size == 1 && !args[0] 21084 // 21085 // In the above Ruby code, args[0] is undefined and Opal will try to call the function "!" on an undefined object. 21086 return this.$resolves_attributes(Opal.nil) 21087 } 21088 return this.$resolves_attributes(value) 21089}; 21090 21091/** 21092 * @deprecated Please use the <code>resolveAttributes</pre> function on the {@link Extensions/Processor}. 21093 * @memberof Extensions/Processor 21094 * @see {Processor#resolveAttributes} 21095 */ 21096Processor.prototype.resolvesAttributes = Processor.prototype.resolveAttributes; 21097 21098/** 21099 * Get the configuration JSON for this processor instance. 21100 * @memberof Extensions/Processor 21101 */ 21102Processor.prototype.getConfig = function () { 21103 return fromHash(this.config) 21104}; 21105 21106/** 21107 * @memberof Extensions/Processor 21108 */ 21109Processor.prototype.option = function (key, value) { 21110 this.$option(key, value); 21111}; 21112 21113/** 21114 * @namespace 21115 * @module Extensions/BlockProcessor 21116 */ 21117const BlockProcessor = Extensions.BlockProcessor; 21118 21119/** 21120 * @param {Object} value - a JSON of default values for attributes 21121 * @memberof Extensions/BlockProcessor 21122 */ 21123BlockProcessor.prototype.defaultAttributes = function (value) { 21124 this.$default_attributes(toHash(value)); 21125}; 21126 21127/** 21128 * @param {string} context - A context name 21129 * @memberof Extensions/BlockProcessor 21130 */ 21131BlockProcessor.prototype.onContext = function (context) { 21132 return this.$on_context(context) 21133}; 21134 21135/** 21136 * @param {...string} contexts - A list of context names 21137 * @memberof Extensions/BlockProcessor 21138 */ 21139BlockProcessor.prototype.onContexts = function (contexts) { 21140 return this.$on_contexts(Array.prototype.slice.call(arguments)) 21141}; 21142 21143/** 21144 * @returns {string} 21145 * @memberof Extensions/BlockProcessor 21146 */ 21147BlockProcessor.prototype.getName = function () { 21148 const name = this.name; 21149 return name === Opal.nil ? undefined : name 21150}; 21151 21152/** 21153 * @param {string} value 21154 * @memberof Extensions/BlockProcessor 21155 */ 21156BlockProcessor.prototype.parseContentAs = function (value) { 21157 this.$parse_content_as(value); 21158}; 21159 21160/** 21161 * @namespace 21162 * @module Extensions/BlockMacroProcessor 21163 */ 21164const BlockMacroProcessor = Extensions.BlockMacroProcessor; 21165 21166/** 21167 * @param {Object} value - a JSON of default values for attributes 21168 * @memberof Extensions/BlockMacroProcessor 21169 */ 21170BlockMacroProcessor.prototype.defaultAttributes = function (value) { 21171 this.$default_attributes(toHash(value)); 21172}; 21173 21174/** 21175 * @returns {string} - the block macro name 21176 * @memberof Extensions/BlockMacroProcessor 21177 */ 21178BlockMacroProcessor.prototype.getName = function () { 21179 const name = this.name; 21180 return name === Opal.nil ? undefined : name 21181}; 21182 21183/** 21184 * @param {string} value 21185 * @memberof Extensions/BlockMacroProcessor 21186 */ 21187BlockMacroProcessor.prototype.parseContentAs = function (value) { 21188 this.$parse_content_as(value); 21189}; 21190 21191/** 21192 * @namespace 21193 * @module Extensions/InlineMacroProcessor 21194 */ 21195const InlineMacroProcessor = Extensions.InlineMacroProcessor; 21196 21197/** 21198 * @param {Object} value - a JSON of default values for attributes 21199 * @memberof Extensions/InlineMacroProcessor 21200 */ 21201InlineMacroProcessor.prototype.defaultAttributes = function (value) { 21202 this.$default_attributes(toHash(value)); 21203}; 21204 21205/** 21206 * @returns {string} - the inline macro name 21207 * @memberof Extensions/InlineMacroProcessor 21208 */ 21209InlineMacroProcessor.prototype.getName = function () { 21210 const name = this.name; 21211 return name === Opal.nil ? undefined : name 21212}; 21213 21214/** 21215 * @param {string} value 21216 * @memberof Extensions/InlineMacroProcessor 21217 */ 21218InlineMacroProcessor.prototype.parseContentAs = function (value) { 21219 this.$parse_content_as(value); 21220}; 21221 21222/** 21223 * @param {string} value 21224 * @memberof Extensions/InlineMacroProcessor 21225 */ 21226InlineMacroProcessor.prototype.matchFormat = function (value) { 21227 this.$match_format(value); 21228}; 21229 21230/** 21231 * @param {RegExp} value 21232 * @memberof Extensions/InlineMacroProcessor 21233 */ 21234InlineMacroProcessor.prototype.match = function (value) { 21235 this.$match(value); 21236}; 21237 21238/** 21239 * @namespace 21240 * @module Extensions/IncludeProcessor 21241 */ 21242const IncludeProcessor = Extensions.IncludeProcessor; 21243 21244/** 21245 * @memberof Extensions/IncludeProcessor 21246 */ 21247IncludeProcessor.prototype.handles = function (block) { 21248 return Opal.send(this, 'handles?', null, toBlock(block)) 21249}; 21250 21251/** 21252 * @memberof Extensions/IncludeProcessor 21253 */ 21254IncludeProcessor.prototype.prefer = function () { 21255 this.$prefer(); 21256}; 21257 21258/** 21259 * @namespace 21260 * @module Extensions/TreeProcessor 21261 */ 21262const TreeProcessor = Extensions.TreeProcessor; 21263 21264/** 21265 * @memberof Extensions/TreeProcessor 21266 */ 21267TreeProcessor.prototype.prefer = function () { 21268 this.$prefer(); 21269}; 21270 21271/** 21272 * @namespace 21273 * @module Extensions/Postprocessor 21274 */ 21275const Postprocessor = Extensions.Postprocessor; 21276 21277/** 21278 * @memberof Extensions/Postprocessor 21279 */ 21280Postprocessor.prototype.prefer = function () { 21281 this.$prefer(); 21282}; 21283 21284/** 21285 * @namespace 21286 * @module Extensions/Preprocessor 21287 */ 21288const Preprocessor = Extensions.Preprocessor; 21289 21290/** 21291 * @memberof Extensions/Preprocessor 21292 */ 21293Preprocessor.prototype.prefer = function () { 21294 this.$prefer(); 21295}; 21296 21297/** 21298 * @namespace 21299 * @module Extensions/DocinfoProcessor 21300 */ 21301const DocinfoProcessor = Extensions.DocinfoProcessor; 21302 21303/** 21304 * @memberof Extensions/DocinfoProcessor 21305 */ 21306DocinfoProcessor.prototype.prefer = function () { 21307 this.$prefer(); 21308}; 21309 21310/** 21311 * @param {string} value - The docinfo location ("head", "header" or "footer") 21312 * @memberof Extensions/DocinfoProcessor 21313 */ 21314DocinfoProcessor.prototype.atLocation = function (value) { 21315 this.$at_location(value); 21316}; 21317 21318function initializeProcessorClass (superclassName, className, functions) { 21319 const superClass = Opal.const_get_qualified(Extensions, superclassName); 21320 return initializeClass(superClass, className, functions, { 21321 'handles?': function () { 21322 return true 21323 } 21324 }) 21325} 21326 21327// Postprocessor 21328 21329/** 21330 * Create a postprocessor 21331 * @description this API is experimental and subject to change 21332 * @memberof Extensions 21333 */ 21334Extensions.createPostprocessor = function (name, functions) { 21335 if (arguments.length === 1) { 21336 functions = name; 21337 name = null; 21338 } 21339 return initializeProcessorClass('Postprocessor', name, functions) 21340}; 21341 21342/** 21343 * Create and instantiate a postprocessor 21344 * @description this API is experimental and subject to change 21345 * @memberof Extensions 21346 */ 21347Extensions.newPostprocessor = function (name, functions) { 21348 if (arguments.length === 1) { 21349 functions = name; 21350 name = null; 21351 } 21352 return this.createPostprocessor(name, functions).$new() 21353}; 21354 21355// Preprocessor 21356 21357/** 21358 * Create a preprocessor 21359 * @description this API is experimental and subject to change 21360 * @memberof Extensions 21361 */ 21362Extensions.createPreprocessor = function (name, functions) { 21363 if (arguments.length === 1) { 21364 functions = name; 21365 name = null; 21366 } 21367 return initializeProcessorClass('Preprocessor', name, functions) 21368}; 21369 21370/** 21371 * Create and instantiate a preprocessor 21372 * @description this API is experimental and subject to change 21373 * @memberof Extensions 21374 */ 21375Extensions.newPreprocessor = function (name, functions) { 21376 if (arguments.length === 1) { 21377 functions = name; 21378 name = null; 21379 } 21380 return this.createPreprocessor(name, functions).$new() 21381}; 21382 21383// Tree Processor 21384 21385/** 21386 * Create a tree processor 21387 * @description this API is experimental and subject to change 21388 * @memberof Extensions 21389 */ 21390Extensions.createTreeProcessor = function (name, functions) { 21391 if (arguments.length === 1) { 21392 functions = name; 21393 name = null; 21394 } 21395 return initializeProcessorClass('TreeProcessor', name, functions) 21396}; 21397 21398/** 21399 * Create and instantiate a tree processor 21400 * @description this API is experimental and subject to change 21401 * @memberof Extensions 21402 */ 21403Extensions.newTreeProcessor = function (name, functions) { 21404 if (arguments.length === 1) { 21405 functions = name; 21406 name = null; 21407 } 21408 return this.createTreeProcessor(name, functions).$new() 21409}; 21410 21411// Include Processor 21412 21413/** 21414 * Create an include processor 21415 * @description this API is experimental and subject to change 21416 * @memberof Extensions 21417 */ 21418Extensions.createIncludeProcessor = function (name, functions) { 21419 if (arguments.length === 1) { 21420 functions = name; 21421 name = null; 21422 } 21423 return initializeProcessorClass('IncludeProcessor', name, functions) 21424}; 21425 21426/** 21427 * Create and instantiate an include processor 21428 * @description this API is experimental and subject to change 21429 * @memberof Extensions 21430 */ 21431Extensions.newIncludeProcessor = function (name, functions) { 21432 if (arguments.length === 1) { 21433 functions = name; 21434 name = null; 21435 } 21436 return this.createIncludeProcessor(name, functions).$new() 21437}; 21438 21439// Docinfo Processor 21440 21441/** 21442 * Create a Docinfo processor 21443 * @description this API is experimental and subject to change 21444 * @memberof Extensions 21445 */ 21446Extensions.createDocinfoProcessor = function (name, functions) { 21447 if (arguments.length === 1) { 21448 functions = name; 21449 name = null; 21450 } 21451 return initializeProcessorClass('DocinfoProcessor', name, functions) 21452}; 21453 21454/** 21455 * Create and instantiate a Docinfo processor 21456 * @description this API is experimental and subject to change 21457 * @memberof Extensions 21458 */ 21459Extensions.newDocinfoProcessor = function (name, functions) { 21460 if (arguments.length === 1) { 21461 functions = name; 21462 name = null; 21463 } 21464 return this.createDocinfoProcessor(name, functions).$new() 21465}; 21466 21467// Block Processor 21468 21469/** 21470 * Create a block processor 21471 * @description this API is experimental and subject to change 21472 * @memberof Extensions 21473 */ 21474Extensions.createBlockProcessor = function (name, functions) { 21475 if (arguments.length === 1) { 21476 functions = name; 21477 name = null; 21478 } 21479 return initializeProcessorClass('BlockProcessor', name, functions) 21480}; 21481 21482/** 21483 * Create and instantiate a block processor 21484 * @description this API is experimental and subject to change 21485 * @memberof Extensions 21486 */ 21487Extensions.newBlockProcessor = function (name, functions) { 21488 if (arguments.length === 1) { 21489 functions = name; 21490 name = null; 21491 } 21492 return this.createBlockProcessor(name, functions).$new() 21493}; 21494 21495// Inline Macro Processor 21496 21497/** 21498 * Create an inline macro processor 21499 * @description this API is experimental and subject to change 21500 * @memberof Extensions 21501 */ 21502Extensions.createInlineMacroProcessor = function (name, functions) { 21503 if (arguments.length === 1) { 21504 functions = name; 21505 name = null; 21506 } 21507 return initializeProcessorClass('InlineMacroProcessor', name, functions) 21508}; 21509 21510/** 21511 * Create and instantiate an inline macro processor 21512 * @description this API is experimental and subject to change 21513 * @memberof Extensions 21514 */ 21515Extensions.newInlineMacroProcessor = function (name, functions) { 21516 if (arguments.length === 1) { 21517 functions = name; 21518 name = null; 21519 } 21520 return this.createInlineMacroProcessor(name, functions).$new() 21521}; 21522 21523// Block Macro Processor 21524 21525/** 21526 * Create a block macro processor 21527 * @description this API is experimental and subject to change 21528 * @memberof Extensions 21529 */ 21530Extensions.createBlockMacroProcessor = function (name, functions) { 21531 if (arguments.length === 1) { 21532 functions = name; 21533 name = null; 21534 } 21535 return initializeProcessorClass('BlockMacroProcessor', name, functions) 21536}; 21537 21538/** 21539 * Create and instantiate a block macro processor 21540 * @description this API is experimental and subject to change 21541 * @memberof Extensions 21542 */ 21543Extensions.newBlockMacroProcessor = function (name, functions) { 21544 if (arguments.length === 1) { 21545 functions = name; 21546 name = null; 21547 } 21548 return this.createBlockMacroProcessor(name, functions).$new() 21549}; 21550 21551 21552var ASCIIDOCTOR_JS_VERSION = '3.0.2'; 21553 21554 /** 21555 * Get Asciidoctor.js version number. 21556 * 21557 * @memberof Asciidoctor 21558 * @returns {string} - returns the version number of Asciidoctor.js. 21559 */ 21560 Asciidoctor.prototype.getVersion = function () { 21561 return ASCIIDOCTOR_JS_VERSION 21562 }; 21563 return Opal.Asciidoctor 21564} 21565 21566module.exports = asciidoctorNode; 21567