]*>(.*?)<\/pre><\/div>/m, "\\1")
- }
- } else {
- opts['$[]=']("nowrap", true);
- result = lexer.$highlight(source, $hash2(["options"], {"options": opts}));
- };};
- if ((($a = self.passthroughs['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- result = result.$gsub($scope.get('PASS_MATCH_HI'), "" + ($scope.get('PASS_START')) + "\\1" + ($scope.get('PASS_END')))
- };
- if ((($a = (($c = process_callouts !== false && process_callouts !== nil) ? callout_marks : process_callouts)) !== nil && (!$a.$$is_boolean || $a == true))) {
- lineno = 0;
- reached_code = linenums_mode['$!=']("table");
- return $rb_times(($a = ($c = result.$split($scope.get('EOL'))).$map, $a.$$p = (TMP_45 = function(line){var self = TMP_45.$$s || this, $a, $b, TMP_46, conums = nil, tail = nil, pos = nil, conums_markup = nil;
- if (self.document == null) self.document = nil;
-if (line == null) line = nil;
- if (reached_code !== false && reached_code !== nil) {
- } else {
- if ((($a = line['$include?']("")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return line;
- };
- reached_code = true;
- };
- lineno = $rb_plus(lineno, 1);
- if ((($a = (conums = callout_marks.$delete(lineno))) !== nil && (!$a.$$is_boolean || $a == true))) {
- tail = nil;
- if ((($a = (($b = callout_on_last !== false && callout_on_last !== nil) ? callout_marks['$empty?']() : callout_on_last)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (pos = line.$index(""))) !== nil && (!$a.$$is_boolean || $a == true))) {
- tail = line['$[]']($range(pos, -1, false));
- line = "" + (line['$[]']($range(0, pos, true)).$chomp(" ")) + " ";
- } else {
- line = "" + (line.$chomp(" ")) + " "
- }};
- if (conums.$size()['$=='](1)) {
- return "" + (line) + ($scope.get('Inline').$new(self, "callout", conums['$[]'](0), $hash2(["id"], {"id": self.document.$callouts().$read_next_id()})).$convert()) + (tail)
- } else {
- conums_markup = $rb_times(($a = ($b = conums).$map, $a.$$p = (TMP_46 = function(conum){var self = TMP_46.$$s || this;
- if (self.document == null) self.document = nil;
-if (conum == null) conum = nil;
- return $scope.get('Inline').$new(self, "callout", conum, $hash2(["id"], {"id": self.document.$callouts().$read_next_id()})).$convert()}, TMP_46.$$s = self, TMP_46), $a).call($b), " ");
- return "" + (line) + (conums_markup) + (tail);
- };
- } else {
- return line
- };}, TMP_45.$$s = self, TMP_45), $a).call($c), $scope.get('EOL'));
- } else {
- return result
- };
- });
-
- Opal.defn(self, '$resolve_lines_to_highlight', function(spec) {
- var $a, $b, TMP_47, self = this, lines = nil;
-
- lines = [];
- ($a = ($b = spec.$delete(" ").$split($scope.get('DataDelimiterRx'))).$map, $a.$$p = (TMP_47 = function(entry){var self = TMP_47.$$s || this, $a, negate = nil, s = nil, e = nil, line_nums = nil;
-if (entry == null) entry = nil;
- negate = false;
- if ((($a = entry['$start_with?']("!")) !== nil && (!$a.$$is_boolean || $a == true))) {
- entry = entry['$[]']($range(1, -1, false));
- negate = true;};
- if ((($a = entry['$include?']("-")) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(entry.$split("-", 2)), s = ($a[0] == null ? nil : $a[0]), e = ($a[1] == null ? nil : $a[1]);
- line_nums = ($range(s.$to_i(), e.$to_i(), false)).$to_a();
- if (negate !== false && negate !== nil) {
- return lines = $rb_minus(lines, line_nums)
- } else {
- return lines.$concat(line_nums)
- };
- } else if (negate !== false && negate !== nil) {
- return lines.$delete(entry.$to_i())
- } else {
- return lines['$<<'](entry.$to_i())
- };}, TMP_47.$$s = self, TMP_47), $a).call($b);
- return lines.$sort().$uniq();
- });
-
- Opal.defn(self, '$sub_source', function(source, process_callouts) {
- var self = this;
-
- return (function() {if (process_callouts !== false && process_callouts !== nil) {
- return self.$sub_callouts(self.$sub_specialchars(source))
- } else {
- return self.$sub_specialchars(source)
- }; return nil; })();
- });
-
- Opal.defn(self, '$lock_in_subs', function() {
- var $a, $b, $c, $d, $e, TMP_48, self = this, default_subs = nil, $case = nil, custom_subs = nil;
- if (self.default_subs == null) self.default_subs = nil;
- if (self.content_model == null) self.content_model = nil;
- if (self.context == null) self.context = nil;
- if (self.attributes == null) self.attributes = nil;
- if (self.style == null) self.style = nil;
- if (self.document == null) self.document = nil;
- if (self.subs == null) self.subs = nil;
-
- if ((($a = self.default_subs) !== nil && (!$a.$$is_boolean || $a == true))) {
- default_subs = self.default_subs
- } else {
- $case = self.content_model;if ("simple"['$===']($case)) {default_subs = $scope.get('SUBS')['$[]']("normal")}else if ("verbatim"['$===']($case)) {if ((($a = ((($b = self.context['$==']("listing")) !== false && $b !== nil) ? $b : ((($c = self.context['$==']("literal")) ? (self['$option?']("listparagraph"))['$!']() : self.context['$==']("literal"))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- default_subs = $scope.get('SUBS')['$[]']("verbatim")
- } else if (self.context['$==']("verse")) {
- default_subs = $scope.get('SUBS')['$[]']("normal")
- } else {
- default_subs = $scope.get('SUBS')['$[]']("basic")
- }}else if ("raw"['$===']($case)) {if (self.context['$==']("stem")) {
- default_subs = $scope.get('SUBS')['$[]']("basic")
- } else {
- default_subs = $scope.get('SUBS')['$[]']("pass")
- }}else {return nil}
- };
- if ((($a = (custom_subs = self.attributes['$[]']("subs"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.subs = self.$resolve_block_subs(custom_subs, default_subs, self.context)
- } else {
- self.subs = default_subs.$dup()
- };
- if ((($a = ($b = ($c = ($d = (($e = self.context['$==']("listing")) ? self.style['$==']("source") : self.context['$==']("listing")), $d !== false && $d !== nil ?self.attributes['$[]']("language") : $d), $c !== false && $c !== nil ?self.document['$basebackend?']("html") : $c), $b !== false && $b !== nil ?$scope.get('SUB_HIGHLIGHT')['$include?'](self.document.$attributes()['$[]']("source-highlighter")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.subs = ($a = ($b = self.subs).$map, $a.$$p = (TMP_48 = function(sub){var self = TMP_48.$$s || this;
-if (sub == null) sub = nil;
- if (sub['$==']("specialcharacters")) {
- return "highlight"
- } else {
- return sub
- }}, TMP_48.$$s = self, TMP_48), $a).call($b)
- } else {
- return nil
- };
- });
- })($scope.base)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/abstract_node"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$include', '$attr_reader', '$attr_accessor', '$==', '$document', '$to_s', '$key?', '$dup', '$[]', '$raise', '$===', '$attributes', '$nil?', '$has_key?', '$[]=', '$update', '$converter', '$include?', '$split', '$*', '$push', '$delete', '$attr?', '$empty?', '$extname', '$image_uri', '$attr', '$normalize_web_path', '$<', '$safe', '$uriish?', '$generate_data_uri_from_uri', '$generate_data_uri', '$normalize_system_path', '$readable?', '$warn', '$respond_to?', '$binread', '$open', '$read', '$encode64', '$require_library', '$!', '$content_type', '$web_path', '$new', '$open_uri', '$normalize_lines_from_string', '$fetch', '$read_asset', '$!=', '$is_root?', '$join', '$base_dir', '$system_path', '$relative_path']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $AbstractNode(){};
- var self = $AbstractNode = $klass($base, $super, 'AbstractNode', $AbstractNode);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.document = def.attributes = def.path_resolver = def.style = nil;
- self.$include($scope.get('Substitutors'));
-
- self.$attr_reader("parent");
-
- self.$attr_reader("document");
-
- self.$attr_reader("context");
-
- self.$attr_reader("node_name");
-
- self.$attr_accessor("id");
-
- self.$attr_reader("attributes");
-
- Opal.defn(self, '$initialize', function(parent, context, opts) {
- var $a, self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if (context['$==']("document")) {
- self.document = parent
- } else if (parent !== false && parent !== nil) {
- self.parent = parent;
- self.document = parent.$document();
- } else {
- self.parent = nil;
- self.document = nil;
- };
- self.context = context;
- self.node_name = context.$to_s();
- self.attributes = (function() {if ((($a = (opts['$key?']("attributes"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return opts['$[]']("attributes").$dup()
- } else {
- return $hash2([], {})
- }; return nil; })();
- return self.passthroughs = $hash2([], {});
- });
-
- Opal.defn(self, '$parent=', function(parent) {
- var self = this;
-
- self.parent = parent;
- self.document = parent.$document();
- return nil;
- });
-
- Opal.defn(self, '$inline?', function() {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- });
-
- Opal.defn(self, '$block?', function() {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- });
-
- Opal.defn(self, '$attr', function(name, default_value, inherit) {
- var $a, $b, self = this;
-
- if (default_value == null) {
- default_value = nil
- }
- if (inherit == null) {
- inherit = true
- }
- if ((($a = Opal.get('Symbol')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- name = name.$to_s()};
- if (self['$=='](self.document)) {
- inherit = false};
- if (inherit !== false && inherit !== nil) {
- return ((($a = ((($b = self.attributes['$[]'](name)) !== false && $b !== nil) ? $b : self.document.$attributes()['$[]'](name))) !== false && $a !== nil) ? $a : default_value)
- } else {
- return ((($a = self.attributes['$[]'](name)) !== false && $a !== nil) ? $a : default_value)
- };
- });
-
- Opal.defn(self, '$attr?', function(name, expect, inherit) {
- var $a, $b, self = this;
-
- if (expect == null) {
- expect = nil
- }
- if (inherit == null) {
- inherit = true
- }
- if ((($a = Opal.get('Symbol')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- name = name.$to_s()};
- if (self['$=='](self.document)) {
- inherit = false};
- if ((($a = expect['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ((($a = self.attributes['$has_key?'](name)) !== false && $a !== nil) ? $a : ((($b = inherit !== false && inherit !== nil) ? self.document.$attributes()['$has_key?'](name) : inherit)))
- } else if (inherit !== false && inherit !== nil) {
- return expect['$==']((((($a = self.attributes['$[]'](name)) !== false && $a !== nil) ? $a : self.document.$attributes()['$[]'](name))))
- } else {
- return expect['$=='](self.attributes['$[]'](name))
- };
- });
-
- Opal.defn(self, '$set_attr', function(name, value, overwrite) {
- var $a, $b, self = this;
-
- if (overwrite == null) {
- overwrite = true
- }
- if ((($a = (($b = overwrite['$=='](false)) ? (self.attributes['$key?'](name)) : overwrite['$=='](false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false
- } else {
- self.attributes['$[]='](name, value);
- return true;
- };
- });
-
- Opal.defn(self, '$set_option', function(name) {
- var $a, self = this;
-
- if ((($a = self.attributes['$has_key?']("options")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.attributes['$[]=']("options", "" + (self.attributes['$[]']("options")) + "," + (name))
- } else {
- self.attributes['$[]=']("options", name)
- };
- return self.attributes['$[]=']("" + (name) + "-option", "");
- });
-
- Opal.defn(self, '$option?', function(name) {
- var self = this;
-
- return self.attributes['$has_key?']("" + (name) + "-option");
- });
-
- Opal.defn(self, '$update_attributes', function(attributes) {
- var self = this;
-
- self.attributes.$update(attributes);
- return nil;
- });
-
- Opal.defn(self, '$converter', function() {
- var self = this;
-
- return self.document.$converter();
- });
-
- Opal.defn(self, '$role?', function(expect) {
- var $a, self = this;
-
- if (expect == null) {
- expect = nil
- }
- if (expect !== false && expect !== nil) {
- return expect['$==']((((($a = self.attributes['$[]']("role")) !== false && $a !== nil) ? $a : self.document.$attributes()['$[]']("role"))))
- } else {
- return ((($a = self.attributes['$has_key?']("role")) !== false && $a !== nil) ? $a : self.document.$attributes()['$has_key?']("role"))
- };
- });
-
- Opal.defn(self, '$role', function() {
- var $a, self = this;
-
- return ((($a = self.attributes['$[]']("role")) !== false && $a !== nil) ? $a : self.document.$attributes()['$[]']("role"));
- });
-
- Opal.defn(self, '$has_role?', function(name) {
- var $a, $b, self = this, val = nil;
-
- if ((($a = (val = (((($b = self.attributes['$[]']("role")) !== false && $b !== nil) ? $b : self.document.$attributes()['$[]']("role"))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return val.$split(" ")['$include?'](name)
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$roles', function() {
- var $a, $b, self = this, val = nil;
-
- if ((($a = (val = (((($b = self.attributes['$[]']("role")) !== false && $b !== nil) ? $b : self.document.$attributes()['$[]']("role"))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return val.$split(" ")
- } else {
- return []
- };
- });
-
- Opal.defn(self, '$add_role', function(name) {
- var $a, $b, self = this, roles = nil;
-
- if ((($a = ((roles = (((($b = self.attributes['$[]']("role")) !== false && $b !== nil) ? $b : "")).$split(" ")))['$include?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return self.attributes['$[]=']("role", $rb_times(roles.$push(name), " "))
- };
- });
-
- Opal.defn(self, '$remove_role', function(name) {
- var $a, $b, self = this, roles = nil;
-
- if ((($a = ((roles = (((($b = self.attributes['$[]']("role")) !== false && $b !== nil) ? $b : "")).$split(" ")))['$include?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- roles.$delete(name);
- return self.attributes['$[]=']("role", $rb_times(roles, " "));
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$reftext?', function() {
- var $a, self = this;
-
- return ((($a = self.attributes['$has_key?']("reftext")) !== false && $a !== nil) ? $a : self.document.$attributes()['$has_key?']("reftext"));
- });
-
- Opal.defn(self, '$reftext', function() {
- var $a, self = this;
-
- return ((($a = self.attributes['$[]']("reftext")) !== false && $a !== nil) ? $a : self.document.$attributes()['$[]']("reftext"));
- });
-
- Opal.defn(self, '$icon_uri', function(name) {
- var $a, self = this, uri = nil;
-
- if ((($a = self['$attr?']("icon")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = Opal.get('File').$extname(uri = (self.$image_uri(self.$attr("icon"), "iconsdir")))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (uri) + "." + (self.document.$attr("icontype", "png"))
- } else {
- return uri
- }
- } else {
- return self.$image_uri("" + (name) + "." + (self.document.$attr("icontype", "png")), "iconsdir")
- };
- });
-
- Opal.defn(self, '$media_uri', function(target, asset_dir_key) {
- var self = this;
-
- if (asset_dir_key == null) {
- asset_dir_key = "imagesdir"
- }
- return self.$normalize_web_path(target, ((function() {if (asset_dir_key !== false && asset_dir_key !== nil) {
- return self.document.$attr(asset_dir_key)
- } else {
- return nil
- }; return nil; })()));
- });
-
- Opal.defn(self, '$image_uri', function(target_image, asset_dir_key) {
- var $a, $b, $c, $d, $e, self = this, doc = nil, images_base = nil;
-
- if (asset_dir_key == null) {
- asset_dir_key = "imagesdir"
- }
- if ((($a = (($b = $rb_lt(((doc = self.document)).$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE')))) ? doc['$attr?']("data-uri") : $rb_lt(((doc = self.document)).$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE'))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ((($b = ($scope.get('Helpers')['$uriish?'](target_image))) !== false && $b !== nil) ? $b : (($c = ($d = (($e = asset_dir_key !== false && asset_dir_key !== nil) ? (images_base = doc.$attr(asset_dir_key)) : asset_dir_key), $d !== false && $d !== nil ?($scope.get('Helpers')['$uriish?'](images_base)) : $d), $c !== false && $c !== nil ?(target_image = self.$normalize_web_path(target_image, images_base, false)) : $c)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = doc['$attr?']("allow-uri-read")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$generate_data_uri_from_uri(target_image, doc['$attr?']("cache-uri"))
- } else {
- return target_image
- }
- } else {
- return self.$generate_data_uri(target_image, asset_dir_key)
- }
- } else {
- return self.$normalize_web_path(target_image, ((function() {if (asset_dir_key !== false && asset_dir_key !== nil) {
- return doc.$attr(asset_dir_key)
- } else {
- return nil
- }; return nil; })()))
- };
- });
-
- Opal.defn(self, '$generate_data_uri', function(target_image, asset_dir_key) {
- var $a, $b, TMP_1, self = this, ext = nil, mimetype = nil, image_path = nil, bindata = nil;
-
- if (asset_dir_key == null) {
- asset_dir_key = nil
- }
- ext = Opal.get('File').$extname(target_image);
- mimetype = ((function() {if (ext['$=='](".svg")) {
- return "image/svg+xml"
- } else {
- return "image/" + (ext['$[]']($range(1, -1, false)))
- }; return nil; })());
- if (asset_dir_key !== false && asset_dir_key !== nil) {
- image_path = self.$normalize_system_path(target_image, self.document.$attr(asset_dir_key), nil, $hash2(["target_name"], {"target_name": "image"}))
- } else {
- image_path = self.$normalize_system_path(target_image)
- };
- if ((($a = Opal.get('File')['$readable?'](image_path)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$warn("asciidoctor: WARNING: image to embed not found or not readable: " + (image_path));
- return "data:" + (mimetype) + ":base64,";
- };
- bindata = nil;
- if ((($a = Opal.get('IO')['$respond_to?']("binread")) !== nil && (!$a.$$is_boolean || $a == true))) {
- bindata = Opal.get('IO').$binread(image_path)
- } else {
- bindata = ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_1 = function(file){var self = TMP_1.$$s || this;
-if (file == null) file = nil;
- return file.$read()}, TMP_1.$$s = self, TMP_1), $a).call($b, image_path, "rb")
- };
- return "data:" + (mimetype) + ";base64," + (Opal.get('Base64').$encode64(bindata).$delete($scope.get('EOL')));
- });
-
- Opal.defn(self, '$generate_data_uri_from_uri', function(image_uri, cache_uri) {
- var $a, $b, TMP_2, self = this, mimetype = nil, bindata = nil;
-
- if (cache_uri == null) {
- cache_uri = false
- }
- if (cache_uri !== false && cache_uri !== nil) {
- $scope.get('Helpers').$require_library("open-uri/cached", "open-uri-cached")
- } else if ((($a = Opal.get('RUBY_ENGINE_OPAL')['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- Opal.get('OpenURI')};
- try {
- mimetype = nil;
- bindata = ($a = ($b = self).$open, $a.$$p = (TMP_2 = function(file){var self = TMP_2.$$s || this;
-if (file == null) file = nil;
- mimetype = file.$content_type();
- return file.$read();}, TMP_2.$$s = self, TMP_2), $a).call($b, image_uri, "rb");
- return "data:" + (mimetype) + ";base64," + (Opal.get('Base64').$encode64(bindata).$delete($scope.get('EOL')));
- } catch ($err) {if (true) {
- try {
- self.$warn("asciidoctor: WARNING: could not retrieve image data from URI: " + (image_uri));
- return image_uri;
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- });
-
- Opal.defn(self, '$read_contents', function(target, opts) {
- var $a, $b, $c, $d, TMP_3, self = this, doc = nil, start = nil, data = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- doc = self.document;
- if ((($a = ((($b = ($scope.get('Helpers')['$uriish?'](target))) !== false && $b !== nil) ? $b : (($c = ($d = (start = opts['$[]']("start")), $d !== false && $d !== nil ?($scope.get('Helpers')['$uriish?'](start)) : $d), $c !== false && $c !== nil ?(target = (((($d = self.path_resolver) !== false && $d !== nil) ? $d : self.path_resolver = $scope.get('PathResolver').$new())).$web_path(target, start)) : $c)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = doc['$attr?']("allow-uri-read")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = doc['$attr?']("cache-uri")) !== nil && (!$a.$$is_boolean || $a == true))) {
- $scope.get('Helpers').$require_library("open-uri/cached", "open-uri-cached")};
- try {
- data = ($a = ($b = Opal.get('OpenURI')).$open_uri, $a.$$p = (TMP_3 = function(fd){var self = TMP_3.$$s || this;
-if (fd == null) fd = nil;
- return fd.$read()}, TMP_3.$$s = self, TMP_3), $a).call($b, target);
- if ((($a = opts['$[]']("normalize")) !== nil && (!$a.$$is_boolean || $a == true))) {
- data = $rb_times(($scope.get('Helpers').$normalize_lines_from_string(data)), $scope.get('EOL'))};
- } catch ($err) {if (true) {
- try {
- if ((($a = opts.$fetch("warn_on_failure", true)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: could not retrieve contents of " + (((($a = opts['$[]']("label")) !== false && $a !== nil) ? $a : "asset")) + " at URI: " + (target))};
- data = nil;
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- } else {
- if ((($a = opts.$fetch("warn_on_failure", true)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: cannot retrieve contents of " + (((($a = opts['$[]']("label")) !== false && $a !== nil) ? $a : "asset")) + " at URI: " + (target) + " (allow-uri-read attribute not enabled)")};
- data = nil;
- }
- } else {
- target = self.$normalize_system_path(target, opts['$[]']("start"), nil, $hash2(["target_name"], {"target_name": (((($a = opts['$[]']("label")) !== false && $a !== nil) ? $a : "asset"))}));
- data = self.$read_asset(target, $hash2(["normalize", "warn_on_failure"], {"normalize": opts['$[]']("normalize"), "warn_on_failure": (opts.$fetch("warn_on_failure", true))}));
- };
- return data;
- });
-
- Opal.defn(self, '$read_asset', function(path, opts) {
- var $a, self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = Opal.get('Hash')['$==='](opts)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- opts = $hash2(["warn_on_failure"], {"warn_on_failure": (opts['$!='](false))})
- };
- if ((($a = Opal.get('File')['$readable?'](path)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = opts['$[]']("normalize")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $rb_times($scope.get('Helpers').$normalize_lines_from_string(Opal.get('IO').$read(path)), $scope.get('EOL'))
- } else {
- return Opal.get('IO').$read(path)
- }
- } else {
- if ((($a = opts['$[]']("warn_on_failure")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: file does not exist or cannot be read: " + (path))};
- return nil;
- };
- });
-
- Opal.defn(self, '$normalize_web_path', function(target, start, preserve_uri_target) {
- var $a, $b, self = this;
-
- if (start == null) {
- start = nil
- }
- if (preserve_uri_target == null) {
- preserve_uri_target = true
- }
- if ((($a = (($b = preserve_uri_target !== false && preserve_uri_target !== nil) ? ($scope.get('Helpers')['$uriish?'](target)) : preserve_uri_target)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return target
- } else {
- return (((($a = self.path_resolver) !== false && $a !== nil) ? $a : self.path_resolver = $scope.get('PathResolver').$new())).$web_path(target, start)
- };
- });
-
- Opal.defn(self, '$normalize_system_path', function(target, start, jail, opts) {
- var $a, self = this, path_resolver = nil, doc = nil;
-
- if (start == null) {
- start = nil
- }
- if (jail == null) {
- jail = nil
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- path_resolver = (((($a = self.path_resolver) !== false && $a !== nil) ? $a : self.path_resolver = $scope.get('PathResolver').$new()));
- if ($rb_lt(((doc = self.document)).$safe(), (($scope.get('SafeMode')).$$scope.get('SAFE')))) {
- if (start !== false && start !== nil) {
- if ((($a = path_resolver['$is_root?'](start)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- start = Opal.get('File').$join(doc.$base_dir(), start)
- }
- } else {
- start = doc.$base_dir()
- }
- } else {
- if (start !== false && start !== nil) {
- } else {
- start = doc.$base_dir()
- };
- if (jail !== false && jail !== nil) {
- } else {
- jail = doc.$base_dir()
- };
- };
- return path_resolver.$system_path(target, start, jail, opts);
- });
-
- Opal.defn(self, '$normalize_asset_path', function(asset_ref, asset_name, autocorrect) {
- var self = this;
-
- if (asset_name == null) {
- asset_name = "path"
- }
- if (autocorrect == null) {
- autocorrect = true
- }
- return self.$normalize_system_path(asset_ref, self.document.$base_dir(), nil, $hash2(["target_name", "recover"], {"target_name": asset_name, "recover": autocorrect}));
- });
-
- Opal.defn(self, '$relative_path', function(filename) {
- var $a, self = this;
-
- return (((($a = self.path_resolver) !== false && $a !== nil) ? $a : self.path_resolver = $scope.get('PathResolver').$new())).$relative_path(filename, self.document.$base_dir());
- });
-
- Opal.defn(self, '$is_uri?', function(str) {
- var self = this;
-
- return $scope.get('Helpers')['$uriish?'](str);
- });
-
- return (Opal.defn(self, '$list_marker_keyword', function(list_type) {
- var $a, self = this;
-
- if (list_type == null) {
- list_type = nil
- }
- return $scope.get('ORDERED_LIST_KEYWORDS')['$[]'](((($a = list_type) !== false && $a !== nil) ? $a : self.style));
- }), nil) && 'list_marker_keyword';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/abstract_block"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$attr_accessor', '$attr_reader', '$attr_writer', '$==', '$!=', '$level', '$to_s', '$playback_attributes', '$convert', '$converter', '$*', '$map', '$file', '$lineno', '$include?', '$!', '$nil_or_empty?', '$apply_title_subs', '$title', '$empty?', '$<<', '$select', '$context', '$>', '$[]', '$has_role?', '$header?', '$concat', '$find_by', '$to_proc', '$each', '$flatten', '$delete', '$title?', '$attributes', '$counter_increment', '$index=', '$+', '$sectname', '$counter', '$numbered', '$number=', '$attr', '$caption=', '$special', '$doctype', '$assign_index', '$reindex_sections']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $AbstractBlock(){};
- var self = $AbstractBlock = $klass($base, $super, 'AbstractBlock', $AbstractBlock);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_4;
-
- def.document = def.attributes = def.blocks = def.source_location = def.subs = def.title = def.subbed_title = def.caption = def.next_section_index = def.context = def.style = def.id = def.header = def.next_section_number = nil;
- self.$attr_accessor("content_model");
-
- self.$attr_reader("subs");
-
- self.$attr_reader("blocks");
-
- self.$attr_accessor("level");
-
- self.$attr_writer("title");
-
- self.$attr_accessor("style");
-
- self.$attr_accessor("caption");
-
- self.$attr_accessor("source_location");
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, context, opts) {var $zuper = $slice.call(arguments, 0);
- var $a, $b, self = this, $iter = TMP_1.$$p, $yield = $iter || nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper);
- self.content_model = "compound";
- self.subs = [];
- self.default_subs = nil;
- self.blocks = [];
- self.id = nil;
- self.title = nil;
- self.caption = nil;
- self.style = nil;
- self.level = (function() {if (context['$==']("document")) {
- return 0
- } else if ((($a = (($b = parent !== false && parent !== nil) ? context['$!=']("section") : parent)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return parent.$level()
- } else {
- return nil
- }; return nil; })();
- self.next_section_index = 0;
- self.next_section_number = 1;
- return self.source_location = nil;
- });
-
- Opal.defn(self, '$block?', function() {
- var self = this;
-
- return true;
- });
-
- Opal.defn(self, '$inline?', function() {
- var self = this;
-
- return false;
- });
-
- Opal.defn(self, '$context=', function(context) {
- var self = this;
-
- self.context = context;
- return self.node_name = context.$to_s();
- });
-
- Opal.defn(self, '$convert', function() {
- var self = this;
-
- self.document.$playback_attributes(self.attributes);
- return self.$converter().$convert(self);
- });
-
- Opal.alias(self, 'render', 'convert');
-
- Opal.defn(self, '$content', function() {
- var $a, $b, TMP_2, self = this;
-
- return $rb_times(($a = ($b = self.blocks).$map, $a.$$p = (TMP_2 = function(b){var self = TMP_2.$$s || this;
-if (b == null) b = nil;
- return b.$convert()}, TMP_2.$$s = self, TMP_2), $a).call($b), $scope.get('EOL'));
- });
-
- Opal.defn(self, '$file', function() {
- var $a, self = this;
-
- if ((($a = self.source_location) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.source_location.$file()
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$lineno', function() {
- var $a, self = this;
-
- if ((($a = self.source_location) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.source_location.$lineno()
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$sub?', function(name) {
- var self = this;
-
- return self.subs['$include?'](name);
- });
-
- Opal.defn(self, '$title?', function() {
- var self = this;
-
- return self.title['$nil_or_empty?']()['$!']();
- });
-
- Opal.defn(self, '$title', function() {
- var $a, $b, self = this;
-
- if ((($a = (($b = self['subbed_title'], $b != null && $b !== nil) ? 'instance-variable' : nil)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.subbed_title
- } else if ((($a = self.title) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.subbed_title = self.$apply_title_subs(self.title)
- } else {
- return self.title
- };
- });
-
- Opal.defn(self, '$captioned_title', function() {
- var self = this;
-
- return "" + (self.caption) + (self.$title());
- });
-
- Opal.defn(self, '$blocks?', function() {
- var self = this;
-
- return self.blocks['$empty?']()['$!']();
- });
-
- Opal.defn(self, '$<<', function(block) {
- var self = this;
-
- self.blocks['$<<'](block);
- return self;
- });
-
- Opal.alias(self, 'append', '<<');
-
- Opal.defn(self, '$sections', function() {
- var $a, $b, TMP_3, self = this;
-
- return ($a = ($b = self.blocks).$select, $a.$$p = (TMP_3 = function(block){var self = TMP_3.$$s || this;
-if (block == null) block = nil;
- return block.$context()['$==']("section")}, TMP_3.$$s = self, TMP_3), $a).call($b);
- });
-
- Opal.defn(self, '$sections?', function() {
- var self = this;
-
- return $rb_gt(self.next_section_index, 0);
- });
-
- Opal.defn(self, '$find_by', TMP_4 = function(selector) {
- var $a, $b, $c, $d, $e, TMP_5, TMP_6, self = this, $iter = TMP_4.$$p, block = $iter || nil, result = nil, any_context = nil, context_selector = nil, style_selector = nil, role_selector = nil, id_selector = nil;
-
- if (selector == null) {
- selector = $hash2([], {})
- }
- TMP_4.$$p = null;
- result = [];
- if ((($a = ($b = ($c = ($d = (((($e = (any_context = ((context_selector = selector['$[]']("context")))['$!']())) !== false && $e !== nil) ? $e : context_selector['$=='](self.context))), $d !== false && $d !== nil ?(((($e = ((style_selector = selector['$[]']("style")))['$!']()) !== false && $e !== nil) ? $e : style_selector['$=='](self.style))) : $d), $c !== false && $c !== nil ?(((($d = ((role_selector = selector['$[]']("role")))['$!']()) !== false && $d !== nil) ? $d : (self['$has_role?'](role_selector)))) : $c), $b !== false && $b !== nil ?(((($c = ((id_selector = selector['$[]']("id")))['$!']()) !== false && $c !== nil) ? $c : id_selector['$=='](self.id))) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (id_selector !== false && id_selector !== nil) {
- if ((block !== nil)) {
- return (function() {if ((($a = (((($b = Opal.yield1(block, self)) === $breaker) ? $breaker.$v : $b))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return [self]
- } else {
- return result
- }; return nil; })()
- } else {
- return [self]
- }
- } else if ((block !== nil)) {
- if ((($a = (((($b = Opal.yield1(block, self)) === $breaker) ? $breaker.$v : $b))) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](self)}
- } else {
- result['$<<'](self)
- }};
- if ((($a = ($b = (($c = self.context['$==']("document")) ? (((($d = any_context) !== false && $d !== nil) ? $d : context_selector['$==']("section"))) : self.context['$==']("document")), $b !== false && $b !== nil ?self['$header?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- result.$concat(($a = ($b = self.header).$find_by, $a.$$p = block.$to_proc(), $a).call($b, selector))};
- if (context_selector['$==']("document")) {
- } else if (self.context['$==']("dlist")) {
- if ((($a = ((($c = any_context) !== false && $c !== nil) ? $c : context_selector['$!=']("section"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($c = self.blocks.$flatten()).$each, $a.$$p = (TMP_5 = function(li){var self = TMP_5.$$s || this, $a, $b;
-if (li == null) li = nil;
- if (li !== false && li !== nil) {
- return result.$concat(($a = ($b = li).$find_by, $a.$$p = block.$to_proc(), $a).call($b, selector))
- } else {
- return nil
- }}, TMP_5.$$s = self, TMP_5), $a).call($c)}
- } else if ((($a = ($d = ($e = self.blocks).$each, $d.$$p = (TMP_6 = function(b){var self = TMP_6.$$s || this, $a, $b;
-if (b == null) b = nil;
- if ((($a = ((($b = context_selector['$==']("section")) ? b.$context()['$!=']("section") : context_selector['$==']("section")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil;};
- return result.$concat(($a = ($b = b).$find_by, $a.$$p = block.$to_proc(), $a).call($b, selector));}, TMP_6.$$s = self, TMP_6), $d).call($e)) !== nil && (!$a.$$is_boolean || $a == true))) {};
- return result;
- });
-
- Opal.alias(self, 'query', 'find_by');
-
- Opal.defn(self, '$remove_sub', function(sub) {
- var self = this;
-
- self.subs.$delete(sub);
- return nil;
- });
-
- Opal.defn(self, '$assign_caption', function(caption, key) {
- var $a, $b, self = this, value = nil, caption_key = nil, caption_title = nil, caption_num = nil;
-
- if (caption == null) {
- caption = nil
- }
- if (key == null) {
- key = nil
- }
- if ((($a = ((($b = self['$title?']()) !== false && $b !== nil) ? $b : self.caption['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- if (caption !== false && caption !== nil) {
- self.caption = caption
- } else if ((($a = (value = self.document.$attributes()['$[]']("caption"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.caption = value
- } else if ((($a = self['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- ((($a = key) !== false && $a !== nil) ? $a : key = self.context.$to_s());
- caption_key = "" + (key) + "-caption";
- if ((($a = (caption_title = self.document.$attributes()['$[]'](caption_key))) !== nil && (!$a.$$is_boolean || $a == true))) {
- caption_num = self.document.$counter_increment("" + (key) + "-number", self);
- self.caption = "" + (caption_title) + " " + (caption_num) + ". ";};};
- return nil;
- });
-
- Opal.defn(self, '$assign_index', function(section) {
- var $a, $b, $c, $d, self = this, appendix_number = nil, caption = nil;
-
- (($a = [self.next_section_index]), $b = section, $b['$index='].apply($b, $a), $a[$a.length-1]);
- self.next_section_index = $rb_plus(self.next_section_index, 1);
- if (section.$sectname()['$==']("appendix")) {
- appendix_number = self.document.$counter("appendix-number", "A");
- if ((($a = section.$numbered()) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [appendix_number]), $b = section, $b['$number='].apply($b, $a), $a[$a.length-1])};
- if ((($a = ((caption = self.document.$attr("appendix-caption", "")))['$!=']("")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (($a = ["" + (caption) + " " + (appendix_number) + ": "]), $b = section, $b['$caption='].apply($b, $a), $a[$a.length-1])
- } else {
- return (($a = ["" + (appendix_number) + ". "]), $b = section, $b['$caption='].apply($b, $a), $a[$a.length-1])
- };
- } else if ((($a = section.$numbered()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = (((($c = section.$level()['$=='](1)) !== false && $c !== nil) ? $c : ((($d = section.$level()['$=='](0)) ? section.$special() : section.$level()['$=='](0))))), $b !== false && $b !== nil ?self.document.$doctype()['$==']("book") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (($a = [self.document.$counter("chapter-number", 1)]), $b = section, $b['$number='].apply($b, $a), $a[$a.length-1])
- } else {
- (($a = [self.next_section_number]), $b = section, $b['$number='].apply($b, $a), $a[$a.length-1]);
- return self.next_section_number = $rb_plus(self.next_section_number, 1);
- }
- } else {
- return nil
- };
- });
-
- return (Opal.defn(self, '$reindex_sections', function() {
- var $a, $b, TMP_7, self = this;
-
- self.next_section_index = 0;
- self.next_section_number = 0;
- return ($a = ($b = self.blocks).$each, $a.$$p = (TMP_7 = function(block){var self = TMP_7.$$s || this;
-if (block == null) block = nil;
- if (block.$context()['$==']("section")) {
- self.$assign_index(block);
- return block.$reindex_sections();
- } else {
- return nil
- }}, TMP_7.$$s = self, TMP_7), $a).call($b);
- }), nil) && 'reindex_sections';
- })($scope.base, $scope.get('AbstractNode'))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/attribute_list"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$==', '$new', '$[]', '$update', '$parse', '$parse_attribute', '$eos?', '$skip_delimiter', '$+', '$rekey', '$each_with_index', '$[]=', '$skip_blank', '$peek', '$parse_attribute_value', '$get_byte', '$scan_name', '$!', '$!=', '$*', '$scan_to_delimiter', '$===', '$each', '$split', '$tr', '$empty?', '$apply_normal_subs', '$scan_to_quote', '$gsub', '$skip', '$scan']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $AttributeList(){};
- var self = $AttributeList = $klass($base, $super, 'AttributeList', $AttributeList);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.attributes = def.scanner = def.delimiter = def.block = def.delimiter_skip_pattern = def.delimiter_boundary_pattern = nil;
- if (Opal.get('RUBY_ENGINE')['$==']("opal")) {
- Opal.cdecl($scope, 'CG_BLANK', "[ \\t]");
-
- Opal.cdecl($scope, 'CC_WORD', "a-zA-Z0-9_");
-
- Opal.cdecl($scope, 'CG_WORD', "[a-zA-Z0-9_]");};
-
- Opal.cdecl($scope, 'BoundaryRxs', $hash2(["\"", "'", ","], {"\"": /.*?[^\\](?=")/, "'": /.*?[^\\](?=')/, ",": (new RegExp(".*?(?=" + $scope.get('CG_BLANK') + "*(,|$))"))}));
-
- Opal.cdecl($scope, 'EscapedQuoteRxs', $hash2(["\"", "'"], {"\"": /\\"/, "'": /\\'/}));
-
- Opal.cdecl($scope, 'NameRx', (new RegExp("" + $scope.get('CG_WORD') + "[" + $scope.get('CC_WORD') + "\\-.]*")));
-
- Opal.cdecl($scope, 'BlankRx', (new RegExp("" + $scope.get('CG_BLANK') + "+")));
-
- Opal.cdecl($scope, 'SkipRxs', $hash2(["blank", ","], {"blank": $scope.get('BlankRx'), ",": (new RegExp("" + $scope.get('CG_BLANK') + "*(,|$)"))}));
-
- Opal.defn(self, '$initialize', function(source, block, delimiter) {
- var self = this;
-
- if (block == null) {
- block = nil
- }
- if (delimiter == null) {
- delimiter = ","
- }
- self.scanner = Opal.get('StringScanner').$new(source);
- self.block = block;
- self.delimiter = delimiter;
- self.delimiter_skip_pattern = $scope.get('SkipRxs')['$[]'](delimiter);
- self.delimiter_boundary_pattern = $scope.get('BoundaryRxs')['$[]'](delimiter);
- return self.attributes = nil;
- });
-
- Opal.defn(self, '$parse_into', function(attributes, posattrs) {
- var self = this;
-
- if (posattrs == null) {
- posattrs = []
- }
- return attributes.$update(self.$parse(posattrs));
- });
-
- Opal.defn(self, '$parse', function(posattrs) {
- var $a, $b, self = this, index = nil;
-
- if (posattrs == null) {
- posattrs = []
- }
- if ((($a = self.attributes) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.attributes};
- self.attributes = $hash2([], {});
- index = 0;
- while ((($b = self.$parse_attribute(index, posattrs)) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = self.scanner['$eos?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;};
- self.$skip_delimiter();
- index = $rb_plus(index, 1);};
- return self.attributes;
- });
-
- Opal.defn(self, '$rekey', function(posattrs) {
- var self = this;
-
- return $scope.get('AttributeList').$rekey(self.attributes, posattrs);
- });
-
- Opal.defs(self, '$rekey', function(attributes, pos_attrs) {
- var $a, $b, TMP_1, self = this;
-
- ($a = ($b = pos_attrs).$each_with_index, $a.$$p = (TMP_1 = function(key, index){var self = TMP_1.$$s || this, $a, pos = nil, val = nil;
-if (key == null) key = nil;if (index == null) index = nil;
- if (key !== false && key !== nil) {
- } else {
- return nil;
- };
- pos = $rb_plus(index, 1);
- if ((($a = (val = attributes['$[]'](pos))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return attributes['$[]='](key, val)
- } else {
- return nil
- };}, TMP_1.$$s = self, TMP_1), $a).call($b);
- return attributes;
- });
-
- Opal.defn(self, '$parse_attribute', function(index, pos_attrs) {
- var $a, $b, TMP_2, $c, $d, self = this, single_quoted_value = nil, first = nil, name = nil, value = nil, skipped = nil, c = nil, $case = nil, resolved_name = nil, pos_name = nil;
-
- if (index == null) {
- index = 0
- }
- if (pos_attrs == null) {
- pos_attrs = []
- }
- single_quoted_value = false;
- self.$skip_blank();
- if (((first = self.scanner.$peek(1)))['$==']("\"")) {
- name = self.$parse_attribute_value(self.scanner.$get_byte());
- value = nil;
- } else if (first['$==']("'")) {
- name = self.$parse_attribute_value(self.scanner.$get_byte());
- value = nil;
- single_quoted_value = true;
- } else {
- name = self.$scan_name();
- skipped = 0;
- c = nil;
- if ((($a = self.scanner['$eos?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (name !== false && name !== nil) {
- } else {
- return false
- }
- } else {
- skipped = ((($a = self.$skip_blank()) !== false && $a !== nil) ? $a : 0);
- c = self.scanner.$get_byte();
- };
- if ((($a = ((($b = c['$!']()) !== false && $b !== nil) ? $b : c['$=='](self.delimiter))) !== nil && (!$a.$$is_boolean || $a == true))) {
- value = nil
- } else if ((($a = ((($b = c['$!=']("=")) !== false && $b !== nil) ? $b : name['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- name = "" + (name) + ($rb_times(" ", skipped)) + (c) + (self.$scan_to_delimiter());
- value = nil;
- } else {
- self.$skip_blank();
- if ((($a = self.scanner.$peek(1)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (((c = self.scanner.$get_byte()))['$==']("\"")) {
- value = self.$parse_attribute_value(c)
- } else if (c['$==']("'")) {
- value = self.$parse_attribute_value(c);
- single_quoted_value = true;
- } else if (c['$=='](self.delimiter)) {
- value = nil
- } else {
- value = "" + (c) + (self.$scan_to_delimiter());
- if (value['$==']("None")) {
- return true};
- }};
- };
- };
- if (value !== false && value !== nil) {
- $case = name;if ("options"['$===']($case) || "opts"['$===']($case)) {name = "options";
- ($a = ($b = value.$tr(" ", "").$split(",")).$each, $a.$$p = (TMP_2 = function(opt){var self = TMP_2.$$s || this;
- if (self.attributes == null) self.attributes = nil;
-if (opt == null) opt = nil;
- return self.attributes['$[]=']("" + (opt) + "-option", "")}, TMP_2.$$s = self, TMP_2), $a).call($b);
- self.attributes['$[]='](name, value);}else if ("title"['$===']($case)) {self.attributes['$[]='](name, value)}else {self.attributes['$[]='](name, (function() {if ((($a = ($c = (($d = single_quoted_value !== false && single_quoted_value !== nil) ? value['$empty?']()['$!']() : single_quoted_value), $c !== false && $c !== nil ?self.block : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (self.block.$apply_normal_subs(value))
- } else {
- return value
- }; return nil; })())}
- } else {
- resolved_name = (function() {if ((($a = ($c = (($d = single_quoted_value !== false && single_quoted_value !== nil) ? name['$empty?']()['$!']() : single_quoted_value), $c !== false && $c !== nil ?self.block : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (self.block.$apply_normal_subs(name))
- } else {
- return name
- }; return nil; })();
- if ((($a = (pos_name = pos_attrs['$[]'](index))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.attributes['$[]='](pos_name, resolved_name)};
- self.attributes['$[]=']($rb_plus(index, 1), resolved_name);
- };
- return true;
- });
-
- Opal.defn(self, '$parse_attribute_value', function(quote) {
- var $a, self = this, value = nil;
-
- if (self.scanner.$peek(1)['$=='](quote)) {
- self.scanner.$get_byte();
- return "";};
- if ((($a = (value = self.$scan_to_quote(quote))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.scanner.$get_byte();
- return value.$gsub($scope.get('EscapedQuoteRxs')['$[]'](quote), quote);
- } else {
- return "" + (quote) + (self.$scan_to_delimiter())
- };
- });
-
- Opal.defn(self, '$skip_blank', function() {
- var self = this;
-
- return self.scanner.$skip($scope.get('BlankRx'));
- });
-
- Opal.defn(self, '$skip_delimiter', function() {
- var self = this;
-
- return self.scanner.$skip(self.delimiter_skip_pattern);
- });
-
- Opal.defn(self, '$scan_name', function() {
- var self = this;
-
- return self.scanner.$scan($scope.get('NameRx'));
- });
-
- Opal.defn(self, '$scan_to_delimiter', function() {
- var self = this;
-
- return self.scanner.$scan(self.delimiter_boundary_pattern);
- });
-
- return (Opal.defn(self, '$scan_to_quote', function(quote) {
- var self = this;
-
- return self.scanner.$scan($scope.get('BoundaryRxs')['$[]'](quote));
- }), nil) && 'scan_to_quote';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/block"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$default=', '$attr_accessor', '$[]', '$key?', '$==', '$===', '$dup', '$delete', '$[]=', '$lock_in_subs', '$nil_or_empty?', '$normalize_lines_from_string', '$apply_subs', '$*', '$<', '$size', '$empty?', '$rstrip', '$shift', '$pop', '$warn', '$to_s', '$class', '$object_id', '$inspect']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Block(){};
- var self = $Block = $klass($base, $super, 'Block', $Block);
-
- var def = self.$$proto, $scope = self.$$scope, $a, $b, TMP_1, TMP_2;
-
- def.attributes = def.content_model = def.lines = def.subs = def.blocks = def.context = def.style = nil;
- (($a = ["simple"]), $b = (Opal.cdecl($scope, '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"}))), $b['$default='].apply($b, $a), $a[$a.length-1]);
-
- Opal.alias(self, 'blockname', 'context');
-
- self.$attr_accessor("lines");
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, context, opts) {var $zuper = $slice.call(arguments, 0);
- var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, subs = nil, raw_source = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper);
- self.content_model = ((($a = opts['$[]']("content_model")) !== false && $a !== nil) ? $a : $scope.get('DEFAULT_CONTENT_MODEL')['$[]'](context));
- if ((($a = opts['$key?']("subs")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (subs = opts['$[]']("subs"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (subs['$==']("default")) {
- self.default_subs = opts['$[]']("default_subs")
- } else if ((($a = Opal.get('Array')['$==='](subs)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.default_subs = subs.$dup();
- self.attributes.$delete("subs");
- } else {
- self.default_subs = nil;
- self.attributes['$[]=']("subs", "" + (subs));
- };
- self.$lock_in_subs();
- } else {
- self.subs = [];
- self.default_subs = [];
- self.attributes.$delete("subs");
- }
- } else {
- self.subs = [];
- self.default_subs = nil;
- };
- if ((($a = ((raw_source = opts['$[]']("source")))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.lines = []
- } else if ((($a = Opal.get('String')['$==='](raw_source)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.lines = $scope.get('Helpers').$normalize_lines_from_string(raw_source)
- } else {
- return self.lines = raw_source.$dup()
- };
- });
-
- Opal.defn(self, '$content', TMP_2 = function() {var $zuper = $slice.call(arguments, 0);
- var $a, $b, $c, self = this, $iter = TMP_2.$$p, $yield = $iter || nil, $case = nil, result = nil, first = nil, last = nil;
-
- TMP_2.$$p = null;
- return (function() {$case = self.content_model;if ("compound"['$===']($case)) {return Opal.find_super_dispatcher(self, 'content', TMP_2, $iter).apply(self, $zuper)}else if ("simple"['$===']($case)) {return self.$apply_subs($rb_times(self.lines, $scope.get('EOL')), self.subs)}else if ("verbatim"['$===']($case) || "raw"['$===']($case)) {result = self.$apply_subs(self.lines, self.subs);
- if ($rb_lt(result.$size(), 2)) {
- return result['$[]'](0)
- } else {
- while ((($b = ($c = (first = result['$[]'](0)), $c !== false && $c !== nil ?first.$rstrip()['$empty?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- result.$shift()};
- while ((($b = ($c = (last = result['$[]'](-1)), $c !== false && $c !== nil ?last.$rstrip()['$empty?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- result.$pop()};
- return $rb_times(result, $scope.get('EOL'));
- };}else {if (self.content_model['$==']("empty")) {
- } else {
- self.$warn("Unknown content model '" + (self.content_model) + "' for block: " + (self.$to_s()))
- };
- return nil;}})();
- });
-
- Opal.defn(self, '$source', function() {
- var self = this;
-
- return $rb_times(self.lines, $scope.get('EOL'));
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var self = this, content_summary = nil;
-
- content_summary = (function() {if (self.content_model['$==']("compound")) {
- return "blocks: " + (self.blocks.$size())
- } else {
- return "lines: " + (self.lines.$size())
- }; return nil; })();
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", content_model: " + (self.content_model.$inspect()) + ", style: " + (self.style.$inspect()) + ", " + (content_summary) + "}>";
- }), nil) && 'to_s';
- })($scope.base, $scope.get('AbstractBlock'))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/callouts"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_le(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs);
- }
- function $rb_minus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$next_list', '$<<', '$current_list', '$to_i', '$generate_next_callout_id', '$+', '$<=', '$size', '$[]', '$-', '$chop', '$join', '$map', '$==', '$<', '$generate_callout_id']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Callouts(){};
- var self = $Callouts = $klass($base, $super, 'Callouts', $Callouts);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.co_index = def.lists = def.list_index = nil;
- Opal.defn(self, '$initialize', function() {
- var self = this;
-
- self.lists = [];
- self.list_index = 0;
- return self.$next_list();
- });
-
- Opal.defn(self, '$register', function(li_ordinal) {
- var self = this, id = nil;
-
- self.$current_list()['$<<']($hash2(["ordinal", "id"], {"ordinal": li_ordinal.$to_i(), "id": (id = self.$generate_next_callout_id())}));
- self.co_index = $rb_plus(self.co_index, 1);
- return id;
- });
-
- Opal.defn(self, '$read_next_id', function() {
- var self = this, id = nil, list = nil;
-
- id = nil;
- list = self.$current_list();
- if ($rb_le(self.co_index, list.$size())) {
- id = list['$[]']($rb_minus(self.co_index, 1))['$[]']("id")};
- self.co_index = $rb_plus(self.co_index, 1);
- return id;
- });
-
- Opal.defn(self, '$callout_ids', function(li_ordinal) {
- var $a, $b, TMP_1, self = this;
-
- return ($a = ($b = self.$current_list()).$map, $a.$$p = (TMP_1 = function(element){var self = TMP_1.$$s || this;
-if (element == null) element = nil;
- if (element['$[]']("ordinal")['$=='](li_ordinal)) {
- return "" + (element['$[]']("id")) + " "
- } else {
- return nil
- }}, TMP_1.$$s = self, TMP_1), $a).call($b).$join().$chop();
- });
-
- Opal.defn(self, '$current_list', function() {
- var self = this;
-
- return self.lists['$[]']($rb_minus(self.list_index, 1));
- });
-
- Opal.defn(self, '$next_list', function() {
- var self = this;
-
- self.list_index = $rb_plus(self.list_index, 1);
- if ($rb_lt(self.lists.$size(), self.list_index)) {
- self.lists['$<<']([])};
- self.co_index = 1;
- return nil;
- });
-
- Opal.defn(self, '$rewind', function() {
- var self = this;
-
- self.list_index = 1;
- self.co_index = 1;
- return nil;
- });
-
- Opal.defn(self, '$generate_next_callout_id', function() {
- var self = this;
-
- return self.$generate_callout_id(self.list_index, self.co_index);
- });
-
- return (Opal.defn(self, '$generate_callout_id', function(list_index, co_index) {
- var self = this;
-
- return "CO" + (list_index) + "-" + (co_index);
- }), nil) && 'generate_callout_id';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/converter/base"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$include', '$node_name', '$empty?', '$send', '$content']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base) {
- var self = $module($base, 'Converter');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- nil
- })($scope.base);
-
- (function($base, $super) {
- function $Base(){};
- var self = $Base = $klass($base, $super, 'Base', $Base);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- return self.$include($scope.get('Converter'))
- })($scope.get('Converter'), null);
-
- (function($base, $super) {
- function $BuiltIn(){};
- var self = $BuiltIn = $klass($base, $super, 'BuiltIn', $BuiltIn);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.defn(self, '$initialize', function(backend, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- return nil;
- });
-
- Opal.defn(self, '$convert', function(node, transform, opts) {
- var $a, self = this;
-
- if (transform == null) {
- transform = nil
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- ((($a = transform) !== false && $a !== nil) ? $a : transform = node.$node_name());
- if ((($a = opts['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (self.$send(transform, node))
- } else {
- return (self.$send(transform, node, opts))
- };
- });
-
- Opal.alias(self, 'handles?', 'respond_to?');
-
- Opal.defn(self, '$content', function(node) {
- var self = this;
-
- return node.$content();
- });
-
- Opal.alias(self, 'pass', 'content');
-
- return (Opal.defn(self, '$skip', function(node) {
- var self = this;
-
- return nil;
- }), nil) && 'skip';
- })($scope.get('Converter'), null);
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/converter/factory"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$new', '$require', '$to_s', '$warn', '$register', '$default', '$resolve', '$create', '$converters', '$unregister_all', '$attr_reader', '$each', '$[]=', '$==', '$[]', '$clear', '$is_a?', '$===', '$key?']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base) {
- var self = $module($base, 'Converter');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Factory(){};
- var self = $Factory = $klass($base, $super, 'Factory', $Factory);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.converters = def.star_converter = nil;
- self.__default__ = nil;
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- Opal.defn(self, '$default', function(initialize_singleton) {
- var $a, $b, self = this;
- if (self.__default__ == null) self.__default__ = nil;
-
- if (initialize_singleton == null) {
- initialize_singleton = true
- }
- if (initialize_singleton !== false && initialize_singleton !== nil) {
- } else {
- return ((($a = self.__default__) !== false && $a !== nil) ? $a : self.$new())
- };
- return ((($a = self.__default__) !== false && $a !== nil) ? $a : self.__default__ = (function() { try {
- (function() {if ((($b = (Opal.Object.$$scope.ThreadSafe == null ? nil : 'constant')) !== nil && (!$b.$$is_boolean || $b == true))) {
- return nil
- } else {
- return self.$require("thread_safe".$to_s())
- }; return nil; })()
- return self.$new(((Opal.get('ThreadSafe')).$$scope.get('Cache')).$new())
- } catch ($err) {if (Opal.rescue($err, [Opal.get('LoadError')])) {
- try {
- self.$warn("asciidoctor: WARNING: gem 'thread_safe' is not installed. This gem is recommended when registering custom converters.")
- return self.$new()
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- }})());
- });
- Opal.defn(self, '$register', function(converter, backends) {
- var self = this;
-
- if (backends == null) {
- backends = ["*"]
- }
- return self.$default().$register(converter, backends);
- });
- Opal.defn(self, '$resolve', function(backend) {
- var self = this;
-
- return self.$default().$resolve(backend);
- });
- Opal.defn(self, '$create', function(backend, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- return self.$default().$create(backend, opts);
- });
- Opal.defn(self, '$converters', function() {
- var self = this;
-
- return self.$default().$converters();
- });
- return (Opal.defn(self, '$unregister_all', function() {
- var self = this;
-
- return self.$default().$unregister_all();
- }), nil) && 'unregister_all';
- })(Opal.get_singleton_class(self));
-
- self.$attr_reader("converters");
-
- Opal.defn(self, '$initialize', function(converters) {
- var $a, self = this;
-
- if (converters == null) {
- converters = nil
- }
- self.converters = ((($a = converters) !== false && $a !== nil) ? $a : $hash2([], {}));
- return self.star_converter = nil;
- });
-
- Opal.defn(self, '$register', function(converter, backends) {
- var $a, $b, TMP_1, self = this;
-
- if (backends == null) {
- backends = ["*"]
- }
- ($a = ($b = backends).$each, $a.$$p = (TMP_1 = function(backend){var self = TMP_1.$$s || this;
- if (self.converters == null) self.converters = nil;
-if (backend == null) backend = nil;
- self.converters['$[]='](backend, converter);
- if (backend['$==']("*")) {
- return self.star_converter = converter
- } else {
- return nil
- };}, TMP_1.$$s = self, TMP_1), $a).call($b);
- return nil;
- });
-
- Opal.defn(self, '$resolve', function(backend) {
- var $a, $b, self = this;
-
- return ($a = self.converters, $a !== false && $a !== nil ?(((($b = self.converters['$[]'](backend)) !== false && $b !== nil) ? $b : self.star_converter)) : $a);
- });
-
- Opal.defn(self, '$unregister_all', function() {
- var self = this;
-
- self.converters.$clear();
- return self.star_converter = nil;
- });
-
- return (Opal.defn(self, '$create', function(backend, opts) {
- var $a, self = this, converter = nil, base_converter = nil, $case = nil, template_converter = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = (converter = self.$resolve(backend))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = converter['$is_a?'](Opal.get('Class'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return converter.$new(backend, opts)
- } else {
- return converter
- }};
- base_converter = (function() {$case = backend;if ("html5"['$===']($case)) {if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('Html5Converter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/html5".$to_s())
- };
- return $scope.get('Html5Converter').$new(backend, opts);}else if ("docbook5"['$===']($case)) {if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('DocBook5Converter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/docbook5".$to_s())
- };
- return $scope.get('DocBook5Converter').$new(backend, opts);}else if ("docbook45"['$===']($case)) {if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('DocBook45Converter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/docbook45".$to_s())
- };
- return $scope.get('DocBook45Converter').$new(backend, opts);}else if ("manpage"['$===']($case)) {if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('ManPageConverter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/manpage".$to_s())
- };
- return $scope.get('ManPageConverter').$new(backend, opts);}else { return nil }})();
- if ((($a = opts['$key?']("template_dirs")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return base_converter
- };
- if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('TemplateConverter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/template".$to_s())
- };
- if ((($a = (function(){ try { return ((((((Opal.get('Asciidoctor')).$$scope.get('Converter'))).$$scope.get('CompositeConverter'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$require("asciidoctor/converter/composite".$to_s())
- };
- template_converter = $scope.get('TemplateConverter').$new(backend, opts['$[]']("template_dirs"), opts);
- return $scope.get('CompositeConverter').$new(backend, template_converter, base_converter);
- }), nil) && 'create';
- })($scope.base, null)
- })($scope.base)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/converter"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $range = Opal.range, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$register', '$==', '$send', '$include?', '$setup_backend_info', '$raise', '$class', '$sub', '$[]', '$[]=', '$backend_info', '$extend', '$include', '$respond_to?', '$write', '$chomp', '$open', '$require']);
- (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base) {
- var self = $module($base, 'Converter');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base) {
- var self = $module($base, 'Config');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.defn(self, '$register_for', function() {
- var $a, $b, TMP_1, $c, TMP_2, self = this, metaclass = nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var backends = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- backends[arg_index] = arguments[arg_index + 0];
- }
- $scope.get('Factory').$register(self, backends);
- metaclass = (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- return self
- })(Opal.get_singleton_class(self));
- if (backends['$=='](["*"])) {
- ($a = ($b = metaclass).$send, $a.$$p = (TMP_1 = function(name){var self = TMP_1.$$s || this;
-if (name == null) name = nil;
- return true}, TMP_1.$$s = self, TMP_1), $a).call($b, "define_method", "converts?")
- } else {
- ($a = ($c = metaclass).$send, $a.$$p = (TMP_2 = function(name){var self = TMP_2.$$s || this;
-if (name == null) name = nil;
- return backends['$include?'](name)}, TMP_2.$$s = self, TMP_2), $a).call($c, "define_method", "converts?")
- };
- return nil;
- })
- })($scope.base);
-
- (function($base) {
- var self = $module($base, 'BackendInfo');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.defn(self, '$backend_info', function() {
- var $a, self = this;
- if (self.backend_info == null) self.backend_info = nil;
-
- return ((($a = self.backend_info) !== false && $a !== nil) ? $a : self.backend_info = self.$setup_backend_info());
- });
-
- Opal.defn(self, '$setup_backend_info', function() {
- var $a, self = this, base = nil, ext = nil, type = nil, syntax = nil;
- if (self.backend == null) self.backend = nil;
-
- if ((($a = self.backend) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError'), "Cannot determine backend for converter: " + (self.$class()))
- };
- base = self.backend.$sub($scope.get('TrailingDigitsRx'), "");
- if ((($a = (ext = $scope.get('DEFAULT_EXTENSIONS')['$[]'](base))) !== nil && (!$a.$$is_boolean || $a == true))) {
- type = ext['$[]']($range(1, -1, false))
- } else {
- base = "html";
- ext = ".html";
- type = "html";
- syntax = "html";
- };
- return $hash2(["basebackend", "outfilesuffix", "filetype", "htmlsyntax"], {"basebackend": base, "outfilesuffix": ext, "filetype": type, "htmlsyntax": syntax});
- });
-
- Opal.defn(self, '$filetype', function(value) {
- var self = this;
-
- if (value == null) {
- value = nil
- }
- if (value !== false && value !== nil) {
- return self.$backend_info()['$[]=']("filetype", value)
- } else {
- return self.$backend_info()['$[]']("filetype")
- };
- });
-
- Opal.defn(self, '$basebackend', function(value) {
- var self = this;
-
- if (value == null) {
- value = nil
- }
- if (value !== false && value !== nil) {
- return self.$backend_info()['$[]=']("basebackend", value)
- } else {
- return self.$backend_info()['$[]']("basebackend")
- };
- });
-
- Opal.defn(self, '$outfilesuffix', function(value) {
- var self = this;
-
- if (value == null) {
- value = nil
- }
- if (value !== false && value !== nil) {
- return self.$backend_info()['$[]=']("outfilesuffix", value)
- } else {
- return self.$backend_info()['$[]']("outfilesuffix")
- };
- });
-
- Opal.defn(self, '$htmlsyntax', function(value) {
- var self = this;
-
- if (value == null) {
- value = nil
- }
- if (value !== false && value !== nil) {
- return self.$backend_info()['$[]=']("htmlsyntax", value)
- } else {
- return self.$backend_info()['$[]']("htmlsyntax")
- };
- });
- })($scope.base);
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- return (Opal.defn(self, '$included', function(converter) {
- var self = this;
-
- return converter.$extend($scope.get('Config'));
- }), nil) && 'included'
- })(Opal.get_singleton_class(self));
-
- self.$include($scope.get('Config'));
-
- self.$include($scope.get('BackendInfo'));
-
- Opal.defn(self, '$initialize', function(backend, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- self.backend = backend;
- return self.$setup_backend_info();
- });
-
- Opal.defn(self, '$convert', function(node, transform, opts) {
- var self = this;
-
- if (transform == null) {
- transform = nil
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- return self.$raise(Opal.get('NotImplementedError'));
- });
-
- Opal.alias(self, 'convert_with_options', 'convert');
- })($scope.base);
-
- (function($base) {
- var self = $module($base, 'Writer');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.defn(self, '$write', function(output, target) {
- var $a, $b, TMP_3, self = this;
-
- if ((($a = target['$respond_to?']("write")) !== nil && (!$a.$$is_boolean || $a == true))) {
- target.$write(output.$chomp());
- target.$write($scope.get('EOL'));
- } else {
- ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_3 = function(f){var self = TMP_3.$$s || this;
-if (f == null) f = nil;
- return f.$write(output)}, TMP_3.$$s = self, TMP_3), $a).call($b, target, "w")
- };
- return nil;
- })
- })($scope.base);
-
- (function($base) {
- var self = $module($base, 'VoidWriter');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$include($scope.get('Writer'));
-
- Opal.defn(self, '$write', function(output, target) {
- var self = this;
-
- return nil;
- });
- })($scope.base);
- })($scope.base);
- self.$require("asciidoctor/converter/base");
- return self.$require("asciidoctor/converter/factory");
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/converter/html5"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_ge(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_le(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$default=', '$==', '$[]', '$instance', '$empty?', '$attr', '$>=', '$safe', '$attr?', '$<<', '$doctitle', '$include?', '$normalize_web_path', '$embed_primary_stylesheet', '$read_asset', '$normalize_system_path', '$===', '$coderay_stylesheet_name', '$embed_coderay_stylesheet', '$pygments_stylesheet_name', '$embed_pygments_stylesheet', '$docinfo', '$id', '$sections?', '$doctype', '$*', '$noheader', '$outline', '$has_header?', '$notitle', '$title', '$header', '$sub_macros', '$>', '$to_i', '$each', '$downcase', '$concat', '$content', '$footnotes?', '$!', '$index', '$text', '$footnotes', '$nofooter', '$inspect', '$!=', '$document', '$sections', '$level', '$special', '$numbered', '$caption', '$<=', '$sectnum', '$<', '$captioned_title', '$+', '$role', '$title?', '$icon_uri', '$compact', '$style', '$media_uri', '$option?', '$append_boolean_attribute', '$each_with_index', '$items', '$text?', '$blocks?', '$chomp', '$read_svg_contents', '$image_uri', '$to_sym', '$start_with?', '$end_with?', '$list_marker_keyword', '$parent', '$warn', '$context', '$times', '$size', '$columns', '$colspan', '$rowspan', '$rows', '$select', '$role?', '$insert', '$split', '$target', '$type', '$attributes', '$references', '$join', '$map', '$chop', '$read_contents', '$sub', '$gsub', '$match']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Html5Converter(){};
- var self = $Html5Converter = $klass($base, $super, 'Html5Converter', $Html5Converter);
-
- var def = self.$$proto, $scope = self.$$scope, $a, $b;
-
- def.xml_mode = def.void_element_slash = def.stylesheets = nil;
- (($a = [[nil, nil, nil]]), $b = (Opal.cdecl($scope, 'QUOTE_TAGS', $hash2(["emphasis", "strong", "monospaced", "superscript", "subscript", "double", "single", "mark", "asciimath", "latexmath"], {"emphasis": ["", " ", true], "strong": ["", " ", true], "monospaced": ["", "
", true], "superscript": ["", " ", true], "subscript": ["", " ", true], "double": ["“", "”", false], "single": ["‘", "’", false], "mark": ["", " ", true], "asciimath": ["\\$", "\\$", false], "latexmath": ["\\(", "\\)", false]}))), $b['$default='].apply($b, $a), $a[$a.length-1]);
-
- Opal.cdecl($scope, 'SvgPreambleRx', /\A.*?(?=])/m);
-
- Opal.cdecl($scope, 'SvgStartTagRx', /\A]*>/);
-
- Opal.cdecl($scope, 'DimensionAttributeRx', /\s(?:width|height|style)=(["']).*?\1/);
-
- Opal.defn(self, '$initialize', function(backend, opts) {
- var $a, self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- self.xml_mode = opts['$[]']("htmlsyntax")['$==']("xml");
- self.void_element_slash = (function() {if ((($a = self.xml_mode) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "/"
- } else {
- return nil
- }; return nil; })();
- return self.stylesheets = $scope.get('Stylesheets').$instance();
- });
-
- Opal.defn(self, '$document', function(node) {
- var $a, $b, $c, $d, TMP_1, TMP_2, self = this, result = nil, slash = nil, br = nil, asset_uri_scheme = nil, cdn_base = nil, linkcss = nil, lang_attribute = nil, webfonts = nil, iconfont_stylesheet = nil, $case = nil, highlighter = nil, pygments_style = nil, docinfo_content = nil, body_attrs = nil, sectioned = nil, details = nil, authorcount = nil, highlightjs_path = nil, prettify_path = nil, eqnums_val = nil, eqnums_opt = nil;
-
- result = [];
- slash = self.void_element_slash;
- br = " ";
- if ((($a = ((asset_uri_scheme = (node.$attr("asset-uri-scheme", "https"))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- asset_uri_scheme = "" + (asset_uri_scheme) + ":"
- };
- cdn_base = "" + (asset_uri_scheme) + "//cdnjs.cloudflare.com/ajax/libs";
- linkcss = ((($a = $rb_ge(node.$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE')))) !== false && $a !== nil) ? $a : (node['$attr?']("linkcss")));
- result['$<<']("");
- lang_attribute = (function() {if ((($a = (node['$attr?']("nolang"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " lang=\"" + (node.$attr("lang", "en")) + "\""
- }; return nil; })();
- result['$<<']("");
- result['$<<']("\n \n\n \n ");
- if ((($a = node['$attr?']("app-name")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- if ((($a = node['$attr?']("description")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- if ((($a = node['$attr?']("keywords")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- if ((($a = node['$attr?']("authors")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- if ((($a = node['$attr?']("copyright")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- result['$<<']("" + (node.$doctitle($hash2(["sanitize", "use_fallback"], {"sanitize": true, "use_fallback": true}))) + " ");
- if ((($a = $scope.get('DEFAULT_STYLESHEET_KEYS')['$include?'](node.$attr("stylesheet"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (webfonts = node.$attr("webfonts"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")};
- if (linkcss !== false && linkcss !== nil) {
- result['$<<'](" ")
- } else {
- result['$<<'](self.stylesheets.$embed_primary_stylesheet())
- };
- } else if ((($a = node['$attr?']("stylesheet")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (linkcss !== false && linkcss !== nil) {
- result['$<<'](" ")
- } else {
- result['$<<']("")
- }};
- if ((($a = node['$attr?']("icons", "font")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = node['$attr?']("iconfont-remote")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](" ")
- } else {
- iconfont_stylesheet = "" + (node.$attr("iconfont-name", "font-awesome")) + ".css";
- result['$<<'](" ");
- }};
- $case = (highlighter = node.$attr("source-highlighter"));if ("coderay"['$===']($case)) {if ((node.$attr("coderay-css", "class"))['$==']("class")) {
- if (linkcss !== false && linkcss !== nil) {
- result['$<<'](" ")
- } else {
- result['$<<'](self.stylesheets.$embed_coderay_stylesheet())
- }}}else if ("pygments"['$===']($case)) {if ((node.$attr("pygments-css", "class"))['$==']("class")) {
- pygments_style = node.$attr("pygments-style");
- if (linkcss !== false && linkcss !== nil) {
- result['$<<'](" ")
- } else {
- result['$<<']((self.stylesheets.$embed_pygments_stylesheet(pygments_style)))
- };}};
- if ((($a = ((docinfo_content = node.$docinfo()))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- result['$<<'](docinfo_content)
- };
- result['$<<']("");
- body_attrs = [];
- if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- body_attrs['$<<']("id=\"" + (node.$id()) + "\"")};
- if ((($a = ($b = ($c = ($d = (sectioned = node['$sections?']()), $d !== false && $d !== nil ?(node['$attr?']("toc-class")) : $d), $c !== false && $c !== nil ?(node['$attr?']("toc")) : $c), $b !== false && $b !== nil ?(node['$attr?']("toc-placement", "auto")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- body_attrs['$<<']("class=\"" + (node.$doctype()) + " " + (node.$attr("toc-class")) + " toc-" + (node.$attr("toc-position", "header")) + "\"")
- } else {
- body_attrs['$<<']("class=\"" + (node.$doctype()) + "\"")
- };
- if ((($a = node['$attr?']("max-width")) !== nil && (!$a.$$is_boolean || $a == true))) {
- body_attrs['$<<']("style=\"max-width: " + (node.$attr("max-width")) + ";\"")};
- result['$<<']("");
- if ((($a = node.$noheader()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- result['$<<']("");
- };
- result['$<<']("\n" + (node.$content()) + "\n
");
- if ((($a = ($c = node['$footnotes?'](), $c !== false && $c !== nil ?(node['$attr?']("nofootnotes"))['$!']() : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("");};
- if ((($a = node.$nofooter()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- result['$<<']("");
- };
- if ((($a = ((docinfo_content = node.$docinfo("footer")))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- result['$<<'](docinfo_content)
- };
- $case = highlighter;if ("highlightjs"['$===']($case) || "highlight.js"['$===']($case)) {highlightjs_path = node.$attr("highlightjsdir", "" + (cdn_base) + "/highlight.js/8.9.1");
- result['$<<'](" ");
- result['$<<']("\n");}else if ("prettify"['$===']($case)) {prettify_path = node.$attr("prettifydir", "" + (cdn_base) + "/prettify/r298");
- result['$<<'](" ");
- result['$<<']("\n");};
- if ((($a = node['$attr?']("stem")) !== nil && (!$a.$$is_boolean || $a == true))) {
- eqnums_val = node.$attr("eqnums", "none");
- if (eqnums_val['$==']("")) {
- eqnums_val = "AMS"};
- eqnums_opt = " equationNumbers: { autoNumber: \"" + (eqnums_val) + "\" } ";
- result['$<<']("\n");};
- result['$<<']("");
- result['$<<']("");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$embedded', function(node) {
- var $a, $b, $c, $d, TMP_3, self = this, result = nil, id_attr = nil, toc_p = nil;
-
- result = [];
- if (node.$doctype()['$==']("manpage")) {
- if ((($a = node.$notitle()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- result['$<<']("" + (node.$doctitle()) + " Manual Page ");
- };
- result['$<<']("" + (node.$attr("manname-title")) + " \n\n
" + (node.$attr("manname")) + " - " + (node.$attr("manpurpose")) + "
\n
");
- } else if ((($a = ($b = node['$has_header?'](), $b !== false && $b !== nil ?node.$notitle()['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- result['$<<']("" + (node.$header().$title()) + " ");};
- if ((($a = ($b = ($c = ($d = node['$sections?'](), $d !== false && $d !== nil ?(node['$attr?']("toc")) : $d), $c !== false && $c !== nil ?((toc_p = node.$attr("toc-placement")))['$!=']("macro") : $c), $b !== false && $b !== nil ?toc_p['$!=']("preamble") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("\n
" + (node.$attr("toc-title")) + "
\n" + (self.$outline(node)) + "\n
")};
- result['$<<'](node.$content());
- if ((($a = ($b = node['$footnotes?'](), $b !== false && $b !== nil ?(node['$attr?']("nofootnotes"))['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("");};
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$outline', function(node, opts) {
- var $a, $b, TMP_4, self = this, sectnumlevels = nil, toclevels = nil, result = nil, sections = nil, slevel = nil, first_section = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = node['$sections?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- sectnumlevels = ((($a = opts['$[]']("sectnumlevels")) !== false && $a !== nil) ? $a : (node.$document().$attr("sectnumlevels", 3)).$to_i());
- toclevels = ((($a = opts['$[]']("toclevels")) !== false && $a !== nil) ? $a : (node.$document().$attr("toclevels", 2)).$to_i());
- result = [];
- sections = node.$sections();
- slevel = ((first_section = sections['$[]'](0))).$level();
- if ((($a = (($b = slevel['$=='](0)) ? first_section.$special() : slevel['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- slevel = 1};
- result['$<<']("");
- ($a = ($b = sections).$each, $a.$$p = (TMP_4 = function(section){var self = TMP_4.$$s || this, $a, $b, $c, section_num = nil, child_toc_level = nil;
-if (section == null) section = nil;
- section_num = (function() {if ((($a = (($b = ($c = section.$numbered(), $c !== false && $c !== nil ?section.$caption()['$!']() : $c), $b !== false && $b !== nil ?$rb_le(section.$level(), sectnumlevels) : $b))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (section.$sectnum()) + " "
- } else {
- return nil
- }; return nil; })();
- if ((($a = (($b = $rb_lt(section.$level(), toclevels)) ? (child_toc_level = self.$outline(section, $hash2(["toclevels", "secnumlevels"], {"toclevels": toclevels, "secnumlevels": sectnumlevels}))) : $rb_lt(section.$level(), toclevels))) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("" + (section_num) + (section.$captioned_title()) + " ");
- result['$<<'](child_toc_level);
- return result['$<<'](" ");
- } else {
- return result['$<<']("" + (section_num) + (section.$captioned_title()) + " ")
- };}, TMP_4.$$s = self, TMP_4), $a).call($b);
- result['$<<'](" ");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$section', function(node) {
- var $a, $b, $c, self = this, slevel = nil, htag = nil, id_attr = nil, anchor = nil, link_start = nil, link_end = nil, class_attr = nil, role = nil, sectnum = nil;
-
- slevel = node.$level();
- if ((($a = (($b = slevel['$=='](0)) ? node.$special() : slevel['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- slevel = 1};
- htag = "h" + ($rb_plus(slevel, 1));
- id_attr = anchor = link_start = link_end = nil;
- if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- id_attr = " id=\"" + (node.$id()) + "\"";
- if ((($a = node.$document()['$attr?']("sectanchors")) !== nil && (!$a.$$is_boolean || $a == true))) {
- anchor = " "
- } else if ((($a = node.$document()['$attr?']("sectlinks")) !== nil && (!$a.$$is_boolean || $a == true))) {
- link_start = "";
- link_end = " ";};};
- if (slevel['$=='](0)) {
- return "" + (anchor) + (link_start) + (node.$title()) + (link_end) + " \n" + (node.$content())
- } else {
- class_attr = (function() {if ((($a = (role = node.$role())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " class=\"sect" + (slevel) + " " + (role) + "\""
- } else {
- return " class=\"sect" + (slevel) + "\""
- }; return nil; })();
- sectnum = (function() {if ((($a = ($b = ($c = node.$numbered(), $c !== false && $c !== nil ?node.$caption()['$!']() : $c), $b !== false && $b !== nil ?$rb_le(slevel, (node.$document().$attr("sectnumlevels", 3)).$to_i()) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$sectnum()) + " "
- } else {
- return nil
- }; return nil; })();
- return "\n<" + (htag) + (id_attr) + ">" + (anchor) + (link_start) + (sectnum) + (node.$captioned_title()) + (link_end) + "" + (htag) + ">\n" + ((function() {if (slevel['$=='](1)) {
- return "
\n" + (node.$content()) + "\n
"
- } else {
- return node.$content()
- }; return nil; })()) + "\n
";
- };
- });
-
- Opal.defn(self, '$admonition', function(node) {
- var $a, $b, self = this, id_attr = nil, name = nil, title_element = nil, caption = nil, role = nil;
-
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- name = node.$attr("name");
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- caption = (function() {if ((($a = node.$document()['$attr?']("icons")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = (node.$document()['$attr?']("icons", "font")), $b !== false && $b !== nil ?(node['$attr?']("icon"))['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " "
- } else {
- return " "
- }
- } else {
- return "" + (node.$caption()) + "
"
- }; return nil; })();
- return "\n
\n\n\n" + (caption) + "\n \n\n" + (title_element) + (node.$content()) + "\n \n \n
\n
";
- });
-
- Opal.defn(self, '$audio', function(node) {
- var $a, self = this, xml = nil, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil;
-
- xml = node.$document()['$attr?']("htmlsyntax", "xml");
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["audioblock", node.$style(), node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$captioned_title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- return "\n" + (title_element) + "
\n
\nYour browser does not support the audio tag.\n \n
\n
";
- });
-
- Opal.defn(self, '$colist', function(node) {
- var $a, $b, TMP_5, $c, TMP_6, self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, font_icons = nil;
-
- result = [];
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["colist", node.$style(), node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- result['$<<']("");
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("
" + (node.$title()) + "
")};
- if ((($a = node.$document()['$attr?']("icons")) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("
");
- font_icons = node.$document()['$attr?']("icons", "font");
- ($a = ($b = node.$items()).$each_with_index, $a.$$p = (TMP_5 = function(item, i){var self = TMP_5.$$s || this, num = nil, num_element = nil;
- if (self.void_element_slash == null) self.void_element_slash = nil;
-if (item == null) item = nil;if (i == null) i = nil;
- num = $rb_plus(i, 1);
- num_element = (function() {if (font_icons !== false && font_icons !== nil) {
- return "" + (num) + " "
- } else {
- return " "
- }; return nil; })();
- return result['$<<']("\n" + (num_element) + " \n" + (item.$text()) + " \n ");}, TMP_5.$$s = self, TMP_5), $a).call($b);
- result['$<<']("
");
- } else {
- result['$<<']("
");
- ($a = ($c = node.$items()).$each, $a.$$p = (TMP_6 = function(item){var self = TMP_6.$$s || this;
-if (item == null) item = nil;
- return result['$<<']("\n" + (item.$text()) + "
\n ")}, TMP_6.$$s = self, TMP_6), $a).call($c);
- result['$<<'](" ");
- };
- result['$<<']("
");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$dlist', function(node) {
- var $a, $b, TMP_7, $c, TMP_9, $d, TMP_11, self = this, result = nil, id_attribute = nil, classes = nil, $case = nil, class_attribute = nil, slash = nil, col_style_attribute = nil, dt_style_attribute = nil;
-
- result = [];
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = (function() {$case = node.$style();if ("qanda"['$===']($case)) {return ["qlist", "qanda", node.$role()]}else if ("horizontal"['$===']($case)) {return ["hdlist", node.$role()]}else {return ["dlist", node.$style(), node.$role()]}})().$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- result['$<<']("");
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("
" + (node.$title()) + "
")};
- $case = node.$style();if ("qanda"['$===']($case)) {result['$<<']("
");
- ($a = ($b = node.$items()).$each, $a.$$p = (TMP_7 = function(terms, dd){var self = TMP_7.$$s || this, $a, $b, TMP_8;
-if (terms == null) terms = nil;if (dd == null) dd = nil;
- result['$<<']("");
- ($a = ($b = [].concat(Opal.to_a(terms))).$each, $a.$$p = (TMP_8 = function(dt){var self = TMP_8.$$s || this;
-if (dt == null) dt = nil;
- return result['$<<']("" + (dt.$text()) + "
")}, TMP_8.$$s = self, TMP_8), $a).call($b);
- if (dd !== false && dd !== nil) {
- if ((($a = dd['$text?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("" + (dd.$text()) + "
")};
- if ((($a = dd['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](dd.$content())};};
- return result['$<<'](" ");}, TMP_7.$$s = self, TMP_7), $a).call($b);
- result['$<<'](" ");}else if ("horizontal"['$===']($case)) {slash = self.void_element_slash;
- result['$<<']("
");
- if ((($a = ((($c = (node['$attr?']("labelwidth"))) !== false && $c !== nil) ? $c : (node['$attr?']("itemwidth")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("");
- col_style_attribute = (function() {if ((($a = (node['$attr?']("labelwidth"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " style=\"width: " + ((node.$attr("labelwidth")).$chomp("%")) + "%;\""
- } else {
- return nil
- }; return nil; })();
- result['$<<'](" ");
- col_style_attribute = (function() {if ((($a = (node['$attr?']("itemwidth"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " style=\"width: " + ((node.$attr("itemwidth")).$chomp("%")) + "%;\""
- } else {
- return nil
- }; return nil; })();
- result['$<<'](" ");
- result['$<<'](" ");};
- ($a = ($c = node.$items()).$each, $a.$$p = (TMP_9 = function(terms, dd){var self = TMP_9.$$s || this, $a, $b, TMP_10, terms_array = nil, last_term = nil;
-if (terms == null) terms = nil;if (dd == null) dd = nil;
- result['$<<']("");
- result['$<<']("");
- terms_array = [].concat(Opal.to_a(terms));
- last_term = terms_array['$[]'](-1);
- ($a = ($b = terms_array).$each, $a.$$p = (TMP_10 = function(dt){var self = TMP_10.$$s || this, $a;
-if (dt == null) dt = nil;
- result['$<<'](dt.$text());
- if ((($a = dt['$!='](last_term)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return result['$<<'](" ")
- } else {
- return nil
- };}, TMP_10.$$s = self, TMP_10), $a).call($b);
- result['$<<'](" ");
- result['$<<']("");
- if (dd !== false && dd !== nil) {
- if ((($a = dd['$text?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("" + (dd.$text()) + "
")};
- if ((($a = dd['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](dd.$content())};};
- result['$<<'](" ");
- return result['$<<'](" ");}, TMP_9.$$s = self, TMP_9), $a).call($c);
- result['$<<']("
");}else {result['$<<']("
");
- dt_style_attribute = (function() {if ((($a = node.$style()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " class=\"hdlist1\""
- }; return nil; })();
- ($a = ($d = node.$items()).$each, $a.$$p = (TMP_11 = function(terms, dd){var self = TMP_11.$$s || this, $a, $b, TMP_12;
-if (terms == null) terms = nil;if (dd == null) dd = nil;
- ($a = ($b = [].concat(Opal.to_a(terms))).$each, $a.$$p = (TMP_12 = function(dt){var self = TMP_12.$$s || this;
-if (dt == null) dt = nil;
- return result['$<<']("" + (dt.$text()) + " ")}, TMP_12.$$s = self, TMP_12), $a).call($b);
- if (dd !== false && dd !== nil) {
- result['$<<']("");
- if ((($a = dd['$text?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("" + (dd.$text()) + "
")};
- if ((($a = dd['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](dd.$content())};
- return result['$<<'](" ");
- } else {
- return nil
- };}, TMP_11.$$s = self, TMP_11), $a).call($d);
- result['$<<'](" ");};
- result['$<<']("
");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$example', function(node) {
- var $a, self = this, id_attribute = nil, title_element = nil, role = nil;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$captioned_title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- return "\n" + (title_element) + "
\n" + (node.$content()) + "\n
\n
";
- });
-
- Opal.defn(self, '$floating_title', function(node) {
- var $a, self = this, tag_name = nil, id_attribute = nil, classes = nil;
-
- tag_name = "h" + ($rb_plus(node.$level(), 1));
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = [node.$style(), node.$role()].$compact();
- return "<" + (tag_name) + (id_attribute) + " class=\"" + ($rb_times(classes, " ")) + "\">" + (node.$title()) + "" + (tag_name) + ">";
- });
-
- Opal.defn(self, '$image', function(node) {
- var $a, $b, $c, self = this, target = nil, width_attr = nil, height_attr = nil, svg = nil, obj = nil, img = nil, fallback = nil, link = nil, id_attr = nil, classes = nil, class_attr = nil, styles = nil, style_attr = nil, title_el = nil;
-
- target = node.$attr("target");
- width_attr = (function() {if ((($a = (node['$attr?']("width"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " width=\"" + (node.$attr("width")) + "\""
- } else {
- return nil
- }; return nil; })();
- height_attr = (function() {if ((($a = (node['$attr?']("height"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " height=\"" + (node.$attr("height")) + "\""
- } else {
- return nil
- }; return nil; })();
- if ((($a = ($b = (((($c = (node['$attr?']("format", "svg", false))) !== false && $c !== nil) ? $c : (target['$include?'](".svg")))), $b !== false && $b !== nil ?$rb_lt(node.$document().$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE'))) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- ((($a = (svg = (node['$option?']("inline")))) !== false && $a !== nil) ? $a : (obj = (node['$option?']("interactive"))));
- if (svg !== false && svg !== nil) {
- img = ((($a = (self.$read_svg_contents(node, target))) !== false && $a !== nil) ? $a : "" + (node.$attr("alt")) + " ")
- } else if (obj !== false && obj !== nil) {
- fallback = (function() {if ((($a = (node['$attr?']("fallback"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " "
- } else {
- return "" + (node.$attr("alt")) + " "
- }; return nil; })();
- img = "" + (fallback) + " ";};};
- ((($a = img) !== false && $a !== nil) ? $a : img = " ");
- if ((($a = (link = node.$attr("link"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- img = "" + (img) + " "};
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["imageblock", node.$style(), node.$role()].$compact();
- class_attr = " class=\"" + ($rb_times(classes, " ")) + "\"";
- styles = [];
- if ((($a = node['$attr?']("align")) !== nil && (!$a.$$is_boolean || $a == true))) {
- styles['$<<']("text-align: " + (node.$attr("align")))};
- if ((($a = node['$attr?']("float")) !== nil && (!$a.$$is_boolean || $a == true))) {
- styles['$<<']("float: " + (node.$attr("float")))};
- style_attr = (function() {if ((($a = styles['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " style=\"" + ($rb_times(styles, ";")) + "\""
- }; return nil; })();
- title_el = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "\n" + (node.$captioned_title()) + "
"
- } else {
- return nil
- }; return nil; })();
- return "\n
\n" + (img) + "\n
" + (title_el) + "\n
";
- });
-
- Opal.defn(self, '$listing', function(node) {
- var $a, self = this, nowrap = nil, language = nil, code_attrs = nil, $case = nil, pre_class = nil, pre_start = nil, pre_end = nil, id_attribute = nil, title_element = nil, role = nil;
-
- nowrap = ((($a = (node.$document()['$attr?']("prewrap"))['$!']()) !== false && $a !== nil) ? $a : (node['$option?']("nowrap")));
- if (node.$style()['$==']("source")) {
- if ((($a = (language = node.$attr("language", nil, false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- code_attrs = " data-lang=\"" + (language) + "\""
- } else {
- code_attrs = nil
- };
- $case = node.$document().$attr("source-highlighter");if ("coderay"['$===']($case)) {pre_class = " class=\"CodeRay highlight" + ((function() {if (nowrap !== false && nowrap !== nil) {
- return " nowrap"
- } else {
- return nil
- }; return nil; })()) + "\""}else if ("pygments"['$===']($case)) {pre_class = " class=\"pygments highlight" + ((function() {if (nowrap !== false && nowrap !== nil) {
- return " nowrap"
- } else {
- return nil
- }; return nil; })()) + "\""}else if ("highlightjs"['$===']($case) || "highlight.js"['$===']($case)) {pre_class = " class=\"highlightjs highlight" + ((function() {if (nowrap !== false && nowrap !== nil) {
- return " nowrap"
- } else {
- return nil
- }; return nil; })()) + "\"";
- if (language !== false && language !== nil) {
- code_attrs = " class=\"language-" + (language) + "\"" + (code_attrs)};}else if ("prettify"['$===']($case)) {pre_class = " class=\"prettyprint highlight" + ((function() {if (nowrap !== false && nowrap !== nil) {
- return " nowrap"
- } else {
- return nil
- }; return nil; })()) + ((function() {if ((($a = (node['$attr?']("linenums"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " linenums"
- } else {
- return nil
- }; return nil; })()) + "\"";
- if (language !== false && language !== nil) {
- code_attrs = " class=\"language-" + (language) + "\"" + (code_attrs)};}else if ("html-pipeline"['$===']($case)) {pre_class = (function() {if (language !== false && language !== nil) {
- return " lang=\"" + (language) + "\""
- } else {
- return nil
- }; return nil; })();
- code_attrs = nil;}else {pre_class = " class=\"highlight" + ((function() {if (nowrap !== false && nowrap !== nil) {
- return " nowrap"
- } else {
- return nil
- }; return nil; })()) + "\"";
- if (language !== false && language !== nil) {
- code_attrs = " class=\"language-" + (language) + "\"" + (code_attrs)};};
- pre_start = "";
- pre_end = "
";
- } else {
- pre_start = "";
- pre_end = " ";
- };
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$captioned_title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- return "\n" + (title_element) + "
\n" + (pre_start) + (node.$content()) + (pre_end) + "\n
\n
";
- });
-
- Opal.defn(self, '$literal', function(node) {
- var $a, self = this, id_attribute = nil, title_element = nil, nowrap = nil, role = nil;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- nowrap = ((($a = (node.$document()['$attr?']("prewrap"))['$!']()) !== false && $a !== nil) ? $a : (node['$option?']("nowrap")));
- return "\n" + (title_element) + "
\n
" + (node.$content()) + " \n
\n
";
- });
-
- Opal.defn(self, '$stem', function(node) {
- var $a, $b, self = this, id_attribute = nil, title_element = nil, open = nil, close = nil, equation = nil, role = nil;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- $a = Opal.to_ary($scope.get('BLOCK_MATH_DELIMITERS')['$[]'](node.$style().$to_sym())), open = ($a[0] == null ? nil : $a[0]), close = ($a[1] == null ? nil : $a[1]);
- if ((($a = ($b = (((equation = node.$content()))['$start_with?'](open)), $b !== false && $b !== nil ?(equation['$end_with?'](close)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- equation = "" + (open) + (equation) + (close)
- };
- return "\n" + (title_element) + "
\n" + (equation) + "\n
\n
";
- });
-
- Opal.defn(self, '$olist', function(node) {
- var $a, $b, TMP_13, self = this, result = nil, id_attribute = nil, classes = nil, class_attribute = nil, type_attribute = nil, keyword = nil, start_attribute = nil;
-
- result = [];
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["olist", node.$style(), node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- result['$<<']("");
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("
" + (node.$title()) + "
")};
- type_attribute = (function() {if ((($a = (keyword = node.$list_marker_keyword())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " type=\"" + (keyword) + "\""
- } else {
- return nil
- }; return nil; })();
- start_attribute = (function() {if ((($a = (node['$attr?']("start"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " start=\"" + (node.$attr("start")) + "\""
- } else {
- return nil
- }; return nil; })();
- result['$<<']("
");
- ($a = ($b = node.$items()).$each, $a.$$p = (TMP_13 = function(item){var self = TMP_13.$$s || this, $a;
-if (item == null) item = nil;
- result['$<<']("");
- result['$<<']("" + (item.$text()) + "
");
- if ((($a = item['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<'](item.$content())};
- return result['$<<'](" ");}, TMP_13.$$s = self, TMP_13), $a).call($b);
- result['$<<'](" ");
- result['$<<']("
");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$open', function(node) {
- var $a, $b, $c, $d, self = this, style = nil, id_attr = nil, title_el = nil, role = nil;
-
- if (((style = node.$style()))['$==']("abstract")) {
- if ((($a = (($b = node.$parent()['$=='](node.$document())) ? node.$document().$doctype()['$==']("book") : node.$parent()['$=='](node.$document()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.");
- return "";
- } else {
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_el = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
"
- } else {
- return nil
- }; return nil; })();
- return "\n" + (title_el) + "
\n" + (node.$content()) + "\n \n
";
- }
- } else if ((($a = (($b = style['$==']("partintro")) ? (((($c = ((($d = node.$level()['$!='](0)) !== false && $d !== nil) ? $d : node.$parent().$context()['$!=']("section"))) !== false && $c !== nil) ? $c : node.$document().$doctype()['$!=']("book"))) : style['$==']("partintro"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: ERROR: partintro block can only be used when doctype is book and it's a child of a book part. Excluding block content.");
- return "";
- } else {
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_el = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
"
- } else {
- return nil
- }; return nil; })();
- return "\n" + (title_el) + "
\n" + (node.$content()) + "\n
\n
";
- };
- });
-
- Opal.defn(self, '$page_break', function(node) {
- var self = this;
-
- return "
";
- });
-
- Opal.defn(self, '$paragraph', function(node) {
- var $a, self = this, class_attribute = nil, attributes = nil;
-
- class_attribute = (function() {if ((($a = node.$role()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "class=\"paragraph " + (node.$role()) + "\""
- } else {
- return "class=\"paragraph\""
- }; return nil; })();
- attributes = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "id=\"" + (node.$id()) + "\" " + (class_attribute)
- } else {
- return class_attribute
- }; return nil; })();
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "\n
" + (node.$title()) + "
\n
" + (node.$content()) + "
\n
"
- } else {
- return "\n
" + (node.$content()) + "
\n
"
- };
- });
-
- Opal.defn(self, '$preamble', function(node) {
- var $a, $b, $c, self = this, doc = nil, toc = nil;
-
- if ((($a = ($b = ($c = ((doc = node.$document()))['$attr?']("toc-placement", "preamble"), $c !== false && $c !== nil ?doc['$sections?']() : $c), $b !== false && $b !== nil ?(doc['$attr?']("toc")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- toc = "\n\n
" + (doc.$attr("toc-title")) + "
\n" + (self.$outline(doc)) + "\n
"
- } else {
- toc = nil
- };
- return "\n
\n" + (node.$content()) + "\n
" + (toc) + "\n
";
- });
-
- Opal.defn(self, '$quote', function(node) {
- var $a, $b, 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;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["quoteblock", node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "\n" + (node.$title()) + "
"
- } else {
- return nil
- }; return nil; })();
- attribution = (function() {if ((($a = (node['$attr?']("attribution"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (node.$attr("attribution"))
- } else {
- return nil
- }; return nil; })();
- citetitle = (function() {if ((($a = (node['$attr?']("citetitle"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (node.$attr("citetitle"))
- } else {
- return nil
- }; return nil; })();
- if ((($a = ((($b = attribution) !== false && $b !== nil) ? $b : citetitle)) !== nil && (!$a.$$is_boolean || $a == true))) {
- cite_element = (function() {if (citetitle !== false && citetitle !== nil) {
- return "" + (citetitle) + " "
- } else {
- return nil
- }; return nil; })();
- attribution_text = (function() {if (attribution !== false && attribution !== nil) {
- return "— " + (attribution) + ((function() {if (citetitle !== false && citetitle !== nil) {
- return " \n"
- } else {
- return nil
- }; return nil; })())
- } else {
- return nil
- }; return nil; })();
- attribution_element = "\n\n" + (attribution_text) + (cite_element) + "\n
";
- } else {
- attribution_element = nil
- };
- return "" + (title_element) + "\n
\n" + (node.$content()) + "\n " + (attribution_element) + "\n
";
- });
-
- Opal.defn(self, '$thematic_break', function(node) {
- var self = this;
-
- return " ";
- });
-
- Opal.defn(self, '$sidebar', function(node) {
- var $a, self = this, id_attribute = nil, title_element = nil, role = nil;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (node.$title()) + "
\n"
- } else {
- return nil
- }; return nil; })();
- return "\n
\n" + (title_element) + (node.$content()) + "\n
\n
";
- });
-
- Opal.defn(self, '$table', function(node) {
- var $a, $b, TMP_14, $c, TMP_15, $d, TMP_16, $e, $f, TMP_20, self = this, result = nil, id_attribute = nil, classes = nil, styles = nil, tablepcwidth = nil, role = nil, class_attribute = nil, style_attribute = nil, slash = nil, tag = nil;
-
- result = [];
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["tableblock", "frame-" + (node.$attr("frame", "all")), "grid-" + (node.$attr("grid", "all"))];
- styles = [];
- if ((($a = node['$option?']("autowidth")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if (((tablepcwidth = node.$attr("tablepcwidth")))['$=='](100)) {
- classes['$<<']("spread")
- } else {
- styles['$<<']("width: " + (tablepcwidth) + "%;")
- };
- if ((($a = (role = node.$role())) !== nil && (!$a.$$is_boolean || $a == true))) {
- classes['$<<'](role)};
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- if ((($a = node['$attr?']("float")) !== nil && (!$a.$$is_boolean || $a == true))) {
- styles['$<<']("float: " + (node.$attr("float")) + ";")};
- style_attribute = (function() {if ((($a = styles['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " style=\"" + ($rb_times(styles, " ")) + "\""
- }; return nil; })();
- result['$<<']("");
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("" + (node.$captioned_title()) + " ")};
- if ($rb_gt((node.$attr("rowcount")), 0)) {
- slash = self.void_element_slash;
- result['$<<']("");
- if ((($a = node['$option?']("autowidth")) !== nil && (!$a.$$is_boolean || $a == true))) {
- tag = " ";
- ($a = ($b = node.$columns().$size()).$times, $a.$$p = (TMP_14 = function(){var self = TMP_14.$$s || this;
-
- return result['$<<'](tag)}, TMP_14.$$s = self, TMP_14), $a).call($b);
- } else {
- ($a = ($c = node.$columns()).$each, $a.$$p = (TMP_15 = function(col){var self = TMP_15.$$s || this;
-if (col == null) col = nil;
- return result['$<<'](" ")}, TMP_15.$$s = self, TMP_15), $a).call($c)
- };
- result['$<<'](" ");
- ($a = ($d = ($e = ($f = ["head", "foot", "body"]).$select, $e.$$p = (TMP_20 = function(tsec){var self = TMP_20.$$s || this;
-if (tsec == null) tsec = nil;
- return node.$rows()['$[]'](tsec)['$empty?']()['$!']()}, TMP_20.$$s = self, TMP_20), $e).call($f)).$each, $a.$$p = (TMP_16 = function(tsec){var self = TMP_16.$$s || this, $a, $b, TMP_17;
-if (tsec == null) tsec = nil;
- result['$<<']("");
- ($a = ($b = node.$rows()['$[]'](tsec)).$each, $a.$$p = (TMP_17 = function(row){var self = TMP_17.$$s || this, $a, $b, TMP_18;
-if (row == null) row = nil;
- result['$<<']("");
- ($a = ($b = row).$each, $a.$$p = (TMP_18 = function(cell){var self = TMP_18.$$s || this, $a, $b, TMP_19, $c, cell_content = nil, $case = nil, cell_tag_name = nil, cell_class_attribute = nil, cell_colspan_attribute = nil, cell_rowspan_attribute = nil, cell_style_attribute = nil;
-if (cell == null) cell = nil;
- if (tsec['$==']("head")) {
- cell_content = cell.$text()
- } else {
- $case = cell.$style();if ("asciidoc"['$===']($case)) {cell_content = "" + (cell.$content()) + "
"}else if ("verse"['$===']($case)) {cell_content = "" + (cell.$text()) + "
"}else if ("literal"['$===']($case)) {cell_content = ""}else {cell_content = "";
- ($a = ($b = cell.$content()).$each, $a.$$p = (TMP_19 = function(text){var self = TMP_19.$$s || this;
-if (text == null) text = nil;
- return cell_content = "" + (cell_content) + "" + (text) + "
"}, TMP_19.$$s = self, TMP_19), $a).call($b);}
- };
- cell_tag_name = ((function() {if ((($a = ((($c = tsec['$==']("head")) !== false && $c !== nil) ? $c : cell.$style()['$==']("header"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "th"
- } else {
- return "td"
- }; return nil; })());
- cell_class_attribute = " class=\"tableblock halign-" + (cell.$attr("halign")) + " valign-" + (cell.$attr("valign")) + "\"";
- cell_colspan_attribute = (function() {if ((($a = cell.$colspan()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " colspan=\"" + (cell.$colspan()) + "\""
- } else {
- return nil
- }; return nil; })();
- cell_rowspan_attribute = (function() {if ((($a = cell.$rowspan()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " rowspan=\"" + (cell.$rowspan()) + "\""
- } else {
- return nil
- }; return nil; })();
- cell_style_attribute = (function() {if ((($a = (node.$document()['$attr?']("cellbgcolor"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " style=\"background-color: " + (node.$document().$attr("cellbgcolor")) + ";\""
- } else {
- return nil
- }; return nil; })();
- return result['$<<']("<" + (cell_tag_name) + (cell_class_attribute) + (cell_colspan_attribute) + (cell_rowspan_attribute) + (cell_style_attribute) + ">" + (cell_content) + "" + (cell_tag_name) + ">");}, TMP_18.$$s = self, TMP_18), $a).call($b);
- return result['$<<'](" ");}, TMP_17.$$s = self, TMP_17), $a).call($b);
- return result['$<<'](" ");}, TMP_16.$$s = self, TMP_16), $a).call($d);};
- result['$<<']("
");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$toc', function(node) {
- var $a, $b, $c, self = this, doc = nil, id_attr = nil, title_id_attr = nil, title = nil, levels = nil, role = nil;
-
- if ((($a = ($b = ($c = ((doc = node.$document()))['$attr?']("toc-placement", "macro"), $c !== false && $c !== nil ?doc['$sections?']() : $c), $b !== false && $b !== nil ?(doc['$attr?']("toc")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return ""
- };
- if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- id_attr = " id=\"" + (node.$id()) + "\"";
- title_id_attr = " id=\"" + (node.$id()) + "title\"";
- } else {
- id_attr = " id=\"toc\"";
- title_id_attr = " id=\"toctitle\"";
- };
- title = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return node.$title()
- } else {
- return (doc.$attr("toc-title"))
- }; return nil; })();
- levels = (function() {if ((($a = (node['$attr?']("levels"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (node.$attr("levels")).$to_i()
- } else {
- return nil
- }; return nil; })();
- role = (function() {if ((($a = node['$role?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return node.$role()
- } else {
- return (doc.$attr("toc-class", "toc"))
- }; return nil; })();
- return "\n
" + (title) + "
\n" + (self.$outline(doc, $hash2(["toclevels"], {"toclevels": levels}))) + "\n
";
- });
-
- Opal.defn(self, '$ulist', function(node) {
- var $a, $b, TMP_21, self = this, result = nil, id_attribute = nil, div_classes = nil, marker_checked = nil, marker_unchecked = nil, checklist = nil, ul_class_attribute = nil;
-
- result = [];
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- div_classes = ["ulist", node.$style(), node.$role()].$compact();
- marker_checked = nil;
- marker_unchecked = nil;
- if ((($a = (checklist = node['$option?']("checklist"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- div_classes.$insert(1, "checklist");
- ul_class_attribute = " class=\"checklist\"";
- if ((($a = node['$option?']("interactive")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = node.$document()['$attr?']("htmlsyntax", "xml")) !== nil && (!$a.$$is_boolean || $a == true))) {
- marker_checked = " ";
- marker_unchecked = " ";
- } else {
- marker_checked = " ";
- marker_unchecked = " ";
- }
- } else if ((($a = node.$document()['$attr?']("icons", "font")) !== nil && (!$a.$$is_boolean || $a == true))) {
- marker_checked = " ";
- marker_unchecked = " ";
- } else {
- marker_checked = "✓ ";
- marker_unchecked = "❏ ";
- };
- } else {
- ul_class_attribute = (function() {if ((($a = node.$style()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " class=\"" + (node.$style()) + "\""
- } else {
- return nil
- }; return nil; })()
- };
- result['$<<']("");
- if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- result['$<<']("
" + (node.$title()) + "
")};
- result['$<<']("
");
- result['$<<']("
");
- return $rb_times(result, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$verse', function(node) {
- var $a, $b, 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;
-
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["verseblock", node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "\n" + (node.$title()) + "
"
- } else {
- return nil
- }; return nil; })();
- attribution = (function() {if ((($a = (node['$attr?']("attribution"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (node.$attr("attribution"))
- } else {
- return nil
- }; return nil; })();
- citetitle = (function() {if ((($a = (node['$attr?']("citetitle"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (node.$attr("citetitle"))
- } else {
- return nil
- }; return nil; })();
- if ((($a = ((($b = attribution) !== false && $b !== nil) ? $b : citetitle)) !== nil && (!$a.$$is_boolean || $a == true))) {
- cite_element = (function() {if (citetitle !== false && citetitle !== nil) {
- return "" + (citetitle) + " "
- } else {
- return nil
- }; return nil; })();
- attribution_text = (function() {if (attribution !== false && attribution !== nil) {
- return "— " + (attribution) + ((function() {if (citetitle !== false && citetitle !== nil) {
- return " \n"
- } else {
- return nil
- }; return nil; })())
- } else {
- return nil
- }; return nil; })();
- attribution_element = "\n\n" + (attribution_text) + (cite_element) + "\n
";
- } else {
- attribution_element = nil
- };
- return "" + (title_element) + "\n
" + (node.$content()) + " " + (attribution_element) + "\n
";
- });
-
- Opal.defn(self, '$video', function(node) {
- var $a, $b, self = this, xml = nil, id_attribute = nil, classes = nil, class_attribute = nil, title_element = nil, width_attribute = nil, height_attribute = nil, $case = nil, asset_uri_scheme = nil, start_anchor = nil, delimiter = nil, autoplay_param = nil, loop_param = nil, rel_param_val = nil, start_param = nil, end_param = nil, controls_param = nil, fs_param = nil, fs_attribute = nil, modest_param = nil, theme_param = nil, hl_param = nil, target = nil, list = nil, list_param = nil, playlist = nil, poster_attribute = nil, poster = nil, start_t = nil, end_t = nil, time_anchor = nil;
-
- xml = node.$document()['$attr?']("htmlsyntax", "xml");
- id_attribute = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- classes = ["videoblock", node.$style(), node.$role()].$compact();
- class_attribute = " class=\"" + ($rb_times(classes, " ")) + "\"";
- title_element = (function() {if ((($a = node['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "\n" + (node.$captioned_title()) + "
"
- } else {
- return nil
- }; return nil; })();
- width_attribute = (function() {if ((($a = (node['$attr?']("width"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " width=\"" + (node.$attr("width")) + "\""
- } else {
- return nil
- }; return nil; })();
- height_attribute = (function() {if ((($a = (node['$attr?']("height"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " height=\"" + (node.$attr("height")) + "\""
- } else {
- return nil
- }; return nil; })();
- return (function() {$case = node.$attr("poster");if ("vimeo"['$===']($case)) {if ((($a = ((asset_uri_scheme = (node.$document().$attr("asset-uri-scheme", "https"))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- asset_uri_scheme = "" + (asset_uri_scheme) + ":"
- };
- start_anchor = (function() {if ((($a = (node['$attr?']("start", nil, false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "#at=" + (node.$attr("start"))
- } else {
- return nil
- }; return nil; })();
- delimiter = "?";
- autoplay_param = (function() {if ((($a = (node['$option?']("autoplay"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (delimiter) + "autoplay=1"
- } else {
- return nil
- }; return nil; })();
- if (autoplay_param !== false && autoplay_param !== nil) {
- delimiter = "&"};
- loop_param = (function() {if ((($a = (node['$option?']("loop"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (delimiter) + "loop=1"
- } else {
- return nil
- }; return nil; })();
- return "" + (title_element) + "\n
\n\n
\n
";}else if ("youtube"['$===']($case)) {if ((($a = ((asset_uri_scheme = (node.$document().$attr("asset-uri-scheme", "https"))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- asset_uri_scheme = "" + (asset_uri_scheme) + ":"
- };
- rel_param_val = (function() {if ((($a = (node['$option?']("related"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return 1
- } else {
- return 0
- }; return nil; })();
- start_param = (function() {if ((($a = (node['$attr?']("start", nil, false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&start=" + (node.$attr("start"))
- } else {
- return nil
- }; return nil; })();
- end_param = (function() {if ((($a = (node['$attr?']("end", nil, false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&end=" + (node.$attr("end"))
- } else {
- return nil
- }; return nil; })();
- autoplay_param = (function() {if ((($a = (node['$option?']("autoplay"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&autoplay=1"
- } else {
- return nil
- }; return nil; })();
- loop_param = (function() {if ((($a = (node['$option?']("loop"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&loop=1"
- } else {
- return nil
- }; return nil; })();
- controls_param = (function() {if ((($a = (node['$option?']("nocontrols"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&controls=0"
- } else {
- return nil
- }; return nil; })();
- if ((($a = node['$option?']("nofullscreen")) !== nil && (!$a.$$is_boolean || $a == true))) {
- fs_param = "&fs=0";
- fs_attribute = nil;
- } else {
- fs_param = nil;
- fs_attribute = self.$append_boolean_attribute("allowfullscreen", xml);
- };
- modest_param = (function() {if ((($a = (node['$option?']("modest"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&modestbranding=1"
- } else {
- return nil
- }; return nil; })();
- theme_param = (function() {if ((($a = (node['$attr?']("theme", nil, false))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&theme=" + (node.$attr("theme"))
- } else {
- return nil
- }; return nil; })();
- hl_param = (function() {if ((($a = (node['$attr?']("lang"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "&hl=" + (node.$attr("lang"))
- } else {
- return nil
- }; return nil; })();
- $a = Opal.to_ary((node.$attr("target")).$split("/", 2)), target = ($a[0] == null ? nil : $a[0]), list = ($a[1] == null ? nil : $a[1]);
- if ((($a = (((($b = list) !== false && $b !== nil) ? $b : list = (node.$attr("list", nil, false))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- list_param = "&list=" + (list)
- } else {
- $a = Opal.to_ary(target.$split(",", 2)), target = ($a[0] == null ? nil : $a[0]), playlist = ($a[1] == null ? nil : $a[1]);
- if ((($a = (((($b = playlist) !== false && $b !== nil) ? $b : playlist = (node.$attr("playlist", nil, false))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- list_param = "&playlist=" + (playlist)
- } else {
- list_param = (function() {if (loop_param !== false && loop_param !== nil) {
- return "&playlist=" + (target)
- } else {
- return nil
- }; return nil; })()
- };
- };
- return "" + (title_element) + "\n
\n\n
\n
";}else {poster_attribute = (function() {if ((($a = (("") + (poster = node.$attr("poster")))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " poster=\"" + (node.$media_uri(poster)) + "\""
- }; return nil; })();
- start_t = node.$attr("start", nil, false);
- end_t = node.$attr("end", nil, false);
- time_anchor = (function() {if ((($a = (((($b = start_t) !== false && $b !== nil) ? $b : end_t))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "#t=" + (start_t) + ((function() {if (end_t !== false && end_t !== nil) {
- return ","
- } else {
- return nil
- }; return nil; })()) + (end_t)
- } else {
- return nil
- }; return nil; })();
- return "" + (title_element) + "\n
\n\nYour browser does not support the video tag.\n \n
\n
";}})();
- });
-
- Opal.defn(self, '$inline_anchor', function(node) {
- var $a, $b, self = this, target = nil, $case = nil, refid = nil, text = nil, attrs = nil, role = nil;
-
- target = node.$target();
- return (function() {$case = node.$type();if ("xref"['$===']($case)) {refid = ((($a = node.$attributes()['$[]']("refid")) !== false && $a !== nil) ? $a : target);
- text = ((($a = node.$text()) !== false && $a !== nil) ? $a : (((($b = node.$document().$references()['$[]']("ids")['$[]'](refid)) !== false && $b !== nil) ? $b : "[" + (refid) + "]")));
- return "" + (text) + " ";}else if ("ref"['$===']($case)) {return " "}else if ("link"['$===']($case)) {attrs = [];
- if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$<<'](" id=\"" + (node.$id()) + "\"")};
- if ((($a = (role = node.$role())) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$<<'](" class=\"" + (role) + "\"")};
- if ((($a = node['$attr?']("title", nil, false)) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$<<'](" title=\"" + (node.$attr("title")) + "\"")};
- if ((($a = node['$attr?']("window", nil, false)) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$<<'](" target=\"" + (node.$attr("window")) + "\"")};
- return "" + (node.$text()) + " ";}else if ("bibref"['$===']($case)) {return " [" + (target) + "]"}else {return self.$warn("asciidoctor: WARNING: unknown anchor type: " + (node.$type().$inspect()))}})();
- });
-
- Opal.defn(self, '$inline_break', function(node) {
- var self = this;
-
- return "" + (node.$text()) + " ";
- });
-
- Opal.defn(self, '$inline_button', function(node) {
- var self = this;
-
- return "" + (node.$text()) + " ";
- });
-
- Opal.defn(self, '$inline_callout', function(node) {
- var $a, self = this, src = nil;
-
- if ((($a = node.$document()['$attr?']("icons", "font")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "(" + (node.$text()) + ") "
- } else if ((($a = node.$document()['$attr?']("icons")) !== nil && (!$a.$$is_boolean || $a == true))) {
- src = node.$icon_uri("callouts/" + (node.$text()));
- return " ";
- } else {
- return "(" + (node.$text()) + ") "
- };
- });
-
- Opal.defn(self, '$inline_footnote', function(node) {
- var $a, self = this, index = nil, id_attr = nil;
-
- if ((($a = (index = node.$attr("index"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (node.$type()['$==']("xref")) {
- return ""
- } else {
- id_attr = (function() {if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " id=\"_footnote_" + (node.$id()) + "\""
- } else {
- return nil
- }; return nil; })();
- return "";
- }
- } else if (node.$type()['$==']("xref")) {
- return ""
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$inline_image', function(node) {
- var $a, $b, TMP_22, $c, TMP_23, $d, $e, $f, $g, self = this, type = nil, class_attr_val = nil, title_attr = nil, img = nil, target = nil, attrs = nil, svg = nil, obj = nil, fallback = nil, window_attr = nil, role = nil, style_attr = nil;
-
- if ((($a = (($b = ((type = node.$type()))['$==']("icon")) ? (node.$document()['$attr?']("icons", "font")) : ((type = node.$type()))['$==']("icon"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- class_attr_val = "fa fa-" + (node.$target());
- ($a = ($b = $hash2(["size", "rotate", "flip"], {"size": "fa-", "rotate": "fa-rotate-", "flip": "fa-flip-"})).$each, $a.$$p = (TMP_22 = function(key, prefix){var self = TMP_22.$$s || this, $a;
-if (key == null) key = nil;if (prefix == null) prefix = nil;
- if ((($a = node['$attr?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return class_attr_val = "" + (class_attr_val) + " " + (prefix) + (node.$attr(key))
- } else {
- return nil
- }}, TMP_22.$$s = self, TMP_22), $a).call($b);
- title_attr = (function() {if ((($a = (node['$attr?']("title"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " title=\"" + (node.$attr("title")) + "\""
- } else {
- return nil
- }; return nil; })();
- img = " ";
- } else if ((($a = (($c = type['$==']("icon")) ? (node.$document()['$attr?']("icons"))['$!']() : type['$==']("icon"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- img = "[" + (node.$attr("alt")) + "]"
- } else {
- target = node.$target();
- attrs = ($a = ($c = ["width", "height", "title"]).$map, $a.$$p = (TMP_23 = function(name){var self = TMP_23.$$s || this, $a;
-if (name == null) name = nil;
- if ((($a = (node['$attr?'](name))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " " + (name) + "=\"" + (node.$attr(name)) + "\""
- } else {
- return nil
- }}, TMP_23.$$s = self, TMP_23), $a).call($c).$join();
- if ((($a = ($d = ($e = ($f = type['$!=']("icon"), $f !== false && $f !== nil ?(((($g = (node['$attr?']("format", "svg", false))) !== false && $g !== nil) ? $g : (target['$include?'](".svg")))) : $f), $e !== false && $e !== nil ?$rb_lt(node.$document().$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE'))) : $e), $d !== false && $d !== nil ?(((($e = (svg = (node['$option?']("inline")))) !== false && $e !== nil) ? $e : (obj = (node['$option?']("interactive"))))) : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (svg !== false && svg !== nil) {
- img = ((($a = (self.$read_svg_contents(node, target))) !== false && $a !== nil) ? $a : "" + (node.$attr("alt")) + " ")
- } else if (obj !== false && obj !== nil) {
- fallback = (function() {if ((($a = (node['$attr?']("fallback"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " "
- } else {
- return "" + (node.$attr("alt")) + " "
- }; return nil; })();
- img = "" + (fallback) + " ";}};
- ((($a = img) !== false && $a !== nil) ? $a : img = " ");
- };
- if ((($a = node['$attr?']("link")) !== nil && (!$a.$$is_boolean || $a == true))) {
- window_attr = (function() {if ((($a = (node['$attr?']("window"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " target=\"" + (node.$attr("window")) + "\""
- } else {
- return nil
- }; return nil; })();
- img = "" + (img) + " ";};
- class_attr_val = (function() {if ((($a = (role = node.$role())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (type) + " " + (role)
- } else {
- return type
- }; return nil; })();
- style_attr = (function() {if ((($a = (node['$attr?']("float"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " style=\"float: " + (node.$attr("float")) + "\""
- } else {
- return nil
- }; return nil; })();
- return "" + (img) + " ";
- });
-
- Opal.defn(self, '$inline_indexterm', function(node) {
- var self = this;
-
- if (node.$type()['$==']("visible")) {
- return node.$text()
- } else {
- return ""
- };
- });
-
- Opal.defn(self, '$inline_kbd', function(node) {
- var $a, $b, TMP_24, self = this, keys = nil, key_combo = nil;
-
- if (((keys = node.$attr("keys"))).$size()['$=='](1)) {
- return "" + (keys['$[]'](0)) + " "
- } else {
- key_combo = ($a = ($b = keys).$map, $a.$$p = (TMP_24 = function(key){var self = TMP_24.$$s || this;
-if (key == null) key = nil;
- return "" + (key) + " +"}, TMP_24.$$s = self, TMP_24), $a).call($b).$join().$chop();
- return "" + (key_combo) + " ";
- };
- });
-
- Opal.defn(self, '$inline_menu', function(node) {
- var $a, $b, TMP_25, self = this, menu = nil, submenus = nil, submenu_path = nil, menuitem = nil;
-
- menu = node.$attr("menu");
- if ((($a = ((submenus = node.$attr("submenus")))['$empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- submenu_path = ($a = ($b = submenus).$map, $a.$$p = (TMP_25 = function(submenu){var self = TMP_25.$$s || this;
-if (submenu == null) submenu = nil;
- return " ▸ "}, TMP_25.$$s = self, TMP_25), $a).call($b).$join().$chop();
- return "";
- } else if ((($a = (menuitem = node.$attr("menuitem"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ""
- } else {
- return ""
- };
- });
-
- Opal.defn(self, '$inline_quoted', function(node) {
- var $a, self = this, open = nil, close = nil, is_tag = nil, role = nil, quoted_text = nil;
-
- $a = Opal.to_ary($scope.get('QUOTE_TAGS')['$[]'](node.$type())), open = ($a[0] == null ? nil : $a[0]), close = ($a[1] == null ? nil : $a[1]), is_tag = ($a[2] == null ? nil : $a[2]);
- if ((($a = (role = node.$role())) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (is_tag !== false && is_tag !== nil) {
- quoted_text = "" + (open.$chop()) + " class=\"" + (role) + "\">" + (node.$text()) + (close)
- } else {
- quoted_text = "" + (open) + (node.$text()) + (close) + " "
- }
- } else {
- quoted_text = "" + (open) + (node.$text()) + (close)
- };
- if ((($a = node.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " " + (quoted_text)
- } else {
- return quoted_text
- };
- });
-
- Opal.defn(self, '$append_boolean_attribute', function(name, xml) {
- var self = this;
-
- if (xml !== false && xml !== nil) {
- return " " + (name) + "=\"" + (name) + "\""
- } else {
- return " " + (name)
- };
- });
-
- return (Opal.defn(self, '$read_svg_contents', function(node, target) {
- var $a, $b, TMP_26, self = this, svg = nil, start_tag = nil;
-
- if ((($a = (svg = node.$read_contents(target, $hash2(["start", "normalize", "label"], {"start": (node.$document().$attr("imagesdir")), "normalize": true, "label": "SVG"})))) !== nil && (!$a.$$is_boolean || $a == true))) {
- svg = svg.$sub($scope.get('SvgPreambleRx'), "");
- start_tag = nil;
- ($a = ($b = ["width", "height"]).$each, $a.$$p = (TMP_26 = function(dim){var self = TMP_26.$$s || this, $a;
-if (dim == null) dim = nil;
- if ((($a = node['$attr?'](dim)) !== nil && (!$a.$$is_boolean || $a == true))) {
- ((($a = start_tag) !== false && $a !== nil) ? $a : start_tag = (svg.$match($scope.get('SvgStartTagRx')))['$[]'](0).$gsub($scope.get('DimensionAttributeRx'), ""));
- return start_tag = "" + (start_tag.$chop()) + " " + (dim) + "=\"" + (node.$attr(dim)) + "px\">";
- } else {
- return nil
- }}, TMP_26.$$s = self, TMP_26), $a).call($b);
- if (start_tag !== false && start_tag !== nil) {
- svg = svg.$sub($scope.get('SvgStartTagRx'), start_tag)};};
- return svg;
- }), nil) && 'read_svg_contents';
- })($scope.get('Converter'), (($scope.get('Converter')).$$scope.get('BuiltIn')))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/document"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_ge(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs);
- }
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$new', '$attr_reader', '$nil?', '$<<', '$[]', '$[]=', '$include?', '$strip', '$tr_s', '$gsub', '$empty?', '$!', '$rpartition', '$delete', '$base_dir', '$inject', '$==', '$references', '$callouts', '$dup', '$attributes', '$each', '$safe', '$compat_mode', '$sourcemap', '$converter', '$extensions', '$start_with?', '$end_with?', '$chop', '$downcase', '$===', '$const_get', '$upcase', '$to_s', '$freeze', '$attribute_undefined', '$attribute_missing', '$detect', '$constants', '$key?', '$expand_path', '$pwd', '$>=', '$+', '$length', '$fetch', '$delete_if', '$parse', '$restore_attributes', '$update_backend_attributes', '$now', '$strftime', '$join', '$build_registry', '$to_proc', '$activate', '$preprocessors?', '$process_method', '$preprocessors', '$treeprocessors?', '$!=', '$treeprocessors', '$nil_or_empty?', '$nextval', '$to_i', '$counter', '$save_to', '$chr', '$ord', '$source', '$source_lines', '$title=', '$title', '$first_section', '$title?', '$merge', '$has_header?', '$context', '$assign_index', '$clear_playback_attributes', '$save_attributes', '$attribute_locked?', '$doctitle', '$has_key?', '$rewind', '$name', '$negate', '$value', '$apply_attribute_value_subs', '$delete?', '$update_doctype_attributes', '$match', '$resolve_pass_subs', '$apply_subs', '$apply_header_subs', '$create_converter', '$basebackend', '$outfilesuffix', '$filetype', '$sub', '$backend', '$default', '$create', '$fail', '$doctype', '$content_model', '$content', '$convert', '$postprocessors?', '$postprocessors', '$write', '$respond_to?', '$chomp', '$open', '$map', '$split', '$&', '$normalize_system_path', '$read_asset', '$resolve_docinfo_subs', '$sub_attributes', '$docinfo_processors?', '$*', '$compact', '$resolve_subs', '$docinfo_processors', '$class', '$object_id', '$inspect', '$size']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Document(){};
- var self = $Document = $klass($base, $super, 'Document', $Document);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_10, TMP_15;
-
- def.attributes = def.safe = def.reader = def.base_dir = def.parsed = def.parent_document = def.extensions = def.options = def.counters = def.references = def.doctype = def.backend = def.header = def.blocks = def.attributes_modified = def.id = def.callouts = def.header_attributes = def.attribute_overrides = def.converter = def.outfilesuffix = def.docinfo_processor_extensions = def.document = nil;
- Opal.cdecl($scope, 'Footnote', Opal.get('Struct').$new("index", "id", "text"));
-
- (function($base, $super) {
- function $AttributeEntry(){};
- var self = $AttributeEntry = $klass($base, $super, 'AttributeEntry', $AttributeEntry);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$attr_reader("name", "value", "negate");
-
- Opal.defn(self, '$initialize', function(name, value, negate) {
- var $a, self = this;
-
- if (negate == null) {
- negate = nil
- }
- self.name = name;
- self.value = value;
- return self.negate = (function() {if ((($a = negate['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return value['$nil?']()
- } else {
- return negate
- }; return nil; })();
- });
-
- return (Opal.defn(self, '$save_to', function(block_attributes) {
- var $a, $b, $c, self = this;
-
- return (($a = "attribute_entries", $b = block_attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, []))))['$<<'](self);
- }), nil) && 'save_to';
- })($scope.base, null);
-
- (function($base, $super) {
- function $Title(){};
- var self = $Title = $klass($base, $super, 'Title', $Title);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.sanitized = def.subtitle = def.combined = nil;
- self.$attr_reader("main");
-
- Opal.alias(self, 'title', 'main');
-
- self.$attr_reader("subtitle");
-
- self.$attr_reader("combined");
-
- Opal.defn(self, '$initialize', function(val, opts) {
- var $a, $b, $c, self = this, sep = nil, _ = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = ($b = (self.sanitized = opts['$[]']("sanitize")), $b !== false && $b !== nil ?val['$include?']("<") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- val = val.$gsub($scope.get('XmlSanitizeRx'), "").$tr_s(" ", " ").$strip()};
- if ((($a = ((($b = ((sep = ((($c = opts['$[]']("separator")) !== false && $c !== nil) ? $c : ":")))['$empty?']()) !== false && $b !== nil) ? $b : val['$include?'](sep = "" + (sep) + " ")['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.main = val;
- self.subtitle = nil;
- } else {
- $a = Opal.to_ary(val.$rpartition(sep)), self.main = ($a[0] == null ? nil : $a[0]), _ = ($a[1] == null ? nil : $a[1]), self.subtitle = ($a[2] == null ? nil : $a[2])
- };
- return self.combined = val;
- });
-
- Opal.defn(self, '$sanitized?', function() {
- var self = this;
-
- return self.sanitized;
- });
-
- Opal.defn(self, '$subtitle?', function() {
- var self = this;
-
- return self.subtitle['$!']()['$!']();
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var self = this;
-
- return self.combined;
- }), nil) && 'to_s';
- })($scope.base, null);
-
- self.$attr_reader("safe");
-
- self.$attr_reader("compat_mode");
-
- self.$attr_reader("sourcemap");
-
- self.$attr_reader("references");
-
- self.$attr_reader("counters");
-
- self.$attr_reader("callouts");
-
- self.$attr_reader("header");
-
- self.$attr_reader("base_dir");
-
- self.$attr_reader("options");
-
- self.$attr_reader("outfilesuffix");
-
- self.$attr_reader("parent_document");
-
- self.$attr_reader("reader");
-
- self.$attr_reader("converter");
-
- self.$attr_reader("extensions");
-
- Opal.defn(self, '$initialize', TMP_1 = function(data, options) {
- var $a, $b, $c, TMP_2, TMP_3, $e, TMP_4, $f, $g, TMP_5, $h, TMP_6, $i, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, parent_doc = nil, attr_overrides = nil, initialize_extensions = nil, safe_mode = nil, header_footer = nil, attrs = nil, safe_mode_name = nil, backend_val = nil, doctype_val = nil, now = nil, localdate = nil, localtime = nil, registry = nil, ext_block = nil;
-
- if (data == null) {
- data = nil
- }
- if (options == null) {
- options = $hash2([], {})
- }
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, null).apply(self, [self, "document"]);
- if ((($a = (parent_doc = options.$delete("parent"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.parent_document = parent_doc;
- ($a = "base_dir", $b = options, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, parent_doc.$base_dir())));
- self.references = ($a = ($b = parent_doc.$references()).$inject, $a.$$p = (TMP_2 = function(accum, $d){var self = TMP_2.$$s || this;
-if (accum == null) accum = nil;var key = $d[0], ref = $d[1];
- if (key['$==']("footnotes")) {
- accum['$[]=']("footnotes", [])
- } else {
- accum['$[]='](key, ref)
- };
- return accum;}, TMP_2.$$s = self, TMP_2), $a).call($b, $hash2([], {}));
- self.callouts = parent_doc.$callouts();
- attr_overrides = parent_doc.$attributes().$dup();
- ($a = ($c = ["doctype", "compat-mode", "toc", "toc-placement", "toc-position"]).$each, $a.$$p = (TMP_3 = function(key){var self = TMP_3.$$s || this;
-if (key == null) key = nil;
- return attr_overrides.$delete(key)}, TMP_3.$$s = self, TMP_3), $a).call($c);
- self.attribute_overrides = attr_overrides;
- self.safe = parent_doc.$safe();
- self.compat_mode = parent_doc.$compat_mode();
- self.sourcemap = parent_doc.$sourcemap();
- self.converter = parent_doc.$converter();
- initialize_extensions = false;
- self.extensions = parent_doc.$extensions();
- } else {
- self.parent_document = nil;
- self.references = $hash2(["ids", "footnotes", "links", "images", "indexterms", "includes"], {"ids": $hash2([], {}), "footnotes": [], "links": [], "images": [], "indexterms": [], "includes": Opal.get('Set').$new()});
- self.callouts = $scope.get('Callouts').$new();
- attr_overrides = $hash2([], {});
- ($a = ($e = (((($f = options['$[]']("attributes")) !== false && $f !== nil) ? $f : $hash2([], {})))).$each, $a.$$p = (TMP_4 = function(key, value){var self = TMP_4.$$s || this, $a;
-if (key == null) key = nil;if (value == null) value = nil;
- if ((($a = key['$start_with?']("!")) !== nil && (!$a.$$is_boolean || $a == true))) {
- key = key['$[]']($range(1, -1, false));
- value = nil;
- } else if ((($a = key['$end_with?']("!")) !== nil && (!$a.$$is_boolean || $a == true))) {
- key = key.$chop();
- value = nil;};
- return attr_overrides['$[]='](key.$downcase(), value);}, TMP_4.$$s = self, TMP_4), $a).call($e);
- self.attribute_overrides = attr_overrides;
- if ((($a = ((safe_mode = options['$[]']("safe")))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.safe = (($scope.get('SafeMode')).$$scope.get('SECURE'))
- } else if ((($a = Opal.get('Fixnum')['$==='](safe_mode)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.safe = safe_mode
- } else {
- try {
- self.safe = $scope.get('SafeMode').$const_get(safe_mode.$to_s().$upcase())
- } catch ($err) {if (true) {
- try {
- self.safe = (($scope.get('SafeMode')).$$scope.get('SECURE'))
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- }
- };
- self.sourcemap = options['$[]']("sourcemap");
- self.compat_mode = false;
- self.converter = nil;
- initialize_extensions = (function(){ try { return ((((Opal.get('Asciidoctor')).$$scope.get('Extensions'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })();
- self.extensions = nil;
- };
- self.parsed = false;
- self.header = nil;
- self.counters = $hash2([], {});
- self.attributes_modified = Opal.get('Set').$new();
- self.options = options;
- self.docinfo_processor_extensions = $hash2([], {});
- header_footer = (($a = "header_footer", $f = options, ((($g = $f['$[]']($a)) !== false && $g !== nil) ? $g : $f['$[]=']($a, false))));
- options.$freeze();
- attrs = self.attributes;
- attrs['$[]=']("sectids", "");
- if (header_footer !== false && header_footer !== nil) {
- } else {
- attrs['$[]=']("notitle", "")
- };
- attrs['$[]=']("toc-placement", "auto");
- attrs['$[]=']("stylesheet", "");
- attrs['$[]=']("webfonts", "");
- if (header_footer !== false && header_footer !== nil) {
- attrs['$[]=']("copycss", "")};
- attrs['$[]=']("prewrap", "");
- attrs['$[]=']("attribute-undefined", $scope.get('Compliance').$attribute_undefined());
- attrs['$[]=']("attribute-missing", $scope.get('Compliance').$attribute_missing());
- attrs['$[]=']("iconfont-remote", "");
- attrs['$[]=']("caution-caption", "Caution");
- attrs['$[]=']("important-caption", "Important");
- attrs['$[]=']("note-caption", "Note");
- attrs['$[]=']("tip-caption", "Tip");
- attrs['$[]=']("warning-caption", "Warning");
- attrs['$[]=']("appendix-caption", "Appendix");
- attrs['$[]=']("example-caption", "Example");
- attrs['$[]=']("figure-caption", "Figure");
- attrs['$[]=']("table-caption", "Table");
- attrs['$[]=']("toc-title", "Table of Contents");
- attrs['$[]=']("manname-title", "NAME");
- attrs['$[]=']("untitled-label", "Untitled");
- attrs['$[]=']("version-label", "Version");
- attrs['$[]=']("last-update-label", "Last updated");
- attr_overrides['$[]=']("asciidoctor", "");
- attr_overrides['$[]=']("asciidoctor-version", $scope.get('VERSION'));
- safe_mode_name = ($a = ($f = $scope.get('SafeMode').$constants()).$detect, $a.$$p = (TMP_5 = function(l){var self = TMP_5.$$s || this;
- if (self.safe == null) self.safe = nil;
-if (l == null) l = nil;
- return $scope.get('SafeMode').$const_get(l)['$=='](self.safe)}, TMP_5.$$s = self, TMP_5), $a).call($f).$to_s().$downcase();
- attr_overrides['$[]=']("safe-mode-name", safe_mode_name);
- attr_overrides['$[]=']("safe-mode-" + (safe_mode_name), "");
- attr_overrides['$[]=']("safe-mode-level", self.safe);
- attr_overrides['$[]=']("embedded", (function() {if (header_footer !== false && header_footer !== nil) {
- return nil
- } else {
- return ""
- }; return nil; })());
- ($a = "max-include-depth", $g = attr_overrides, ((($h = $g['$[]']($a)) !== false && $h !== nil) ? $h : $g['$[]=']($a, 64)));
- if ((($a = attr_overrides['$[]']("allow-uri-read")['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attr_overrides['$[]=']("allow-uri-read", nil)
- };
- attr_overrides['$[]=']("user-home", $scope.get('USER_HOME'));
- if ((($a = attr_overrides['$key?']("numbered")) !== nil && (!$a.$$is_boolean || $a == true))) {
- attr_overrides['$[]=']("sectnums", attr_overrides.$delete("numbered"))};
- if ((($a = options['$[]']("base_dir")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.base_dir = attr_overrides['$[]=']("docdir", Opal.get('File').$expand_path(options['$[]']("base_dir")))
- } else if ((($a = attr_overrides['$[]']("docdir")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.base_dir = attr_overrides['$[]=']("docdir", Opal.get('File').$expand_path(attr_overrides['$[]']("docdir")))
- } else {
- self.base_dir = attr_overrides['$[]=']("docdir", Opal.get('File').$expand_path(Opal.get('Dir').$pwd()))
- };
- if ((($a = (backend_val = options['$[]']("backend"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attr_overrides['$[]=']("backend", "" + (backend_val))};
- if ((($a = (doctype_val = options['$[]']("doctype"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attr_overrides['$[]=']("doctype", "" + (doctype_val))};
- if ($rb_ge(self.safe, (($scope.get('SafeMode')).$$scope.get('SERVER')))) {
- ($a = "copycss", $g = attr_overrides, ((($h = $g['$[]']($a)) !== false && $h !== nil) ? $h : $g['$[]=']($a, nil)));
- ($a = "source-highlighter", $g = attr_overrides, ((($h = $g['$[]']($a)) !== false && $h !== nil) ? $h : $g['$[]=']($a, nil)));
- ($a = "backend", $g = attr_overrides, ((($h = $g['$[]']($a)) !== false && $h !== nil) ? $h : $g['$[]=']($a, $scope.get('DEFAULT_BACKEND'))));
- if ((($a = ($g = parent_doc['$!'](), $g !== false && $g !== nil ?attr_overrides['$key?']("docfile") : $g)) !== nil && (!$a.$$is_boolean || $a == true))) {
- attr_overrides['$[]=']("docfile", attr_overrides['$[]']("docfile")['$[]']($range(($rb_plus(attr_overrides['$[]']("docdir").$length(), 1)), -1, false)))};
- attr_overrides['$[]=']("docdir", "");
- attr_overrides['$[]=']("user-home", ".");
- if ($rb_ge(self.safe, (($scope.get('SafeMode')).$$scope.get('SECURE')))) {
- if ((($a = attr_overrides.$fetch("linkcss", "")['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attr_overrides['$[]=']("linkcss", "")
- };
- ($a = "icons", $g = attr_overrides, ((($h = $g['$[]']($a)) !== false && $h !== nil) ? $h : $g['$[]=']($a, nil)));};};
- ($a = ($g = attr_overrides).$delete_if, $a.$$p = (TMP_6 = function(key, val){var self = TMP_6.$$s || this, $a, $b, verdict = nil;
-if (key == null) key = nil;if (val == null) val = nil;
- verdict = false;
- if ((($a = val['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs.$delete(key)
- } else {
- if ((($a = ($b = Opal.get('String')['$==='](val), $b !== false && $b !== nil ?(val['$end_with?']("@")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- val = val.$chop();
- verdict = true;};
- attrs['$[]='](key, val);
- };
- return verdict;}, TMP_6.$$s = self, TMP_6), $a).call($g);
- if ((($a = attrs['$key?']("compat-mode")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.compat_mode = true};
- if (parent_doc !== false && parent_doc !== nil) {
- ($a = "doctype", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, $scope.get('DEFAULT_DOCTYPE'))));
- self.reader = $scope.get('Reader').$new(data, options['$[]']("cursor"));
- $scope.get('Parser').$parse(self.reader, self);
- self.$restore_attributes();
- return self.parsed = true;
- } else {
- if ((($a = "backend", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, $scope.get('DEFAULT_BACKEND')))))['$==']("manpage")) {
- attrs['$[]=']("doctype", attr_overrides['$[]=']("doctype", "manpage"))
- } else {
- ($a = "doctype", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, $scope.get('DEFAULT_DOCTYPE'))))
- };
- self.$update_backend_attributes(attrs['$[]']("backend"), true);
- now = Opal.get('Time').$now();
- localdate = (($a = "localdate", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, now.$strftime("%Y-%m-%d")))));
- if ((($a = (localtime = attrs['$[]']("localtime"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- try {
- localtime = attrs['$[]=']("localtime", now.$strftime("%H:%M:%S %Z"))
- } catch ($err) {if (true) {
- try {
- localtime = attrs['$[]=']("localtime", now.$strftime("%H:%M:%S"))
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- }
- };
- ($a = "localdatetime", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, "" + (localdate) + " " + (localtime))));
- ($a = "docdate", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, localdate)));
- ($a = "doctime", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, localtime)));
- ($a = "docdatetime", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, "" + (localdate) + " " + (localtime))));
- ($a = "stylesdir", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, ".")));
- ($a = "iconsdir", $h = attrs, ((($i = $h['$[]']($a)) !== false && $i !== nil) ? $i : $h['$[]=']($a, Opal.get('File').$join(attrs.$fetch("imagesdir", "./images"), "icons"))));
- if (initialize_extensions !== false && initialize_extensions !== nil) {
- if ((($a = (registry = options['$[]']("extensions_registry"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ((($h = (($scope.get('Extensions')).$$scope.get('Registry'))['$==='](registry)) !== false && $h !== nil) ? $h : (($i = Opal.get('RUBY_ENGINE_JRUBY'), $i !== false && $i !== nil ?((((Opal.get('AsciidoctorJ')).$$scope.get('Extensions'))).$$scope.get('ExtensionRegistry'))['$==='](registry) : $i)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- registry = (($scope.get('Extensions')).$$scope.get('Registry')).$new()
- }
- } else if ((($a = Opal.get('Proc')['$===']((ext_block = options['$[]']("extensions")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- registry = ($a = ($h = $scope.get('Extensions')).$build_registry, $a.$$p = ext_block.$to_proc(), $a).call($h)
- } else {
- registry = (($scope.get('Extensions')).$$scope.get('Registry')).$new()
- };
- self.extensions = registry.$activate(self);};
- return self.reader = $scope.get('PreprocessorReader').$new(self, data, (($scope.get('Reader')).$$scope.get('Cursor')).$new(attrs['$[]']("docfile"), self.base_dir));
- };
- });
-
- Opal.defn(self, '$parse', function(data) {
- var $a, $b, $c, TMP_7, TMP_8, self = this, doc = nil, exts = nil;
-
- if (data == null) {
- data = nil
- }
- if ((($a = self.parsed) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self
- } else {
- doc = self;
- if (data !== false && data !== nil) {
- self.reader = $scope.get('PreprocessorReader').$new(doc, data, (($scope.get('Reader')).$$scope.get('Cursor')).$new(self.attributes['$[]']("docfile"), self.base_dir))};
- if ((($a = ($b = (exts = (function() {if ((($c = self.parent_document) !== nil && (!$c.$$is_boolean || $c == true))) {
- return nil
- } else {
- return self.extensions
- }; return nil; })()), $b !== false && $b !== nil ?exts['$preprocessors?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = exts.$preprocessors()).$each, $a.$$p = (TMP_7 = function(ext){var self = TMP_7.$$s || this, $a;
- if (self.reader == null) self.reader = nil;
-if (ext == null) ext = nil;
- return self.reader = ((($a = ext.$process_method()['$[]'](doc, self.reader)) !== false && $a !== nil) ? $a : self.reader)}, TMP_7.$$s = self, TMP_7), $a).call($b)};
- $scope.get('Parser').$parse(self.reader, doc, $hash2(["header_only"], {"header_only": self.options['$[]']("parse_header_only")['$!']()['$!']()}));
- self.$restore_attributes();
- if ((($a = (($c = exts !== false && exts !== nil) ? exts['$treeprocessors?']() : exts)) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($c = exts.$treeprocessors()).$each, $a.$$p = (TMP_8 = function(ext){var self = TMP_8.$$s || this, $a, $b, $c, result = nil;
-if (ext == null) ext = nil;
- if ((($a = ($b = ($c = (result = ext.$process_method()['$[]'](doc)), $c !== false && $c !== nil ?$scope.get('Document')['$==='](result) : $c), $b !== false && $b !== nil ?result['$!='](doc) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return doc = result
- } else {
- return nil
- }}, TMP_8.$$s = self, TMP_8), $a).call($c)};
- self.parsed = true;
- return doc;
- };
- });
-
- Opal.defn(self, '$counter', function(name, seed) {
- var $a, $b, self = this, attr_is_seed = nil, attr_val = nil;
-
- if (seed == null) {
- seed = nil
- }
- if ((($a = ($b = (attr_is_seed = ((attr_val = self.attributes['$[]'](name)))['$nil_or_empty?']()['$!']()), $b !== false && $b !== nil ?self.counters['$key?'](name) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.counters['$[]='](name, self.$nextval(attr_val))
- } else {
- if ((($a = seed['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- seed = self.$nextval((function() {if (attr_is_seed !== false && attr_is_seed !== nil) {
- return attr_val
- } else {
- return 0
- }; return nil; })())
- } else if (seed.$to_i().$to_s()['$=='](seed)) {
- seed = seed.$to_i()};
- self.counters['$[]='](name, seed);
- };
- return (self.attributes['$[]='](name, self.counters['$[]'](name)));
- });
-
- Opal.defn(self, '$counter_increment', function(counter_name, block) {
- var self = this, val = nil;
-
- val = self.$counter(counter_name);
- $scope.get('AttributeEntry').$new(counter_name, val).$save_to(block.$attributes());
- return val;
- });
-
- Opal.defn(self, '$nextval', function(current) {
- var $a, self = this, intval = nil;
-
- if ((($a = Opal.get('Integer')['$==='](current)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $rb_plus(current, 1)
- } else {
- intval = current.$to_i();
- if ((($a = intval.$to_s()['$!='](current.$to_s())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($rb_plus(current['$[]'](0).$ord(), 1)).$chr()
- } else {
- return $rb_plus(intval, 1)
- };
- };
- });
-
- Opal.defn(self, '$register', function(type, value, force) {
- var $a, $b, $c, self = this, $case = nil, id = nil, reftext = nil;
-
- if (force == null) {
- force = false
- }
- return (function() {$case = type;if ("ids"['$===']($case)) {$a = Opal.to_ary([].concat(Opal.to_a(value))), id = ($a[0] == null ? nil : $a[0]), reftext = ($a[1] == null ? nil : $a[1]);
- ((($a = reftext) !== false && $a !== nil) ? $a : reftext = $rb_plus($rb_plus("[", id), "]"));
- if (force !== false && force !== nil) {
- return self.references['$[]']("ids")['$[]='](id, reftext)
- } else {
- return ($a = id, $b = self.references['$[]']("ids"), ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, reftext)))
- };}else if ("footnotes"['$===']($case) || "indexterms"['$===']($case)) {return self.references['$[]'](type)['$<<'](value)}else {if ((($a = self.options['$[]']("catalog_assets")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.references['$[]'](type)['$<<'](value)
- } else {
- return nil
- }}})();
- });
-
- Opal.defn(self, '$footnotes?', function() {
- var self = this;
-
- return self.references['$[]']("footnotes")['$empty?']()['$!']();
- });
-
- Opal.defn(self, '$footnotes', function() {
- var self = this;
-
- return self.references['$[]']("footnotes");
- });
-
- Opal.defn(self, '$nested?', function() {
- var self = this;
-
- return self.parent_document['$!']()['$!']();
- });
-
- Opal.defn(self, '$embedded?', function() {
- var self = this;
-
- return self.attributes['$key?']("embedded");
- });
-
- Opal.defn(self, '$extensions?', function() {
- var self = this;
-
- return self.extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$source', function() {
- var $a, self = this;
-
- if ((($a = self.reader) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.reader.$source()
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$source_lines', function() {
- var $a, self = this;
-
- if ((($a = self.reader) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.reader.$source_lines()
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$doctype', function() {
- var $a, self = this;
-
- return ((($a = self.doctype) !== false && $a !== nil) ? $a : self.doctype = self.attributes['$[]']("doctype"));
- });
-
- Opal.defn(self, '$backend', function() {
- var $a, self = this;
-
- return ((($a = self.backend) !== false && $a !== nil) ? $a : self.backend = self.attributes['$[]']("backend"));
- });
-
- Opal.defn(self, '$basebackend?', function(base) {
- var self = this;
-
- return self.attributes['$[]']("basebackend")['$=='](base);
- });
-
- Opal.defn(self, '$title', function() {
- var self = this;
-
- return self.attributes['$[]']("title");
- });
-
- Opal.defn(self, '$title=', function(title) {
- var $a, $b, self = this;
-
- ((($a = self.header) !== false && $a !== nil) ? $a : self.header = $scope.get('Section').$new(self, 0));
- return (($a = [title]), $b = self.header, $b['$title='].apply($b, $a), $a[$a.length-1]);
- });
-
- Opal.defn(self, '$doctitle', function(opts) {
- var $a, $b, self = this, val = nil, sect = nil, separator = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = ((val = self.attributes['$[]']("title")['$nil_or_empty?']()))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- val = self.$title()
- } else if ((($a = ($b = (sect = self.$first_section()), $b !== false && $b !== nil ?sect['$title?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- val = sect.$title()
- } else if ((($a = ($b = opts['$[]']("use_fallback"), $b !== false && $b !== nil ?(val = self.attributes['$[]']("untitled-label")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- if ((($a = (separator = opts['$[]']("partition"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('Title').$new(val, opts.$merge($hash2(["separator"], {"separator": ((function() {if (separator['$=='](true)) {
- return self.attributes['$[]']("title-separator")
- } else {
- return separator
- }; return nil; })())})))
- } else if ((($a = ($b = opts['$[]']("sanitize"), $b !== false && $b !== nil ?val['$include?']("<") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return val.$gsub($scope.get('XmlSanitizeRx'), "").$tr_s(" ", " ").$strip()
- } else {
- return val
- };
- });
-
- Opal.alias(self, 'name', 'doctitle');
-
- Opal.defn(self, '$author', function() {
- var self = this;
-
- return self.attributes['$[]']("author");
- });
-
- Opal.defn(self, '$revdate', function() {
- var self = this;
-
- return self.attributes['$[]']("revdate");
- });
-
- Opal.defn(self, '$notitle', function() {
- var $a, self = this;
-
- return ($a = self.attributes['$key?']("showtitle")['$!'](), $a !== false && $a !== nil ?self.attributes['$key?']("notitle") : $a);
- });
-
- Opal.defn(self, '$noheader', function() {
- var self = this;
-
- return self.attributes['$key?']("noheader");
- });
-
- Opal.defn(self, '$nofooter', function() {
- var self = this;
-
- return self.attributes['$key?']("nofooter");
- });
-
- Opal.defn(self, '$first_section', function() {
- var $a, $b, TMP_9, $c, self = this;
-
- if ((($a = self['$has_header?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.header
- } else {
- return ($a = ($b = (((($c = self.blocks) !== false && $c !== nil) ? $c : []))).$detect, $a.$$p = (TMP_9 = function(e){var self = TMP_9.$$s || this;
-if (e == null) e = nil;
- return e.$context()['$==']("section")}, TMP_9.$$s = self, TMP_9), $a).call($b)
- };
- });
-
- Opal.defn(self, '$has_header?', function() {
- var $a, self = this;
-
- if ((($a = self.header) !== nil && (!$a.$$is_boolean || $a == true))) {
- return true
- } else {
- return false
- };
- });
-
- Opal.alias(self, 'header?', 'has_header?');
-
- Opal.defn(self, '$<<', TMP_10 = function(block) {var $zuper = $slice.call(arguments, 0);
- var self = this, $iter = TMP_10.$$p, $yield = $iter || nil;
-
- TMP_10.$$p = null;
- if (block.$context()['$==']("section")) {
- self.$assign_index(block)};
- return Opal.find_super_dispatcher(self, '<<', TMP_10, $iter).apply(self, $zuper);
- });
-
- Opal.defn(self, '$finalize_header', function(unrooted_attributes, header_valid) {
- var self = this;
-
- if (header_valid == null) {
- header_valid = true
- }
- self.$clear_playback_attributes(unrooted_attributes);
- self.$save_attributes();
- if (header_valid !== false && header_valid !== nil) {
- } else {
- unrooted_attributes['$[]=']("invalid-header", true)
- };
- return unrooted_attributes;
- });
-
- Opal.defn(self, '$save_attributes', function() {
- var $a, $b, $c, TMP_11, self = this, attrs = nil, val = nil, toc_position_val = nil, toc_val = nil, toc_placement = nil, default_toc_position = nil, default_toc_class = nil, position = nil, $case = nil;
-
- if (((attrs = self.attributes))['$[]']("basebackend")['$==']("docbook")) {
- if ((($a = ((($b = self['$attribute_locked?']("toc")) !== false && $b !== nil) ? $b : self.attributes_modified['$include?']("toc"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attrs['$[]=']("toc", "")
- };
- if ((($a = ((($b = self['$attribute_locked?']("sectnums")) !== false && $b !== nil) ? $b : self.attributes_modified['$include?']("sectnums"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attrs['$[]=']("sectnums", "")
- };};
- if ((($a = ((($b = attrs['$key?']("doctitle")) !== false && $b !== nil) ? $b : ((val = self.$doctitle()))['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attrs['$[]=']("doctitle", val)
- };
- if ((($a = self.id) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.id = attrs['$[]']("css-signature")
- };
- toc_position_val = (function() {if ((($a = (toc_val = ((function() {if ((($b = attrs.$delete("toc2")) !== nil && (!$b.$$is_boolean || $b == true))) {
- return "left"
- } else {
- return attrs['$[]']("toc")
- }; return nil; })()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = (toc_placement = attrs.$fetch("toc-placement", "macro")), $b !== false && $b !== nil ?toc_placement['$!=']("auto") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return toc_placement
- } else {
- return attrs['$[]']("toc-position")
- }
- } else {
- return nil
- }; return nil; })();
- if ((($a = (($b = toc_val !== false && toc_val !== nil) ? (((($c = toc_val['$empty?']()['$!']()) !== false && $c !== nil) ? $c : toc_position_val['$nil_or_empty?']()['$!']())) : toc_val)) !== nil && (!$a.$$is_boolean || $a == true))) {
- default_toc_position = "left";
- default_toc_class = "toc2";
- if ((($a = toc_position_val['$nil_or_empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- position = toc_position_val
- } else if ((($a = toc_val['$empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- position = toc_val
- } else {
- position = default_toc_position
- };
- attrs['$[]=']("toc", "");
- attrs['$[]=']("toc-placement", "auto");
- $case = position;if ("left"['$===']($case) || "<"['$===']($case) || "<"['$===']($case)) {attrs['$[]=']("toc-position", "left")}else if ("right"['$===']($case) || ">"['$===']($case) || ">"['$===']($case)) {attrs['$[]=']("toc-position", "right")}else if ("top"['$===']($case) || "^"['$===']($case)) {attrs['$[]=']("toc-position", "top")}else if ("bottom"['$===']($case) || "v"['$===']($case)) {attrs['$[]=']("toc-position", "bottom")}else if ("preamble"['$===']($case) || "macro"['$===']($case)) {attrs['$[]=']("toc-position", "content");
- attrs['$[]=']("toc-placement", position);
- default_toc_class = nil;}else {attrs.$delete("toc-position");
- default_toc_class = nil;};
- if (default_toc_class !== false && default_toc_class !== nil) {
- ($a = "toc-class", $b = attrs, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, default_toc_class)))};};
- if ((($a = attrs['$key?']("compat-mode")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = attrs['$has_key?']("language")) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$[]=']("source-language", attrs['$[]']("language"))};
- self.compat_mode = true;
- } else {
- self.compat_mode = false
- };
- self.outfilesuffix = attrs['$[]']("outfilesuffix");
- self.header_attributes = attrs.$dup();
- if ((($a = self.parent_document) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return ($a = ($b = $scope.get('FLEXIBLE_ATTRIBUTES')).$each, $a.$$p = (TMP_11 = function(name){var self = TMP_11.$$s || this, $a, $b;
- if (self.attribute_overrides == null) self.attribute_overrides = nil;
-if (name == null) name = nil;
- if ((($a = ($b = self.attribute_overrides['$key?'](name), $b !== false && $b !== nil ?self.attribute_overrides['$[]'](name) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.attribute_overrides.$delete(name)
- } else {
- return nil
- }}, TMP_11.$$s = self, TMP_11), $a).call($b)
- };
- });
-
- Opal.defn(self, '$restore_attributes', function() {
- var $a, self = this;
-
- if ((($a = self.parent_document) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.callouts.$rewind()
- };
- return self.attributes = self.header_attributes;
- });
-
- Opal.defn(self, '$clear_playback_attributes', function(attributes) {
- var self = this;
-
- return attributes.$delete("attribute_entries");
- });
-
- Opal.defn(self, '$playback_attributes', function(block_attributes) {
- var $a, $b, TMP_12, self = this;
-
- if ((($a = block_attributes['$key?']("attribute_entries")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = ($b = block_attributes['$[]']("attribute_entries")).$each, $a.$$p = (TMP_12 = function(entry){var self = TMP_12.$$s || this, $a, name = nil;
- if (self.attributes == null) self.attributes = nil;
-if (entry == null) entry = nil;
- name = entry.$name();
- if ((($a = entry.$negate()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.attributes.$delete(name);
- if (name['$==']("compat-mode")) {
- return self.compat_mode = false
- } else {
- return nil
- };
- } else {
- self.attributes['$[]='](name, entry.$value());
- if (name['$==']("compat-mode")) {
- return self.compat_mode = true
- } else {
- return nil
- };
- };}, TMP_12.$$s = self, TMP_12), $a).call($b)
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$set_attribute', function(name, value) {
- var $a, self = this, $case = nil;
-
- if ((($a = self['$attribute_locked?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false
- } else {
- $case = name;if ("backend"['$===']($case)) {self.$update_backend_attributes(self.$apply_attribute_value_subs(value), self.attributes_modified['$delete?']("htmlsyntax")['$!']()['$!']())}else if ("doctype"['$===']($case)) {self.$update_doctype_attributes(self.$apply_attribute_value_subs(value))}else {self.attributes['$[]='](name, self.$apply_attribute_value_subs(value))};
- self.attributes_modified['$<<'](name);
- return true;
- };
- });
-
- Opal.defn(self, '$delete_attribute', function(name) {
- var $a, self = this;
-
- if ((($a = self['$attribute_locked?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false
- } else {
- self.attributes.$delete(name);
- self.attributes_modified['$<<'](name);
- return true;
- };
- });
-
- Opal.defn(self, '$attribute_locked?', function(name) {
- var self = this;
-
- return self.attribute_overrides['$key?'](name);
- });
-
- Opal.defn(self, '$apply_attribute_value_subs', function(value) {
- var $a, self = this, m = nil, subs = nil;
-
- if ((($a = (m = $scope.get('AttributeEntryPassMacroRx').$match(value))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = m['$[]'](1)['$empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- subs = self.$resolve_pass_subs(m['$[]'](1));
- if ((($a = subs['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return m['$[]'](2)
- } else {
- return (self.$apply_subs(m['$[]'](2), subs))
- };
- } else {
- return m['$[]'](2)
- }
- } else {
- return self.$apply_header_subs(value)
- };
- });
-
- Opal.defn(self, '$update_backend_attributes', function(new_backend, force) {
- var $a, $b, $c, self = this, attrs = nil, current_backend = nil, current_basebackend = nil, current_doctype = nil, resolved_name = nil, new_basebackend = nil, new_filetype = nil, new_outfilesuffix = nil, current_filetype = nil, page_width = nil;
-
- if (force == null) {
- force = false
- }
- if ((($a = ((($b = force) !== false && $b !== nil) ? $b : ((($c = new_backend !== false && new_backend !== nil) ? new_backend['$!='](self.attributes['$[]']("backend")) : new_backend)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs = self.attributes;
- current_backend = attrs['$[]']("backend");
- current_basebackend = attrs['$[]']("basebackend");
- current_doctype = attrs['$[]']("doctype");
- if ((($a = new_backend['$start_with?']("xhtml")) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$[]=']("htmlsyntax", "xml");
- new_backend = new_backend['$[]']($range(1, -1, false));
- } else if ((($a = new_backend['$start_with?']("html")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (attrs['$[]']("htmlsyntax")['$==']("xml")) {
- } else {
- attrs['$[]=']("htmlsyntax", "html")
- }};
- if ((($a = (resolved_name = $scope.get('BACKEND_ALIASES')['$[]'](new_backend))) !== nil && (!$a.$$is_boolean || $a == true))) {
- new_backend = resolved_name};
- if (current_backend !== false && current_backend !== nil) {
- attrs.$delete("backend-" + (current_backend));
- if (current_doctype !== false && current_doctype !== nil) {
- attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype))};};
- if (current_doctype !== false && current_doctype !== nil) {
- attrs['$[]=']("doctype-" + (current_doctype), "");
- attrs['$[]=']("backend-" + (new_backend) + "-doctype-" + (current_doctype), "");};
- attrs['$[]=']("backend", new_backend);
- attrs['$[]=']("backend-" + (new_backend), "");
- if ((($a = (($scope.get('Converter')).$$scope.get('BackendInfo'))['$===']((self.converter = self.$create_converter()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- new_basebackend = self.converter.$basebackend();
- if ((($a = self['$attribute_locked?']("outfilesuffix")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attrs['$[]=']("outfilesuffix", self.converter.$outfilesuffix())
- };
- new_filetype = self.converter.$filetype();
- } else {
- new_basebackend = new_backend.$sub($scope.get('TrailingDigitsRx'), "");
- new_outfilesuffix = ((($a = $scope.get('DEFAULT_EXTENSIONS')['$[]'](new_basebackend)) !== false && $a !== nil) ? $a : ".html");
- new_filetype = new_outfilesuffix['$[]']($range(1, -1, false));
- if ((($a = self['$attribute_locked?']("outfilesuffix")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attrs['$[]=']("outfilesuffix", new_outfilesuffix)
- };
- };
- if ((($a = (current_filetype = attrs['$[]']("filetype"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs.$delete("filetype-" + (current_filetype))};
- attrs['$[]=']("filetype", new_filetype);
- attrs['$[]=']("filetype-" + (new_filetype), "");
- if ((($a = (page_width = $scope.get('DEFAULT_PAGE_WIDTHS')['$[]'](new_basebackend))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs['$[]=']("pagewidth", page_width)
- } else {
- attrs.$delete("pagewidth")
- };
- if ((($a = new_basebackend['$!='](current_basebackend)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (current_basebackend !== false && current_basebackend !== nil) {
- attrs.$delete("basebackend-" + (current_basebackend));
- if (current_doctype !== false && current_doctype !== nil) {
- attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype))};};
- attrs['$[]=']("basebackend", new_basebackend);
- attrs['$[]=']("basebackend-" + (new_basebackend), "");
- if (current_doctype !== false && current_doctype !== nil) {
- attrs['$[]=']("basebackend-" + (new_basebackend) + "-doctype-" + (current_doctype), "")};};
- return self.backend = nil;
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$update_doctype_attributes', function(new_doctype) {
- var $a, $b, self = this, attrs = nil, current_doctype = nil, current_backend = nil, current_basebackend = nil;
-
- if ((($a = (($b = new_doctype !== false && new_doctype !== nil) ? new_doctype['$!='](self.attributes['$[]']("doctype")) : new_doctype)) !== nil && (!$a.$$is_boolean || $a == true))) {
- attrs = self.attributes;
- current_doctype = attrs['$[]']("doctype");
- current_backend = attrs['$[]']("backend");
- current_basebackend = attrs['$[]']("basebackend");
- if (current_doctype !== false && current_doctype !== nil) {
- attrs.$delete("doctype-" + (current_doctype));
- if (current_backend !== false && current_backend !== nil) {
- attrs.$delete("backend-" + (current_backend) + "-doctype-" + (current_doctype))};
- if (current_basebackend !== false && current_basebackend !== nil) {
- attrs.$delete("basebackend-" + (current_basebackend) + "-doctype-" + (current_doctype))};};
- attrs['$[]=']("doctype", new_doctype);
- attrs['$[]=']("doctype-" + (new_doctype), "");
- if (current_backend !== false && current_backend !== nil) {
- attrs['$[]=']("backend-" + (current_backend) + "-doctype-" + (new_doctype), "")};
- if (current_basebackend !== false && current_basebackend !== nil) {
- attrs['$[]=']("basebackend-" + (current_basebackend) + "-doctype-" + (new_doctype), "")};
- return self.doctype = nil;
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$create_converter', function() {
- var $a, self = this, converter_opts = nil, template_dirs = nil, template_dir = nil, converter = nil, converter_factory = nil;
-
- converter_opts = $hash2([], {});
- converter_opts['$[]=']("htmlsyntax", self.attributes['$[]']("htmlsyntax"));
- template_dirs = (function() {if ((($a = (template_dir = self.options['$[]']("template_dir"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return converter_opts['$[]=']("template_dirs", [template_dir])
- } else if ((($a = (template_dirs = self.options['$[]']("template_dirs"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return converter_opts['$[]=']("template_dirs", template_dirs)
- } else {
- return nil
- }; return nil; })();
- if (template_dirs !== false && template_dirs !== nil) {
- converter_opts['$[]=']("template_cache", self.options.$fetch("template_cache", true));
- converter_opts['$[]=']("template_engine", self.options['$[]']("template_engine"));
- converter_opts['$[]=']("template_engine_options", self.options['$[]']("template_engine_options"));
- converter_opts['$[]=']("eruby", self.options['$[]']("eruby"));
- converter_opts['$[]=']("safe", self.safe);};
- if ((($a = (converter = self.options['$[]']("converter"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- converter_factory = (($scope.get('Converter')).$$scope.get('Factory')).$new(Opal.get('Hash')['$[]'](self.$backend(), converter))
- } else {
- converter_factory = (($scope.get('Converter')).$$scope.get('Factory')).$default(false)
- };
- return converter_factory.$create(self.$backend(), converter_opts);
- });
-
- Opal.defn(self, '$convert', function(opts) {
- var $a, $b, TMP_13, self = this, block = nil, output = nil, transform = nil, exts = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = self.parsed) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$parse()
- };
- if ((($a = ((($b = $rb_ge(self.safe, (($scope.get('SafeMode')).$$scope.get('SERVER')))) !== false && $b !== nil) ? $b : opts['$empty?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- if ((($a = (self.attributes['$[]=']("outfile", opts['$[]']("outfile")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.attributes.$delete("outfile")
- };
- if ((($a = (self.attributes['$[]=']("outdir", opts['$[]']("outdir")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.attributes.$delete("outdir")
- };
- };
- if ((($a = self.converter) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$fail("asciidoctor: FAILED: missing converter for backend '" + (self.$backend()) + "'. Processing aborted.")
- };
- if (self.$doctype()['$==']("inline")) {
- if ((($a = ($b = (block = self.blocks['$[]'](0)), $b !== false && $b !== nil ?block.$content_model()['$!=']("compound") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- output = block.$content()
- } else {
- output = nil
- }
- } else {
- transform = (function() {if ((($a = ((function() {if ((($b = (opts['$key?']("header_footer"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- return opts['$[]']("header_footer")
- } else {
- return self.options['$[]']("header_footer")
- }; return nil; })())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "document"
- } else {
- return "embedded"
- }; return nil; })();
- output = self.converter.$convert(self, transform);
- };
- if ((($a = self.parent_document) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if ((($a = ($b = (exts = self.extensions), $b !== false && $b !== nil ?exts['$postprocessors?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = exts.$postprocessors()).$each, $a.$$p = (TMP_13 = function(ext){var self = TMP_13.$$s || this;
-if (ext == null) ext = nil;
- return output = ext.$process_method()['$[]'](self, output)}, TMP_13.$$s = self, TMP_13), $a).call($b)};
- return output;
- });
-
- Opal.alias(self, 'render', 'convert');
-
- Opal.defn(self, '$write', function(output, target) {
- var $a, $b, TMP_14, self = this;
-
- if ((($a = $scope.get('Writer')['$==='](self.converter)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.converter.$write(output, target)
- } else {
- if ((($a = target['$respond_to?']("write")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = output['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- target.$write(output.$chomp());
- target.$write($scope.get('EOL'));
- }
- } else {
- ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_14 = function(f){var self = TMP_14.$$s || this;
-if (f == null) f = nil;
- return f.$write(output)}, TMP_14.$$s = self, TMP_14), $a).call($b, target, "w")
- };
- return nil;
- };
- });
-
- Opal.defn(self, '$content', TMP_15 = function() {var $zuper = $slice.call(arguments, 0);
- var self = this, $iter = TMP_15.$$p, $yield = $iter || nil;
-
- TMP_15.$$p = null;
- self.attributes.$delete("title");
- return Opal.find_super_dispatcher(self, 'content', TMP_15, $iter).apply(self, $zuper);
- });
-
- Opal.defn(self, '$docinfo', function(location, ext) {
- var $a, $b, $c, TMP_16, self = this, qualifier = nil, docinfodir = nil, content = nil, docinfo = nil, docinfo_filename = nil, docinfo_path = nil, docinfosubs = nil, content2 = nil, contentx = nil;
-
- if (location == null) {
- location = "head"
- }
- if (ext == null) {
- ext = nil
- }
- if ($rb_ge(self.$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE')))) {
- return ""
- } else {
- qualifier = ((function() {if (location['$==']("footer")) {
- return "-footer"
- } else {
- return nil
- }; return nil; })());
- if (ext !== false && ext !== nil) {
- } else {
- ext = self.outfilesuffix
- };
- docinfodir = self.attributes['$[]']("docinfodir");
- content = nil;
- if ((($a = ((docinfo = self.attributes['$[]']("docinfo")))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self.attributes['$key?']("docinfo2")) !== nil && (!$a.$$is_boolean || $a == true))) {
- docinfo = ["private", "shared"]
- } else if ((($a = self.attributes['$key?']("docinfo1")) !== nil && (!$a.$$is_boolean || $a == true))) {
- docinfo = ["shared"]
- } else {
- docinfo = (function() {if (docinfo !== false && docinfo !== nil) {
- return ["private"]
- } else {
- return nil
- }; return nil; })()
- }
- } else {
- docinfo = ($a = ($b = docinfo.$split(",")).$map, $a.$$p = "strip".$to_proc(), $a).call($b)
- };
- if (docinfo !== false && docinfo !== nil) {
- docinfo_filename = "docinfo" + (qualifier) + (ext);
- if ((($a = (docinfo['$&'](["shared", "shared-" + (location)]))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- docinfo_path = self.$normalize_system_path(docinfo_filename, docinfodir);
- if ((($a = (content = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true})))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (((($c = docinfosubs) !== false && $c !== nil) ? $c : docinfosubs = self.$resolve_docinfo_subs()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- content = (function() {if ((($a = (docinfosubs['$==']("attributes"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$sub_attributes(content)
- } else {
- return self.$apply_subs(content, docinfosubs)
- }; return nil; })()}};
- };
- if ((($a = ((($c = self.attributes['$[]']("docname")['$nil_or_empty?']()) !== false && $c !== nil) ? $c : (docinfo['$&'](["private", "private-" + (location)]))['$empty?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- docinfo_path = self.$normalize_system_path("" + (self.attributes['$[]']("docname")) + "-" + (docinfo_filename), docinfodir);
- if ((($a = (content2 = self.$read_asset(docinfo_path, $hash2(["normalize"], {"normalize": true})))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (((($c = docinfosubs) !== false && $c !== nil) ? $c : docinfosubs = self.$resolve_docinfo_subs()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- content2 = (function() {if ((($a = (docinfosubs['$==']("attributes"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$sub_attributes(content2)
- } else {
- return self.$apply_subs(content2, docinfosubs)
- }; return nil; })()};
- content = (function() {if (content !== false && content !== nil) {
- return "" + (content) + ($scope.get('EOL')) + (content2)
- } else {
- return content2
- }; return nil; })();};
- };};
- if ((($a = ($c = self.extensions, $c !== false && $c !== nil ?self['$docinfo_processors?'](location) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- contentx = $rb_times(($a = ($c = self.docinfo_processor_extensions['$[]'](location)).$map, $a.$$p = (TMP_16 = function(candidate){var self = TMP_16.$$s || this;
-if (candidate == null) candidate = nil;
- return candidate.$process_method()['$[]'](self)}, TMP_16.$$s = self, TMP_16), $a).call($c).$compact(), $scope.get('EOL'));
- content = (function() {if (content !== false && content !== nil) {
- return "" + (content) + ($scope.get('EOL')) + (contentx)
- } else {
- return contentx
- }; return nil; })();};
- return "" + (content);
- };
- });
-
- Opal.defn(self, '$resolve_docinfo_subs', function() {
- var $a, self = this, subs = nil;
-
- if ((($a = self.attributes['$key?']("docinfosubs")) !== nil && (!$a.$$is_boolean || $a == true))) {
- subs = self.$resolve_subs(self.attributes['$[]']("docinfosubs"), "block", nil, "docinfo");
- if ((($a = subs['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return subs
- };
- } else {
- return "attributes"
- };
- });
-
- Opal.defn(self, '$docinfo_processors?', function(location) {
- var $a, $b, self = this;
-
- if (location == null) {
- location = "head"
- }
- if ((($a = self.docinfo_processor_extensions['$key?'](location)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.docinfo_processor_extensions['$[]'](location)['$!='](false)
- } else if ((($a = ($b = self.extensions, $b !== false && $b !== nil ?self.document.$extensions()['$docinfo_processors?'](location) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (self.docinfo_processor_extensions['$[]='](location, self.document.$extensions().$docinfo_processors(location)))['$!']()['$!']()
- } else {
- return self.docinfo_processor_extensions['$[]='](location, false)
- };
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var $a, self = this;
-
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {doctype: " + (self.$doctype().$inspect()) + ", doctitle: " + (((function() {if ((($a = self.header['$!='](nil)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.header.$title()
- } else {
- return nil
- }; return nil; })()).$inspect()) + ", blocks: " + (self.blocks.$size()) + "}>";
- }), nil) && 'to_s';
- })($scope.base, $scope.get('AbstractBlock'))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/inline"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$attr_reader', '$attr_accessor', '$[]', '$nil_or_empty?', '$update_attributes', '$convert', '$converter']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Inline(){};
- var self = $Inline = $klass($base, $super, 'Inline', $Inline);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1;
-
- self.$attr_reader("text");
-
- self.$attr_reader("type");
-
- self.$attr_accessor("target");
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, context, text, opts) {
- var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, more_attributes = nil;
-
- if (text == null) {
- text = nil
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, null).apply(self, [parent, context]);
- self.node_name = "inline_" + (context);
- self.text = text;
- self.id = opts['$[]']("id");
- self.type = opts['$[]']("type");
- self.target = opts['$[]']("target");
- if ((($a = ((more_attributes = opts['$[]']("attributes")))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return self.$update_attributes(more_attributes)
- };
- });
-
- Opal.defn(self, '$block?', function() {
- var self = this;
-
- return false;
- });
-
- Opal.defn(self, '$inline?', function() {
- var self = this;
-
- return true;
- });
-
- Opal.defn(self, '$convert', function() {
- var self = this;
-
- return self.$converter().$convert(self);
- });
-
- return Opal.alias(self, 'render', 'convert');
- })($scope.base, $scope.get('AbstractNode'))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/list"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
-
- Opal.add_stubs(['$==', '$next_list', '$callouts', '$class', '$object_id', '$inspect', '$size', '$items', '$attr_accessor', '$level', '$!', '$nil_or_empty?', '$apply_subs', '$empty?', '$===', '$[]', '$outline?', '$simple?', '$context', '$option?', '$shift', '$blocks', '$unshift', '$lines', '$source', '$parent']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $List(){};
- var self = $List = $klass($base, $super, 'List', $List);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2;
-
- def.context = def.document = def.style = nil;
- Opal.alias(self, 'items', 'blocks');
-
- Opal.alias(self, 'content', 'blocks');
-
- Opal.alias(self, 'items?', 'blocks?');
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, context) {var $zuper = $slice.call(arguments, 0);
- var self = this, $iter = TMP_1.$$p, $yield = $iter || nil;
-
- TMP_1.$$p = null;
- return Opal.find_super_dispatcher(self, 'initialize', TMP_1, $iter).apply(self, $zuper);
- });
-
- Opal.defn(self, '$outline?', function() {
- var $a, self = this;
-
- return ((($a = self.context['$==']("ulist")) !== false && $a !== nil) ? $a : self.context['$==']("olist"));
- });
-
- Opal.defn(self, '$convert', TMP_2 = function() {var $zuper = $slice.call(arguments, 0);
- var self = this, $iter = TMP_2.$$p, $yield = $iter || nil, result = nil;
-
- TMP_2.$$p = null;
- if (self.context['$==']("colist")) {
- result = Opal.find_super_dispatcher(self, 'convert', TMP_2, $iter).apply(self, $zuper);
- self.document.$callouts().$next_list();
- return result;
- } else {
- return Opal.find_super_dispatcher(self, 'convert', TMP_2, $iter).apply(self, $zuper)
- };
- });
-
- Opal.alias(self, 'render', 'convert');
-
- return (Opal.defn(self, '$to_s', function() {
- var self = this;
-
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {context: " + (self.context.$inspect()) + ", style: " + (self.style.$inspect()) + ", items: " + (self.$items().$size()) + "}>";
- }), nil) && 'to_s';
- })($scope.base, $scope.get('AbstractBlock'));
-
- (function($base, $super) {
- function $ListItem(){};
- var self = $ListItem = $klass($base, $super, 'ListItem', $ListItem);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_3;
-
- def.text = def.blocks = nil;
- self.$attr_accessor("marker");
-
- Opal.defn(self, '$initialize', TMP_3 = function(parent, text) {
- var self = this, $iter = TMP_3.$$p, $yield = $iter || nil;
-
- if (text == null) {
- text = nil
- }
- TMP_3.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_3, null).apply(self, [parent, "list_item"]);
- self.text = text;
- return self.level = parent.$level();
- });
-
- Opal.defn(self, '$text?', function() {
- var self = this;
-
- return self.text['$nil_or_empty?']()['$!']();
- });
-
- Opal.defn(self, '$text', function() {
- var self = this;
-
- return self.$apply_subs(self.text);
- });
-
- Opal.defn(self, '$simple?', function() {
- var $a, $b, $c, self = this, blk = nil;
-
- return ((($a = self.blocks['$empty?']()) !== false && $a !== nil) ? $a : (($b = (($c = self.blocks.$size()['$=='](1)) ? $scope.get('List')['$===']((blk = self.blocks['$[]'](0))) : self.blocks.$size()['$=='](1)), $b !== false && $b !== nil ?blk['$outline?']() : $b)));
- });
-
- Opal.defn(self, '$compound?', function() {
- var self = this;
-
- return self['$simple?']()['$!']();
- });
-
- Opal.defn(self, '$fold_first', function(continuation_connects_first_block, content_adjacent) {
- var $a, $b, $c, $d, $e, $f, self = this, first_block = nil, block = nil;
-
- if (continuation_connects_first_block == null) {
- continuation_connects_first_block = false
- }
- if (content_adjacent == null) {
- content_adjacent = false
- }
- if ((($a = ($b = ($c = (first_block = self.blocks['$[]'](0)), $c !== false && $c !== nil ?$scope.get('Block')['$==='](first_block) : $c), $b !== false && $b !== nil ?(((($c = ((($d = first_block.$context()['$==']("paragraph")) ? continuation_connects_first_block['$!']() : first_block.$context()['$==']("paragraph")))) !== false && $c !== nil) ? $c : (($d = ($e = (((($f = content_adjacent) !== false && $f !== nil) ? $f : continuation_connects_first_block['$!']())), $e !== false && $e !== nil ?first_block.$context()['$==']("literal") : $e), $d !== false && $d !== nil ?first_block['$option?']("listparagraph") : $d)))) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- block = self.$blocks().$shift();
- if ((($a = self.text['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- block.$lines().$unshift(self.text)
- };
- self.text = block.$source();};
- return nil;
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var $a, self = this;
-
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {list_context: " + (self.$parent().$context().$inspect()) + ", text: " + (self.text.$inspect()) + ", blocks: " + ((((($a = self.blocks) !== false && $a !== nil) ? $a : [])).$size()) + "}>";
- }), nil) && 'to_s';
- })($scope.base, $scope.get('AbstractBlock'));
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/parser"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_ge(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs);
- }
- function $rb_minus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
- }
- function $rb_le(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $hash = Opal.hash, $range = Opal.range, $gvars = Opal.gvars;
-
- Opal.add_stubs(['$new', '$lambda', '$start_with?', '$=~', '$is_delimited_block?', '$raise', '$parse_document_header', '$[]', '$has_more_lines?', '$next_section', '$<<', '$parse_block_metadata_lines', '$is_next_line_document_title?', '$has_key?', '$finalize_header', '$nil_or_empty?', '$attributes', '$title=', '$sourcemap', '$cursor', '$parse_section_title', '$id=', '$set_attribute', '$delete', '$source_location=', '$header', '$[]=', '$id', '$parse_style_attribute', '$key?', '$parse_header_metadata', '$==', '$doctype', '$parse_manpage_header', '$match', '$sub_attributes', '$downcase', '$rstrip', '$strip', '$warn', '$prev_line_info', '$skip_blank_lines', '$is_next_line_section?', '$initialize_section', '$level', '$tr_s', '$join', '$read_lines_until', '$backend', '$context', '$empty?', '$blocks', '$has_header?', '$!', '$!=', '$attr?', '$attr', '$document', '$special', '$include?', '$sectname', '$+', '$to_i', '$>', '$line_info', '$size', '$*', '$next_block', '$blocks?', '$style', '$context=', '$style=', '$parent=', '$content_model', '$shift', '$unwrap_standalone_preamble', '$dup', '$fetch', '$extensions', '$block_macros?', '$===', '$parse_block_metadata_line', '$advance', '$read_line', '$terminator', '$to_s', '$masq', '$to_sym', '$registered_for_block?', '$strict_verbatim_paragraphs', '$unshift_line', '$markdown_syntax', '$chr', '$lstrip', '$>=', '$length', '$end_with?', '$parse_attributes', '$attribute_missing', '$clear', '$registered_for_block_macro?', '$config', '$each', '$process_method', '$replace', '$peek_line', '$path', '$-', '$lineno', '$next_list_item', '$callout_ids', '$callouts', '$items', '$next_list', '$next_outline_list', '$marker', '$detect', '$next_labeled_list', '$is_section_title?', '$underline_style_section_titles', '$generate_id', '$level=', '$read_paragraph_lines', '$adjust_indentation!', '$set_option', '$catalog_inline_anchors', '$post_match', '$map!', '$split', '$pop', '$build_block', '$blockquote?', '$chop', '$tr', '$rekey', '$next_table', '$concat', '$title?', '$register', '$basename', '$sub_specialchars', '$assign_caption', '$ord', '$caption', '$caption=', '$title', '$update', '$lock_in_subs', '$sub?', '$catalog_callouts', '$source', '$remove_sub', '$block_terminates_paragraph', '$to_proc', '$<=', '$<', '$nil?', '$lines', '$parse_blocks', '$resolve_list_marker', '$items?', '$parent', '$scan', '$marker=', '$read_lines_for_list_item', '$skip_line_comments', '$unshift_lines', '$fold_first', '$text?', '$is_sibling_list_item?', '$delete_at', '$sectname=', '$special=', '$update_attributes', '$peek_lines', '$is_single_line_section_title?', '$is_two_line_section_title?', '$single_line_section_level', '$abs', '$line_length', '$section_level', '$process_attribute_entries', '$next_line_empty?', '$process_authors', '$is_a?', '$apply_header_subs', '$map', '$each_with_index', '$zero?', '$push', '$to_a', '$process_attribute_entry', '$skip_comment_lines', '$store_attribute', '$sanitize_attribute_name', '$delete_attribute', '$save_to', '$resolve_ordered_list_marker', '$chomp', '$roman_numeral_to_int', '$parse_col_specs', '$create_columns', '$has_header_option=', '$format', '$starts_with_delimiter?', '$close_open_cell', '$parse_cell_spec', '$delimiter', '$match_delimiter', '$buffer_has_unclosed_quotes?', '$pre_match', '$skip_matched_delimiter', '$buffer=', '$buffer', '$keep_cell_open', '$push_cell_spec', '$close_cell', '$cell_open?', '$columns', '$assign_col_widths', '$partition_header_footer', '$upto', '$shorthand_property_syntax', '$each_char', '$call', '$sub!', '$gsub!', '$%', '$begin', '$gsub']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Parser(){};
- var self = $Parser = $klass($base, $super, 'Parser', $Parser);
-
- var def = self.$$proto, $scope = self.$$scope, $a, $b, TMP_1, $c, TMP_2, $d, TMP_3;
-
- Opal.cdecl($scope, 'BlockMatchData', $scope.get('Struct').$new("context", "masq", "tip", "terminator"));
-
- Opal.cdecl($scope, 'TabRx', /\t/);
-
- Opal.cdecl($scope, 'TabIndentRx', /^\t+/);
-
- Opal.cdecl($scope, 'StartOfBlockProc', ($a = ($b = self).$lambda, $a.$$p = (TMP_1 = function(l){var self = TMP_1.$$s || this, $a, $b;
-if (l == null) l = nil;
- return ((($a = (($b = (l['$start_with?']("[")), $b !== false && $b !== nil ?$scope.get('BlockAttributeLineRx')['$=~'](l) : $b))) !== false && $a !== nil) ? $a : (self['$is_delimited_block?'](l)))}, TMP_1.$$s = self, TMP_1), $a).call($b));
-
- Opal.cdecl($scope, 'StartOfListProc', ($a = ($c = self).$lambda, $a.$$p = (TMP_2 = function(l){var self = TMP_2.$$s || this;
-if (l == null) l = nil;
- return $scope.get('AnyListRx')['$=~'](l)}, TMP_2.$$s = self, TMP_2), $a).call($c));
-
- Opal.cdecl($scope, 'StartOfBlockOrListProc', ($a = ($d = self).$lambda, $a.$$p = (TMP_3 = function(l){var self = TMP_3.$$s || this, $a, $b, $c;
-if (l == null) l = nil;
- return ((($a = ((($b = (self['$is_delimited_block?'](l))) !== false && $b !== nil) ? $b : (($c = (l['$start_with?']("[")), $c !== false && $c !== nil ?$scope.get('BlockAttributeLineRx')['$=~'](l) : $c)))) !== false && $a !== nil) ? $a : $scope.get('AnyListRx')['$=~'](l))}, TMP_3.$$s = self, TMP_3), $a).call($d));
-
- Opal.cdecl($scope, 'NoOp', nil);
-
- Opal.defn(self, '$initialize', function() {
- var self = this;
-
- return self.$raise("Au contraire, mon frere. No lexer instances will be running around.");
- });
-
- Opal.defs(self, '$parse', function(reader, document, options) {
- var $a, $b, self = this, block_attributes = nil, new_section = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- block_attributes = self.$parse_document_header(reader, document);
- if ((($a = options['$[]']("header_only")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- while ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- $b = Opal.to_ary(self.$next_section(reader, document, block_attributes)), new_section = ($b[0] == null ? nil : $b[0]), block_attributes = ($b[1] == null ? nil : $b[1]);
- if (new_section !== false && new_section !== nil) {
- document['$<<'](new_section)};}
- };
- return document;
- });
-
- Opal.defs(self, '$parse_document_header', function(reader, document) {
- var $a, $b, self = this, block_attributes = nil, has_doctitle_line = nil, assigned_doctitle = nil, val = nil, section_title = nil, source_location = nil, _ = nil, doctitle = nil, single_line = nil, separator = nil, style = nil, style_attrs = nil;
-
- block_attributes = self.$parse_block_metadata_lines(reader, document);
- if ((($a = ($b = (has_doctitle_line = self['$is_next_line_document_title?'](reader, block_attributes)), $b !== false && $b !== nil ?block_attributes['$has_key?']("title") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return document.$finalize_header(block_attributes, false)};
- assigned_doctitle = nil;
- if ((($a = ((val = document.$attributes()['$[]']("doctitle")))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- (($a = [assigned_doctitle = val]), $b = document, $b['$title='].apply($b, $a), $a[$a.length-1])
- };
- section_title = nil;
- if (has_doctitle_line !== false && has_doctitle_line !== nil) {
- if ((($a = document.$sourcemap()) !== nil && (!$a.$$is_boolean || $a == true))) {
- source_location = reader.$cursor()};
- $a = Opal.to_ary(self.$parse_section_title(reader, document)), document['$id='](($a[0] == null ? nil : $a[0])), _ = ($a[1] == null ? nil : $a[1]), doctitle = ($a[2] == null ? nil : $a[2]), _ = ($a[3] == null ? nil : $a[3]), single_line = ($a[4] == null ? nil : $a[4]);
- if (assigned_doctitle !== false && assigned_doctitle !== nil) {
- } else {
- (($a = [assigned_doctitle = doctitle]), $b = document, $b['$title='].apply($b, $a), $a[$a.length-1])
- };
- if (single_line !== false && single_line !== nil) {
- } else {
- document.$set_attribute("compat-mode", "")
- };
- if ((($a = (separator = block_attributes.$delete("separator"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$set_attribute("title-separator", separator)};
- if (source_location !== false && source_location !== nil) {
- (($a = [source_location]), $b = document.$header(), $b['$source_location='].apply($b, $a), $a[$a.length-1])};
- document.$attributes()['$[]=']("doctitle", section_title = doctitle);
- if ((($a = document.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- block_attributes.$delete(1);
- block_attributes.$delete("id");
- } else {
- if ((($a = (style = block_attributes.$delete(1))) !== nil && (!$a.$$is_boolean || $a == true))) {
- style_attrs = $hash(1, style);
- self.$parse_style_attribute(style_attrs, reader);
- if ((($a = style_attrs['$key?']("id")) !== nil && (!$a.$$is_boolean || $a == true))) {
- block_attributes['$[]=']("id", style_attrs['$[]']("id"))};};
- (($a = [block_attributes.$delete("id")]), $b = document, $b['$id='].apply($b, $a), $a[$a.length-1]);
- };
- self.$parse_header_metadata(reader, document);};
- if ((($a = ((($b = ((val = document.$attributes()['$[]']("doctitle")))['$nil_or_empty?']()) !== false && $b !== nil) ? $b : val['$=='](section_title))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- (($a = [assigned_doctitle = val]), $b = document, $b['$title='].apply($b, $a), $a[$a.length-1])
- };
- if (assigned_doctitle !== false && assigned_doctitle !== nil) {
- document.$attributes()['$[]=']("doctitle", assigned_doctitle)};
- if (document.$doctype()['$==']("manpage")) {
- self.$parse_manpage_header(reader, document)};
- return document.$finalize_header(block_attributes);
- });
-
- Opal.defs(self, '$parse_manpage_header', function(reader, document) {
- var $a, self = this, m = nil, name_section = nil, name_section_buffer = nil;
-
- if ((($a = (m = $scope.get('ManpageTitleVolnumRx').$match(document.$attributes()['$[]']("doctitle")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$attributes()['$[]=']("mantitle", document.$sub_attributes(m['$[]'](1).$rstrip().$downcase()));
- document.$attributes()['$[]=']("manvolnum", m['$[]'](2).$strip());
- } else {
- self.$warn("asciidoctor: ERROR: " + (reader.$prev_line_info()) + ": malformed manpage title");
- document.$attributes()['$[]=']("mantitle", document.$attributes()['$[]']("doctitle"));
- document.$attributes()['$[]=']("manvolnum", "1");
- };
- reader.$skip_blank_lines();
- if ((($a = self['$is_next_line_section?'](reader, $hash2([], {}))) !== nil && (!$a.$$is_boolean || $a == true))) {
- name_section = self.$initialize_section(reader, document, $hash2([], {}));
- if (name_section.$level()['$=='](1)) {
- name_section_buffer = reader.$read_lines_until($hash2(["break_on_blank_lines"], {"break_on_blank_lines": true})).$join(" ").$tr_s(" ", " ");
- if ((($a = (m = $scope.get('ManpageNamePurposeRx').$match(name_section_buffer))) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$attributes()['$[]=']("manname", document.$sub_attributes(m['$[]'](1)));
- document.$attributes()['$[]=']("manpurpose", m['$[]'](2));
- if (document.$backend()['$==']("manpage")) {
- document.$attributes()['$[]=']("docname", document.$attributes()['$[]']("manname"));
- return document.$attributes()['$[]=']("outfilesuffix", "." + (document.$attributes()['$[]']("manvolnum")));
- } else {
- return nil
- };
- } else {
- return self.$warn("asciidoctor: ERROR: " + (reader.$prev_line_info()) + ": malformed name section body")
- };
- } else {
- return self.$warn("asciidoctor: ERROR: " + (reader.$prev_line_info()) + ": name section title must be at level 1")
- };
- } else {
- return self.$warn("asciidoctor: ERROR: " + (reader.$prev_line_info()) + ": name section expected")
- };
- });
-
- Opal.defs(self, '$next_section', function(reader, parent, attributes) {
- var $a, $b, $c, $d, self = this, preamble = nil, part = nil, intro = nil, has_header = nil, doctype = nil, section = nil, current_level = nil, expected_next_levels = nil, title = nil, next_level = nil, new_section = nil, block_line_info = nil, new_block = nil, first_block = nil, document = nil, child_block = nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- preamble = false;
- part = false;
- intro = false;
- if ((($a = ($b = (($c = parent.$context()['$==']("document")) ? parent.$blocks()['$empty?']() : parent.$context()['$==']("document")), $b !== false && $b !== nil ?(((($c = ((($d = (has_header = parent['$has_header?']())) !== false && $d !== nil) ? $d : attributes.$delete("invalid-header"))) !== false && $c !== nil) ? $c : self['$is_next_line_section?'](reader, attributes)['$!']())) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- doctype = parent.$doctype();
- if ((($a = ((($b = has_header) !== false && $b !== nil) ? $b : ((($c = doctype['$==']("book")) ? attributes['$[]'](1)['$!=']("abstract") : doctype['$==']("book"))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- preamble = intro = $scope.get('Block').$new(parent, "preamble", $hash2(["content_model"], {"content_model": "compound"}));
- if ((($a = (($b = doctype['$==']("book")) ? (parent['$attr?']("preface-title")) : doctype['$==']("book"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [parent.$attr("preface-title")]), $b = preamble, $b['$title='].apply($b, $a), $a[$a.length-1])};
- parent['$<<'](preamble);};
- section = parent;
- current_level = 0;
- if ((($a = parent.$attributes()['$has_key?']("fragment")) !== nil && (!$a.$$is_boolean || $a == true))) {
- expected_next_levels = nil
- } else if (doctype['$==']("book")) {
- expected_next_levels = [0, 1]
- } else {
- expected_next_levels = [1]
- };
- } else {
- doctype = parent.$document().$doctype();
- section = self.$initialize_section(reader, parent, attributes);
- attributes = (function() {if ((($a = (title = attributes['$[]']("title"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $hash2(["title"], {"title": title})
- } else {
- return $hash2([], {})
- }; return nil; })();
- current_level = section.$level();
- if ((($a = (($b = current_level['$=='](0)) ? doctype['$==']("book") : current_level['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- part = section.$special()['$!']();
- if ((($a = ($b = section.$special(), $b !== false && $b !== nil ?(["preface", "appendix"]['$include?'](section.$sectname())) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- expected_next_levels = [$rb_plus(current_level, 2)]
- } else {
- expected_next_levels = [$rb_plus(current_level, 1)]
- };
- } else {
- expected_next_levels = [$rb_plus(current_level, 1)]
- };
- };
- reader.$skip_blank_lines();
- while ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$parse_block_metadata_lines(reader, section, attributes);
- if ((($b = (next_level = self['$is_next_line_section?'](reader, attributes))) !== nil && (!$b.$$is_boolean || $b == true))) {
- next_level = $rb_plus(next_level, section.$document().$attr("leveloffset", 0).$to_i());
- if ((($b = ((($c = $rb_gt(next_level, current_level)) !== false && $c !== nil) ? $c : ((($d = section.$context()['$==']("document")) ? next_level['$=='](0) : section.$context()['$==']("document"))))) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = (($c = next_level['$=='](0)) ? doctype['$!=']("book") : next_level['$=='](0))) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$warn("asciidoctor: ERROR: " + (reader.$line_info()) + ": only book doctypes can contain level 0 sections")
- } else if ((($b = (($c = expected_next_levels !== false && expected_next_levels !== nil) ? expected_next_levels['$include?'](next_level)['$!']() : expected_next_levels)) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$warn($rb_plus($rb_plus("asciidoctor: WARNING: " + (reader.$line_info()) + ": section title out of sequence: ", "expected " + ((function() {if ($rb_gt(expected_next_levels.$size(), 1)) {
- return "levels"
- } else {
- return "level"
- }; return nil; })()) + " " + ($rb_times(expected_next_levels, " or ")) + ", "), "got level " + (next_level)))};
- $b = Opal.to_ary(self.$next_section(reader, section, attributes)), new_section = ($b[0] == null ? nil : $b[0]), attributes = ($b[1] == null ? nil : $b[1]);
- section['$<<'](new_section);
- } else {
- if ((($b = (($c = next_level['$=='](0)) ? doctype['$!=']("book") : next_level['$=='](0))) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$warn("asciidoctor: ERROR: " + (reader.$line_info()) + ": only book doctypes can contain level 0 sections")};
- break;;
- };
- } else {
- block_line_info = reader.$line_info();
- if ((($b = (new_block = self.$next_block(reader, (((($c = intro) !== false && $c !== nil) ? $c : section)), attributes, $hash2(["parse_metadata"], {"parse_metadata": false})))) !== nil && (!$b.$$is_boolean || $b == true))) {
- if (part !== false && part !== nil) {
- if ((($b = section['$blocks?']()['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = new_block.$style()['$!=']("partintro")) !== nil && (!$b.$$is_boolean || $b == true))) {
- if (new_block.$context()['$==']("paragraph")) {
- (($b = ["open"]), $c = new_block, $c['$context='].apply($c, $b), $b[$b.length-1]);
- (($b = ["partintro"]), $c = new_block, $c['$style='].apply($c, $b), $b[$b.length-1]);
- } else {
- intro = $scope.get('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"}));
- (($b = ["partintro"]), $c = intro, $c['$style='].apply($c, $b), $b[$b.length-1]);
- (($b = [intro]), $c = new_block, $c['$parent='].apply($c, $b), $b[$b.length-1]);
- section['$<<'](intro);
- }}
- } else if (section.$blocks().$size()['$=='](1)) {
- first_block = section.$blocks()['$[]'](0);
- if ((($b = ($c = intro['$!'](), $c !== false && $c !== nil ?first_block.$content_model()['$==']("compound") : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$warn("asciidoctor: ERROR: " + (block_line_info) + ": illegal block content outside of partintro block")
- } else if ((($b = first_block.$content_model()['$!=']("compound")) !== nil && (!$b.$$is_boolean || $b == true))) {
- intro = $scope.get('Block').$new(section, "open", $hash2(["content_model"], {"content_model": "compound"}));
- (($b = ["partintro"]), $c = intro, $c['$style='].apply($c, $b), $b[$b.length-1]);
- section.$blocks().$shift();
- if (first_block.$style()['$==']("partintro")) {
- (($b = ["paragraph"]), $c = first_block, $c['$context='].apply($c, $b), $b[$b.length-1]);
- (($b = [nil]), $c = first_block, $c['$style='].apply($c, $b), $b[$b.length-1]);};
- (($b = [intro]), $c = first_block, $c['$parent='].apply($c, $b), $b[$b.length-1]);
- intro['$<<'](first_block);
- (($b = [intro]), $c = new_block, $c['$parent='].apply($c, $b), $b[$b.length-1]);
- section['$<<'](intro);};}};
- (((($b = intro) !== false && $b !== nil) ? $b : section))['$<<'](new_block);
- attributes = $hash2([], {});};
- };
- reader.$skip_blank_lines();};
- if (part !== false && part !== nil) {
- if ((($a = ($b = section['$blocks?'](), $b !== false && $b !== nil ?section.$blocks()['$[]'](-1).$context()['$==']("section") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$warn("asciidoctor: ERROR: " + (reader.$line_info()) + ": invalid part, must have at least one section (e.g., chapter, appendix, etc.)")
- }
- } else if (preamble !== false && preamble !== nil) {
- document = parent;
- if ((($a = preamble['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = ($c = $scope.get('Compliance').$unwrap_standalone_preamble(), $c !== false && $c !== nil ?document.$blocks().$size()['$=='](1) : $c), $b !== false && $b !== nil ?doctype['$!=']("book") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$blocks().$shift();
- while ((($b = (child_block = preamble.$blocks().$shift())) !== nil && (!$b.$$is_boolean || $b == true))) {
- (($b = [document]), $c = child_block, $c['$parent='].apply($c, $b), $b[$b.length-1]);
- document['$<<'](child_block);};}
- } else {
- document.$blocks().$shift()
- };};
- return [(function() {if ((($a = section['$!='](parent)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return section
- } else {
- return nil
- }; return nil; })(), attributes.$dup()];
- });
-
- Opal.defs(self, '$next_block', function(reader, parent, attributes, options) {
- var $a, $b, $c, $d, $e, TMP_4, $f, $g, TMP_5, TMP_6, TMP_7, self = this, skipped = nil, text_only = nil, parse_metadata = nil, document = nil, extensions = nil, block_extensions = nil, block_macro_extensions = nil, in_list = nil, block = nil, style = nil, explicit_style = nil, sourcemap = nil, source_location = nil, this_line = nil, delimited_block = nil, block_context = nil, cloaked_context = nil, terminator = nil, delimited_blk_match = nil, first_char = nil, match = nil, blk_ctx = nil, posattrs = nil, target = nil, extension = nil, raw_attributes = nil, default_attrs = nil, expected_index = nil, list_item = nil, coids = nil, marker = nil, float_id = nil, float_reftext = nil, float_title = nil, float_level = nil, _ = nil, tmp_sect = nil, break_at_list = nil, lines = nil, first_line = nil, admonition_match = nil, admonition_name = nil, attribution = nil, citetitle = nil, $case = nil, language = nil, linenums = nil, default_language = nil, explicit_stem_syntax = nil, default_stem_syntax = nil, cursor = nil, block_reader = nil, content_model = nil, pos_attrs = nil, resolved_target = nil, scaledwidth = nil, block_id = nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- if (options == null) {
- options = $hash2([], {})
- }
- skipped = reader.$skip_blank_lines();
- if ((($a = reader['$has_more_lines?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- if ((($a = ($b = (text_only = options['$[]']("text")), $b !== false && $b !== nil ?$rb_gt(skipped, 0) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- options.$delete("text");
- text_only = false;};
- parse_metadata = options.$fetch("parse_metadata", true);
- document = parent.$document();
- if ((($a = (extensions = document.$extensions())) !== nil && (!$a.$$is_boolean || $a == true))) {
- block_extensions = extensions['$blocks?']();
- block_macro_extensions = extensions['$block_macros?']();
- } else {
- block_extensions = block_macro_extensions = false
- };
- in_list = $scope.get('ListItem')['$==='](parent);
- block = nil;
- style = nil;
- explicit_style = nil;
- sourcemap = document.$sourcemap();
- source_location = nil;
- while ((($b = ($c = block['$!'](), $c !== false && $c !== nil ?reader['$has_more_lines?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = (($c = parse_metadata !== false && parse_metadata !== nil) ? self.$parse_block_metadata_line(reader, document, attributes, options) : parse_metadata)) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$advance();
- continue;;};
- if (sourcemap !== false && sourcemap !== nil) {
- source_location = reader.$cursor()};
- this_line = reader.$read_line();
- delimited_block = false;
- block_context = nil;
- cloaked_context = nil;
- terminator = nil;
- if ((($b = attributes['$[]'](1)) !== nil && (!$b.$$is_boolean || $b == true))) {
- $b = Opal.to_ary(self.$parse_style_attribute(attributes, reader)), style = ($b[0] == null ? nil : $b[0]), explicit_style = ($b[1] == null ? nil : $b[1])};
- if ((($b = (delimited_blk_match = self['$is_delimited_block?'](this_line, true))) !== nil && (!$b.$$is_boolean || $b == true))) {
- delimited_block = true;
- block_context = cloaked_context = delimited_blk_match.$context();
- terminator = delimited_blk_match.$terminator();
- if ((($b = style['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- style = attributes['$[]=']("style", block_context.$to_s())
- } else if ((($b = style['$!='](block_context.$to_s())) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = delimited_blk_match.$masq()['$include?'](style)) !== nil && (!$b.$$is_boolean || $b == true))) {
- block_context = style.$to_sym()
- } else if ((($b = ($c = delimited_blk_match.$masq()['$include?']("admonition"), $c !== false && $c !== nil ?$scope.get('ADMONITION_STYLES')['$include?'](style) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- block_context = "admonition"
- } else if ((($b = (($c = block_extensions !== false && block_extensions !== nil) ? extensions['$registered_for_block?'](style, block_context) : block_extensions)) !== nil && (!$b.$$is_boolean || $b == true))) {
- block_context = style.$to_sym()
- } else {
- self.$warn("asciidoctor: WARNING: " + (reader.$prev_line_info()) + ": invalid style for " + (block_context) + " block: " + (style));
- style = block_context.$to_s();
- }};};
- if (delimited_block !== false && delimited_block !== nil) {
- } else {
- while ((($c = true) !== nil && (!$c.$$is_boolean || $c == true))) {
- if ((($c = ($d = (($e = style !== false && style !== nil) ? $scope.get('Compliance').$strict_verbatim_paragraphs() : style), $d !== false && $d !== nil ?$scope.get('VERBATIM_STYLES')['$include?'](style) : $d)) !== nil && (!$c.$$is_boolean || $c == true))) {
- block_context = style.$to_sym();
- reader.$unshift_line(this_line);
- break;;};
- if (text_only !== false && text_only !== nil) {
- } else {
- first_char = (function() {if ((($c = $scope.get('Compliance').$markdown_syntax()) !== nil && (!$c.$$is_boolean || $c == true))) {
- return this_line.$lstrip().$chr()
- } else {
- return this_line.$chr()
- }; return nil; })();
- if ((($c = ($d = ($e = ($scope.get('LAYOUT_BREAK_LINES')['$has_key?'](first_char)), $e !== false && $e !== nil ?$rb_ge(this_line.$length(), 3) : $e), $d !== false && $d !== nil ?((function() {if ((($e = $scope.get('Compliance').$markdown_syntax()) !== nil && (!$e.$$is_boolean || $e == true))) {
- return $scope.get('LayoutBreakLinePlusRx')
- } else {
- return $scope.get('LayoutBreakLineRx')
- }; return nil; })())['$=~'](this_line) : $d)) !== nil && (!$c.$$is_boolean || $c == true))) {
- block = $scope.get('Block').$new(parent, $scope.get('LAYOUT_BREAK_LINES')['$[]'](first_char), $hash2(["content_model"], {"content_model": "empty"}));
- break;;
- } else if ((($c = ($d = this_line['$end_with?']("]"), $d !== false && $d !== nil ?(match = $scope.get('MediaBlockMacroRx').$match(this_line)) : $d)) !== nil && (!$c.$$is_boolean || $c == true))) {
- blk_ctx = match['$[]'](1).$to_sym();
- block = $scope.get('Block').$new(parent, blk_ctx, $hash2(["content_model"], {"content_model": "empty"}));
- if (blk_ctx['$==']("image")) {
- posattrs = ["alt", "width", "height"]
- } else if (blk_ctx['$==']("video")) {
- posattrs = ["poster", "width", "height"]
- } else {
- posattrs = []
- };
- if ((($c = ((($d = style['$!']()) !== false && $d !== nil) ? $d : explicit_style)) !== nil && (!$c.$$is_boolean || $c == true))) {
- } else {
- if (blk_ctx['$==']("image")) {
- attributes['$[]=']("alt", style)};
- attributes.$delete("style");
- style = nil;
- };
- block.$parse_attributes(match['$[]'](3), posattrs, $hash2(["unescape_input", "sub_input", "sub_result", "into"], {"unescape_input": (blk_ctx['$==']("image")), "sub_input": true, "sub_result": false, "into": attributes}));
- target = block.$sub_attributes(match['$[]'](2), $hash2(["attribute_missing"], {"attribute_missing": "drop-line"}));
- if ((($c = target['$empty?']()) !== nil && (!$c.$$is_boolean || $c == true))) {
- if (document.$attributes().$fetch("attribute-missing", $scope.get('Compliance').$attribute_missing())['$==']("skip")) {
- return $scope.get('Block').$new(parent, "paragraph", $hash2(["content_model", "source"], {"content_model": "simple", "source": [this_line]}))
- } else {
- attributes.$clear();
- return nil;
- }};
- attributes['$[]=']("target", target);
- break;;
- } else if ((($c = (($d = first_char['$==']("t")) ? (match = $scope.get('TocBlockMacroRx').$match(this_line)) : first_char['$==']("t"))) !== nil && (!$c.$$is_boolean || $c == true))) {
- block = $scope.get('Block').$new(parent, "toc", $hash2(["content_model"], {"content_model": "empty"}));
- block.$parse_attributes(match['$[]'](1), [], $hash2(["sub_result", "into"], {"sub_result": false, "into": attributes}));
- break;;
- } else if ((($c = ($d = (($e = block_macro_extensions !== false && block_macro_extensions !== nil) ? (match = $scope.get('GenericBlockMacroRx').$match(this_line)) : block_macro_extensions), $d !== false && $d !== nil ?(extension = extensions['$registered_for_block_macro?'](match['$[]'](1))) : $d)) !== nil && (!$c.$$is_boolean || $c == true))) {
- target = match['$[]'](2);
- raw_attributes = match['$[]'](3);
- if (extension.$config()['$[]']("content_model")['$==']("attributes")) {
- if ((($c = raw_attributes['$empty?']()) !== nil && (!$c.$$is_boolean || $c == true))) {
- } else {
- document.$parse_attributes(raw_attributes, (((($c = extension.$config()['$[]']("pos_attrs")) !== false && $c !== nil) ? $c : [])), $hash2(["sub_input", "sub_result", "into"], {"sub_input": true, "sub_result": false, "into": attributes}))
- }
- } else {
- attributes['$[]=']("text", raw_attributes)
- };
- if ((($c = (default_attrs = extension.$config()['$[]']("default_attrs"))) !== nil && (!$c.$$is_boolean || $c == true))) {
- ($c = ($d = default_attrs).$each, $c.$$p = (TMP_4 = function(k, v){var self = TMP_4.$$s || this, $a, $b, $c;
-if (k == null) k = nil;if (v == null) v = nil;
- return ($a = k, $b = attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, v)))}, TMP_4.$$s = self, TMP_4), $c).call($d)};
- if ((($c = (block = extension.$process_method()['$[]'](parent, target, attributes.$dup()))) !== nil && (!$c.$$is_boolean || $c == true))) {
- attributes.$replace(block.$attributes())
- } else {
- attributes.$clear();
- return nil;
- };
- break;;};
- };
- if ((($c = (match = $scope.get('CalloutListRx').$match(this_line))) !== nil && (!$c.$$is_boolean || $c == true))) {
- block = $scope.get('List').$new(parent, "colist");
- attributes['$[]=']("style", "arabic");
- reader.$unshift_line(this_line);
- expected_index = 1;
- while ((($e = ((($f = match) !== false && $f !== nil) ? $f : (($g = reader['$has_more_lines?'](), $g !== false && $g !== nil ?(match = $scope.get('CalloutListRx').$match(reader.$peek_line())) : $g)))) !== nil && (!$e.$$is_boolean || $e == true))) {
- if ((($e = match['$[]'](1).$to_i()['$!='](expected_index)) !== nil && (!$e.$$is_boolean || $e == true))) {
- self.$warn("asciidoctor: WARNING: " + (reader.$path()) + ": line " + ($rb_minus(reader.$lineno(), 2)) + ": callout list item index: expected " + (expected_index) + " got " + (match['$[]'](1)))};
- list_item = self.$next_list_item(reader, block, match);
- expected_index = $rb_plus(expected_index, 1);
- if (list_item !== false && list_item !== nil) {
- block['$<<'](list_item);
- coids = document.$callouts().$callout_ids(block.$items().$size());
- if ((($e = coids['$empty?']()['$!']()) !== nil && (!$e.$$is_boolean || $e == true))) {
- list_item.$attributes()['$[]=']("coids", coids)
- } else {
- self.$warn("asciidoctor: WARNING: " + (reader.$path()) + ": line " + ($rb_minus(reader.$lineno(), 2)) + ": no callouts refer to list item " + (block.$items().$size()))
- };};
- match = nil;};
- document.$callouts().$next_list();
- break;;
- } else if ((($c = $scope.get('UnorderedListRx')['$=~'](this_line)) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$unshift_line(this_line);
- block = self.$next_outline_list(reader, "ulist", parent);
- break;;
- } else if ((($c = (match = $scope.get('OrderedListRx').$match(this_line))) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$unshift_line(this_line);
- block = self.$next_outline_list(reader, "olist", parent);
- if ((($c = ($e = attributes['$[]']("style")['$!'](), $e !== false && $e !== nil ?block.$attributes()['$[]']("style")['$!']() : $e)) !== nil && (!$c.$$is_boolean || $c == true))) {
- marker = block.$items()['$[]'](0).$marker();
- if ((($c = marker['$start_with?'](".")) !== nil && (!$c.$$is_boolean || $c == true))) {
- attributes['$[]=']("style", (((($c = $scope.get('ORDERED_LIST_STYLES')['$[]']($rb_minus(marker.$length(), 1))) !== false && $c !== nil) ? $c : $scope.get('ORDERED_LIST_STYLES')['$[]'](0))).$to_s())
- } else {
- style = ($c = ($e = $scope.get('ORDERED_LIST_STYLES')).$detect, $c.$$p = (TMP_5 = function(s){var self = TMP_5.$$s || this;
-if (s == null) s = nil;
- return $scope.get('OrderedListMarkerRxMap')['$[]'](s)['$=~'](marker)}, TMP_5.$$s = self, TMP_5), $c).call($e);
- attributes['$[]=']("style", (((($c = style) !== false && $c !== nil) ? $c : $scope.get('ORDERED_LIST_STYLES')['$[]'](0))).$to_s());
- };};
- break;;
- } else if ((($c = (match = $scope.get('DefinitionListRx').$match(this_line))) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$unshift_line(this_line);
- block = self.$next_labeled_list(reader, match, parent);
- break;;
- } else if ((($c = ($f = (((($g = style['$==']("float")) !== false && $g !== nil) ? $g : style['$==']("discrete"))), $f !== false && $f !== nil ?self['$is_section_title?'](this_line, ((function() {if ((($g = $scope.get('Compliance').$underline_style_section_titles()) !== nil && (!$g.$$is_boolean || $g == true))) {
- return reader.$peek_line(true)
- } else {
- return nil
- }; return nil; })())) : $f)) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$unshift_line(this_line);
- $c = Opal.to_ary(self.$parse_section_title(reader, document)), float_id = ($c[0] == null ? nil : $c[0]), float_reftext = ($c[1] == null ? nil : $c[1]), float_title = ($c[2] == null ? nil : $c[2]), float_level = ($c[3] == null ? nil : $c[3]), _ = ($c[4] == null ? nil : $c[4]);
- if (float_reftext !== false && float_reftext !== nil) {
- attributes['$[]=']("reftext", float_reftext)};
- if ((($c = attributes['$has_key?']("id")) !== nil && (!$c.$$is_boolean || $c == true))) {
- ((($c = float_id) !== false && $c !== nil) ? $c : float_id = attributes['$[]']("id"))};
- block = $scope.get('Block').$new(parent, "floating_title", $hash2(["content_model"], {"content_model": "empty"}));
- if ((($c = float_id['$nil_or_empty?']()) !== nil && (!$c.$$is_boolean || $c == true))) {
- tmp_sect = $scope.get('Section').$new(parent);
- (($c = [float_title]), $f = tmp_sect, $f['$title='].apply($f, $c), $c[$c.length-1]);
- (($c = [tmp_sect.$generate_id()]), $f = block, $f['$id='].apply($f, $c), $c[$c.length-1]);
- } else {
- (($c = [float_id]), $f = block, $f['$id='].apply($f, $c), $c[$c.length-1])
- };
- (($c = [float_level]), $f = block, $f['$level='].apply($f, $c), $c[$c.length-1]);
- (($c = [float_title]), $f = block, $f['$title='].apply($f, $c), $c[$c.length-1]);
- break;;
- } else if ((($c = (($f = style !== false && style !== nil) ? style['$!=']("normal") : style)) !== nil && (!$c.$$is_boolean || $c == true))) {
- if ((($c = $scope.get('PARAGRAPH_STYLES')['$include?'](style)) !== nil && (!$c.$$is_boolean || $c == true))) {
- block_context = style.$to_sym();
- cloaked_context = "paragraph";
- reader.$unshift_line(this_line);
- break;;
- } else if ((($c = $scope.get('ADMONITION_STYLES')['$include?'](style)) !== nil && (!$c.$$is_boolean || $c == true))) {
- block_context = "admonition";
- cloaked_context = "paragraph";
- reader.$unshift_line(this_line);
- break;;
- } else if ((($c = (($f = block_extensions !== false && block_extensions !== nil) ? extensions['$registered_for_block?'](style, "paragraph") : block_extensions)) !== nil && (!$c.$$is_boolean || $c == true))) {
- block_context = style.$to_sym();
- cloaked_context = "paragraph";
- reader.$unshift_line(this_line);
- break;;
- } else {
- self.$warn("asciidoctor: WARNING: " + (reader.$prev_line_info()) + ": invalid style for paragraph: " + (style));
- style = nil;
- }};
- break_at_list = ((($c = skipped['$=='](0)) ? in_list : skipped['$=='](0)));
- if ((($c = ($f = style['$!=']("normal"), $f !== false && $f !== nil ?$scope.get('LiteralParagraphRx')['$=~'](this_line) : $f)) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$unshift_line(this_line);
- lines = self.$read_paragraph_lines(reader, break_at_list, $hash2(["skip_line_comments"], {"skip_line_comments": text_only}));
- self['$adjust_indentation!'](lines);
- block = $scope.get('Block').$new(parent, "literal", $hash2(["content_model", "source", "attributes"], {"content_model": "verbatim", "source": lines, "attributes": attributes}));
- if (in_list !== false && in_list !== nil) {
- block.$set_option("listparagraph")};
- } else {
- reader.$unshift_line(this_line);
- lines = self.$read_paragraph_lines(reader, break_at_list, $hash2(["skip_line_comments"], {"skip_line_comments": true}));
- if ((($c = lines['$empty?']()) !== nil && (!$c.$$is_boolean || $c == true))) {
- reader.$advance();
- return nil;};
- self.$catalog_inline_anchors(lines.$join($scope.get('EOL')), document);
- first_line = lines['$[]'](0);
- if ((($c = ($f = text_only['$!'](), $f !== false && $f !== nil ?(admonition_match = $scope.get('AdmonitionParagraphRx').$match(first_line)) : $f)) !== nil && (!$c.$$is_boolean || $c == true))) {
- lines['$[]='](0, admonition_match.$post_match().$lstrip());
- attributes['$[]=']("style", admonition_match['$[]'](1));
- attributes['$[]=']("name", admonition_name = admonition_match['$[]'](1).$downcase());
- ($c = "caption", $f = attributes, ((($g = $f['$[]']($c)) !== false && $g !== nil) ? $g : $f['$[]=']($c, document.$attributes()['$[]']("" + (admonition_name) + "-caption"))));
- block = $scope.get('Block').$new(parent, "admonition", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
- } else if ((($c = ($f = ($g = text_only['$!'](), $g !== false && $g !== nil ?$scope.get('Compliance').$markdown_syntax() : $g), $f !== false && $f !== nil ?first_line['$start_with?']("> ") : $f)) !== nil && (!$c.$$is_boolean || $c == true))) {
- ($c = ($f = lines)['$map!'], $c.$$p = (TMP_6 = function(line){var self = TMP_6.$$s || this, $a;
-if (line == null) line = nil;
- if (line['$=='](">")) {
- return line['$[]']($range(1, -1, false))
- } else if ((($a = line['$start_with?']("> ")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line['$[]']($range(2, -1, false))
- } else {
- return line
- }}, TMP_6.$$s = self, TMP_6), $c).call($f);
- if ((($c = lines['$[]'](-1)['$start_with?']("-- ")) !== nil && (!$c.$$is_boolean || $c == true))) {
- $c = Opal.to_ary(lines.$pop()['$[]']($range(3, -1, false)).$split(", ", 2)), attribution = ($c[0] == null ? nil : $c[0]), citetitle = ($c[1] == null ? nil : $c[1]);
- while ((($g = lines['$[]'](-1)['$empty?']()) !== nil && (!$g.$$is_boolean || $g == true))) {
- lines.$pop()};
- } else {
- $c = Opal.to_ary(nil), attribution = ($c[0] == null ? nil : $c[0]), citetitle = ($c[1] == null ? nil : $c[1])
- };
- attributes['$[]=']("style", "quote");
- if (attribution !== false && attribution !== nil) {
- attributes['$[]=']("attribution", attribution)};
- if (citetitle !== false && citetitle !== nil) {
- attributes['$[]=']("citetitle", citetitle)};
- block = self.$build_block("quote", "compound", false, parent, $scope.get('Reader').$new(lines), attributes);
- } else if ((($c = ($g = text_only['$!'](), $g !== false && $g !== nil ?(self['$blockquote?'](lines, first_line)) : $g)) !== nil && (!$c.$$is_boolean || $c == true))) {
- lines['$[]='](0, first_line['$[]']($range(1, -1, false)));
- $c = Opal.to_ary(lines.$pop()['$[]']($range(3, -1, false)).$split(", ", 2)), attribution = ($c[0] == null ? nil : $c[0]), citetitle = ($c[1] == null ? nil : $c[1]);
- while ((($g = lines['$[]'](-1)['$empty?']()) !== nil && (!$g.$$is_boolean || $g == true))) {
- lines.$pop()};
- lines['$[]='](-1, lines['$[]'](-1).$chop());
- attributes['$[]=']("style", "quote");
- if (attribution !== false && attribution !== nil) {
- attributes['$[]=']("attribution", attribution)};
- if (citetitle !== false && citetitle !== nil) {
- attributes['$[]=']("citetitle", citetitle)};
- block = $scope.get('Block').$new(parent, "quote", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
- } else {
- if (style['$==']("normal")) {
- self['$adjust_indentation!'](lines)};
- block = $scope.get('Block').$new(parent, "paragraph", $hash2(["content_model", "source", "attributes"], {"content_model": "simple", "source": lines, "attributes": attributes}));
- };
- };
- break;;}
- };
- if ((($b = ($c = block['$!'](), $c !== false && $c !== nil ?block_context : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = ((($c = block_context['$==']("abstract")) !== false && $c !== nil) ? $c : block_context['$==']("partintro"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- block_context = "open"};
- $case = block_context;if ("admonition"['$===']($case)) {attributes['$[]=']("name", admonition_name = style.$downcase());
- ($b = "caption", $c = attributes, ((($g = $c['$[]']($b)) !== false && $g !== nil) ? $g : $c['$[]=']($b, document.$attributes()['$[]']("" + (admonition_name) + "-caption"))));
- block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes);}else if ("comment"['$===']($case)) {self.$build_block(block_context, "skip", terminator, parent, reader, attributes);
- return nil;}else if ("example"['$===']($case)) {block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes)}else if ("listing"['$===']($case) || "fenced_code"['$===']($case) || "source"['$===']($case)) {if (block_context['$==']("fenced_code")) {
- style = attributes['$[]=']("style", "source");
- $b = Opal.to_ary(this_line['$[]']($range(3, -1, false)).$tr(" ", "").$split(",", 2)), language = ($b[0] == null ? nil : $b[0]), linenums = ($b[1] == null ? nil : $b[1]);
- if ((($b = language['$nil_or_empty?']()['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- attributes['$[]=']("language", language);
- if ((($b = linenums['$nil_or_empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else {
- attributes['$[]=']("linenums", "")
- };
- } else if ((($b = (default_language = document.$attributes()['$[]']("source-language"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- attributes['$[]=']("language", default_language)};
- if ((($b = ($c = attributes['$key?']("indent")['$!'](), $c !== false && $c !== nil ?document.$attributes()['$key?']("source-indent") : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- attributes['$[]=']("indent", document.$attributes()['$[]']("source-indent"))};
- terminator = terminator['$[]']($range(0, 2, false));
- } else if (block_context['$==']("source")) {
- $scope.get('AttributeList').$rekey(attributes, [nil, "language", "linenums"]);
- if ((($b = attributes['$key?']("language")) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else if ((($b = (default_language = document.$attributes()['$[]']("source-language"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- attributes['$[]=']("language", default_language)};
- if ((($b = ($c = attributes['$key?']("indent")['$!'](), $c !== false && $c !== nil ?document.$attributes()['$key?']("source-indent") : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- attributes['$[]=']("indent", document.$attributes()['$[]']("source-indent"))};};
- block = self.$build_block("listing", "verbatim", terminator, parent, reader, attributes);}else if ("literal"['$===']($case)) {block = self.$build_block(block_context, "verbatim", terminator, parent, reader, attributes)}else if ("pass"['$===']($case)) {block = self.$build_block(block_context, "raw", terminator, parent, reader, attributes)}else if ("stem"['$===']($case) || "latexmath"['$===']($case) || "asciimath"['$===']($case)) {if (block_context['$==']("stem")) {
- attributes['$[]=']("style", (function() {if ((($b = (explicit_stem_syntax = attributes['$[]'](2))) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = explicit_stem_syntax['$include?']("tex")) !== nil && (!$b.$$is_boolean || $b == true))) {
- return "latexmath"
- } else {
- return "asciimath"
- }
- } else if ((($b = ((default_stem_syntax = document.$attributes()['$[]']("stem")))['$nil_or_empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- return "asciimath"
- } else {
- return default_stem_syntax
- }; return nil; })())};
- block = self.$build_block("stem", "raw", terminator, parent, reader, attributes);}else if ("open"['$===']($case) || "sidebar"['$===']($case)) {block = self.$build_block(block_context, "compound", terminator, parent, reader, attributes)}else if ("table"['$===']($case)) {cursor = reader.$cursor();
- block_reader = $scope.get('Reader').$new(reader.$read_lines_until($hash2(["terminator", "skip_line_comments"], {"terminator": terminator, "skip_line_comments": true})), cursor);
- $case = terminator.$chr();if (","['$===']($case)) {attributes['$[]=']("format", "csv")}else if (":"['$===']($case)) {attributes['$[]=']("format", "dsv")};
- block = self.$next_table(block_reader, parent, attributes);}else if ("quote"['$===']($case) || "verse"['$===']($case)) {$scope.get('AttributeList').$rekey(attributes, [nil, "attribution", "citetitle"]);
- block = self.$build_block(block_context, ((function() {if (block_context['$==']("verse")) {
- return "verbatim"
- } else {
- return "compound"
- }; return nil; })()), terminator, parent, reader, attributes);}else {if ((($b = (($c = block_extensions !== false && block_extensions !== nil) ? (extension = extensions['$registered_for_block?'](block_context, cloaked_context)) : block_extensions)) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = ((content_model = extension.$config()['$[]']("content_model")))['$!=']("skip")) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = ((pos_attrs = ((($c = extension.$config()['$[]']("pos_attrs")) !== false && $c !== nil) ? $c : [])))['$empty?']()['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- $scope.get('AttributeList').$rekey(attributes, [nil].$concat(pos_attrs))};
- if ((($b = (default_attrs = extension.$config()['$[]']("default_attrs"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- ($b = ($c = default_attrs).$each, $b.$$p = (TMP_7 = function(k, v){var self = TMP_7.$$s || this, $a, $b, $c;
-if (k == null) k = nil;if (v == null) v = nil;
- return ($a = k, $b = attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, v)))}, TMP_7.$$s = self, TMP_7), $b).call($c)};};
- block = self.$build_block(block_context, content_model, terminator, parent, reader, attributes, $hash2(["extension"], {"extension": extension}));
- if ((($b = (($g = block !== false && block !== nil) ? content_model['$!=']("skip") : block)) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else {
- attributes.$clear();
- return nil;
- };
- } else {
- self.$raise("Unsupported block type " + (block_context) + " at " + (reader.$line_info()))
- }};};};
- if (block !== false && block !== nil) {
- if (source_location !== false && source_location !== nil) {
- (($a = [source_location]), $b = block, $b['$source_location='].apply($b, $a), $a[$a.length-1])};
- if ((($a = block['$title?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- (($a = [attributes['$[]']("title")]), $b = block, $b['$title='].apply($b, $a), $a[$a.length-1])
- };
- if (block.$context()['$==']("image")) {
- resolved_target = attributes['$[]']("target");
- block.$document().$register("images", resolved_target);
- ($a = "alt", $b = attributes, ((($g = $b['$[]']($a)) !== false && $g !== nil) ? $g : $b['$[]=']($a, $scope.get('Helpers').$basename(resolved_target, true).$tr("_-", " "))));
- attributes['$[]=']("alt", block.$sub_specialchars(attributes['$[]']("alt")));
- block.$assign_caption(attributes.$delete("caption"), "figure");
- if ((($a = (scaledwidth = attributes['$[]']("scaledwidth"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($range(48, 57, false))['$include?']((((($b = scaledwidth['$[]'](-1)) !== false && $b !== nil) ? $b : 0)).$ord())) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes['$[]=']("scaledwidth", "" + (scaledwidth) + "%")}};
- } else {
- ($a = block, ((($b = $a.$caption()) !== false && $b !== nil) ? $b : $a['$caption='](attributes.$delete("caption"))))
- };
- (($a = [attributes['$[]']("style")]), $b = block, $b['$style='].apply($b, $a), $a[$a.length-1]);
- if ((($a = (block_id = (($b = block, ((($g = $b.$id()) !== false && $g !== nil) ? $g : $b['$id='](attributes['$[]']("id"))))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$register("ids", [block_id, (((($a = attributes['$[]']("reftext")) !== false && $a !== nil) ? $a : ((function() {if ((($b = block['$title?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- return block.$title()
- } else {
- return nil
- }; return nil; })())))])};
- if ((($a = attributes['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- block.$attributes().$update(attributes)
- };
- block.$lock_in_subs();
- if ((($a = block['$sub?']("callouts")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (self.$catalog_callouts(block.$source(), document))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- block.$remove_sub("callouts")
- }};};
- return block;
- });
-
- Opal.defs(self, '$blockquote?', function(lines, first_line) {
- var $a, $b, $c, $d, self = this;
-
- if (first_line == null) {
- first_line = nil
- }
- return ($a = ($b = (($c = $rb_gt(lines.$size(), 1)) ? ((((($d = first_line) !== false && $d !== nil) ? $d : lines['$[]'](0)))['$start_with?']("\"")) : $rb_gt(lines.$size(), 1)), $b !== false && $b !== nil ?(lines['$[]'](-1)['$start_with?']("-- ")) : $b), $a !== false && $a !== nil ?(lines['$[]'](-2)['$end_with?']("\"")) : $a);
- });
-
- Opal.defs(self, '$read_paragraph_lines', function(reader, break_at_list, opts) {
- var $a, $b, self = this, break_condition = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- opts['$[]=']("break_on_blank_lines", true);
- opts['$[]=']("break_on_list_continuation", true);
- opts['$[]=']("preserve_last_line", true);
- break_condition = ((function() {if (break_at_list !== false && break_at_list !== nil) {
- return ((function() {if ((($a = $scope.get('Compliance').$block_terminates_paragraph()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('StartOfBlockOrListProc')
- } else {
- return $scope.get('StartOfListProc')
- }; return nil; })())
- } else {
- return ((function() {if ((($a = $scope.get('Compliance').$block_terminates_paragraph()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('StartOfBlockProc')
- } else {
- return $scope.get('NoOp')
- }; return nil; })())
- }; return nil; })());
- return ($a = ($b = reader).$read_lines_until, $a.$$p = break_condition.$to_proc(), $a).call($b, opts);
- });
-
- Opal.defs(self, '$is_delimited_block?', function(line, return_match_data) {
- var $a, $b, self = this, line_len = nil, tip = nil, tl = nil, fenced_code = nil, tip_3 = nil, context = nil, masq = nil;
-
- if (return_match_data == null) {
- return_match_data = false
- }
- if ((($a = (($b = $rb_gt((line_len = line.$length()), 1)) ? ($scope.get('DELIMITED_BLOCK_LEADERS')['$include?'](line['$[]']($range(0, 1, false)))) : $rb_gt((line_len = line.$length()), 1))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- if (line_len['$=='](2)) {
- tip = line;
- tl = 2;
- } else {
- if ($rb_le(line_len, 4)) {
- tip = line;
- tl = line_len;
- } else {
- tip = line['$[]']($range(0, 3, false));
- tl = 4;
- };
- fenced_code = false;
- if ((($a = $scope.get('Compliance').$markdown_syntax()) !== nil && (!$a.$$is_boolean || $a == true))) {
- tip_3 = ((function() {if (tl['$=='](4)) {
- return tip.$chop()
- } else {
- return tip
- }; return nil; })());
- if (tip_3['$==']("```")) {
- if ((($a = (($b = tl['$=='](4)) ? tip['$end_with?']("`") : tl['$=='](4))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil};
- tip = tip_3;
- tl = 3;
- fenced_code = true;};};
- if ((($a = (($b = tl['$=='](3)) ? fenced_code['$!']() : tl['$=='](3))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil};
- };
- if ((($a = $scope.get('DELIMITED_BLOCKS')['$has_key?'](tip)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ((($b = $rb_lt(tl, 4)) !== false && $b !== nil) ? $b : tl['$=='](line_len))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (return_match_data !== false && return_match_data !== nil) {
- $a = Opal.to_a($scope.get('DELIMITED_BLOCKS')['$[]'](tip)), context = ($a[0] == null ? nil : $a[0]), masq = ($a[1] == null ? nil : $a[1]);
- return $scope.get('BlockMatchData').$new(context, masq, tip, tip);
- } else {
- return true
- }
- } else if (((("") + (tip)) + ($rb_times(tip['$[]']($range(-1, -1, false)), ($rb_minus(line_len, tl)))))['$=='](line)) {
- if (return_match_data !== false && return_match_data !== nil) {
- $a = Opal.to_a($scope.get('DELIMITED_BLOCKS')['$[]'](tip)), context = ($a[0] == null ? nil : $a[0]), masq = ($a[1] == null ? nil : $a[1]);
- return $scope.get('BlockMatchData').$new(context, masq, tip, line);
- } else {
- return true
- }
- } else {
- return nil
- }
- } else {
- return nil
- };
- });
-
- Opal.defs(self, '$build_block', function(block_context, content_model, terminator, parent, reader, attributes, options) {
- var $a, $b, self = this, skip_processing = nil, parse_as_content_model = nil, lines = nil, block_reader = nil, cursor = nil, indent = nil, tab_size = nil, extension = nil, block = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- if ((($a = ((($b = content_model['$==']("skip")) !== false && $b !== nil) ? $b : content_model['$==']("raw"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- skip_processing = content_model['$==']("skip");
- parse_as_content_model = "simple";
- } else {
- skip_processing = false;
- parse_as_content_model = content_model;
- };
- if ((($a = terminator['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (parse_as_content_model['$==']("verbatim")) {
- lines = reader.$read_lines_until($hash2(["break_on_blank_lines", "break_on_list_continuation"], {"break_on_blank_lines": true, "break_on_list_continuation": true}))
- } else {
- if (content_model['$==']("compound")) {
- content_model = "simple"};
- lines = self.$read_paragraph_lines(reader, false, $hash2(["skip_line_comments", "skip_processing"], {"skip_line_comments": true, "skip_processing": true}));
- };
- block_reader = nil;
- } else if ((($a = parse_as_content_model['$!=']("compound")) !== nil && (!$a.$$is_boolean || $a == true))) {
- lines = reader.$read_lines_until($hash2(["terminator", "skip_processing"], {"terminator": terminator, "skip_processing": skip_processing}));
- block_reader = nil;
- } else if (terminator['$=='](false)) {
- lines = nil;
- block_reader = reader;
- } else {
- lines = nil;
- cursor = reader.$cursor();
- block_reader = $scope.get('Reader').$new(reader.$read_lines_until($hash2(["terminator", "skip_processing"], {"terminator": terminator, "skip_processing": skip_processing})), cursor);
- };
- if (content_model['$==']("skip")) {
- attributes.$clear();
- return lines;};
- if (content_model['$==']("verbatim")) {
- if ((($a = (indent = attributes['$[]']("indent"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self['$adjust_indentation!'](lines, indent, (((($a = attributes['$[]']("tabsize")) !== false && $a !== nil) ? $a : parent.$document().$attributes()['$[]']("tabsize"))))
- } else if ($rb_gt((tab_size = (((($a = attributes['$[]']("tabsize")) !== false && $a !== nil) ? $a : parent.$document().$attributes()['$[]']("tabsize"))).$to_i()), 0)) {
- self['$adjust_indentation!'](lines, nil, tab_size)}};
- if ((($a = (extension = options['$[]']("extension"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes.$delete("style");
- if ((($a = (block = extension.$process_method()['$[]'](parent, ((($b = block_reader) !== false && $b !== nil) ? $b : ($scope.get('Reader').$new(lines))), attributes.$dup()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes.$replace(block.$attributes());
- if ((($a = (($b = block.$content_model()['$==']("compound")) ? ((lines = block.$lines()))['$nil_or_empty?']()['$!']() : block.$content_model()['$==']("compound"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- content_model = "compound";
- block_reader = $scope.get('Reader').$new(lines);};
- } else {
- return nil
- };
- } else {
- block = $scope.get('Block').$new(parent, block_context, $hash2(["content_model", "source", "attributes"], {"content_model": content_model, "source": lines, "attributes": attributes}))
- };
- if ((($a = ($b = (attributes['$has_key?']("title")), $b !== false && $b !== nil ?(block.$document()['$attr?']("" + (block.$context()) + "-caption")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [attributes.$delete("title")]), $b = block, $b['$title='].apply($b, $a), $a[$a.length-1]);
- block.$assign_caption(attributes.$delete("caption"));};
- if (content_model['$==']("compound")) {
- self.$parse_blocks(block_reader, block)};
- return block;
- });
-
- Opal.defs(self, '$parse_blocks', function(reader, parent) {
- var $a, $b, self = this, block = nil;
-
- while ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- block = $scope.get('Parser').$next_block(reader, parent);
- if (block !== false && block !== nil) {
- parent['$<<'](block)};};
- });
-
- Opal.defs(self, '$next_outline_list', function(reader, list_type, parent) {
- var $a, $b, $c, self = this, list_block = nil, match = nil, marker = nil, this_item_level = nil, ancestor = nil, list_item = nil;
-
- list_block = $scope.get('List').$new(parent, list_type);
- if (parent.$context()['$=='](list_type)) {
- (($a = [$rb_plus(parent.$level(), 1)]), $b = list_block, $b['$level='].apply($b, $a), $a[$a.length-1])
- } else {
- (($a = [1]), $b = list_block, $b['$level='].apply($b, $a), $a[$a.length-1])
- };
- while ((($b = ($c = reader['$has_more_lines?'](), $c !== false && $c !== nil ?(match = $scope.get('ListRxMap')['$[]'](list_type).$match(reader.$peek_line())) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- marker = self.$resolve_list_marker(list_type, match['$[]'](1));
- if ((($b = ($c = list_block['$items?'](), $c !== false && $c !== nil ?marker['$!='](list_block.$items()['$[]'](0).$marker()) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- this_item_level = $rb_plus(list_block.$level(), 1);
- ancestor = parent;
- while (ancestor.$context()['$=='](list_type)) {
- if (marker['$=='](ancestor.$items()['$[]'](0).$marker())) {
- this_item_level = ancestor.$level();
- break;;};
- ancestor = ancestor.$parent();};
- } else {
- this_item_level = list_block.$level()
- };
- if ((($b = ((($c = list_block['$items?']()['$!']()) !== false && $c !== nil) ? $c : this_item_level['$=='](list_block.$level()))) !== nil && (!$b.$$is_boolean || $b == true))) {
- list_item = self.$next_list_item(reader, list_block, match)
- } else if ($rb_lt(this_item_level, list_block.$level())) {
- break;
- } else if ($rb_gt(this_item_level, list_block.$level())) {
- list_block.$items()['$[]'](-1)['$<<'](self.$next_block(reader, list_block))};
- if (list_item !== false && list_item !== nil) {
- list_block['$<<'](list_item)};
- list_item = nil;
- reader.$skip_blank_lines();};
- return list_block;
- });
-
- Opal.defs(self, '$catalog_callouts', function(text, document) {
- var $a, $b, TMP_8, self = this, found = nil;
-
- found = false;
- if ((($a = text['$include?']("<")) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = text).$scan, $a.$$p = (TMP_8 = function(){var self = TMP_8.$$s || this, $a, m = nil;
- if ($gvars["~"] == null) $gvars["~"] = nil;
-
- m = $gvars["~"];
- if ((($a = m['$[]'](0).$chr()['$!=']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$callouts().$register(m['$[]'](2))};
- return found = true;}, TMP_8.$$s = self, TMP_8), $a).call($b, $scope.get('CalloutQuickScanRx'))};
- return found;
- });
-
- Opal.defs(self, '$catalog_inline_anchors', function(text, document) {
- var $a, $b, TMP_9, self = this;
-
- if ((($a = text['$include?']("[")) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = text).$scan, $a.$$p = (TMP_9 = function(){var self = TMP_9.$$s || this, $a, m = nil, id = nil, reftext = nil;
- if ($gvars["~"] == null) $gvars["~"] = nil;
-
- m = $gvars["~"];
- if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil;};
- id = ((($a = m['$[]'](1)) !== false && $a !== nil) ? $a : m['$[]'](3));
- reftext = ((($a = m['$[]'](2)) !== false && $a !== nil) ? $a : m['$[]'](4));
- return document.$register("ids", [id, reftext]);}, TMP_9.$$s = self, TMP_9), $a).call($b, $scope.get('InlineAnchorRx'))};
- return nil;
- });
-
- Opal.defs(self, '$next_labeled_list', function(reader, match, parent) {
- var $a, $b, $c, $d, self = this, list_block = nil, previous_pair = nil, sibling_pattern = nil, term = nil, item = nil;
-
- list_block = $scope.get('List').$new(parent, "dlist");
- previous_pair = nil;
- sibling_pattern = $scope.get('DefinitionListSiblingRx')['$[]'](match['$[]'](2));
- while ((($b = ((($c = match) !== false && $c !== nil) ? $c : (($d = reader['$has_more_lines?'](), $d !== false && $d !== nil ?(match = sibling_pattern.$match(reader.$peek_line())) : $d)))) !== nil && (!$b.$$is_boolean || $b == true))) {
- $b = Opal.to_ary(self.$next_list_item(reader, list_block, match, sibling_pattern)), term = ($b[0] == null ? nil : $b[0]), item = ($b[1] == null ? nil : $b[1]);
- if ((($b = (($c = previous_pair !== false && previous_pair !== nil) ? previous_pair['$[]'](-1)['$!']() : previous_pair)) !== nil && (!$b.$$is_boolean || $b == true))) {
- previous_pair.$pop();
- previous_pair['$[]'](0)['$<<'](term);
- previous_pair['$<<'](item);
- } else {
- list_block.$items()['$<<']((previous_pair = [[term], item]))
- };
- match = nil;};
- return list_block;
- });
-
- Opal.defs(self, '$next_list_item', function(reader, list_block, match, sibling_trait) {
- var $a, $b, self = this, list_type = nil, list_term = nil, list_item = nil, has_text = nil, text = nil, checkbox = nil, checked = nil, cursor = nil, list_item_reader = nil, comment_lines = nil, subsequent_line = nil, continuation_connects_first_block = nil, content_adjacent = nil, options = nil, new_block = nil;
-
- if (sibling_trait == null) {
- sibling_trait = nil
- }
- if (((list_type = list_block.$context()))['$==']("dlist")) {
- list_term = $scope.get('ListItem').$new(list_block, match['$[]'](1));
- list_item = $scope.get('ListItem').$new(list_block, match['$[]'](3));
- has_text = match['$[]'](3)['$nil_or_empty?']()['$!']();
- } else {
- text = match['$[]'](2);
- checkbox = false;
- if ((($a = (($b = list_type['$==']("ulist")) ? text['$start_with?']("[") : list_type['$==']("ulist"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = text['$start_with?']("[ ] ")) !== nil && (!$a.$$is_boolean || $a == true))) {
- checkbox = true;
- checked = false;
- text = text['$[]']($range(3, -1, false)).$lstrip();
- } else if ((($a = ((($b = text['$start_with?']("[x] ")) !== false && $b !== nil) ? $b : text['$start_with?']("[*] "))) !== nil && (!$a.$$is_boolean || $a == true))) {
- checkbox = true;
- checked = true;
- text = text['$[]']($range(3, -1, false)).$lstrip();}};
- list_item = $scope.get('ListItem').$new(list_block, text);
- if (checkbox !== false && checkbox !== nil) {
- list_block.$attributes()['$[]=']("checklist-option", "");
- list_item.$attributes()['$[]=']("checkbox", "");
- if (checked !== false && checked !== nil) {
- list_item.$attributes()['$[]=']("checked", "")};};
- ((($a = sibling_trait) !== false && $a !== nil) ? $a : sibling_trait = self.$resolve_list_marker(list_type, match['$[]'](1), list_block.$items().$size(), true, reader));
- (($a = [sibling_trait]), $b = list_item, $b['$marker='].apply($b, $a), $a[$a.length-1]);
- has_text = true;
- };
- reader.$advance();
- cursor = reader.$cursor();
- list_item_reader = $scope.get('Reader').$new(self.$read_lines_for_list_item(reader, list_type, sibling_trait, has_text), cursor);
- if ((($a = list_item_reader['$has_more_lines?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- comment_lines = list_item_reader.$skip_line_comments();
- subsequent_line = list_item_reader.$peek_line();
- if ((($a = comment_lines['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- list_item_reader.$unshift_lines(comment_lines)
- };
- if ((($a = subsequent_line['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- continuation_connects_first_block = subsequent_line['$empty?']();
- if ((($a = ($b = continuation_connects_first_block['$!'](), $b !== false && $b !== nil ?list_type['$!=']("dlist") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- has_text = false};
- content_adjacent = ($a = continuation_connects_first_block['$!'](), $a !== false && $a !== nil ?subsequent_line['$empty?']()['$!']() : $a);
- } else {
- continuation_connects_first_block = false;
- content_adjacent = false;
- };
- options = $hash2(["text"], {"text": has_text['$!']()});
- while ((($b = list_item_reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = (new_block = self.$next_block(list_item_reader, list_item, $hash2([], {}), options))) !== nil && (!$b.$$is_boolean || $b == true))) {
- list_item['$<<'](new_block)}};
- list_item.$fold_first(continuation_connects_first_block, content_adjacent);};
- if (list_type['$==']("dlist")) {
- if ((($a = ((($b = list_item['$text?']()) !== false && $b !== nil) ? $b : list_item['$blocks?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- list_item = nil
- };
- return [list_term, list_item];
- } else {
- return list_item
- };
- });
-
- Opal.defs(self, '$read_lines_for_list_item', function(reader, list_type, sibling_trait, has_text) {
- var $a, $b, $c, $d, TMP_10, $e, TMP_11, $f, TMP_12, TMP_13, $g, $h, TMP_14, self = this, buffer = nil, continuation = nil, within_nested_list = nil, detached_continuation = nil, this_line = nil, prev_line = nil, match = nil, nested_list_type = nil;
- if ($gvars["~"] == null) $gvars["~"] = nil;
-
- if (sibling_trait == null) {
- sibling_trait = nil
- }
- if (has_text == null) {
- has_text = true
- }
- buffer = [];
- continuation = "inactive";
- within_nested_list = false;
- detached_continuation = nil;
- while ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- this_line = reader.$read_line();
- if ((($b = self['$is_sibling_list_item?'](this_line, list_type, sibling_trait)) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;};
- prev_line = (function() {if ((($b = buffer['$empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- return nil
- } else {
- return buffer['$[]'](-1)
- }; return nil; })();
- if (prev_line['$==']($scope.get('LIST_CONTINUATION'))) {
- if (continuation['$==']("inactive")) {
- continuation = "active";
- has_text = true;
- if (within_nested_list !== false && within_nested_list !== nil) {
- } else {
- buffer['$[]='](-1, "")
- };};
- if (this_line['$==']($scope.get('LIST_CONTINUATION'))) {
- if ((($b = continuation['$!=']("frozen")) !== nil && (!$b.$$is_boolean || $b == true))) {
- continuation = "frozen";
- buffer['$<<'](this_line);};
- this_line = nil;
- continue;;};};
- if ((($b = (match = self['$is_delimited_block?'](this_line, true))) !== nil && (!$b.$$is_boolean || $b == true))) {
- if (continuation['$==']("active")) {
- buffer['$<<'](this_line);
- buffer.$concat(reader.$read_lines_until($hash2(["terminator", "read_last_line"], {"terminator": match.$terminator(), "read_last_line": true})));
- continuation = "inactive";
- } else {
- break;
- }
- } else if ((($b = ($c = (($d = list_type['$==']("dlist")) ? continuation['$!=']("active") : list_type['$==']("dlist")), $c !== false && $c !== nil ?$scope.get('BlockAttributeLineRx')['$=~'](this_line) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;
- } else if ((($b = (($c = continuation['$==']("active")) ? this_line['$empty?']()['$!']() : continuation['$==']("active"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = $scope.get('LiteralParagraphRx')['$=~'](this_line)) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$unshift_line(this_line);
- buffer.$concat(($b = ($c = reader).$read_lines_until, $b.$$p = (TMP_10 = function(line){var self = TMP_10.$$s || this, $a;
-if (line == null) line = nil;
- return (($a = list_type['$==']("dlist")) ? self['$is_sibling_list_item?'](line, list_type, sibling_trait) : list_type['$==']("dlist"))}, TMP_10.$$s = self, TMP_10), $b).call($c, $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})));
- continuation = "inactive";
- } else if ((($b = ((($d = ((($e = $scope.get('BlockTitleRx')['$=~'](this_line)) !== false && $e !== nil) ? $e : $scope.get('BlockAttributeLineRx')['$=~'](this_line))) !== false && $d !== nil) ? $d : $scope.get('AttributeEntryRx')['$=~'](this_line))) !== nil && (!$b.$$is_boolean || $b == true))) {
- buffer['$<<'](this_line)
- } else {
- if ((($b = nested_list_type = ($d = ($e = ((function() {if (within_nested_list !== false && within_nested_list !== nil) {
- return ["dlist"]
- } else {
- return $scope.get('NESTABLE_LIST_CONTEXTS')
- }; return nil; })())).$detect, $d.$$p = (TMP_11 = function(ctx){var self = TMP_11.$$s || this;
-if (ctx == null) ctx = nil;
- return $scope.get('ListRxMap')['$[]'](ctx)['$=~'](this_line)}, TMP_11.$$s = self, TMP_11), $d).call($e)) !== nil && (!$b.$$is_boolean || $b == true))) {
- within_nested_list = true;
- if ((($b = (($d = nested_list_type['$==']("dlist")) ? $gvars["~"]['$[]'](3)['$nil_or_empty?']() : nested_list_type['$==']("dlist"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- has_text = false};};
- buffer['$<<'](this_line);
- continuation = "inactive";
- }
- } else if ((($b = ($d = prev_line['$nil?']()['$!'](), $d !== false && $d !== nil ?prev_line['$empty?']() : $d)) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = this_line['$empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$skip_blank_lines();
- this_line = reader.$read_line();
- if ((($b = ((($d = this_line['$nil?']()) !== false && $d !== nil) ? $d : self['$is_sibling_list_item?'](this_line, list_type, sibling_trait))) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;};};
- if (this_line['$==']($scope.get('LIST_CONTINUATION'))) {
- detached_continuation = buffer.$size();
- buffer['$<<'](this_line);
- } else if (has_text !== false && has_text !== nil) {
- if ((($b = self['$is_sibling_list_item?'](this_line, list_type, sibling_trait)) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;
- } else if ((($b = nested_list_type = ($d = ($f = $scope.get('NESTABLE_LIST_CONTEXTS')).$detect, $d.$$p = (TMP_12 = function(ctx){var self = TMP_12.$$s || this;
-if (ctx == null) ctx = nil;
- return $scope.get('ListRxMap')['$[]'](ctx)['$=~'](this_line)}, TMP_12.$$s = self, TMP_12), $d).call($f)) !== nil && (!$b.$$is_boolean || $b == true))) {
- buffer['$<<'](this_line);
- within_nested_list = true;
- if ((($b = (($d = nested_list_type['$==']("dlist")) ? $gvars["~"]['$[]'](3)['$nil_or_empty?']() : nested_list_type['$==']("dlist"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- has_text = false};
- } else if ((($b = $scope.get('LiteralParagraphRx')['$=~'](this_line)) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$unshift_line(this_line);
- buffer.$concat(($b = ($d = reader).$read_lines_until, $b.$$p = (TMP_13 = function(line){var self = TMP_13.$$s || this, $a;
-if (line == null) line = nil;
- return (($a = list_type['$==']("dlist")) ? self['$is_sibling_list_item?'](line, list_type, sibling_trait) : list_type['$==']("dlist"))}, TMP_13.$$s = self, TMP_13), $b).call($d, $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})));
- } else {
- break;
- }
- } else {
- if (within_nested_list !== false && within_nested_list !== nil) {
- } else {
- buffer.$pop()
- };
- buffer['$<<'](this_line);
- has_text = true;
- };
- } else {
- if ((($b = this_line['$empty?']()['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- has_text = true};
- if ((($b = nested_list_type = ($g = ($h = ((function() {if (within_nested_list !== false && within_nested_list !== nil) {
- return ["dlist"]
- } else {
- return $scope.get('NESTABLE_LIST_CONTEXTS')
- }; return nil; })())).$detect, $g.$$p = (TMP_14 = function(ctx){var self = TMP_14.$$s || this;
-if (ctx == null) ctx = nil;
- return $scope.get('ListRxMap')['$[]'](ctx)['$=~'](this_line)}, TMP_14.$$s = self, TMP_14), $g).call($h)) !== nil && (!$b.$$is_boolean || $b == true))) {
- within_nested_list = true;
- if ((($b = (($g = nested_list_type['$==']("dlist")) ? $gvars["~"]['$[]'](3)['$nil_or_empty?']() : nested_list_type['$==']("dlist"))) !== nil && (!$b.$$is_boolean || $b == true))) {
- has_text = false};};
- buffer['$<<'](this_line);
- };
- this_line = nil;};
- if (this_line !== false && this_line !== nil) {
- reader.$unshift_line(this_line)};
- if (detached_continuation !== false && detached_continuation !== nil) {
- buffer.$delete_at(detached_continuation)};
- while ((($b = ($g = buffer['$empty?']()['$!'](), $g !== false && $g !== nil ?buffer['$[]'](-1)['$empty?']() : $g)) !== nil && (!$b.$$is_boolean || $b == true))) {
- buffer.$pop()};
- if ((($a = ($b = buffer['$empty?']()['$!'](), $b !== false && $b !== nil ?buffer['$[]'](-1)['$==']($scope.get('LIST_CONTINUATION')) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- buffer.$pop()};
- return buffer;
- });
-
- Opal.defs(self, '$initialize_section', function(reader, parent, attributes) {
- var $a, $b, self = this, document = nil, source_location = nil, sect_id = nil, sect_reftext = nil, sect_title = nil, sect_level = nil, _ = nil, section = nil, style = nil, id = nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- document = parent.$document();
- if ((($a = document.$sourcemap()) !== nil && (!$a.$$is_boolean || $a == true))) {
- source_location = reader.$cursor()};
- $a = Opal.to_ary(self.$parse_section_title(reader, document)), 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]), _ = ($a[4] == null ? nil : $a[4]);
- if (sect_reftext !== false && sect_reftext !== nil) {
- attributes['$[]=']("reftext", sect_reftext)};
- section = $scope.get('Section').$new(parent, sect_level, document.$attributes()['$has_key?']("sectnums"));
- if (source_location !== false && source_location !== nil) {
- (($a = [source_location]), $b = section, $b['$source_location='].apply($b, $a), $a[$a.length-1])};
- (($a = [sect_id]), $b = section, $b['$id='].apply($b, $a), $a[$a.length-1]);
- (($a = [sect_title]), $b = section, $b['$title='].apply($b, $a), $a[$a.length-1]);
- if ((($a = attributes['$[]'](1)) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(self.$parse_style_attribute(attributes, reader)), style = ($a[0] == null ? nil : $a[0]), _ = ($a[1] == null ? nil : $a[1]);
- if (style !== false && style !== nil) {
- (($a = [style]), $b = section, $b['$sectname='].apply($b, $a), $a[$a.length-1]);
- (($a = [true]), $b = section, $b['$special='].apply($b, $a), $a[$a.length-1]);
- if ((($a = (($b = section.$sectname()['$==']("abstract")) ? document.$doctype()['$==']("book") : section.$sectname()['$==']("abstract"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = ["sect1"]), $b = section, $b['$sectname='].apply($b, $a), $a[$a.length-1]);
- (($a = [false]), $b = section, $b['$special='].apply($b, $a), $a[$a.length-1]);
- (($a = [1]), $b = section, $b['$level='].apply($b, $a), $a[$a.length-1]);};
- } else {
- (($a = ["sect" + (section.$level())]), $b = section, $b['$sectname='].apply($b, $a), $a[$a.length-1])
- };
- } else if ((($a = (($b = sect_title.$downcase()['$==']("synopsis")) ? document.$doctype()['$==']("manpage") : sect_title.$downcase()['$==']("synopsis"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [true]), $b = section, $b['$special='].apply($b, $a), $a[$a.length-1]);
- (($a = ["synopsis"]), $b = section, $b['$sectname='].apply($b, $a), $a[$a.length-1]);
- } else {
- (($a = ["sect" + (section.$level())]), $b = section, $b['$sectname='].apply($b, $a), $a[$a.length-1])
- };
- if ((($a = ($b = section.$id()['$!'](), $b !== false && $b !== nil ?(id = attributes['$[]']("id")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [id]), $b = section, $b['$id='].apply($b, $a), $a[$a.length-1])
- } else {
- ($a = section, ((($b = $a.$id()) !== false && $b !== nil) ? $b : $a['$id='](section.$generate_id())))
- };
- if ((($a = section.$id()) !== nil && (!$a.$$is_boolean || $a == true))) {
- section.$document().$register("ids", [section.$id(), (((($a = attributes['$[]']("reftext")) !== false && $a !== nil) ? $a : section.$title()))])};
- section.$update_attributes(attributes);
- reader.$skip_blank_lines();
- return section;
- });
-
- Opal.defs(self, '$section_level', function(line) {
- var self = this;
-
- return $scope.get('SECTION_LEVELS')['$[]'](line.$chr());
- });
-
- Opal.defs(self, '$single_line_section_level', function(marker) {
- var self = this;
-
- return $rb_minus(marker.$length(), 1);
- });
-
- Opal.defs(self, '$is_next_line_section?', function(reader, attributes) {
- var $a, $b, $c, $d, self = this, val = nil, ord_0 = nil;
-
- if ((($a = ($b = ($c = ((val = attributes['$[]'](1)))['$nil?']()['$!'](), $c !== false && $c !== nil ?(((($d = ((ord_0 = val['$[]'](0).$ord()))['$=='](100)) !== false && $d !== nil) ? $d : ord_0['$=='](102))) : $c), $b !== false && $b !== nil ?val['$=~']($scope.get('FloatingTitleStyleRx')) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false};
- if ((($a = reader['$has_more_lines?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return false
- };
- if ((($a = $scope.get('Compliance').$underline_style_section_titles()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = self)['$is_section_title?'].apply($a, Opal.to_a(reader.$peek_lines(2)))
- } else {
- return self['$is_section_title?'](reader.$peek_line())
- };
- });
-
- Opal.defs(self, '$is_next_line_document_title?', function(reader, attributes) {
- var self = this;
-
- return self['$is_next_line_section?'](reader, attributes)['$=='](0);
- });
-
- Opal.defs(self, '$is_section_title?', function(line1, line2) {
- var $a, $b, self = this, level = nil;
-
- if (line2 == null) {
- line2 = nil
- }
- if ((($a = (level = self['$is_single_line_section_title?'](line1))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return level
- } else if ((($a = (($b = line2 !== false && line2 !== nil) ? (level = self['$is_two_line_section_title?'](line1, line2)) : line2)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return level
- } else {
- return false
- };
- });
-
- Opal.defs(self, '$is_single_line_section_title?', function(line1) {
- var $a, $b, $c, $d, self = this, first_char = nil, match = nil;
-
- first_char = (function() {if (line1 !== false && line1 !== nil) {
- return line1.$chr()
- } else {
- return nil
- }; return nil; })();
- if ((($a = ($b = (((($c = first_char['$==']("=")) !== false && $c !== nil) ? $c : (($d = $scope.get('Compliance').$markdown_syntax(), $d !== false && $d !== nil ?first_char['$==']("#") : $d)))), $b !== false && $b !== nil ?(match = $scope.get('AtxSectionRx').$match(line1)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$single_line_section_level(match['$[]'](1))
- } else {
- return false
- };
- });
-
- Opal.defs(self, '$is_two_line_section_title?', function(line1, line2) {
- var $a, $b, $c, $d, $e, $f, self = this;
-
- if ((($a = ($b = ($c = ($d = ($e = (($f = line1 !== false && line1 !== nil) ? line2 : line1), $e !== false && $e !== nil ?$scope.get('SECTION_LEVELS')['$has_key?'](line2.$chr()) : $e), $d !== false && $d !== nil ?line2['$=~']($scope.get('SetextSectionLineRx')) : $d), $c !== false && $c !== nil ?line1['$=~']($scope.get('SetextSectionTitleRx')) : $c), $b !== false && $b !== nil ?$rb_le(($rb_minus(self.$line_length(line1), self.$line_length(line2))).$abs(), 1) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$section_level(line2)
- } else {
- return false
- };
- });
-
- Opal.defs(self, '$parse_section_title', function(reader, document) {
- var $a, $b, $c, $d, $e, self = this, line1 = nil, sect_id = nil, sect_title = nil, sect_level = nil, sect_reftext = nil, single_line = nil, first_char = nil, match = nil, anchor_match = nil, line2 = nil, name_match = nil;
-
- line1 = reader.$read_line();
- sect_id = nil;
- sect_title = nil;
- sect_level = -1;
- sect_reftext = nil;
- single_line = true;
- first_char = line1.$chr();
- if ((($a = ($b = (((($c = first_char['$==']("=")) !== false && $c !== nil) ? $c : (($d = $scope.get('Compliance').$markdown_syntax(), $d !== false && $d !== nil ?first_char['$==']("#") : $d)))), $b !== false && $b !== nil ?(match = $scope.get('AtxSectionRx').$match(line1)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- sect_level = self.$single_line_section_level(match['$[]'](1));
- sect_title = match['$[]'](2);
- if ((($a = ($b = sect_title['$end_with?']("]]"), $b !== false && $b !== nil ?(anchor_match = $scope.get('InlineSectionAnchorRx').$match(sect_title)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = anchor_match['$[]'](2)['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- sect_title = anchor_match['$[]'](1);
- sect_id = anchor_match['$[]'](3);
- sect_reftext = anchor_match['$[]'](4);}};
- } else if ((($a = $scope.get('Compliance').$underline_style_section_titles()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = ($c = ($d = ($e = (line2 = reader.$peek_line(true)), $e !== false && $e !== nil ?$scope.get('SECTION_LEVELS')['$has_key?'](line2.$chr()) : $e), $d !== false && $d !== nil ?line2['$=~']($scope.get('SetextSectionLineRx')) : $d), $c !== false && $c !== nil ?(name_match = $scope.get('SetextSectionTitleRx').$match(line1)) : $c), $b !== false && $b !== nil ?$rb_le(($rb_minus(self.$line_length(line1), self.$line_length(line2))).$abs(), 1) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- sect_title = name_match['$[]'](1);
- if ((($a = ($b = sect_title['$end_with?']("]]"), $b !== false && $b !== nil ?(anchor_match = $scope.get('InlineSectionAnchorRx').$match(sect_title)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = anchor_match['$[]'](2)['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- sect_title = anchor_match['$[]'](1);
- sect_id = anchor_match['$[]'](3);
- sect_reftext = anchor_match['$[]'](4);}};
- sect_level = self.$section_level(line2);
- single_line = false;
- reader.$advance();}};
- if ($rb_ge(sect_level, 0)) {
- sect_level = $rb_plus(sect_level, document.$attr("leveloffset", 0).$to_i())};
- return [sect_id, sect_reftext, sect_title, sect_level, single_line];
- });
-
- Opal.defs(self, '$line_length', function(line) {
- var $a, self = this;
-
- if ((($a = $scope.get('FORCE_UNICODE_LINE_LENGTH')) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line.$scan($scope.get('UnicodeCharScanRx')).$length()
- } else {
- return line.$length()
- };
- });
-
- Opal.defs(self, '$parse_header_metadata', function(reader, document) {
- var $a, $b, TMP_15, $c, TMP_16, $d, self = this, metadata = nil, implicit_author = nil, implicit_authors = nil, author_metadata = nil, rev_metadata = nil, rev_line = nil, match = nil, component = nil, author_line = nil, authors = nil, author_key = nil;
-
- if (document == null) {
- document = nil
- }
- self.$process_attribute_entries(reader, document);
- metadata = $hash2([], {});
- implicit_author = nil;
- implicit_authors = nil;
- if ((($a = ($b = reader['$has_more_lines?'](), $b !== false && $b !== nil ?reader['$next_line_empty?']()['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata = self.$process_authors(reader.$read_line());
- if ((($a = author_metadata['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- if (document !== false && document !== nil) {
- ($a = ($b = author_metadata).$each, $a.$$p = (TMP_15 = function(key, val){var self = TMP_15.$$s || this, $a;
-if (key == null) key = nil;if (val == null) val = nil;
- if ((($a = document.$attributes()['$has_key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return document.$attributes()['$[]='](key, ((function() {if ((($a = (val['$is_a?'](Opal.get('String')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return document.$apply_header_subs(val)
- } else {
- return val
- }; return nil; })()))
- }}, TMP_15.$$s = self, TMP_15), $a).call($b);
- implicit_author = document.$attributes()['$[]']("author");
- implicit_authors = document.$attributes()['$[]']("authors");};
- metadata = author_metadata;
- };
- self.$process_attribute_entries(reader, document);
- rev_metadata = $hash2([], {});
- if ((($a = ($c = reader['$has_more_lines?'](), $c !== false && $c !== nil ?reader['$next_line_empty?']()['$!']() : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- rev_line = reader.$read_line();
- if ((($a = (match = $scope.get('RevisionInfoLineRx').$match(rev_line))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = match['$[]'](1)) !== nil && (!$a.$$is_boolean || $a == true))) {
- rev_metadata['$[]=']("revnumber", match['$[]'](1).$rstrip())};
- if (((component = match['$[]'](2).$strip()))['$==']("")) {
- } else if ((($a = ($c = match['$[]'](1)['$!'](), $c !== false && $c !== nil ?(component['$start_with?']("v")) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- rev_metadata['$[]=']("revnumber", component['$[]']($range(1, -1, false)))
- } else {
- rev_metadata['$[]=']("revdate", component)
- };
- if ((($a = match['$[]'](3)) !== nil && (!$a.$$is_boolean || $a == true))) {
- rev_metadata['$[]=']("revremark", match['$[]'](3).$rstrip())};
- } else {
- reader.$unshift_line(rev_line)
- };};
- if ((($a = rev_metadata['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- if (document !== false && document !== nil) {
- ($a = ($c = rev_metadata).$each, $a.$$p = (TMP_16 = function(key, val){var self = TMP_16.$$s || this, $a;
-if (key == null) key = nil;if (val == null) val = nil;
- if ((($a = document.$attributes()['$has_key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return document.$attributes()['$[]='](key, document.$apply_header_subs(val))
- }}, TMP_16.$$s = self, TMP_16), $a).call($c)};
- metadata.$update(rev_metadata);
- };
- self.$process_attribute_entries(reader, document);
- reader.$skip_blank_lines();};
- if (document !== false && document !== nil) {
- author_metadata = nil;
- if ((($a = ($d = document.$attributes()['$has_key?']("author"), $d !== false && $d !== nil ?((author_line = document.$attributes()['$[]']("author")))['$!='](implicit_author) : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata = self.$process_authors(author_line, true, false)
- } else if ((($a = ($d = document.$attributes()['$has_key?']("authors"), $d !== false && $d !== nil ?((author_line = document.$attributes()['$[]']("authors")))['$!='](implicit_authors) : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata = self.$process_authors(author_line, true)
- } else {
- authors = [];
- author_key = "author_" + ($rb_plus(authors.$size(), 1));
- while ((($d = document.$attributes()['$has_key?'](author_key)) !== nil && (!$d.$$is_boolean || $d == true))) {
- authors['$<<'](document.$attributes()['$[]'](author_key));
- author_key = "author_" + ($rb_plus(authors.$size(), 1));};
- if (authors.$size()['$=='](1)) {
- author_metadata = self.$process_authors(authors['$[]'](0), true, false)
- } else if ($rb_gt(authors.$size(), 1)) {
- author_metadata = self.$process_authors(authors.$join("; "), true)};
- };
- if (author_metadata !== false && author_metadata !== nil) {
- document.$attributes().$update(author_metadata);
- if ((($a = ($d = document.$attributes()['$has_key?']("email")['$!'](), $d !== false && $d !== nil ?document.$attributes()['$has_key?']("email_1") : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- document.$attributes()['$[]=']("email", document.$attributes()['$[]']("email_1"))};};};
- return metadata;
- });
-
- Opal.defs(self, '$process_authors', function(author_line, names_only, multiple) {
- var $a, $b, TMP_17, $c, TMP_18, self = this, author_metadata = nil, keys = nil, author_entries = nil;
-
- if (names_only == null) {
- names_only = false
- }
- if (multiple == null) {
- multiple = true
- }
- author_metadata = $hash2([], {});
- keys = ["author", "authorinitials", "firstname", "middlename", "lastname", "email"];
- author_entries = (function() {if (multiple !== false && multiple !== nil) {
- return ($a = ($b = (author_line.$split(";"))).$map, $a.$$p = (TMP_17 = function(line){var self = TMP_17.$$s || this;
-if (line == null) line = nil;
- return line.$strip()}, TMP_17.$$s = self, TMP_17), $a).call($b)
- } else {
- return [author_line]
- }; return nil; })();
- ($a = ($c = author_entries).$each_with_index, $a.$$p = (TMP_18 = function(author_entry, idx){var self = TMP_18.$$s || this, $a, $b, TMP_19, $c, TMP_20, $d, TMP_21, key_map = nil, segments = nil, match = nil, fname = nil, mname = nil, lname = nil;
-if (author_entry == null) author_entry = nil;if (idx == null) idx = nil;
- if ((($a = author_entry['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil;};
- key_map = $hash2([], {});
- if ((($a = idx['$zero?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = keys).$each, $a.$$p = (TMP_19 = function(key){var self = TMP_19.$$s || this;
-if (key == null) key = nil;
- return key_map['$[]='](key.$to_sym(), key)}, TMP_19.$$s = self, TMP_19), $a).call($b)
- } else {
- ($a = ($c = keys).$each, $a.$$p = (TMP_20 = function(key){var self = TMP_20.$$s || this;
-if (key == null) key = nil;
- return key_map['$[]='](key.$to_sym(), "" + (key) + "_" + ($rb_plus(idx, 1)))}, TMP_20.$$s = self, TMP_20), $a).call($c)
- };
- segments = nil;
- if (names_only !== false && names_only !== nil) {
- if ($rb_gt(((segments = author_entry.$split(" "))).$size(), 3)) {
- segments = segments['$[]']($range(0, 1, false)).$push(segments['$[]']($range(2, -1, false)).$join(" "))}
- } else if ((($a = (match = $scope.get('AuthorInfoLineRx').$match(author_entry))) !== nil && (!$a.$$is_boolean || $a == true))) {
- segments = match.$to_a();
- segments.$shift();};
- if ((($a = segments['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata['$[]='](key_map['$[]']("author"), author_metadata['$[]='](key_map['$[]']("firstname"), fname = author_entry.$strip().$tr_s(" ", " ")));
- author_metadata['$[]='](key_map['$[]']("authorinitials"), fname['$[]'](0, 1));
- } else {
- author_metadata['$[]='](key_map['$[]']("firstname"), fname = segments['$[]'](0).$tr("_", " "));
- author_metadata['$[]='](key_map['$[]']("author"), fname);
- author_metadata['$[]='](key_map['$[]']("authorinitials"), fname['$[]'](0, 1));
- if ((($a = ($d = segments['$[]'](1)['$nil?']()['$!'](), $d !== false && $d !== nil ?segments['$[]'](2)['$nil?']()['$!']() : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata['$[]='](key_map['$[]']("middlename"), mname = segments['$[]'](1).$tr("_", " "));
- author_metadata['$[]='](key_map['$[]']("lastname"), lname = segments['$[]'](2).$tr("_", " "));
- author_metadata['$[]='](key_map['$[]']("author"), [fname, mname, lname].$join(" "));
- author_metadata['$[]='](key_map['$[]']("authorinitials"), [fname['$[]'](0, 1), mname['$[]'](0, 1), lname['$[]'](0, 1)].$join());
- } else if ((($a = segments['$[]'](1)['$nil?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- author_metadata['$[]='](key_map['$[]']("lastname"), lname = segments['$[]'](1).$tr("_", " "));
- author_metadata['$[]='](key_map['$[]']("author"), [fname, lname].$join(" "));
- author_metadata['$[]='](key_map['$[]']("authorinitials"), [fname['$[]'](0, 1), lname['$[]'](0, 1)].$join());};
- if ((($a = ((($d = names_only) !== false && $d !== nil) ? $d : segments['$[]'](3)['$nil?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- author_metadata['$[]='](key_map['$[]']("email"), segments['$[]'](3))
- };
- };
- author_metadata['$[]=']("authorcount", $rb_plus(idx, 1));
- if (idx['$=='](1)) {
- ($a = ($d = keys).$each, $a.$$p = (TMP_21 = function(key){var self = TMP_21.$$s || this, $a;
-if (key == null) key = nil;
- if ((($a = author_metadata['$has_key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return author_metadata['$[]=']("" + (key) + "_1", author_metadata['$[]'](key))
- } else {
- return nil
- }}, TMP_21.$$s = self, TMP_21), $a).call($d)};
- if ((($a = idx['$zero?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return author_metadata['$[]=']("authors", author_metadata['$[]'](key_map['$[]']("author")))
- } else {
- return author_metadata['$[]=']("authors", "" + (author_metadata['$[]']("authors")) + ", " + (author_metadata['$[]'](key_map['$[]']("author"))))
- };}, TMP_18.$$s = self, TMP_18), $a).call($c);
- return author_metadata;
- });
-
- Opal.defs(self, '$parse_block_metadata_lines', function(reader, parent, attributes, options) {
- var $a, $b, self = this;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- if (options == null) {
- options = $hash2([], {})
- }
- while ((($b = self.$parse_block_metadata_line(reader, parent, attributes, options)) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$advance();
- reader.$skip_blank_lines();};
- return attributes;
- });
-
- Opal.defs(self, '$parse_block_metadata_line', function(reader, parent, attributes, options) {
- var $a, $b, $c, self = this, next_line = nil, commentish = nil, match = nil, terminator = nil, in_square_brackets = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- if ((($a = reader['$has_more_lines?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return false
- };
- next_line = reader.$peek_line();
- if ((($a = ($b = (commentish = next_line['$start_with?']("//")), $b !== false && $b !== nil ?(match = $scope.get('CommentBlockRx').$match(next_line)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- terminator = match['$[]'](0);
- reader.$read_lines_until($hash2(["skip_first_line", "preserve_last_line", "terminator", "skip_processing"], {"skip_first_line": true, "preserve_last_line": true, "terminator": terminator, "skip_processing": true}));
- } else if ((($a = (($b = commentish !== false && commentish !== nil) ? $scope.get('CommentLineRx')['$=~'](next_line) : commentish)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if ((($a = ($b = ($c = options['$[]']("text")['$!'](), $c !== false && $c !== nil ?next_line['$start_with?'](":") : $c), $b !== false && $b !== nil ?(match = $scope.get('AttributeEntryRx').$match(next_line)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$process_attribute_entry(reader, parent, attributes, match)
- } else if ((($a = ($b = (in_square_brackets = ($c = next_line['$start_with?']("["), $c !== false && $c !== nil ?next_line['$end_with?']("]") : $c)), $b !== false && $b !== nil ?(match = $scope.get('BlockAnchorRx').$match(next_line)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = match['$[]'](1)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attributes['$[]=']("id", match['$[]'](1));
- if ((($a = match['$[]'](2)['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- attributes['$[]=']("reftext", match['$[]'](2))
- };
- }
- } else if ((($a = (($b = in_square_brackets !== false && in_square_brackets !== nil) ? (match = $scope.get('BlockAttributeListRx').$match(next_line)) : in_square_brackets)) !== nil && (!$a.$$is_boolean || $a == true))) {
- parent.$document().$parse_attributes(match['$[]'](1), [], $hash2(["sub_input", "into"], {"sub_input": true, "into": attributes}))
- } else if ((($a = ($b = options['$[]']("text")['$!'](), $b !== false && $b !== nil ?(match = $scope.get('BlockTitleRx').$match(next_line)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes['$[]=']("title", match['$[]'](1))
- } else {
- return false
- };
- return true;
- });
-
- Opal.defs(self, '$process_attribute_entries', function(reader, parent, attributes) {
- var $a, $b, self = this;
-
- if (attributes == null) {
- attributes = nil
- }
- reader.$skip_comment_lines();
- while ((($b = self.$process_attribute_entry(reader, parent, attributes)) !== nil && (!$b.$$is_boolean || $b == true))) {
- reader.$advance();
- reader.$skip_comment_lines();};
- });
-
- Opal.defs(self, '$process_attribute_entry', function(reader, parent, attributes, match) {
- var $a, $b, self = this, name = nil, value = nil, line_continuation = nil, next_line = nil, keep_open = nil, separator = nil;
-
- if (attributes == null) {
- attributes = nil
- }
- if (match == null) {
- match = nil
- }
- ((($a = match) !== false && $a !== nil) ? $a : match = ((function() {if ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- return $scope.get('AttributeEntryRx').$match(reader.$peek_line())
- } else {
- return nil
- }; return nil; })()));
- if (match !== false && match !== nil) {
- name = match['$[]'](1);
- if ((($a = ((value = ((($b = match['$[]'](2)) !== false && $b !== nil) ? $b : "")))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if ((($a = ((($b = value['$end_with?'](line_continuation = $scope.get('LINE_CONTINUATION'))) !== false && $b !== nil) ? $b : value['$end_with?'](line_continuation = $scope.get('LINE_CONTINUATION_LEGACY')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- value = value.$chop().$rstrip();
- while ((($b = reader.$advance()) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = ((next_line = reader.$peek_line().$strip()))['$empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- break;};
- if ((($b = (keep_open = next_line['$end_with?'](line_continuation))) !== nil && (!$b.$$is_boolean || $b == true))) {
- next_line = next_line.$chop().$rstrip()};
- separator = (function() {if ((($b = (value['$end_with?']($scope.get('LINE_BREAK')))) !== nil && (!$b.$$is_boolean || $b == true))) {
- return $scope.get('EOL')
- } else {
- return " "
- }; return nil; })();
- value = "" + (value) + (separator) + (next_line);
- if (keep_open !== false && keep_open !== nil) {
- } else {
- break;
- };};};
- self.$store_attribute(name, value, ((function() {if (parent !== false && parent !== nil) {
- return parent.$document()
- } else {
- return nil
- }; return nil; })()), attributes);
- return true;
- } else {
- return false
- };
- });
-
- Opal.defs(self, '$store_attribute', function(name, value, doc, attrs) {
- var $a, $b, self = this, accessible = nil, $case = nil;
-
- if (doc == null) {
- doc = nil
- }
- if (attrs == null) {
- attrs = nil
- }
- if ((($a = name['$end_with?']("!")) !== nil && (!$a.$$is_boolean || $a == true))) {
- value = nil;
- name = name.$chop();
- } else if ((($a = name['$start_with?']("!")) !== nil && (!$a.$$is_boolean || $a == true))) {
- value = nil;
- name = name['$[]']($range(1, -1, false));};
- name = self.$sanitize_attribute_name(name);
- accessible = true;
- if (doc !== false && doc !== nil) {
- if (name['$==']("numbered")) {
- name = "sectnums"
- } else if (name['$==']("leveloffset")) {
- if (value !== false && value !== nil) {
- $case = value.$chr();if ("+"['$===']($case)) {value = ($rb_plus((doc.$attr("leveloffset", 0)).$to_i(), (((($a = value['$[]']($range(1, -1, false))) !== false && $a !== nil) ? $a : 0)).$to_i())).$to_s()}else if ("-"['$===']($case)) {value = ($rb_minus((doc.$attr("leveloffset", 0)).$to_i(), (((($a = value['$[]']($range(1, -1, false))) !== false && $a !== nil) ? $a : 0)).$to_i())).$to_s()}}};
- accessible = (function() {if (value !== false && value !== nil) {
- return doc.$set_attribute(name, value)
- } else {
- return doc.$delete_attribute(name)
- }; return nil; })();};
- if ((($a = (($b = accessible !== false && accessible !== nil) ? attrs : accessible)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (value !== false && value !== nil) {
- value = doc.$attributes()['$[]'](name)};
- (($scope.get('Document')).$$scope.get('AttributeEntry')).$new(name, value).$save_to(attrs);};
- return [name, value];
- });
-
- Opal.defs(self, '$resolve_list_marker', function(list_type, marker, ordinal, validate, reader) {
- var $a, $b, self = this;
-
- if (ordinal == null) {
- ordinal = 0
- }
- if (validate == null) {
- validate = false
- }
- if (reader == null) {
- reader = nil
- }
- if ((($a = (($b = list_type['$==']("olist")) ? marker['$start_with?'](".")['$!']() : list_type['$==']("olist"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$resolve_ordered_list_marker(marker, ordinal, validate, reader)
- } else if (list_type['$==']("colist")) {
- return "<1>"
- } else {
- return marker
- };
- });
-
- Opal.defs(self, '$resolve_ordered_list_marker', function(marker, ordinal, validate, reader) {
- var $a, $b, TMP_22, $c, self = this, number_style = nil, expected = nil, actual = nil, $case = nil;
-
- if (ordinal == null) {
- ordinal = 0
- }
- if (validate == null) {
- validate = false
- }
- if (reader == null) {
- reader = nil
- }
- number_style = ($a = ($b = $scope.get('ORDERED_LIST_STYLES')).$detect, $a.$$p = (TMP_22 = function(s){var self = TMP_22.$$s || this;
-if (s == null) s = nil;
- return $scope.get('OrderedListMarkerRxMap')['$[]'](s)['$=~'](marker)}, TMP_22.$$s = self, TMP_22), $a).call($b);
- expected = actual = nil;
- $case = number_style;if ("arabic"['$===']($case)) {if (validate !== false && validate !== nil) {
- expected = $rb_plus(ordinal, 1);
- actual = marker.$to_i();};
- marker = "1.";}else if ("loweralpha"['$===']($case)) {if (validate !== false && validate !== nil) {
- expected = ($rb_plus("a"['$[]'](0).$ord(), ordinal)).$chr();
- actual = marker.$chomp(".");};
- marker = "a.";}else if ("upperalpha"['$===']($case)) {if (validate !== false && validate !== nil) {
- expected = ($rb_plus("A"['$[]'](0).$ord(), ordinal)).$chr();
- actual = marker.$chomp(".");};
- marker = "A.";}else if ("lowerroman"['$===']($case)) {if (validate !== false && validate !== nil) {
- expected = $rb_plus(ordinal, 1);
- actual = self.$roman_numeral_to_int(marker.$chomp(")"));};
- marker = "i)";}else if ("upperroman"['$===']($case)) {if (validate !== false && validate !== nil) {
- expected = $rb_plus(ordinal, 1);
- actual = self.$roman_numeral_to_int(marker.$chomp(")"));};
- marker = "I)";};
- if ((($a = (($c = validate !== false && validate !== nil) ? expected['$!='](actual) : validate)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: " + (reader.$line_info()) + ": list item index: expected " + (expected) + ", got " + (actual))};
- return marker;
- });
-
- Opal.defs(self, '$is_sibling_list_item?', function(line, list_type, sibling_trait) {
- var $a, self = this, matcher = nil, expected_marker = nil, m = nil;
-
- if ((($a = sibling_trait['$is_a?'](Opal.get('Regexp'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- matcher = sibling_trait;
- expected_marker = false;
- } else {
- matcher = $scope.get('ListRxMap')['$[]'](list_type);
- expected_marker = sibling_trait;
- };
- if ((($a = (m = matcher.$match(line))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (expected_marker !== false && expected_marker !== nil) {
- return expected_marker['$=='](self.$resolve_list_marker(list_type, m['$[]'](1)))
- } else {
- return true
- }
- } else {
- return false
- };
- });
-
- Opal.defs(self, '$next_table', function(table_reader, parent, attributes) {
- var $a, $b, $c, $d, $e, $f, self = this, table = nil, col_specs = nil, explicit_col_specs = nil, skipped = nil, parser_ctx = nil, loop_idx = nil, line = nil, next_line = nil, next_cell_spec = nil, seen = nil, m = nil, cell_text = nil;
-
- table = $scope.get('Table').$new(parent, attributes);
- if ((($a = (attributes['$has_key?']("title"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [attributes.$delete("title")]), $b = table, $b['$title='].apply($b, $a), $a[$a.length-1]);
- table.$assign_caption(attributes.$delete("caption"));};
- if ((($a = ($b = (attributes['$key?']("cols")), $b !== false && $b !== nil ?((col_specs = self.$parse_col_specs(attributes['$[]']("cols"))))['$empty?']()['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- table.$create_columns(col_specs);
- explicit_col_specs = true;
- } else {
- explicit_col_specs = false
- };
- skipped = table_reader.$skip_blank_lines();
- parser_ctx = (($scope.get('Table')).$$scope.get('ParserContext')).$new(table_reader, table, attributes);
- loop_idx = -1;
- while ((($b = table_reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- loop_idx = $rb_plus(loop_idx, 1);
- line = table_reader.$read_line();
- if ((($b = ($c = ($d = ($e = (($f = skipped['$=='](0)) ? loop_idx['$zero?']() : skipped['$=='](0)), $e !== false && $e !== nil ?attributes['$has_key?']("options")['$!']() : $e), $d !== false && $d !== nil ?((next_line = table_reader.$peek_line()))['$nil?']()['$!']() : $d), $c !== false && $c !== nil ?next_line['$empty?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- (($b = [true]), $c = table, $c['$has_header_option='].apply($c, $b), $b[$b.length-1]);
- table.$set_option("header");};
- if (parser_ctx.$format()['$==']("psv")) {
- if ((($b = parser_ctx['$starts_with_delimiter?'](line)) !== nil && (!$b.$$is_boolean || $b == true))) {
- line = line['$[]']($range(1, -1, false));
- parser_ctx.$close_open_cell();
- } else {
- $b = Opal.to_ary(self.$parse_cell_spec(line, "start", parser_ctx.$delimiter())), next_cell_spec = ($b[0] == null ? nil : $b[0]), line = ($b[1] == null ? nil : $b[1]);
- if ((($b = next_cell_spec['$nil?']()['$!']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- parser_ctx.$close_open_cell(next_cell_spec)};
- }};
- seen = false;
- while ((($c = ((($d = seen['$!']()) !== false && $d !== nil) ? $d : line['$empty?']()['$!']())) !== nil && (!$c.$$is_boolean || $c == true))) {
- seen = true;
- if ((($c = (m = parser_ctx.$match_delimiter(line))) !== nil && (!$c.$$is_boolean || $c == true))) {
- if (parser_ctx.$format()['$==']("csv")) {
- if ((($c = parser_ctx['$buffer_has_unclosed_quotes?'](m.$pre_match())) !== nil && (!$c.$$is_boolean || $c == true))) {
- line = parser_ctx.$skip_matched_delimiter(m);
- continue;;}
- } else if ((($c = m.$pre_match()['$end_with?']("\\")) !== nil && (!$c.$$is_boolean || $c == true))) {
- if ((($c = ((line = parser_ctx.$skip_matched_delimiter(m, true)))['$empty?']()) !== nil && (!$c.$$is_boolean || $c == true))) {
- (($c = ["" + (parser_ctx.$buffer()) + ($scope.get('EOL'))]), $d = parser_ctx, $d['$buffer='].apply($d, $c), $c[$c.length-1]);
- parser_ctx.$keep_cell_open();
- break;;};
- continue;;};
- if (parser_ctx.$format()['$==']("psv")) {
- $c = Opal.to_ary(self.$parse_cell_spec(m.$pre_match(), "end")), next_cell_spec = ($c[0] == null ? nil : $c[0]), cell_text = ($c[1] == null ? nil : $c[1]);
- parser_ctx.$push_cell_spec(next_cell_spec);
- (($c = ["" + (parser_ctx.$buffer()) + (cell_text)]), $d = parser_ctx, $d['$buffer='].apply($d, $c), $c[$c.length-1]);
- } else {
- (($c = ["" + (parser_ctx.$buffer()) + (m.$pre_match())]), $d = parser_ctx, $d['$buffer='].apply($d, $c), $c[$c.length-1])
- };
- if (((line = m.$post_match()))['$==']("")) {
- seen = false};
- parser_ctx.$close_cell();
- } else {
- (($c = ["" + (parser_ctx.$buffer()) + (line) + ($scope.get('EOL'))]), $d = parser_ctx, $d['$buffer='].apply($d, $c), $c[$c.length-1]);
- if (parser_ctx.$format()['$==']("csv")) {
- (($c = ["" + (parser_ctx.$buffer().$rstrip()) + " "]), $d = parser_ctx, $d['$buffer='].apply($d, $c), $c[$c.length-1])};
- line = "";
- if ((($c = ((($d = parser_ctx.$format()['$==']("psv")) !== false && $d !== nil) ? $d : ((($e = parser_ctx.$format()['$==']("csv")) ? parser_ctx['$buffer_has_unclosed_quotes?']() : parser_ctx.$format()['$==']("csv"))))) !== nil && (!$c.$$is_boolean || $c == true))) {
- parser_ctx.$keep_cell_open()
- } else {
- parser_ctx.$close_cell(true)
- };
- };};
- if ((($b = parser_ctx['$cell_open?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else {
- skipped = table_reader.$skip_blank_lines()
- };
- if ((($b = table_reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else if ((($b = parser_ctx['$cell_open?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- parser_ctx.$close_cell(true)};};
- if ((($a = ((($b = (($c = "colcount", $d = table.$attributes(), ((($e = $d['$[]']($c)) !== false && $e !== nil) ? $e : $d['$[]=']($c, table.$columns().$size()))))['$=='](0)) !== false && $b !== nil) ? $b : explicit_col_specs)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- table.$assign_col_widths()
- };
- table.$partition_header_footer(attributes);
- return table;
- });
-
- Opal.defs(self, '$parse_col_specs', function(records) {
- var $a, $b, TMP_23, $c, TMP_24, self = this, specs = nil;
-
- if ((($a = records['$include?'](" ")) !== nil && (!$a.$$is_boolean || $a == true))) {
- records = records.$tr(" ", "")};
- if (records['$=='](records.$to_i().$to_s())) {
- return ($a = ($b = Opal.get('Array')).$new, $a.$$p = (TMP_23 = function(){var self = TMP_23.$$s || this;
-
- return $hash2(["width"], {"width": 1})}, TMP_23.$$s = self, TMP_23), $a).call($b, records.$to_i())};
- specs = [];
- ($a = ($c = records.$split(",", -1)).$each, $a.$$p = (TMP_24 = function(record){var self = TMP_24.$$s || this, $a, $b, TMP_25, m = nil, spec = nil, colspec = nil, rowspec = nil;
-if (record == null) record = nil;
- if (record['$==']("")) {
- return specs['$<<']($hash2(["width"], {"width": 1}))
- } else if ((($a = (m = $scope.get('ColumnSpecRx').$match(record))) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec = $hash2([], {});
- if ((($a = m['$[]'](2)) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(m['$[]'](2).$split(".")), colspec = ($a[0] == null ? nil : $a[0]), rowspec = ($a[1] == null ? nil : $a[1]);
- if ((($a = ($b = colspec['$nil_or_empty?']()['$!'](), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("h")['$has_key?'](colspec) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("halign", (($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("h")['$[]'](colspec))};
- if ((($a = ($b = rowspec['$nil_or_empty?']()['$!'](), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("v")['$has_key?'](rowspec) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("valign", (($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("v")['$[]'](rowspec))};};
- spec['$[]=']("width", ((function() {if ((($a = m['$[]'](3)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return m['$[]'](3).$to_i()
- } else {
- return 1
- }; return nil; })()));
- if ((($a = ($b = m['$[]'](4), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('TEXT_STYLES'))['$has_key?'](m['$[]'](4)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("style", (($scope.get('Table')).$$scope.get('TEXT_STYLES'))['$[]'](m['$[]'](4)))};
- if ((($a = m['$[]'](1)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = ($b = (1)).$upto, $a.$$p = (TMP_25 = function(){var self = TMP_25.$$s || this;
-
- return specs['$<<'](spec.$dup())}, TMP_25.$$s = self, TMP_25), $a).call($b, m['$[]'](1).$to_i())
- } else {
- return specs['$<<'](spec)
- };
- } else {
- return nil
- }}, TMP_24.$$s = self, TMP_24), $a).call($c);
- return specs;
- });
-
- Opal.defs(self, '$parse_cell_spec', function(line, pos, delimiter) {
- var $a, $b, self = this, m = nil, rest = nil, $case = nil, spec_part = nil, spec = nil, colspec = nil, rowspec = nil;
-
- if (pos == null) {
- pos = "start"
- }
- if (delimiter == null) {
- delimiter = nil
- }
- m = nil;
- rest = "";
- $case = pos;if ("start"['$===']($case)) {if ((($a = line['$include?'](delimiter)) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(line.$split(delimiter, 2)), spec_part = ($a[0] == null ? nil : $a[0]), rest = ($a[1] == null ? nil : $a[1]);
- if ((($a = (m = $scope.get('CellSpecStartRx').$match(spec_part))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = m['$[]'](0)['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return [$hash2([], {}), rest]}
- } else {
- return [nil, line]
- };
- } else {
- return [nil, line]
- }}else if ("end"['$===']($case)) {if ((($a = (m = $scope.get('CellSpecEndRx').$match(line))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = m['$[]'](0).$lstrip()['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return [$hash2([], {}), line.$rstrip()]};
- rest = m.$pre_match();
- } else {
- return [$hash2([], {}), line]
- }};
- spec = $hash2([], {});
- if ((($a = m['$[]'](1)) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(m['$[]'](1).$split(".")), colspec = ($a[0] == null ? nil : $a[0]), rowspec = ($a[1] == null ? nil : $a[1]);
- colspec = (function() {if ((($a = colspec['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return 1
- } else {
- return colspec.$to_i()
- }; return nil; })();
- rowspec = (function() {if ((($a = rowspec['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return 1
- } else {
- return rowspec.$to_i()
- }; return nil; })();
- if (m['$[]'](2)['$==']("+")) {
- if (colspec['$=='](1)) {
- } else {
- spec['$[]=']("colspan", colspec)
- };
- if (rowspec['$=='](1)) {
- } else {
- spec['$[]=']("rowspan", rowspec)
- };
- } else if (m['$[]'](2)['$==']("*")) {
- if (colspec['$=='](1)) {
- } else {
- spec['$[]=']("repeatcol", colspec)
- }};};
- if ((($a = m['$[]'](3)) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(m['$[]'](3).$split(".")), colspec = ($a[0] == null ? nil : $a[0]), rowspec = ($a[1] == null ? nil : $a[1]);
- if ((($a = ($b = colspec['$nil_or_empty?']()['$!'](), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("h")['$has_key?'](colspec) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("halign", (($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("h")['$[]'](colspec))};
- if ((($a = ($b = rowspec['$nil_or_empty?']()['$!'](), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("v")['$has_key?'](rowspec) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("valign", (($scope.get('Table')).$$scope.get('ALIGNMENTS'))['$[]']("v")['$[]'](rowspec))};};
- if ((($a = ($b = m['$[]'](4), $b !== false && $b !== nil ?(($scope.get('Table')).$$scope.get('TEXT_STYLES'))['$has_key?'](m['$[]'](4)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- spec['$[]=']("style", (($scope.get('Table')).$$scope.get('TEXT_STYLES'))['$[]'](m['$[]'](4)))};
- return [spec, rest];
- });
-
- Opal.defs(self, '$parse_style_attribute', function(attributes, reader) {
- var $a, $b, $c, TMP_26, TMP_27, $d, TMP_28, self = this, original_style = nil, raw_style = nil, type = nil, collector = nil, parsed = nil, save_current = nil, parsed_style = nil, options = nil, existing_opts = nil;
-
- if (reader == null) {
- reader = nil
- }
- original_style = attributes['$[]']("style");
- raw_style = attributes['$[]'](1);
- if ((($a = ($b = (($c = raw_style !== false && raw_style !== nil) ? raw_style['$include?'](" ")['$!']() : raw_style), $b !== false && $b !== nil ?$scope.get('Compliance').$shorthand_property_syntax() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- type = "style";
- collector = [];
- parsed = $hash2([], {});
- save_current = ($a = ($b = self).$lambda, $a.$$p = (TMP_26 = function(){var self = TMP_26.$$s || this, $a, $b, $c, $case = nil;
-
- if ((($a = collector['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = type['$!=']("style")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$warn("asciidoctor: WARNING:" + ((function() {if ((($a = reader['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " " + (reader.$prev_line_info()) + ":"
- }; return nil; })()) + " invalid empty " + (type) + " detected in style attribute")
- } else {
- return nil
- }
- } else {
- $case = type;if ("role"['$===']($case) || "option"['$===']($case)) {($a = type, $b = parsed, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, [])));
- parsed['$[]'](type).$push(collector.$join());}else if ("id"['$===']($case)) {if ((($a = parsed['$has_key?']("id")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING:" + ((function() {if ((($a = reader['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return " " + (reader.$prev_line_info()) + ":"
- }; return nil; })()) + " multiple ids detected in style attribute")};
- parsed['$[]='](type, collector.$join());}else {parsed['$[]='](type, collector.$join())};
- return collector = [];
- }}, TMP_26.$$s = self, TMP_26), $a).call($b);
- ($a = ($c = raw_style).$each_char, $a.$$p = (TMP_27 = function(c){var self = TMP_27.$$s || this, $a, $b, $c, $case = nil;
-if (c == null) c = nil;
- if ((($a = ((($b = ((($c = c['$=='](".")) !== false && $c !== nil) ? $c : c['$==']("#"))) !== false && $b !== nil) ? $b : c['$==']("%"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- save_current.$call();
- return (function() {$case = c;if ("."['$===']($case)) {return type = "role"}else if ("#"['$===']($case)) {return type = "id"}else if ("%"['$===']($case)) {return type = "option"}else { return nil }})();
- } else {
- return collector.$push(c)
- }}, TMP_27.$$s = self, TMP_27), $a).call($c);
- if (type['$==']("style")) {
- parsed_style = attributes['$[]=']("style", raw_style)
- } else {
- save_current.$call();
- if ((($a = parsed['$has_key?']("style")) !== nil && (!$a.$$is_boolean || $a == true))) {
- parsed_style = attributes['$[]=']("style", parsed['$[]']("style"))
- } else {
- parsed_style = nil
- };
- if ((($a = parsed['$has_key?']("id")) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes['$[]=']("id", parsed['$[]']("id"))};
- if ((($a = parsed['$has_key?']("role")) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes['$[]=']("role", $rb_times(parsed['$[]']("role"), " "))};
- if ((($a = parsed['$has_key?']("option")) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($d = ((options = parsed['$[]']("option")))).$each, $a.$$p = (TMP_28 = function(option){var self = TMP_28.$$s || this;
-if (option == null) option = nil;
- return attributes['$[]=']("" + (option) + "-option", "")}, TMP_28.$$s = self, TMP_28), $a).call($d);
- if ((($a = (existing_opts = attributes['$[]']("options"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes['$[]=']("options", $rb_times(($rb_plus(options, existing_opts.$split(","))), ","))
- } else {
- attributes['$[]=']("options", $rb_times(options, ","))
- };};
- };
- return [parsed_style, original_style];
- } else {
- attributes['$[]=']("style", raw_style);
- return [raw_style, original_style];
- };
- });
-
- Opal.defs(self, '$adjust_indentation!', function(lines, indent, tab_size) {
- var $a, $b, TMP_29, $c, TMP_32, $d, TMP_33, $e, TMP_34, $f, TMP_35, self = this, full_tab_space = nil, gutter_width = nil, padding = nil;
-
- if (indent == null) {
- indent = 0
- }
- if (tab_size == null) {
- tab_size = 0
- }
- if ((($a = lines['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil};
- if ((($a = (($b = $rb_gt((tab_size = tab_size.$to_i()), 0)) ? (lines.$join()['$include?']($scope.get('TAB'))) : $rb_gt((tab_size = tab_size.$to_i()), 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- full_tab_space = $rb_times(" ", tab_size);
- ($a = ($b = lines)['$map!'], $a.$$p = (TMP_29 = function(line){var self = TMP_29.$$s || this, $a, $b, TMP_30, $c, TMP_31, spaces_added = nil;
-if (line == null) line = nil;
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line;};
- if ((($a = line['$start_with?']($scope.get('TAB'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = ($b = line)['$sub!'], $a.$$p = (TMP_30 = function(tabs){var self = TMP_30.$$s || this;
-if (tabs == null) tabs = nil;
- return $rb_times(full_tab_space, tabs.$length())}, TMP_30.$$s = self, TMP_30), $a).call($b, $scope.get('TabIndentRx'))};
- if ((($a = line['$include?']($scope.get('TAB'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- spaces_added = 0;
- return ($a = ($c = line)['$gsub!'], $a.$$p = (TMP_31 = function(){var self = TMP_31.$$s || this, offset = nil, spaces = nil;
- if ($gvars["~"] == null) $gvars["~"] = nil;
-
- if (((offset = $rb_plus(($gvars["~"].$begin(0)), spaces_added)))['$%'](tab_size)['$=='](0)) {
- spaces_added = $rb_plus(spaces_added, ($rb_minus(tab_size, 1)));
- return full_tab_space;
- } else {
- if (((spaces = $rb_minus(tab_size, offset['$%'](tab_size))))['$=='](1)) {
- } else {
- spaces_added = $rb_plus(spaces_added, ($rb_minus(spaces, 1)))
- };
- return $rb_times(" ", spaces);
- }}, TMP_31.$$s = self, TMP_31), $a).call($c, $scope.get('TabRx'));
- } else {
- return line
- };}, TMP_29.$$s = self, TMP_29), $a).call($b);};
- if ((($a = (($c = indent !== false && indent !== nil) ? $rb_gt((indent = indent.$to_i()), -1) : indent)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return nil
- };
- gutter_width = nil;
- ($a = ($c = lines).$each, $a.$$p = (TMP_32 = function(line){var self = TMP_32.$$s || this, $a, $b, line_indent = nil;
-if (line == null) line = nil;
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil;};
- if (((line_indent = $rb_minus(line.$length(), line.$lstrip().$length())))['$=='](0)) {
- gutter_width = nil;
- return ($breaker.$v = nil, $breaker);
- } else if ((($a = (($b = gutter_width !== false && gutter_width !== nil) ? $rb_gt(line_indent, gutter_width) : gutter_width)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return gutter_width = line_indent
- };}, TMP_32.$$s = self, TMP_32), $a).call($c);
- if (indent['$=='](0)) {
- if (gutter_width !== false && gutter_width !== nil) {
- ($a = ($d = lines)['$map!'], $a.$$p = (TMP_33 = function(line){var self = TMP_33.$$s || this, $a;
-if (line == null) line = nil;
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line
- } else {
- return line['$[]']($range(gutter_width, -1, false))
- }}, TMP_33.$$s = self, TMP_33), $a).call($d)}
- } else {
- padding = $rb_times(" ", indent);
- if (gutter_width !== false && gutter_width !== nil) {
- ($a = ($e = lines)['$map!'], $a.$$p = (TMP_34 = function(line){var self = TMP_34.$$s || this, $a;
-if (line == null) line = nil;
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line
- } else {
- return $rb_plus(padding, line['$[]']($range(gutter_width, -1, false)))
- }}, TMP_34.$$s = self, TMP_34), $a).call($e)
- } else {
- ($a = ($f = lines)['$map!'], $a.$$p = (TMP_35 = function(line){var self = TMP_35.$$s || this, $a;
-if (line == null) line = nil;
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line
- } else {
- return $rb_plus(padding, line)
- }}, TMP_35.$$s = self, TMP_35), $a).call($f)
- };
- };
- return nil;
- });
-
- Opal.defs(self, '$sanitize_attribute_name', function(name) {
- var self = this;
-
- return name.$gsub($scope.get('InvalidAttributeNameCharsRx'), "").$downcase();
- });
-
- return (Opal.defs(self, '$roman_numeral_to_int', function(value) {
- var $a, $b, TMP_36, self = this, digits = nil, result = nil;
-
- value = value.$downcase();
- digits = $hash2(["i", "v", "x"], {"i": 1, "v": 5, "x": 10});
- result = 0;
- ($a = ($b = ($range(0, $rb_minus(value.$length(), 1), false))).$each, $a.$$p = (TMP_36 = function(i){var self = TMP_36.$$s || this, $a, $b, digit = nil;
-if (i == null) i = nil;
- digit = digits['$[]'](value['$[]']($range(i, i, false)));
- if ((($a = (($b = $rb_lt($rb_plus(i, 1), value.$length())) ? $rb_gt(digits['$[]'](value['$[]']($range($rb_plus(i, 1), $rb_plus(i, 1), false))), digit) : $rb_lt($rb_plus(i, 1), value.$length()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return result = $rb_minus(result, digit)
- } else {
- return result = $rb_plus(result, digit)
- };}, TMP_36.$$s = self, TMP_36), $a).call($b);
- return result;
- }), nil) && 'roman_numeral_to_int';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/path_resolver"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$attr_accessor', '$is_root?', '$expand_path', '$pwd', '$start_with?', '$==', '$=~', '$nil_or_empty?', '$include?', '$tr', '$partition_path', '$join_path', '$[]', '$posixfy', '$is_web_root?', '$is_unc?', '$index', '$split', '$shift', '$delete', '$[]=', '$*', '$raise', '$empty?', '$system_path', '$!=', '$!', '$dup', '$each', '$>', '$length', '$pop', '$fetch', '$warn', '$push', '$uri_prefix', '$<<', '$+', '$chomp']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $PathResolver(){};
- var self = $PathResolver = $klass($base, $super, 'PathResolver', $PathResolver);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.file_separator = def._partition_path_web = def._partition_path_sys = def.working_dir = nil;
- Opal.cdecl($scope, 'DOT', ".");
-
- Opal.cdecl($scope, 'DOT_DOT', "..");
-
- Opal.cdecl($scope, 'DOT_SLASH', "./");
-
- Opal.cdecl($scope, 'SLASH', "/");
-
- Opal.cdecl($scope, 'BACKSLASH', "\\");
-
- Opal.cdecl($scope, 'DOUBLE_SLASH', "//");
-
- Opal.cdecl($scope, 'WindowsRootRx', /^[a-zA-Z]:(?:\\|\/)/);
-
- self.$attr_accessor("file_separator");
-
- self.$attr_accessor("working_dir");
-
- Opal.defn(self, '$initialize', function(file_separator, working_dir) {
- var $a, self = this;
-
- if (file_separator == null) {
- file_separator = nil
- }
- if (working_dir == null) {
- working_dir = nil
- }
- self.file_separator = (function() {if (file_separator !== false && file_separator !== nil) {
- return file_separator
- } else {
- return (((($a = ((Opal.get('File')).$$scope.get('ALT_SEPARATOR'))) !== false && $a !== nil) ? $a : ((Opal.get('File')).$$scope.get('SEPARATOR'))))
- }; return nil; })();
- if (working_dir !== false && working_dir !== nil) {
- self.working_dir = (function() {if ((($a = (self['$is_root?'](working_dir))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return working_dir
- } else {
- return (Opal.get('File').$expand_path(working_dir))
- }; return nil; })()
- } else {
- self.working_dir = Opal.get('File').$expand_path(Opal.get('Dir').$pwd())
- };
- self._partition_path_sys = $hash2([], {});
- return self._partition_path_web = $hash2([], {});
- });
-
- Opal.defn(self, '$is_root?', function(path) {
- var $a, $b, $c, self = this;
-
- if ((($a = path['$start_with?']($scope.get('SLASH'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return true
- } else if ((($a = (($b = self.file_separator['$==']($scope.get('BACKSLASH'))) ? $scope.get('WindowsRootRx')['$=~'](path) : self.file_separator['$==']($scope.get('BACKSLASH')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return true
- } else if ((($a = ($b = ($c = Opal.get('RUBY_ENGINE_OPAL'), $c !== false && $c !== nil ?Opal.get('JAVASCRIPT_PLATFORM')['$==']("browser") : $c), $b !== false && $b !== nil ?(path['$start_with?']("file:///")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return true
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$is_unc?', function(path) {
- var self = this;
-
- return path['$start_with?']($scope.get('DOUBLE_SLASH'));
- });
-
- Opal.defn(self, '$is_web_root?', function(path) {
- var self = this;
-
- return path['$start_with?']($scope.get('SLASH'));
- });
-
- Opal.defn(self, '$posixfy', function(path) {
- var $a, self = this;
-
- if ((($a = path['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ""
- } else if ((($a = path['$include?']($scope.get('BACKSLASH'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return path.$tr($scope.get('BACKSLASH'), $scope.get('SLASH'))
- } else {
- return path
- };
- });
-
- Opal.defn(self, '$expand_path', function(path) {
- var $a, self = this, path_segments = nil, path_root = nil, _ = nil;
-
- $a = Opal.to_ary(self.$partition_path(path)), path_segments = ($a[0] == null ? nil : $a[0]), path_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- return self.$join_path(path_segments, path_root);
- });
-
- Opal.defn(self, '$partition_path', function(path, web_path) {
- var $a, self = this, result = nil, posix_path = nil, root = nil, path_segments = nil;
-
- if (web_path == null) {
- web_path = false
- }
- if ((($a = (result = (function() {if (web_path !== false && web_path !== nil) {
- return self._partition_path_web['$[]'](path)
- } else {
- return self._partition_path_sys['$[]'](path)
- }; return nil; })())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return result};
- posix_path = self.$posixfy(path);
- root = (function() {if (web_path !== false && web_path !== nil) {
- if ((($a = self['$is_web_root?'](posix_path)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('SLASH')
- } else if ((($a = posix_path['$start_with?']($scope.get('DOT_SLASH'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('DOT_SLASH')
- } else {
- return nil
- }
- } else if ((($a = self['$is_root?'](posix_path)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self['$is_unc?'](posix_path)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('DOUBLE_SLASH')
- } else if ((($a = posix_path['$start_with?']($scope.get('SLASH'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('SLASH')
- } else {
- return posix_path['$[]']($range(0, (posix_path.$index($scope.get('SLASH'))), false))
- }
- } else if ((($a = posix_path['$start_with?']($scope.get('DOT_SLASH'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('DOT_SLASH')
- } else {
- return nil
- }; return nil; })();
- path_segments = posix_path.$split($scope.get('SLASH'));
- if (root['$==']($scope.get('DOUBLE_SLASH'))) {
- path_segments = path_segments['$[]']($range(2, -1, false))
- } else if (root !== false && root !== nil) {
- path_segments.$shift()};
- path_segments.$delete($scope.get('DOT'));
- return ((function() {if (web_path !== false && web_path !== nil) {
- return self._partition_path_web
- } else {
- return self._partition_path_sys
- }; return nil; })())['$[]='](path, [path_segments, root, posix_path]);
- });
-
- Opal.defn(self, '$join_path', function(segments, root) {
- var self = this;
-
- if (root == null) {
- root = nil
- }
- if (root !== false && root !== nil) {
- return "" + (root) + ($rb_times(segments, $scope.get('SLASH')))
- } else {
- return $rb_times(segments, $scope.get('SLASH'))
- };
- });
-
- Opal.defn(self, '$system_path', function(target, start, jail, opts) {
- var $a, $b, TMP_1, self = this, target_segments = nil, target_root = nil, _ = nil, resolved_target = nil, jail_segments = nil, jail_root = nil, start_segments = nil, start_root = nil, resolved_segments = nil, warned = nil;
-
- if (jail == null) {
- jail = nil
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- if (jail !== false && jail !== nil) {
- if ((($a = self['$is_root?'](jail)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('SecurityError'), "Jail is not an absolute path: " + (jail))
- };
- jail = self.$posixfy(jail);};
- if ((($a = target['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- target_segments = []
- } else {
- $a = Opal.to_ary(self.$partition_path(target)), target_segments = ($a[0] == null ? nil : $a[0]), target_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2])
- };
- if ((($a = target_segments['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = start['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (function() {if (jail !== false && jail !== nil) {
- return jail
- } else {
- return self.working_dir
- }; return nil; })()
- } else if ((($a = self['$is_root?'](start)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (jail !== false && jail !== nil) {
- } else {
- return self.$expand_path(start)
- }
- } else {
- return self.$system_path(start, jail, jail, opts)
- }};
- if ((($a = (($b = target_root !== false && target_root !== nil) ? target_root['$!=']($scope.get('DOT_SLASH')) : target_root)) !== nil && (!$a.$$is_boolean || $a == true))) {
- resolved_target = self.$join_path(target_segments, target_root);
- if ((($a = ((($b = jail['$!']()) !== false && $b !== nil) ? $b : (resolved_target['$start_with?'](jail)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return resolved_target};};
- if ((($a = start['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- start = (function() {if (jail !== false && jail !== nil) {
- return jail
- } else {
- return self.working_dir
- }; return nil; })()
- } else if ((($a = self['$is_root?'](start)) !== nil && (!$a.$$is_boolean || $a == true))) {
- start = self.$posixfy(start)
- } else {
- start = self.$system_path(start, jail, jail, opts)
- };
- if (jail['$=='](start)) {
- $a = Opal.to_ary(self.$partition_path(jail)), jail_segments = ($a[0] == null ? nil : $a[0]), jail_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- start_segments = jail_segments.$dup();
- } else if (jail !== false && jail !== nil) {
- if ((($a = start['$start_with?'](jail)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('SecurityError'), "" + (((($a = opts['$[]']("target_name")) !== false && $a !== nil) ? $a : "Start path")) + " " + (start) + " is outside of jail: " + (jail) + " (disallowed in safe mode)")
- };
- $a = Opal.to_ary(self.$partition_path(start)), start_segments = ($a[0] == null ? nil : $a[0]), start_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- $a = Opal.to_ary(self.$partition_path(jail)), jail_segments = ($a[0] == null ? nil : $a[0]), jail_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- } else {
- $a = Opal.to_ary(self.$partition_path(start)), start_segments = ($a[0] == null ? nil : $a[0]), start_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- jail_root = start_root;
- };
- resolved_segments = start_segments.$dup();
- warned = false;
- ($a = ($b = target_segments).$each, $a.$$p = (TMP_1 = function(segment){var self = TMP_1.$$s || this, $a, $b, recover = nil;
-if (segment == null) segment = nil;
- if (segment['$==']($scope.get('DOT_DOT'))) {
- if (jail !== false && jail !== nil) {
- if ($rb_gt(resolved_segments.$length(), jail_segments.$length())) {
- return resolved_segments.$pop()
- } else if ((($a = (((($b = recover) !== false && $b !== nil) ? $b : recover = (opts.$fetch("recover", true))))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$raise(Opal.get('SecurityError'), "" + (((($a = opts['$[]']("target_name")) !== false && $a !== nil) ? $a : "path")) + " " + (target) + " refers to location outside jail: " + (jail) + " (disallowed in safe mode)")
- } else if ((($a = warned['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: WARNING: " + (((($a = opts['$[]']("target_name")) !== false && $a !== nil) ? $a : "path")) + " has illegal reference to ancestor of jail, auto-recovering");
- return warned = true;
- } else {
- return nil
- }
- } else {
- return resolved_segments.$pop()
- }
- } else {
- return resolved_segments.$push(segment)
- }}, TMP_1.$$s = self, TMP_1), $a).call($b);
- return self.$join_path(resolved_segments, jail_root);
- });
-
- Opal.defn(self, '$web_path', function(target, start) {
- var $a, $b, TMP_2, self = this, uri_prefix = nil, target_segments = nil, target_root = nil, _ = nil, resolved_segments = nil;
-
- if (start == null) {
- start = nil
- }
- target = self.$posixfy(target);
- start = self.$posixfy(start);
- uri_prefix = nil;
- if ((($a = ((($b = start['$nil_or_empty?']()) !== false && $b !== nil) ? $b : (self['$is_web_root?'](target)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- target = "" + (start) + ($scope.get('SLASH')) + (target);
- if ((($a = (uri_prefix = $scope.get('Helpers').$uri_prefix(target))) !== nil && (!$a.$$is_boolean || $a == true))) {
- target = target['$[]']($range(uri_prefix.$length(), -1, false))};
- };
- $a = Opal.to_ary(self.$partition_path(target, true)), target_segments = ($a[0] == null ? nil : $a[0]), target_root = ($a[1] == null ? nil : $a[1]), _ = ($a[2] == null ? nil : $a[2]);
- resolved_segments = [];
- ($a = ($b = target_segments).$each, $a.$$p = (TMP_2 = function(segment){var self = TMP_2.$$s || this, $a, $b;
-if (segment == null) segment = nil;
- if (segment['$==']($scope.get('DOT_DOT'))) {
- if ((($a = resolved_segments['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (($b = target_root !== false && target_root !== nil) ? target_root['$!=']($scope.get('DOT_SLASH')) : target_root)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- return resolved_segments['$<<'](segment)
- }
- } else if (resolved_segments['$[]'](-1)['$==']($scope.get('DOT_DOT'))) {
- return resolved_segments['$<<'](segment)
- } else {
- return resolved_segments.$pop()
- }
- } else {
- return resolved_segments['$<<'](segment)
- }}, TMP_2.$$s = self, TMP_2), $a).call($b);
- if (uri_prefix !== false && uri_prefix !== nil) {
- return "" + (uri_prefix) + (self.$join_path(resolved_segments, target_root))
- } else {
- return self.$join_path(resolved_segments, target_root)
- };
- });
-
- return (Opal.defn(self, '$relative_path', function(filename, base_directory) {
- var $a, $b, self = this, offset = nil;
-
- if ((($a = ($b = (self['$is_root?'](filename)), $b !== false && $b !== nil ?(self['$is_root?'](base_directory)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- offset = $rb_plus(base_directory.$chomp(self.file_separator).$length(), 1);
- return filename['$[]']($range(offset, -1, false));
- } else {
- return filename
- };
- }), nil) && 'relative_path';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/reader"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_minus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- function $rb_ge(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs);
- }
- function $rb_divide(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs);
- }
- function $rb_le(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$attr_accessor', '$path', '$lineno', '$attr_reader', '$!', '$is_a?', '$split', '$file', '$dir', '$dirname', '$==', '$basename', '$prepare_lines', '$dup', '$empty?', '$[]', '$normalize_lines_from_string', '$normalize_lines_array', '$+', '$nil?', '$peek_line', '$nil_or_empty?', '$>', '$process_line', '$times', '$read_line', '$<<', '$reverse_each', '$unshift', '$has_more_lines?', '$shift', '$*', '$read_lines', '$advance', '$eof?', '$start_with?', '$match', '$push', '$read_lines_until', '$=~', '$size', '$clear', '$[]=', '$-', '$new', '$line_info', '$to_i', '$fetch', '$attributes', '$<', '$references', '$has_key?', '$skip_front_matter!', '$pop', '$adjust_indentation!', '$attr', '$end_with?', '$include?', '$preprocess_conditional_inclusion', '$captures', '$preprocess_include', '$strip', '$pop_include', '$downcase', '$warn', '$===', '$detect', '$resolve_expr_val', '$send', '$to_sym', '$replace_next_line', '$rstrip', '$sub_attributes', '$attribute_missing', '$include_processors?', '$find', '$handles?', '$instance', '$process_method', '$parse', '$>=', '$safe', '$pwd', '$base_dir', '$join', '$uriish?', '$require_library', '$normalize_system_path', '$file?', '$relative_path', '$each', '$map', '$to_proc', '$/', '$concat', '$to_a', '$uniq', '$sort', '$to_set', '$open', '$each_line', '$infinite?', '$push_include', '$force_encoding', '$chomp', '$read', '$extname', '$rootname', '$<=', '$!=', '$to_f', '$extensions?', '$extensions', '$include_processors', '$class', '$object_id', '$inspect', '$to_s']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Reader(){};
- var self = $Reader = $klass($base, $super, 'Reader', $Reader);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_4;
-
- def.file = def.dir = def.lines = def.process_lines = def.look_ahead = def.eof = def.unescape_next_line = def.lineno = def.path = def.source_lines = nil;
- (function($base, $super) {
- function $Cursor(){};
- var self = $Cursor = $klass($base, $super, 'Cursor', $Cursor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$attr_accessor("file");
-
- self.$attr_accessor("dir");
-
- self.$attr_accessor("path");
-
- self.$attr_accessor("lineno");
-
- Opal.defn(self, '$initialize', function(file, dir, path, lineno) {
- var self = this;
-
- if (dir == null) {
- dir = nil
- }
- if (path == null) {
- path = nil
- }
- if (lineno == null) {
- lineno = nil
- }
- self.file = file;
- self.dir = dir;
- self.path = path;
- return self.lineno = lineno;
- });
-
- Opal.defn(self, '$line_info', function() {
- var self = this;
-
- return "" + (self.$path()) + ": line " + (self.$lineno());
- });
-
- return Opal.alias(self, 'to_s', 'line_info');
- })($scope.base, null);
-
- self.$attr_reader("file");
-
- self.$attr_reader("dir");
-
- self.$attr_reader("path");
-
- self.$attr_reader("lineno");
-
- self.$attr_reader("source_lines");
-
- self.$attr_accessor("process_lines");
-
- Opal.defn(self, '$initialize', function(data, cursor, opts) {
- var $a, self = this;
-
- if (data == null) {
- data = nil
- }
- if (cursor == null) {
- cursor = nil
- }
- if (opts == null) {
- opts = $hash2(["normalize"], {"normalize": false})
- }
- if ((($a = cursor['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.file = self.dir = nil;
- self.path = "";
- self.lineno = 1;
- } else if ((($a = cursor['$is_a?'](Opal.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.file = cursor;
- $a = Opal.to_ary(Opal.get('File').$split(self.file)), self.dir = ($a[0] == null ? nil : $a[0]), self.path = ($a[1] == null ? nil : $a[1]);
- self.lineno = 1;
- } else {
- self.file = cursor.$file();
- self.dir = cursor.$dir();
- self.path = ((($a = cursor.$path()) !== false && $a !== nil) ? $a : "");
- if ((($a = self.file) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self.dir) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.dir = Opal.get('File').$dirname(self.file);
- if (self.dir['$=='](".")) {
- self.dir = nil};
- };
- if ((($a = cursor.$path()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.path = Opal.get('File').$basename(self.file)
- };};
- self.lineno = ((($a = cursor.$lineno()) !== false && $a !== nil) ? $a : 1);
- };
- self.lines = (function() {if (data !== false && data !== nil) {
- return (self.$prepare_lines(data, opts))
- } else {
- return []
- }; return nil; })();
- self.source_lines = self.lines.$dup();
- self.eof = self.lines['$empty?']();
- self.look_ahead = 0;
- self.process_lines = true;
- return self.unescape_next_line = false;
- });
-
- Opal.defn(self, '$prepare_lines', function(data, opts) {
- var $a, self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = data['$is_a?'](Opal.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = opts['$[]']("normalize")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('Helpers').$normalize_lines_from_string(data)
- } else {
- return data.$split($scope.get('EOL'))
- }
- } else if ((($a = opts['$[]']("normalize")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $scope.get('Helpers').$normalize_lines_array(data)
- } else {
- return data.$dup()
- };
- });
-
- Opal.defn(self, '$process_line', function(line) {
- var $a, self = this;
-
- if ((($a = self.process_lines) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.look_ahead = $rb_plus(self.look_ahead, 1)};
- return line;
- });
-
- Opal.defn(self, '$has_more_lines?', function() {
- var $a, self = this;
-
- return (((($a = self.eof) !== false && $a !== nil) ? $a : (self.eof = self.$peek_line()['$nil?']())))['$!']();
- });
-
- Opal.defn(self, '$next_line_empty?', function() {
- var self = this;
-
- return self.$peek_line()['$nil_or_empty?']();
- });
-
- Opal.defn(self, '$peek_line', function(direct) {
- var $a, $b, self = this, line = nil;
-
- if (direct == null) {
- direct = false
- }
- if ((($a = ((($b = direct) !== false && $b !== nil) ? $b : $rb_gt(self.look_ahead, 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self.unescape_next_line) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.lines['$[]'](0)['$[]']($range(1, -1, false))
- } else {
- return self.lines['$[]'](0)
- }
- } else if ((($a = ((($b = self.eof) !== false && $b !== nil) ? $b : self.lines['$empty?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.eof = true;
- self.look_ahead = 0;
- return nil;
- } else if ((($a = ((line = self.$process_line(self.lines['$[]'](0))))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$peek_line()
- } else {
- return line
- };
- });
-
- Opal.defn(self, '$peek_lines', function(num, direct) {
- var $a, $b, TMP_1, $c, TMP_2, self = this, old_look_ahead = nil, result = nil;
-
- if (num == null) {
- num = 1
- }
- if (direct == null) {
- direct = true
- }
- old_look_ahead = self.look_ahead;
- result = [];
- ($a = ($b = num).$times, $a.$$p = (TMP_1 = function(){var self = TMP_1.$$s || this, $a, line = nil;
-
- if ((($a = (line = self.$read_line(direct))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return result['$<<'](line)
- } else {
- return ($breaker.$v = nil, $breaker)
- }}, TMP_1.$$s = self, TMP_1), $a).call($b);
- if ((($a = result['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- ($a = ($c = result).$reverse_each, $a.$$p = (TMP_2 = function(line){var self = TMP_2.$$s || this;
-if (line == null) line = nil;
- return self.$unshift(line)}, TMP_2.$$s = self, TMP_2), $a).call($c);
- if (direct !== false && direct !== nil) {
- self.look_ahead = old_look_ahead};
- };
- return result;
- });
-
- Opal.defn(self, '$read_line', function(direct) {
- var $a, $b, $c, self = this;
-
- if (direct == null) {
- direct = false
- }
- if ((($a = ((($b = ((($c = direct) !== false && $c !== nil) ? $c : $rb_gt(self.look_ahead, 0))) !== false && $b !== nil) ? $b : self['$has_more_lines?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$shift()
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$read_lines', function() {
- var $a, $b, self = this, lines = nil;
-
- lines = [];
- while ((($b = self['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- lines['$<<'](self.$shift())};
- return lines;
- });
-
- Opal.alias(self, 'readlines', 'read_lines');
-
- Opal.defn(self, '$read', function() {
- var self = this;
-
- return $rb_times(self.$read_lines(), $scope.get('EOL'));
- });
-
- Opal.defn(self, '$advance', function(direct) {
- var self = this;
-
- if (direct == null) {
- direct = true
- }
- return self.$read_line(direct)['$!']()['$!']();
- });
-
- Opal.defn(self, '$unshift_line', function(line_to_restore) {
- var self = this;
-
- self.$unshift(line_to_restore);
- return nil;
- });
-
- Opal.alias(self, 'restore_line', 'unshift_line');
-
- Opal.defn(self, '$unshift_lines', function(lines_to_restore) {
- var $a, $b, TMP_3, self = this;
-
- ($a = ($b = lines_to_restore).$reverse_each, $a.$$p = (TMP_3 = function(line){var self = TMP_3.$$s || this;
-if (line == null) line = nil;
- return self.$unshift(line)}, TMP_3.$$s = self, TMP_3), $a).call($b);
- return nil;
- });
-
- Opal.alias(self, 'restore_lines', 'unshift_lines');
-
- Opal.defn(self, '$replace_next_line', function(replacement) {
- var self = this;
-
- self.$advance();
- self.$unshift(replacement);
- return nil;
- });
-
- Opal.alias(self, 'replace_line', 'replace_next_line');
-
- Opal.defn(self, '$skip_blank_lines', function() {
- var $a, $b, self = this, num_skipped = nil, next_line = nil;
-
- if ((($a = self['$eof?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return 0};
- num_skipped = 0;
- while ((($b = (next_line = self.$peek_line())) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = next_line['$empty?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$advance();
- num_skipped = $rb_plus(num_skipped, 1);
- } else {
- return num_skipped
- }};
- return num_skipped;
- });
-
- Opal.defn(self, '$skip_comment_lines', function(opts) {
- var $a, $b, $c, $d, self = this, comment_lines = nil, include_blank_lines = nil, next_line = nil, commentish = nil, match = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- if ((($a = self['$eof?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return []};
- comment_lines = [];
- include_blank_lines = opts['$[]']("include_blank_lines");
- while ((($b = (next_line = self.$peek_line())) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = (($c = include_blank_lines !== false && include_blank_lines !== nil) ? next_line['$empty?']() : include_blank_lines)) !== nil && (!$b.$$is_boolean || $b == true))) {
- comment_lines['$<<'](self.$shift())
- } else if ((($b = ($c = (commentish = next_line['$start_with?']("//")), $c !== false && $c !== nil ?(match = $scope.get('CommentBlockRx').$match(next_line)) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- comment_lines['$<<'](self.$shift());
- ($b = comment_lines).$push.apply($b, Opal.to_a((self.$read_lines_until($hash2(["terminator", "read_last_line", "skip_processing"], {"terminator": match['$[]'](0), "read_last_line": true, "skip_processing": true})))));
- } else if ((($c = (($d = commentish !== false && commentish !== nil) ? $scope.get('CommentLineRx')['$=~'](next_line) : commentish)) !== nil && (!$c.$$is_boolean || $c == true))) {
- comment_lines['$<<'](self.$shift())
- } else {
- break;
- }};
- return comment_lines;
- });
-
- Opal.defn(self, '$skip_line_comments', function() {
- var $a, $b, self = this, comment_lines = nil, next_line = nil;
-
- if ((($a = self['$eof?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return []};
- comment_lines = [];
- while ((($b = (next_line = self.$peek_line())) !== nil && (!$b.$$is_boolean || $b == true))) {
- if ((($b = $scope.get('CommentLineRx')['$=~'](next_line)) !== nil && (!$b.$$is_boolean || $b == true))) {
- comment_lines['$<<'](self.$shift())
- } else {
- break;
- }};
- return comment_lines;
- });
-
- Opal.defn(self, '$terminate', function() {
- var self = this;
-
- self.lineno = $rb_plus(self.lineno, self.lines.$size());
- self.lines.$clear();
- self.eof = true;
- self.look_ahead = 0;
- return nil;
- });
-
- Opal.defn(self, '$eof?', function() {
- var self = this;
-
- return self['$has_more_lines?']()['$!']();
- });
-
- Opal.alias(self, 'empty?', 'eof?');
-
- Opal.defn(self, '$read_lines_until', TMP_4 = function(options) {
- var $a, $b, $c, $d, $e, self = this, $iter = TMP_4.$$p, $yield = $iter || nil, result = nil, restore_process_lines = nil, terminator = nil, break_on_blank_lines = nil, break_on_list_continuation = nil, skip_comments = nil, line_read = nil, line_restored = nil, complete = nil, line = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- TMP_4.$$p = null;
- result = [];
- if ((($a = options['$[]']("skip_first_line")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance()};
- if ((($a = ($b = self.process_lines, $b !== false && $b !== nil ?options['$[]']("skip_processing") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.process_lines = false;
- restore_process_lines = true;
- } else {
- restore_process_lines = false
- };
- if ((($a = (terminator = options['$[]']("terminator"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- break_on_blank_lines = false;
- break_on_list_continuation = false;
- } else {
- break_on_blank_lines = options['$[]']("break_on_blank_lines");
- break_on_list_continuation = options['$[]']("break_on_list_continuation");
- };
- skip_comments = options['$[]']("skip_line_comments");
- line_read = false;
- line_restored = false;
- complete = false;
- while ((($b = ($c = complete['$!'](), $c !== false && $c !== nil ?(line = self.$read_line()) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- complete = (function() {while ((($c = true) !== nil && (!$c.$$is_boolean || $c == true))) {
- if ((($c = (($d = terminator !== false && terminator !== nil) ? line['$=='](terminator) : terminator)) !== nil && (!$c.$$is_boolean || $c == true))) {
- return true};
- if ((($c = (($d = break_on_blank_lines !== false && break_on_blank_lines !== nil) ? line['$empty?']() : break_on_blank_lines)) !== nil && (!$c.$$is_boolean || $c == true))) {
- return true};
- if ((($c = ($d = (($e = break_on_list_continuation !== false && break_on_list_continuation !== nil) ? line_read : break_on_list_continuation), $d !== false && $d !== nil ?line['$==']($scope.get('LIST_CONTINUATION')) : $d)) !== nil && (!$c.$$is_boolean || $c == true))) {
- options['$[]=']("preserve_last_line", true);
- return true;};
- if ((($c = (($d = ($yield !== nil)) ? (((($e = Opal.yield1($yield, line)) === $breaker) ? $breaker.$v : $e)) : ($yield !== nil))) !== nil && (!$c.$$is_boolean || $c == true))) {
- return true};
- return false;}; return nil; })();
- if (complete !== false && complete !== nil) {
- if ((($b = options['$[]']("read_last_line")) !== nil && (!$b.$$is_boolean || $b == true))) {
- result['$<<'](line);
- line_read = true;};
- if ((($b = options['$[]']("preserve_last_line")) !== nil && (!$b.$$is_boolean || $b == true))) {
- self.$unshift(line);
- line_restored = true;};
- } else if ((($b = ($c = (($d = skip_comments !== false && skip_comments !== nil) ? line['$start_with?']("//") : skip_comments), $c !== false && $c !== nil ?$scope.get('CommentLineRx')['$=~'](line) : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- } else {
- result['$<<'](line);
- line_read = true;
- };};
- if (restore_process_lines !== false && restore_process_lines !== nil) {
- self.process_lines = true;
- if ((($a = (($b = line_restored !== false && line_restored !== nil) ? terminator['$!']() : line_restored)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.look_ahead = $rb_minus(self.look_ahead, 1)};};
- return result;
- });
-
- Opal.defn(self, '$shift', function() {
- var self = this;
-
- self.lineno = $rb_plus(self.lineno, 1);
- if (self.look_ahead['$=='](0)) {
- } else {
- self.look_ahead = $rb_minus(self.look_ahead, 1)
- };
- return self.lines.$shift();
- });
-
- Opal.defn(self, '$unshift', function(line) {
- var self = this;
-
- self.lineno = $rb_minus(self.lineno, 1);
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- self.eof = false;
- return self.lines.$unshift(line);
- });
-
- Opal.defn(self, '$cursor', function() {
- var self = this;
-
- return $scope.get('Cursor').$new(self.file, self.dir, self.path, self.lineno);
- });
-
- Opal.defn(self, '$line_info', function() {
- var self = this;
-
- return "" + (self.path) + ": line " + (self.lineno);
- });
-
- Opal.alias(self, 'next_line_info', 'line_info');
-
- Opal.defn(self, '$prev_line_info', function() {
- var self = this;
-
- return "" + (self.path) + ": line " + ($rb_minus(self.lineno, 1));
- });
-
- Opal.defn(self, '$lines', function() {
- var self = this;
-
- return self.lines.$dup();
- });
-
- Opal.defn(self, '$string', function() {
- var self = this;
-
- return $rb_times(self.lines, $scope.get('EOL'));
- });
-
- Opal.defn(self, '$source', function() {
- var self = this;
-
- return $rb_times(self.source_lines, $scope.get('EOL'));
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var self = this;
-
- return self.$line_info();
- }), nil) && 'to_s';
- })($scope.base, null);
-
- (function($base, $super) {
- function $PreprocessorReader(){};
- var self = $PreprocessorReader = $klass($base, $super, 'PreprocessorReader', $PreprocessorReader);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_5, TMP_6, TMP_7, TMP_20;
-
- def.document = def.lineno = def.process_lines = def.look_ahead = def.skipping = def.include_stack = def.conditional_stack = def.path = def.include_processor_extensions = def.maxdepth = def.dir = def.lines = def.file = def.includes = def.unescape_next_line = nil;
- self.$attr_reader("include_stack");
-
- self.$attr_reader("includes");
-
- Opal.defn(self, '$initialize', TMP_5 = function(document, data, cursor) {
- var $a, $b, $c, self = this, $iter = TMP_5.$$p, $yield = $iter || nil, include_depth_default = nil;
-
- if (data == null) {
- data = nil
- }
- if (cursor == null) {
- cursor = nil
- }
- TMP_5.$$p = null;
- self.document = document;
- Opal.find_super_dispatcher(self, 'initialize', TMP_5, null).apply(self, [data, cursor, $hash2(["normalize"], {"normalize": true})]);
- include_depth_default = document.$attributes().$fetch("max-include-depth", 64).$to_i();
- if ($rb_lt(include_depth_default, 0)) {
- include_depth_default = 0};
- self.maxdepth = $hash2(["abs", "rel"], {"abs": include_depth_default, "rel": include_depth_default});
- self.include_stack = [];
- self.includes = (($a = "includes", $b = document.$references(), ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, []))));
- self.skipping = false;
- self.conditional_stack = [];
- return self.include_processor_extensions = nil;
- });
-
- Opal.defn(self, '$prepare_lines', TMP_6 = function(data, opts) {var $zuper = $slice.call(arguments, 0);
- var $a, $b, $c, self = this, $iter = TMP_6.$$p, $yield = $iter || nil, result = nil, front_matter = nil, first = nil, last = nil;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- TMP_6.$$p = null;
- result = Opal.find_super_dispatcher(self, 'prepare_lines', TMP_6, $iter).apply(self, $zuper);
- if ((($a = ($b = self.document, $b !== false && $b !== nil ?(self.document.$attributes()['$has_key?']("skip-front-matter")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (front_matter = self['$skip_front_matter!'](result))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.document.$attributes()['$[]=']("front-matter", $rb_times(front_matter, $scope.get('EOL')))}};
- if ((($a = opts.$fetch("condense", true)) !== nil && (!$a.$$is_boolean || $a == true))) {
- while ((($b = ($c = (first = result['$[]'](0)), $c !== false && $c !== nil ?first['$empty?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- ($b = result.$shift(), $b !== false && $b !== nil ?self.lineno = $rb_plus(self.lineno, 1) : $b)};
- while ((($b = ($c = (last = result['$[]'](-1)), $c !== false && $c !== nil ?last['$empty?']() : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- result.$pop()};};
- if ((($a = opts['$[]']("indent")) !== nil && (!$a.$$is_boolean || $a == true))) {
- $scope.get('Parser')['$adjust_indentation!'](result, opts['$[]']("indent"), (self.document.$attr("tabsize")))};
- return result;
- });
-
- Opal.defn(self, '$process_line', function(line) {
- var $a, $b, $c, $d, self = this, match = nil, escaped = nil;
-
- if ((($a = self.process_lines) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- return line
- };
- if ((($a = line['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return "";};
- if ((($a = ($b = ($c = line['$end_with?']("]"), $c !== false && $c !== nil ?line['$start_with?']("[")['$!']() : $c), $b !== false && $b !== nil ?line['$include?']("::") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = line['$include?']("if"), $b !== false && $b !== nil ?(match = $scope.get('ConditionalDirectiveRx').$match(line)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = line['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.unescape_next_line = true;
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line['$[]']($range(1, -1, false));
- } else if ((($a = ($b = self).$preprocess_conditional_inclusion.apply($b, Opal.to_a(match.$captures()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance();
- return nil;
- } else {
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line;
- }
- } else if ((($a = self.skipping) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance();
- return nil;
- } else if ((($a = ($c = (((($d = (escaped = line['$start_with?']("\\include::"))) !== false && $d !== nil) ? $d : line['$start_with?']("include::"))), $c !== false && $c !== nil ?(match = $scope.get('IncludeDirectiveRx').$match(line)) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (escaped !== false && escaped !== nil) {
- self.unescape_next_line = true;
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line['$[]']($range(1, -1, false));
- } else if ((($a = self.$preprocess_include(match['$[]'](1), match['$[]'](2).$strip())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line;
- }
- } else {
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line;
- }
- } else if ((($a = self.skipping) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance();
- return nil;
- } else {
- self.look_ahead = $rb_plus(self.look_ahead, 1);
- return line;
- };
- });
-
- Opal.defn(self, '$peek_line', TMP_7 = function(direct) {var $zuper = $slice.call(arguments, 0);
- var $a, self = this, $iter = TMP_7.$$p, $yield = $iter || nil, line = nil;
-
- if (direct == null) {
- direct = false
- }
- TMP_7.$$p = null;
- if ((($a = (line = Opal.find_super_dispatcher(self, 'peek_line', TMP_7, $iter).apply(self, $zuper))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return line
- } else if ((($a = self.include_stack['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else {
- self.$pop_include();
- return self.$peek_line(direct);
- };
- });
-
- Opal.defn(self, '$preprocess_conditional_inclusion', function(directive, target, delimiter, text) {
- var $a, $b, $c, $d, TMP_8, TMP_9, TMP_10, $e, TMP_11, $f, self = this, stack_size = nil, pair = nil, skip = nil, $case = nil, expr_match = nil, lhs = nil, rhs = nil, op = nil, conditional_line = nil;
-
- if ((($a = ((($b = (($c = (((($d = directive['$==']("ifdef")) !== false && $d !== nil) ? $d : directive['$==']("ifndef"))), $c !== false && $c !== nil ?target['$empty?']() : $c))) !== false && $b !== nil) ? $b : ((($c = directive['$==']("endif")) ? text : directive['$==']("endif"))))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false};
- target = target.$downcase();
- if (directive['$==']("endif")) {
- stack_size = self.conditional_stack.$size();
- if ($rb_gt(stack_size, 0)) {
- pair = self.conditional_stack['$[]'](-1);
- if ((($a = ((($b = target['$empty?']()) !== false && $b !== nil) ? $b : target['$=='](pair['$[]']("target")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.conditional_stack.$pop();
- self.skipping = (function() {if ((($a = self.conditional_stack['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false
- } else {
- return self.conditional_stack['$[]'](-1)['$[]']("skipping")
- }; return nil; })();
- } else {
- self.$warn("asciidoctor: ERROR: " + (self.$line_info()) + ": mismatched macro: endif::" + (target) + "[], expected endif::" + (pair['$[]']("target")) + "[]")
- };
- } else {
- self.$warn("asciidoctor: ERROR: " + (self.$line_info()) + ": unmatched macro: endif::" + (target) + "[]")
- };
- return true;};
- skip = false;
- if ((($a = self.skipping) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- $case = directive;if ("ifdef"['$===']($case)) {$case = delimiter;if (nil['$===']($case)) {skip = self.document.$attributes()['$has_key?'](target)['$!']()}else if (","['$===']($case)) {skip = ($a = ($b = target.$split(",")).$detect, $a.$$p = (TMP_8 = function(name){var self = TMP_8.$$s || this;
- if (self.document == null) self.document = nil;
-if (name == null) name = nil;
- return self.document.$attributes()['$has_key?'](name)}, TMP_8.$$s = self, TMP_8), $a).call($b)['$!']()}else if ("+"['$===']($case)) {skip = ($a = ($c = target.$split("+")).$detect, $a.$$p = (TMP_9 = function(name){var self = TMP_9.$$s || this;
- if (self.document == null) self.document = nil;
-if (name == null) name = nil;
- return self.document.$attributes()['$has_key?'](name)['$!']()}, TMP_9.$$s = self, TMP_9), $a).call($c)}}else if ("ifndef"['$===']($case)) {$case = delimiter;if (nil['$===']($case)) {skip = self.document.$attributes()['$has_key?'](target)}else if (","['$===']($case)) {skip = ($a = ($d = target.$split(",")).$detect, $a.$$p = (TMP_10 = function(name){var self = TMP_10.$$s || this;
- if (self.document == null) self.document = nil;
-if (name == null) name = nil;
- return self.document.$attributes()['$has_key?'](name)['$!']()}, TMP_10.$$s = self, TMP_10), $a).call($d)['$!']()}else if ("+"['$===']($case)) {skip = ($a = ($e = target.$split("+")).$detect, $a.$$p = (TMP_11 = function(name){var self = TMP_11.$$s || this;
- if (self.document == null) self.document = nil;
-if (name == null) name = nil;
- return self.document.$attributes()['$has_key?'](name)}, TMP_11.$$s = self, TMP_11), $a).call($e)}}else if ("ifeval"['$===']($case)) {if ((($a = ((($f = target['$empty?']()['$!']()) !== false && $f !== nil) ? $f : ((expr_match = $scope.get('EvalExpressionRx').$match(text.$strip())))['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- return false};
- lhs = self.$resolve_expr_val(expr_match['$[]'](1));
- rhs = self.$resolve_expr_val(expr_match['$[]'](3));
- if (((op = expr_match['$[]'](2)))['$==']("!=")) {
- skip = lhs.$send("==", rhs)
- } else {
- skip = (lhs.$send(op.$to_sym(), rhs))['$!']()
- };}
- };
- if ((($a = ((($f = directive['$==']("ifeval")) !== false && $f !== nil) ? $f : text['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (skip !== false && skip !== nil) {
- self.skipping = true};
- self.conditional_stack['$<<']($hash2(["target", "skip", "skipping"], {"target": target, "skip": skip, "skipping": self.skipping}));
- } else if ((($a = ((($f = self.skipping) !== false && $f !== nil) ? $f : skip)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- conditional_line = self.$peek_line(true);
- self.$replace_next_line(text.$rstrip());
- self.$unshift(conditional_line);
- return true;
- };
- return true;
- });
-
- Opal.defn(self, '$preprocess_include', function(raw_target, raw_attributes) {
- var $a, $b, $c, $d, TMP_12, TMP_13, TMP_14, $e, TMP_16, $f, TMP_19, self = this, target = nil, extension = nil, abs_maxdepth = nil, target_type = nil, include_file = nil, path = nil, inc_lines = nil, tags = nil, attributes = nil, selected = nil, inc_line_offset = nil, inc_lineno = nil, active_tag = nil, tags_found = nil, missing_tags = nil, include_content = nil;
-
- if ((($a = ((target = self.document.$sub_attributes(raw_target, $hash2(["attribute_missing"], {"attribute_missing": "drop-line"}))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance();
- if (self.document.$attributes().$fetch("attribute-missing", $scope.get('Compliance').$attribute_missing())['$==']("skip")) {
- self.$unshift("Unresolved directive in " + (self.path) + " - include::" + (raw_target) + "[" + (raw_attributes) + "]")};
- return true;
- } else if ((($a = ($b = self['$include_processors?'](), $b !== false && $b !== nil ?(extension = ($c = ($d = self.include_processor_extensions).$find, $c.$$p = (TMP_12 = function(candidate){var self = TMP_12.$$s || this;
-if (candidate == null) candidate = nil;
- return candidate.$instance()['$handles?'](target)}, TMP_12.$$s = self, TMP_12), $c).call($d)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$advance();
- extension.$process_method()['$[]'](self.document, self, target, $scope.get('AttributeList').$new(raw_attributes).$parse());
- return true;
- } else if ($rb_ge(self.document.$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE')))) {
- self.$replace_next_line("link:" + (target) + "[]");
- return true;
- } else if ((($a = (($b = $rb_gt((abs_maxdepth = self.maxdepth['$[]']("abs")), 0)) ? $rb_ge(self.include_stack.$size(), abs_maxdepth) : $rb_gt((abs_maxdepth = self.maxdepth['$[]']("abs")), 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$warn("asciidoctor: ERROR: " + (self.$line_info()) + ": maximum include depth of " + (self.maxdepth['$[]']("rel")) + " exceeded");
- return false;
- } else if ($rb_gt(abs_maxdepth, 0)) {
- if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) {
- target_type = "file";
- include_file = path = (function() {if ((($a = self.include_stack['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (Opal.get('Dir').$pwd()['$=='](self.document.$base_dir())) {
- return target
- } else {
- return (Opal.get('File').$join(self.dir, target))
- }
- } else {
- return Opal.get('File').$join(self.dir, target)
- }; return nil; })();
- } else if ((($a = $scope.get('Helpers')['$uriish?'](target)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self.document.$attributes()['$has_key?']("allow-uri-read")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$replace_next_line("link:" + (target) + "[]");
- return true;
- };
- target_type = "uri";
- include_file = path = target;
- if ((($a = self.document.$attributes()['$has_key?']("cache-uri")) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (function(){ try { return ((((Opal.get('OpenURI')).$$scope.get('Cache'))) != null ? 'constant' : nil); } catch (err) { if (err.$$class === Opal.NameError) { return nil; } else { throw(err); }}; })()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- $scope.get('Helpers').$require_library("open-uri/cached", "open-uri-cached")
- }
- } else if ((($a = Opal.get('RUBY_ENGINE_OPAL')['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- Opal.get('OpenURI')};
- } else {
- target_type = "file";
- include_file = self.document.$normalize_system_path(target, self.dir, nil, $hash2(["target_name"], {"target_name": "include file"}));
- if ((($a = Opal.get('File')['$file?'](include_file)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$warn("asciidoctor: WARNING: " + (self.$line_info()) + ": include file not found: " + (include_file));
- self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (raw_attributes) + "]");
- return true;
- };
- path = $scope.get('PathResolver').$new().$relative_path(include_file, self.document.$base_dir());
- };
- inc_lines = nil;
- tags = nil;
- attributes = $hash2([], {});
- if ((($a = raw_attributes['$empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- attributes = $scope.get('AttributeList').$new(raw_attributes).$parse();
- if ((($a = attributes['$has_key?']("lines")) !== nil && (!$a.$$is_boolean || $a == true))) {
- inc_lines = [];
- ($a = ($b = attributes['$[]']("lines").$split($scope.get('DataDelimiterRx'))).$each, $a.$$p = (TMP_13 = function(linedef){var self = TMP_13.$$s || this, $a, $b, $c, from = nil, to = nil;
-if (linedef == null) linedef = nil;
- if ((($a = linedef['$include?']("..")) !== nil && (!$a.$$is_boolean || $a == true))) {
- $a = Opal.to_ary(($b = ($c = linedef.$split("..")).$map, $b.$$p = "to_i".$to_proc(), $b).call($c)), from = ($a[0] == null ? nil : $a[0]), to = ($a[1] == null ? nil : $a[1]);
- if (to['$=='](-1)) {
- inc_lines['$<<'](from);
- return inc_lines['$<<']($rb_divide(1.0, 0.0));
- } else {
- return inc_lines.$concat(Opal.get('Range').$new(from, to).$to_a())
- };
- } else {
- return inc_lines['$<<'](linedef.$to_i())
- }}, TMP_13.$$s = self, TMP_13), $a).call($b);
- inc_lines = inc_lines.$sort().$uniq();
- } else if ((($a = attributes['$has_key?']("tag")) !== nil && (!$a.$$is_boolean || $a == true))) {
- tags = [attributes['$[]']("tag")].$to_set()
- } else if ((($a = attributes['$has_key?']("tags")) !== nil && (!$a.$$is_boolean || $a == true))) {
- tags = attributes['$[]']("tags").$split($scope.get('DataDelimiterRx')).$to_set()};};
- if (inc_lines !== false && inc_lines !== nil) {
- if ((($a = inc_lines['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- selected = [];
- inc_line_offset = 0;
- inc_lineno = 0;
- try {
- ($a = ($c = self).$open, $a.$$p = (TMP_14 = function(f){var self = TMP_14.$$s || this, $a, $b, TMP_15;
-if (f == null) f = nil;
- return ($a = ($b = f).$each_line, $a.$$p = (TMP_15 = function(l){var self = TMP_15.$$s || this, $a, $b, take = nil;
-if (l == null) l = nil;
- inc_lineno = $rb_plus(inc_lineno, 1);
- take = inc_lines['$[]'](0);
- if ((($a = ($b = take['$is_a?'](Opal.get('Float')), $b !== false && $b !== nil ?take['$infinite?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- selected.$push(l);
- if (inc_line_offset['$=='](0)) {
- return inc_line_offset = inc_lineno
- } else {
- return nil
- };
- } else {
- if (f.$lineno()['$=='](take)) {
- selected.$push(l);
- if (inc_line_offset['$=='](0)) {
- inc_line_offset = inc_lineno};
- inc_lines.$shift();};
- if ((($a = inc_lines['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($breaker.$v = nil, $breaker)
- } else {
- return nil
- };
- };}, TMP_15.$$s = self, TMP_15), $a).call($b)}, TMP_14.$$s = self, TMP_14), $a).call($c, include_file, "r")
- } catch ($err) {if (true) {
- try {
- self.$warn("asciidoctor: WARNING: " + (self.$line_info()) + ": include " + (target_type) + " not readable: " + (include_file));
- self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (raw_attributes) + "]");
- return true;
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- self.$advance();
- self.$push_include(selected, include_file, path, inc_line_offset, attributes);
- }
- } else if (tags !== false && tags !== nil) {
- if ((($a = tags['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- selected = [];
- inc_line_offset = 0;
- inc_lineno = 0;
- active_tag = nil;
- tags_found = Opal.get('Set').$new();
- try {
- ($a = ($e = self).$open, $a.$$p = (TMP_16 = function(f){var self = TMP_16.$$s || this, $a, $b, TMP_17;
-if (f == null) f = nil;
- return ($a = ($b = f).$each_line, $a.$$p = (TMP_17 = function(l){var self = TMP_17.$$s || this, $a, $b, TMP_18, tl = nil;
-if (l == null) l = nil;
- inc_lineno = $rb_plus(inc_lineno, 1);
- if ((($a = $scope.get('FORCE_ENCODING')) !== nil && (!$a.$$is_boolean || $a == true))) {
- l.$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_8')))};
- l = l.$rstrip();
- tl = l.$chomp("-->").$rstrip();
- if (active_tag !== false && active_tag !== nil) {
- if ((($a = tl['$end_with?']("end::" + (active_tag) + "[]")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return active_tag = nil
- } else {
- if ((($a = ($b = tl['$end_with?']("[]"), $b !== false && $b !== nil ?$scope.get('TagDirectiveRx')['$=~'](tl) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- selected.$push(l)
- };
- if (inc_line_offset['$=='](0)) {
- return inc_line_offset = inc_lineno
- } else {
- return nil
- };
- }
- } else if ((($a = ($b = tl['$end_with?']("[]"), $b !== false && $b !== nil ?$scope.get('TagDirectiveRx')['$=~'](tl) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = ($b = tags).$each, $a.$$p = (TMP_18 = function(tag){var self = TMP_18.$$s || this, $a;
-if (tag == null) tag = nil;
- if ((($a = tl['$end_with?']("tag::" + (tag) + "[]")) !== nil && (!$a.$$is_boolean || $a == true))) {
- active_tag = tag;
- tags_found['$<<'](tag);
- return ($breaker.$v = nil, $breaker);
- } else {
- return nil
- }}, TMP_18.$$s = self, TMP_18), $a).call($b)
- } else {
- return nil
- };}, TMP_17.$$s = self, TMP_17), $a).call($b)}, TMP_16.$$s = self, TMP_16), $a).call($e, include_file, "r")
- } catch ($err) {if (true) {
- try {
- self.$warn("asciidoctor: WARNING: " + (self.$line_info()) + ": include " + (target_type) + " not readable: " + (include_file));
- self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (raw_attributes) + "]");
- return true;
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- if ((($a = ((missing_tags = $rb_minus(tags.$to_a(), tags_found.$to_a())))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$warn("asciidoctor: WARNING: " + (self.$line_info()) + ": tag" + ((function() {if ($rb_gt(missing_tags.$size(), 1)) {
- return "s"
- } else {
- return nil
- }; return nil; })()) + " '" + ($rb_times(missing_tags, ",")) + "' not found in include " + (target_type) + ": " + (include_file))
- };
- self.$advance();
- self.$push_include(selected, include_file, path, inc_line_offset, attributes);
- }
- } else {
- try {
- include_content = ($a = ($f = self).$open, $a.$$p = (TMP_19 = function(f){var self = TMP_19.$$s || this;
-if (f == null) f = nil;
- return f.$read()}, TMP_19.$$s = self, TMP_19), $a).call($f, include_file, "r");
- self.$advance();
- self.$push_include(include_content, include_file, path, 1, attributes);
- } catch ($err) {if (true) {
- try {
- self.$warn("asciidoctor: WARNING: " + (self.$line_info()) + ": include " + (target_type) + " not readable: " + (include_file));
- self.$replace_next_line("Unresolved directive in " + (self.path) + " - include::" + (target) + "[" + (raw_attributes) + "]");
- return true;
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- }
- };
- return true;
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$push_include', function(data, file, path, lineno, attributes) {
- var $a, self = this, depth = nil, old_leveloffset = nil;
-
- if (file == null) {
- file = nil
- }
- if (path == null) {
- path = nil
- }
- if (lineno == null) {
- lineno = 1
- }
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- self.include_stack['$<<']([self.lines, self.file, self.dir, self.path, self.lineno, self.maxdepth, self.process_lines]);
- if (file !== false && file !== nil) {
- self.file = file;
- self.dir = $scope.get('File').$dirname(file);
- self.process_lines = $scope.get('ASCIIDOC_EXTENSIONS')['$[]'](Opal.get('File').$extname(file));
- } else {
- self.file = nil;
- self.dir = ".";
- self.process_lines = true;
- };
- self.path = (function() {if (path !== false && path !== nil) {
- self.includes['$<<']($scope.get('Helpers').$rootname(path));
- return path;
- } else {
- return ""
- }; return nil; })();
- self.lineno = lineno;
- if ((($a = attributes['$has_key?']("depth")) !== nil && (!$a.$$is_boolean || $a == true))) {
- depth = attributes['$[]']("depth").$to_i();
- if ($rb_le(depth, 0)) {
- depth = 1};
- self.maxdepth = $hash2(["abs", "rel"], {"abs": $rb_plus(($rb_minus(self.include_stack.$size(), 1)), depth), "rel": depth});};
- if ((($a = (self.lines = self.$prepare_lines(data, $hash2(["normalize", "condense", "indent"], {"normalize": true, "condense": false, "indent": attributes['$[]']("indent")})))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$pop_include()
- } else {
- if ((($a = attributes['$has_key?']("leveloffset")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.lines.$unshift("");
- self.lines.$unshift(":leveloffset: " + (attributes['$[]']("leveloffset")));
- self.lines.$push("");
- if ((($a = (old_leveloffset = self.document.$attr("leveloffset"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.lines.$push(":leveloffset: " + (old_leveloffset))
- } else {
- self.lines.$push(":leveloffset!:")
- };
- self.lineno = $rb_minus(self.lineno, 2);};
- self.eof = false;
- self.look_ahead = 0;
- };
- return nil;
- });
-
- Opal.defn(self, '$pop_include', function() {
- var $a, self = this;
-
- if ($rb_gt(self.include_stack.$size(), 0)) {
- $a = Opal.to_ary(self.include_stack.$pop()), 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]);
- self.eof = self.lines['$empty?']();
- self.look_ahead = 0;};
- return nil;
- });
-
- Opal.defn(self, '$include_depth', function() {
- var self = this;
-
- return self.include_stack.$size();
- });
-
- Opal.defn(self, '$exceeded_max_depth?', function() {
- var $a, $b, self = this, abs_maxdepth = nil;
-
- if ((($a = (($b = $rb_gt((abs_maxdepth = self.maxdepth['$[]']("abs")), 0)) ? $rb_ge(self.include_stack.$size(), abs_maxdepth) : $rb_gt((abs_maxdepth = self.maxdepth['$[]']("abs")), 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.maxdepth['$[]']("rel")
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$shift', TMP_20 = function() {var $zuper = $slice.call(arguments, 0);
- var $a, self = this, $iter = TMP_20.$$p, $yield = $iter || nil;
-
- TMP_20.$$p = null;
- if ((($a = self.unescape_next_line) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.unescape_next_line = false;
- return Opal.find_super_dispatcher(self, 'shift', TMP_20, $iter).apply(self, $zuper)['$[]']($range(1, -1, false));
- } else {
- return Opal.find_super_dispatcher(self, 'shift', TMP_20, $iter).apply(self, $zuper)
- };
- });
-
- Opal.defn(self, '$skip_front_matter!', function(data, increment_linenos) {
- var $a, $b, $c, self = this, front_matter = nil, original_data = nil;
-
- if (increment_linenos == null) {
- increment_linenos = true
- }
- front_matter = nil;
- if (data['$[]'](0)['$==']("---")) {
- original_data = data.$dup();
- front_matter = [];
- data.$shift();
- if (increment_linenos !== false && increment_linenos !== nil) {
- self.lineno = $rb_plus(self.lineno, 1)};
- while ((($b = ($c = data['$empty?']()['$!'](), $c !== false && $c !== nil ?data['$[]'](0)['$!=']("---") : $c)) !== nil && (!$b.$$is_boolean || $b == true))) {
- front_matter.$push(data.$shift());
- if (increment_linenos !== false && increment_linenos !== nil) {
- self.lineno = $rb_plus(self.lineno, 1)};};
- if ((($a = data['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- ($a = data).$unshift.apply($a, Opal.to_a(original_data));
- if (increment_linenos !== false && increment_linenos !== nil) {
- self.lineno = 0};
- front_matter = nil;
- } else {
- data.$shift();
- if (increment_linenos !== false && increment_linenos !== nil) {
- self.lineno = $rb_plus(self.lineno, 1)};
- };};
- return front_matter;
- });
-
- Opal.defn(self, '$resolve_expr_val', function(val) {
- var $a, $b, $c, self = this, quoted = nil;
-
- if ((($a = ((($b = (($c = (val['$start_with?']("\"")), $c !== false && $c !== nil ?(val['$end_with?']("\"")) : $c))) !== false && $b !== nil) ? $b : (($c = (val['$start_with?']("'")), $c !== false && $c !== nil ?(val['$end_with?']("'")) : $c)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- quoted = true;
- val = val['$[]']($range(1, -1, true));
- } else {
- quoted = false
- };
- if ((($a = val['$include?']("{")) !== nil && (!$a.$$is_boolean || $a == true))) {
- val = self.document.$sub_attributes(val, $hash2(["attribute_missing"], {"attribute_missing": "drop"}))};
- if (quoted !== false && quoted !== nil) {
- return val
- } else if ((($a = val['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else if (val['$==']("true")) {
- return true
- } else if (val['$==']("false")) {
- return false
- } else if ((($a = val.$rstrip()['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return " "
- } else if ((($a = val['$include?'](".")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return val.$to_f()
- } else {
- return val.$to_i()
- };
- });
-
- Opal.defn(self, '$include_processors?', function() {
- var $a, $b, self = this;
-
- if ((($a = self.include_processor_extensions['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = self.document['$extensions?'](), $b !== false && $b !== nil ?self.document.$extensions()['$include_processors?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (self.include_processor_extensions = self.document.$extensions().$include_processors())['$!']()['$!']()
- } else {
- return self.include_processor_extensions = false
- }
- } else {
- return self.include_processor_extensions['$!='](false)
- };
- });
-
- return (Opal.defn(self, '$to_s', function() {
- var $a, $b, TMP_21, self = this;
-
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {path: " + (self.path.$inspect()) + ", line #: " + (self.lineno) + ", include depth: " + (self.include_stack.$size()) + ", include stack: [" + (($a = ($b = self.include_stack).$map, $a.$$p = (TMP_21 = function(inc){var self = TMP_21.$$s || this;
-if (inc == null) inc = nil;
- return inc.$to_s()}, TMP_21.$$s = self, TMP_21), $a).call($b).$join(", ")) + "]}>";
- }), nil) && 'to_s';
- })($scope.base, $scope.get('Reader'));
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/section"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$attr_accessor', '$+', '$level', '$>', '$==', '$context', '$special', '$has_key?', '$attributes', '$[]', '$chomp', '$tr_s', '$gsub', '$downcase', '$title', '$empty?', '$start_with?', '$unique_id_start_index', '$references', '$sectnum', '$assign_index', '$!=', '$class', '$object_id', '$inspect', '$size']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Section(){};
- var self = $Section = $klass($base, $super, 'Section', $Section);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3;
-
- def.level = def.document = def.parent = def.number = def.title = def.numbered = def.blocks = nil;
- self.$attr_accessor("index");
-
- self.$attr_accessor("number");
-
- self.$attr_accessor("sectname");
-
- self.$attr_accessor("special");
-
- self.$attr_accessor("numbered");
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, level, numbered, opts) {
- var $a, $b, self = this, $iter = TMP_1.$$p, $yield = $iter || nil;
-
- if (parent == null) {
- parent = nil
- }
- if (level == null) {
- level = nil
- }
- if (numbered == null) {
- numbered = true
- }
- if (opts == null) {
- opts = $hash2([], {})
- }
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, null).apply(self, [parent, "section", opts]);
- if (level !== false && level !== nil) {
- self.level = level
- } else {
- self.level = (function() {if (parent !== false && parent !== nil) {
- return ($rb_plus(parent.$level(), 1))
- } else {
- return 1
- }; return nil; })()
- };
- self.numbered = (($a = numbered !== false && numbered !== nil) ? $rb_gt(self.level, 0) : numbered);
- self.special = ($a = (($b = parent !== false && parent !== nil) ? parent.$context()['$==']("section") : parent), $a !== false && $a !== nil ?parent.$special() : $a);
- self.index = 0;
- return self.number = 1;
- });
-
- Opal.alias(self, 'name', 'title');
-
- Opal.defn(self, '$generate_id', function() {
- var $a, $b, self = this, sep = nil, pre = nil, base_id = nil, gen_id = nil, cnt = nil;
-
- if ((($a = self.document.$attributes()['$has_key?']("sectids")) !== nil && (!$a.$$is_boolean || $a == true))) {
- sep = ((($a = self.document.$attributes()['$[]']("idseparator")) !== false && $a !== nil) ? $a : "_");
- pre = ((($a = self.document.$attributes()['$[]']("idprefix")) !== false && $a !== nil) ? $a : "_");
- base_id = "" + (pre) + (self.$title().$downcase().$gsub($scope.get('InvalidSectionIdCharsRx'), sep).$tr_s(sep, sep).$chomp(sep));
- if ((($a = ($b = pre['$empty?'](), $b !== false && $b !== nil ?base_id['$start_with?'](sep) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- base_id = base_id['$[]']($range(1, -1, false));
- while ((($b = base_id['$start_with?'](sep)) !== nil && (!$b.$$is_boolean || $b == true))) {
- base_id = base_id['$[]']($range(1, -1, false))};};
- gen_id = base_id;
- cnt = $scope.get('Compliance').$unique_id_start_index();
- while ((($b = self.document.$references()['$[]']("ids")['$has_key?'](gen_id)) !== nil && (!$b.$$is_boolean || $b == true))) {
- gen_id = "" + (base_id) + (sep) + (cnt);
- cnt = $rb_plus(cnt, 1);};
- return gen_id;
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$sectnum', function(delimiter, append) {
- var $a, $b, $c, $d, self = this;
-
- if (delimiter == null) {
- delimiter = "."
- }
- if (append == null) {
- append = nil
- }
- ((($a = append) !== false && $a !== nil) ? $a : append = ((function() {if (append['$=='](false)) {
- return ""
- } else {
- return delimiter
- }; return nil; })()));
- if ((($a = ($b = ($c = ($d = self.level, $d !== false && $d !== nil ?$rb_gt(self.level, 1) : $d), $c !== false && $c !== nil ?self.parent : $c), $b !== false && $b !== nil ?self.parent.$context()['$==']("section") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (self.parent.$sectnum(delimiter)) + (self.number) + (append)
- } else {
- return "" + (self.number) + (append)
- };
- });
-
- Opal.defn(self, '$<<', TMP_2 = function(block) {var $zuper = $slice.call(arguments, 0);
- var self = this, $iter = TMP_2.$$p, $yield = $iter || nil;
-
- TMP_2.$$p = null;
- if (block.$context()['$==']("section")) {
- self.$assign_index(block)};
- return Opal.find_super_dispatcher(self, '<<', TMP_2, $iter).apply(self, $zuper);
- });
-
- return (Opal.defn(self, '$to_s', TMP_3 = function() {var $zuper = $slice.call(arguments, 0);
- var $a, self = this, $iter = TMP_3.$$p, $yield = $iter || nil, qualified_title = nil;
-
- TMP_3.$$p = null;
- if ((($a = self.title['$!='](nil)) !== nil && (!$a.$$is_boolean || $a == true))) {
- qualified_title = (function() {if ((($a = self.numbered) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "" + (self.$sectnum()) + " " + (self.title)
- } else {
- return self.title
- }; return nil; })();
- return "#<" + (self.$class()) + "@" + (self.$object_id()) + " {level: " + (self.level) + ", title: " + (qualified_title.$inspect()) + ", blocks: " + (self.blocks.$size()) + "}>";
- } else {
- return Opal.find_super_dispatcher(self, 'to_s', TMP_3, $iter).apply(self, $zuper)
- };
- }), nil) && 'to_s';
- })($scope.base, $scope.get('AbstractBlock'))
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/stylesheets"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2;
-
- Opal.add_stubs(['$join', '$new', '$chomp', '$read', '$primary_stylesheet_data', '$open', '$write', '$primary_stylesheet_name', '$coderay_stylesheet_data', '$coderay_stylesheet_name', '$load_pygments', '$pygments_stylesheet_data', '$pygments_stylesheet_name', '$!', '$nil?', '$require_library']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Stylesheets(){};
- var self = $Stylesheets = $klass($base, $super, 'Stylesheets', $Stylesheets);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.primary_stylesheet_data = def.coderay_stylesheet_data = def.pygments_stylesheet_data = nil;
- Opal.cdecl($scope, 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css");
-
- Opal.cdecl($scope, 'DEFAULT_PYGMENTS_STYLE', "default");
-
- Opal.cdecl($scope, 'STYLESHEETS_DATA_PATH', Opal.get('File').$join($scope.get('DATA_PATH'), "stylesheets"));
-
- self.__instance__ = self.$new();
-
- Opal.defs(self, '$instance', function() {
- var self = this;
- if (self.__instance__ == null) self.__instance__ = nil;
-
- return self.__instance__;
- });
-
- Opal.defn(self, '$primary_stylesheet_name', function() {
- var self = this;
-
- return $scope.get('DEFAULT_STYLESHEET_NAME');
- });
-
- Opal.defn(self, '$primary_stylesheet_data', function() {
- var $a, self = this;
-
- return ((($a = self.primary_stylesheet_data) !== false && $a !== nil) ? $a : self.primary_stylesheet_data = Opal.get('IO').$read(Opal.get('File').$join($scope.get('STYLESHEETS_DATA_PATH'), "asciidoctor-default.css")).$chomp());
- });
-
- Opal.defn(self, '$embed_primary_stylesheet', function() {
- var self = this;
-
- return "";
- });
-
- Opal.defn(self, '$write_primary_stylesheet', function(target_dir) {
- var $a, $b, TMP_1, self = this;
-
- return ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_1 = function(f){var self = TMP_1.$$s || this;
-if (f == null) f = nil;
- return f.$write(self.$primary_stylesheet_data())}, TMP_1.$$s = self, TMP_1), $a).call($b, Opal.get('File').$join(target_dir, self.$primary_stylesheet_name()), "w");
- });
-
- Opal.defn(self, '$coderay_stylesheet_name', function() {
- var self = this;
-
- return "coderay-asciidoctor.css";
- });
-
- Opal.defn(self, '$coderay_stylesheet_data', function() {
- var $a, self = this;
-
- return ((($a = self.coderay_stylesheet_data) !== false && $a !== nil) ? $a : self.coderay_stylesheet_data = Opal.get('IO').$read(Opal.get('File').$join($scope.get('STYLESHEETS_DATA_PATH'), "coderay-asciidoctor.css")).$chomp());
- });
-
- Opal.defn(self, '$embed_coderay_stylesheet', function() {
- var self = this;
-
- return "";
- });
-
- Opal.defn(self, '$write_coderay_stylesheet', function(target_dir) {
- var $a, $b, TMP_2, self = this;
-
- return ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_2 = function(f){var self = TMP_2.$$s || this;
-if (f == null) f = nil;
- return f.$write(self.$coderay_stylesheet_data())}, TMP_2.$$s = self, TMP_2), $a).call($b, Opal.get('File').$join(target_dir, self.$coderay_stylesheet_name()), "w");
- });
-
- Opal.defn(self, '$pygments_stylesheet_name', function(style) {
- var $a, self = this;
-
- if (style == null) {
- style = nil
- }
- return "pygments-" + (((($a = style) !== false && $a !== nil) ? $a : $scope.get('DEFAULT_PYGMENTS_STYLE'))) + ".css";
- });
-
- Opal.defn(self, '$pygments_stylesheet_data', function(style) {
- var $a, self = this;
-
- if (style == null) {
- style = nil
- }
- if ((($a = self.$load_pygments()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (((($a = self.pygments_stylesheet_data) !== false && $a !== nil) ? $a : self.pygments_stylesheet_data = $hash2([], {})))
- } else {
- return "/* Pygments styles disabled. Pygments is not available. */"
- };
- });
-
- Opal.defn(self, '$embed_pygments_stylesheet', function(style) {
- var self = this;
-
- if (style == null) {
- style = nil
- }
- return "";
- });
-
- Opal.defn(self, '$write_pygments_stylesheet', function(target_dir, style) {
- var $a, $b, TMP_3, self = this;
-
- if (style == null) {
- style = nil
- }
- return ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_3 = function(f){var self = TMP_3.$$s || this;
-if (f == null) f = nil;
- return f.$write(self.$pygments_stylesheet_data(style))}, TMP_3.$$s = self, TMP_3), $a).call($b, Opal.get('File').$join(target_dir, self.$pygments_stylesheet_name(style)), "w");
- });
-
- return (Opal.defn(self, '$load_pygments', function() {
- var $a, self = this;
-
- if ((($a = ((Opal.Object.$$scope.Pygments == null ? nil : 'constant'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return true
- } else {
- return ($scope.get('Helpers').$require_library("pygments", "pygments.rb", "ignore"))['$nil?']()['$!']()
- };
- }), nil) && 'load_pygments';
- })($scope.base, null)
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-Opal.modules["asciidoctor/table"] = function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_divide(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs);
- }
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_minus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range;
-
- Opal.add_stubs(['$attr_accessor', '$new', '$key?', '$[]', '$abs', '$to_i', '$==', '$!=', '$>', '$[]=', '$attributes', '$round', '$*', '$/', '$to_f', '$empty?', '$body', '$each', '$+', '$<<', '$size', '$assign_col_widths', '$**', '$assign_width', '$-', '$shift', '$style=', '$head=', '$foot=', '$pop', '$update_attributes', '$parent', '$attr_reader', '$delete', '$!', '$header_row?', '$table', '$split', '$include?', '$readlines', '$unshift', '$nil?', '$strip', '$apply_normal_subs', '$convert', '$map', '$text', '$to_s', '$cursor', '$raise', '$nested?', '$document', '$escape', '$columns', '$start_with?', '$match', '$chop', '$pre_match', '$post_match', '$end_with?', '$lstrip', '$push_cell_spec', '$cell_open?', '$close_cell', '$advance', '$take_cell_spec', '$fetch', '$warn', '$line_info', '$tr_s', '$upto', '$times', '$rowspan', '$activate_rowspan', '$colspan', '$end_of_row?', '$close_row', '$rows', '$effective_col_visits']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Table(){};
- var self = $Table = $klass($base, $super, 'Table', $Table);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_1;
-
- def.attributes = def.document = def.has_header_option = def.rows = def.columns = nil;
- (function($base, $super) {
- function $Rows(){};
- var self = $Rows = $klass($base, $super, 'Rows', $Rows);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$attr_accessor("head", "foot", "body");
-
- Opal.defn(self, '$initialize', function(head, foot, body) {
- var self = this;
-
- if (head == null) {
- head = []
- }
- if (foot == null) {
- foot = []
- }
- if (body == null) {
- body = []
- }
- self.head = head;
- self.foot = foot;
- return self.body = body;
- });
-
- return Opal.alias(self, '[]', 'send');
- })($scope.base, null);
-
- Opal.cdecl($scope, 'DEFAULT_DATA_FORMAT', "psv");
-
- Opal.cdecl($scope, 'DATA_FORMATS', ["psv", "dsv", "csv"]);
-
- Opal.cdecl($scope, 'DEFAULT_DELIMITERS', $hash2(["psv", "dsv", "csv"], {"psv": "|", "dsv": ":", "csv": ","}));
-
- Opal.cdecl($scope, 'TEXT_STYLES', $hash2(["d", "s", "e", "m", "h", "l", "v", "a"], {"d": "none", "s": "strong", "e": "emphasis", "m": "monospaced", "h": "header", "l": "literal", "v": "verse", "a": "asciidoc"}));
-
- Opal.cdecl($scope, 'ALIGNMENTS', $hash2(["h", "v"], {"h": $hash2(["<", ">", "^"], {"<": "left", ">": "right", "^": "center"}), "v": $hash2(["<", ">", "^"], {"<": "top", ">": "bottom", "^": "middle"})}));
-
- self.$attr_accessor("columns");
-
- self.$attr_accessor("rows");
-
- self.$attr_accessor("has_header_option");
-
- Opal.defn(self, '$initialize', TMP_1 = function(parent, attributes) {
- var $a, $b, $c, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, pcwidth = nil, pcwidth_intval = nil;
-
- TMP_1.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_1, null).apply(self, [parent, "table"]);
- self.rows = $scope.get('Rows').$new();
- self.columns = [];
- self.has_header_option = attributes['$key?']("header-option");
- pcwidth = attributes['$[]']("width");
- pcwidth_intval = pcwidth.$to_i().$abs();
- if ((($a = ((($b = (($c = pcwidth_intval['$=='](0)) ? pcwidth['$!=']("0") : pcwidth_intval['$=='](0))) !== false && $b !== nil) ? $b : $rb_gt(pcwidth_intval, 100))) !== nil && (!$a.$$is_boolean || $a == true))) {
- pcwidth_intval = 100};
- self.attributes['$[]=']("tablepcwidth", pcwidth_intval);
- if ((($a = self.document.$attributes()['$key?']("pagewidth")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = "tableabswidth", $b = self.attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, ($rb_times(($rb_divide(self.attributes['$[]']("tablepcwidth").$to_f(), 100)), self.document.$attributes()['$[]']("pagewidth"))).$round())))
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$header_row?', function() {
- var $a, self = this;
-
- return ($a = self.has_header_option, $a !== false && $a !== nil ?self.rows.$body()['$empty?']() : $a);
- });
-
- Opal.defn(self, '$create_columns', function(col_specs) {
- var $a, $b, TMP_2, self = this, cols = nil, width_base = nil;
-
- cols = [];
- width_base = 0;
- ($a = ($b = col_specs).$each, $a.$$p = (TMP_2 = function(col_spec){var self = TMP_2.$$s || this;
-if (col_spec == null) col_spec = nil;
- width_base = $rb_plus(width_base, col_spec['$[]']("width"));
- return cols['$<<'](($scope.get('Column').$new(self, cols.$size(), col_spec)));}, TMP_2.$$s = self, TMP_2), $a).call($b);
- if ((($a = (self.columns = cols)['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.attributes['$[]=']("colcount", cols.$size());
- self.$assign_col_widths((function() {if (width_base['$=='](0)) {
- return nil
- } else {
- return width_base
- }; return nil; })());
- };
- return nil;
- });
-
- Opal.defn(self, '$assign_col_widths', function(width_base) {
- var $a, $b, TMP_3, $c, TMP_4, self = this, pf = nil, total_width = nil, col_pcwidth = nil;
-
- if (width_base == null) {
- width_base = nil
- }
- pf = (10.0)['$**'](4);
- total_width = col_pcwidth = 0;
- if (width_base !== false && width_base !== nil) {
- ($a = ($b = self.columns).$each, $a.$$p = (TMP_3 = function(col){var self = TMP_3.$$s || this;
-if (col == null) col = nil;
- return total_width = $rb_plus(total_width, (col_pcwidth = col.$assign_width(nil, width_base, pf)))}, TMP_3.$$s = self, TMP_3), $a).call($b)
- } else {
- col_pcwidth = $rb_divide((($rb_divide($rb_times(100, pf), self.columns.$size())).$to_i()), pf);
- if (col_pcwidth.$to_i()['$=='](col_pcwidth)) {
- col_pcwidth = col_pcwidth.$to_i()};
- ($a = ($c = self.columns).$each, $a.$$p = (TMP_4 = function(col){var self = TMP_4.$$s || this;
-if (col == null) col = nil;
- return total_width = $rb_plus(total_width, col.$assign_width(col_pcwidth))}, TMP_4.$$s = self, TMP_4), $a).call($c);
- };
- if (total_width['$=='](100)) {
- } else {
- self.columns['$[]'](-1).$assign_width($rb_divide(($rb_times(($rb_plus($rb_minus(100, total_width), col_pcwidth)), pf)).$round(), pf))
- };
- return nil;
- });
-
- return (Opal.defn(self, '$partition_header_footer', function(attributes) {
- var $a, $b, TMP_5, $c, self = this, num_body_rows = nil, head = nil;
-
- self.attributes['$[]=']("rowcount", self.rows.$body().$size());
- num_body_rows = self.rows.$body().$size();
- if ((($a = (($b = $rb_gt(num_body_rows, 0)) ? self.has_header_option : $rb_gt(num_body_rows, 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- head = self.rows.$body().$shift();
- num_body_rows = $rb_minus(num_body_rows, 1);
- ($a = ($b = head).$each, $a.$$p = (TMP_5 = function(c){var self = TMP_5.$$s || this, $a, $b;
-if (c == null) c = nil;
- return (($a = [nil]), $b = c, $b['$style='].apply($b, $a), $a[$a.length-1])}, TMP_5.$$s = self, TMP_5), $a).call($b);
- (($a = [[head]]), $c = self.rows, $c['$head='].apply($c, $a), $a[$a.length-1]);};
- if ((($a = (($c = $rb_gt(num_body_rows, 0)) ? attributes['$key?']("footer-option") : $rb_gt(num_body_rows, 0))) !== nil && (!$a.$$is_boolean || $a == true))) {
- (($a = [[self.rows.$body().$pop()]]), $c = self.rows, $c['$foot='].apply($c, $a), $a[$a.length-1])};
- return nil;
- }), nil) && 'partition_header_footer';
- })($scope.base, $scope.get('AbstractBlock'));
-
- (function($base, $super) {
- function $Column(){};
- var self = $Column = $klass($base, $super, 'Column', $Column);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_6;
-
- def.attributes = nil;
- self.$attr_accessor("style");
-
- Opal.defn(self, '$initialize', TMP_6 = function(table, index, attributes) {
- var $a, $b, $c, self = this, $iter = TMP_6.$$p, $yield = $iter || nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- TMP_6.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_6, null).apply(self, [table, "column"]);
- self.style = attributes['$[]']("style");
- attributes['$[]=']("colnumber", $rb_plus(index, 1));
- ($a = "width", $b = attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, 1)));
- ($a = "halign", $b = attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "left")));
- ($a = "valign", $b = attributes, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "top")));
- return self.$update_attributes(attributes);
- });
-
- Opal.alias(self, 'table', 'parent');
-
- return (Opal.defn(self, '$assign_width', function(col_pcwidth, width_base, pf) {
- var $a, self = this;
-
- if (width_base == null) {
- width_base = nil
- }
- if (pf == null) {
- pf = 10000.0
- }
- if (width_base !== false && width_base !== nil) {
- col_pcwidth = $rb_divide(($rb_times($rb_times(($rb_divide(self.attributes['$[]']("width").$to_f(), width_base)), 100), pf)).$to_i(), pf);
- if (col_pcwidth.$to_i()['$=='](col_pcwidth)) {
- col_pcwidth = col_pcwidth.$to_i()};};
- self.attributes['$[]=']("colpcwidth", col_pcwidth);
- if ((($a = self.$parent().$attributes()['$key?']("tableabswidth")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.attributes['$[]=']("colabswidth", ($rb_times(($rb_divide(col_pcwidth, 100.0)), self.$parent().$attributes()['$[]']("tableabswidth"))).$round())};
- return col_pcwidth;
- }), nil) && 'assign_width';
- })($scope.get('Table'), $scope.get('AbstractNode'));
-
- (function($base, $super) {
- function $Cell(){};
- var self = $Cell = $klass($base, $super, 'Cell', $Cell);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_7, TMP_9;
-
- def.style = def.document = def.text = def.inner_document = def.colspan = def.rowspan = def.attributes = nil;
- self.$attr_accessor("style");
-
- self.$attr_accessor("colspan");
-
- self.$attr_accessor("rowspan");
-
- Opal.alias(self, 'column', 'parent');
-
- self.$attr_reader("inner_document");
-
- Opal.defn(self, '$initialize', TMP_7 = function(column, text, attributes, cursor) {
- var $a, $b, self = this, $iter = TMP_7.$$p, $yield = $iter || nil, parent_doctitle = nil, inner_document_lines = nil, unprocessed_lines = nil, processed_lines = nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- if (cursor == null) {
- cursor = nil
- }
- TMP_7.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_7, null).apply(self, [column, "cell"]);
- self.text = text;
- self.style = nil;
- self.colspan = nil;
- self.rowspan = nil;
- if (column !== false && column !== nil) {
- self.style = column.$attributes()['$[]']("style");
- self.$update_attributes(column.$attributes());};
- if (attributes !== false && attributes !== nil) {
- self.colspan = attributes.$delete("colspan");
- self.rowspan = attributes.$delete("rowspan");
- if ((($a = attributes['$key?']("style")) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.style = attributes['$[]']("style")};
- self.$update_attributes(attributes);};
- if ((($a = (($b = self.style['$==']("asciidoc")) ? column.$table()['$header_row?']()['$!']() : self.style['$==']("asciidoc"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- parent_doctitle = self.document.$attributes().$delete("doctitle");
- inner_document_lines = self.text.$split($scope.get('EOL'));
- if ((($a = ((($b = inner_document_lines['$empty?']()) !== false && $b !== nil) ? $b : inner_document_lines['$[]'](0)['$include?']("::")['$!']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- unprocessed_lines = inner_document_lines['$[]'](0);
- processed_lines = $scope.get('PreprocessorReader').$new(self.document, unprocessed_lines).$readlines();
- if ((($a = processed_lines['$!='](unprocessed_lines)) !== nil && (!$a.$$is_boolean || $a == true))) {
- inner_document_lines.$shift();
- ($a = inner_document_lines).$unshift.apply($a, Opal.to_a(processed_lines));};
- };
- self.inner_document = $scope.get('Document').$new(inner_document_lines, $hash2(["header_footer", "parent", "cursor"], {"header_footer": false, "parent": self.document, "cursor": cursor}));
- if ((($b = parent_doctitle['$nil?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- return nil
- } else {
- return self.document.$attributes()['$[]=']("doctitle", parent_doctitle)
- };
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$text', function() {
- var self = this;
-
- return self.$apply_normal_subs(self.text).$strip();
- });
-
- Opal.defn(self, '$content', function() {
- var $a, $b, TMP_8, self = this;
-
- if (self.style['$==']("asciidoc")) {
- return self.inner_document.$convert()
- } else {
- return ($a = ($b = self.$text().$split($scope.get('BlankLineRx'))).$map, $a.$$p = (TMP_8 = function(p){var self = TMP_8.$$s || this, $a, $b;
- if (self.style == null) self.style = nil;
-if (p == null) p = nil;
- if ((($a = ((($b = self.style['$!']()) !== false && $b !== nil) ? $b : self.style['$==']("header"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return p
- } else {
- return $scope.get('Inline').$new(self.$parent(), "quoted", p, $hash2(["type"], {"type": self.style})).$convert()
- }}, TMP_8.$$s = self, TMP_8), $a).call($b)
- };
- });
-
- return (Opal.defn(self, '$to_s', TMP_9 = function() {var $zuper = $slice.call(arguments, 0);
- var $a, self = this, $iter = TMP_9.$$p, $yield = $iter || nil;
-
- TMP_9.$$p = null;
- return "" + (Opal.find_super_dispatcher(self, 'to_s', TMP_9, $iter).apply(self, $zuper).$to_s()) + " - [text: " + (self.text) + ", colspan: " + (((($a = self.colspan) !== false && $a !== nil) ? $a : 1)) + ", rowspan: " + (((($a = self.rowspan) !== false && $a !== nil) ? $a : 1)) + ", attributes: " + (self.attributes) + "]";
- }), nil) && 'to_s';
- })($scope.get('Table'), $scope.get('AbstractNode'));
-
- (function($base, $super) {
- function $ParserContext(){};
- var self = $ParserContext = $klass($base, $super, 'ParserContext', $ParserContext);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.format = def.delimiter = def.delimiter_re = def.buffer = def.cell_specs = def.cell_open = def.last_cursor = def.table = def.current_row = def.col_count = def.col_visits = def.active_rowspans = def.linenum = nil;
- self.$attr_accessor("table");
-
- self.$attr_accessor("format");
-
- self.$attr_reader("col_count");
-
- self.$attr_accessor("buffer");
-
- self.$attr_reader("delimiter");
-
- self.$attr_reader("delimiter_re");
-
- Opal.defn(self, '$initialize', function(reader, table, attributes) {
- var $a, $b, $c, self = this;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- self.reader = reader;
- self.table = table;
- self.last_cursor = reader.$cursor();
- if ((($a = (self.format = attributes['$[]']("format"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (($scope.get('Table')).$$scope.get('DATA_FORMATS'))['$include?'](self.format)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise("Illegal table format: " + (self.format))
- }
- } else {
- self.format = (($scope.get('Table')).$$scope.get('DEFAULT_DATA_FORMAT'))
- };
- self.delimiter = (function() {if ((($a = ($b = (($c = self.format['$==']("psv")) ? (attributes['$key?']("separator"))['$!']() : self.format['$==']("psv")), $b !== false && $b !== nil ?table.$document()['$nested?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return "!"
- } else {
- return ((($a = attributes['$[]']("separator")) !== false && $a !== nil) ? $a : (($scope.get('Table')).$$scope.get('DEFAULT_DELIMITERS'))['$[]'](self.format))
- }; return nil; })();
- self.delimiter_re = (new RegExp("" + $scope.get('Regexp').$escape(self.delimiter)));
- self.col_count = (function() {if ((($a = table.$columns()['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return -1
- } else {
- return table.$columns().$size()
- }; return nil; })();
- self.buffer = "";
- self.cell_specs = [];
- self.cell_open = false;
- self.active_rowspans = [0];
- self.col_visits = 0;
- self.current_row = [];
- return self.linenum = -1;
- });
-
- Opal.defn(self, '$starts_with_delimiter?', function(line) {
- var self = this;
-
- return line['$start_with?'](self.delimiter);
- });
-
- Opal.defn(self, '$match_delimiter', function(line) {
- var self = this;
-
- return self.delimiter_re.$match(line);
- });
-
- Opal.defn(self, '$skip_matched_delimiter', function(match, escaped) {
- var self = this;
-
- if (escaped == null) {
- escaped = false
- }
- self.buffer = "" + (self.buffer) + ((function() {if (escaped !== false && escaped !== nil) {
- return match.$pre_match().$chop()
- } else {
- return match.$pre_match()
- }; return nil; })()) + (self.delimiter);
- return match.$post_match();
- });
-
- Opal.defn(self, '$buffer_has_unclosed_quotes?', function(append) {
- var $a, $b, self = this, record = nil;
-
- if (append == null) {
- append = nil
- }
- record = ((("") + (self.buffer)) + (append)).$strip();
- return ($a = ($b = record['$start_with?']("\""), $b !== false && $b !== nil ?record['$start_with?']("\"\"")['$!']() : $b), $a !== false && $a !== nil ?record['$end_with?']("\"")['$!']() : $a);
- });
-
- Opal.defn(self, '$buffer_quoted?', function() {
- var $a, self = this;
-
- self.buffer = self.buffer.$lstrip();
- return ($a = self.buffer['$start_with?']("\""), $a !== false && $a !== nil ?self.buffer['$start_with?']("\"\"")['$!']() : $a);
- });
-
- Opal.defn(self, '$take_cell_spec', function() {
- var self = this;
-
- return self.cell_specs.$shift();
- });
-
- Opal.defn(self, '$push_cell_spec', function(cell_spec) {
- var $a, self = this;
-
- if (cell_spec == null) {
- cell_spec = $hash2([], {})
- }
- self.cell_specs['$<<']((((($a = cell_spec) !== false && $a !== nil) ? $a : $hash2([], {}))));
- return nil;
- });
-
- Opal.defn(self, '$keep_cell_open', function() {
- var self = this;
-
- self.cell_open = true;
- return nil;
- });
-
- Opal.defn(self, '$mark_cell_closed', function() {
- var self = this;
-
- self.cell_open = false;
- return nil;
- });
-
- Opal.defn(self, '$cell_open?', function() {
- var self = this;
-
- return self.cell_open;
- });
-
- Opal.defn(self, '$cell_closed?', function() {
- var self = this;
-
- return self.cell_open['$!']();
- });
-
- Opal.defn(self, '$close_open_cell', function(next_cell_spec) {
- var $a, self = this;
-
- if (next_cell_spec == null) {
- next_cell_spec = $hash2([], {})
- }
- self.$push_cell_spec(next_cell_spec);
- if ((($a = self['$cell_open?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$close_cell(true)};
- self.$advance();
- return nil;
- });
-
- Opal.defn(self, '$close_cell', function(eol) {try {
-
- var $a, $b, TMP_10, self = this, cell_text = nil, cell_spec = nil, repeat = nil;
-
- if (eol == null) {
- eol = false
- }
- cell_text = self.buffer.$strip();
- self.buffer = "";
- if (self.format['$==']("psv")) {
- cell_spec = self.$take_cell_spec();
- if (cell_spec !== false && cell_spec !== nil) {
- repeat = cell_spec.$fetch("repeatcol", 1);
- cell_spec.$delete("repeatcol");
- } else {
- self.$warn("asciidoctor: ERROR: " + (self.last_cursor.$line_info()) + ": table missing leading separator, recovering automatically");
- cell_spec = $hash2([], {});
- repeat = 1;
- };
- } else {
- cell_spec = nil;
- repeat = 1;
- if (self.format['$==']("csv")) {
- if ((($a = ($b = cell_text['$empty?']()['$!'](), $b !== false && $b !== nil ?cell_text['$include?']("\"") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ($b = cell_text['$start_with?']("\""), $b !== false && $b !== nil ?cell_text['$end_with?']("\"") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- cell_text = cell_text['$[]']($range(1, -1, true)).$strip()};
- cell_text = cell_text.$tr_s("\"", "\"");}};
- };
- ($a = ($b = (1)).$upto, $a.$$p = (TMP_10 = function(i){var self = TMP_10.$$s || this, $a, $b, $c, TMP_11, $d, $e, column = nil, extra_cols = nil, offset = nil, cell = nil;
- if (self.col_count == null) self.col_count = nil;
- if (self.table == null) self.table = nil;
- if (self.current_row == null) self.current_row = nil;
- if (self.last_cursor == null) self.last_cursor = nil;
- if (self.reader == null) self.reader = nil;
- if (self.col_visits == null) self.col_visits = nil;
- if (self.linenum == null) self.linenum = nil;
-if (i == null) i = nil;
- if (self.col_count['$=='](-1)) {
- self.table.$columns()['$<<']((column = (($scope.get('Table')).$$scope.get('Column')).$new(self.table, $rb_minus($rb_plus(self.table.$columns().$size(), i), 1))));
- if ((($a = ($b = (($c = cell_spec !== false && cell_spec !== nil) ? (cell_spec['$key?']("colspan")) : cell_spec), $b !== false && $b !== nil ?$rb_gt((extra_cols = $rb_minus(cell_spec['$[]']("colspan").$to_i(), 1)), 0) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- offset = self.table.$columns().$size();
- ($a = ($b = extra_cols).$times, $a.$$p = (TMP_11 = function(j){var self = TMP_11.$$s || this;
- if (self.table == null) self.table = nil;
-if (j == null) j = nil;
- return self.table.$columns()['$<<']((($scope.get('Table')).$$scope.get('Column')).$new(self.table, $rb_plus(offset, j)))}, TMP_11.$$s = self, TMP_11), $a).call($b);};
- } else if ((($a = (column = self.table.$columns()['$[]'](self.current_row.$size()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$warn("asciidoctor: ERROR: " + (self.last_cursor.$line_info()) + ": dropping cell because it exceeds specified number of columns");
- Opal.ret(nil);
- };
- cell = (($scope.get('Table')).$$scope.get('Cell')).$new(column, cell_text, cell_spec, self.last_cursor);
- self.last_cursor = self.reader.$cursor();
- if ((($a = ((($c = cell.$rowspan()['$!']()) !== false && $c !== nil) ? $c : cell.$rowspan()['$=='](1))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$activate_rowspan(cell.$rowspan(), (((($a = cell.$colspan()) !== false && $a !== nil) ? $a : 1)))
- };
- self.col_visits = $rb_plus(self.col_visits, (((($a = cell.$colspan()) !== false && $a !== nil) ? $a : 1)));
- self.current_row['$<<'](cell);
- if ((($a = ($c = self['$end_of_row?'](), $c !== false && $c !== nil ?(((($d = ((($e = self.col_count['$!='](-1)) !== false && $e !== nil) ? $e : $rb_gt(self.linenum, 0))) !== false && $d !== nil) ? $d : ((($e = eol !== false && eol !== nil) ? i['$=='](repeat) : eol)))) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$close_row()
- } else {
- return nil
- };}, TMP_10.$$s = self, TMP_10), $a).call($b, repeat);
- self.cell_open = false;
- return nil;
- } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; }
- });
-
- Opal.defn(self, '$close_row', function() {
- var $a, $b, $c, self = this;
-
- self.table.$rows().$body()['$<<'](self.current_row);
- if (self.col_count['$=='](-1)) {
- self.col_count = self.col_visits};
- self.col_visits = 0;
- self.current_row = [];
- self.active_rowspans.$shift();
- ($a = 0, $b = self.active_rowspans, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, 0)));
- return nil;
- });
-
- Opal.defn(self, '$activate_rowspan', function(rowspan, colspan) {
- var $a, $b, TMP_12, self = this;
-
- ($a = ($b = (1).$upto($rb_minus(rowspan, 1))).$each, $a.$$p = (TMP_12 = function(i){var self = TMP_12.$$s || this, $a;
- if (self.active_rowspans == null) self.active_rowspans = nil;
-if (i == null) i = nil;
- return self.active_rowspans['$[]='](i, $rb_plus((((($a = self.active_rowspans['$[]'](i)) !== false && $a !== nil) ? $a : 0)), colspan))}, TMP_12.$$s = self, TMP_12), $a).call($b);
- return nil;
- });
-
- Opal.defn(self, '$end_of_row?', function() {
- var $a, self = this;
-
- return ((($a = self.col_count['$=='](-1)) !== false && $a !== nil) ? $a : self.$effective_col_visits()['$=='](self.col_count));
- });
-
- Opal.defn(self, '$effective_col_visits', function() {
- var self = this;
-
- return $rb_plus(self.col_visits, self.active_rowspans['$[]'](0));
- });
-
- return (Opal.defn(self, '$advance', function() {
- var self = this;
-
- return self.linenum = $rb_plus(self.linenum, 1);
- }), nil) && 'advance';
- })($scope.get('Table'), null);
- })($scope.base)
-};
-
-/* Generated by Opal 0.9.0.beta2 */
-(function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_ge(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs);
- }
- function $rb_times(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- var $a, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $gvars = Opal.gvars, $module = Opal.module, $hash2 = Opal.hash2, $range = Opal.range, $hash = Opal.hash;
- if ($gvars[":"] == null) $gvars[":"] = nil;
-
- Opal.add_stubs(['$==', '$>=', '$require', '$unshift', '$dirname', '$new', '$attr', '$instance_variable_set', '$send', '$<<', '$define', '$expand_path', '$join', '$home', '$[]', '$pwd', '$!', '$!=', '$default_external', '$to_a', '$bytes', '$to_set', '$map', '$keys', '$*', '$dup', '$[]=', '$insert', '$start', '$===', '$inject', '$split', '$gsub', '$respond_to?', '$each', '$raise', '$ancestors', '$class', '$path', '$mtime', '$readlines', '$basename', '$strftime', '$rewind', '$entries', '$lines', '$record', '$parse', '$exception', '$message', '$set_backtrace', '$backtrace', '$stack_trace=', '$stack_trace', '$load', '$delete', '$key?', '$attributes', '$outfilesuffix', '$has_key?', '$safe', '$normalize_system_path', '$directory?', '$mkdir_p', '$convert', '$write', '$<', '$attr?', '$uriish?', '$include?', '$write_primary_stylesheet', '$instance', '$empty?', '$nil?', '$read_asset', '$open', '$write_coderay_stylesheet', '$write_pygments_stylesheet']);
- if ((($a = ($scope.RUBY_ENGINE != null)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- Opal.cdecl($scope, 'RUBY_ENGINE', "unknown")
- };
- Opal.cdecl($scope, 'RUBY_ENGINE_OPAL', ($scope.get('RUBY_ENGINE')['$==']("opal")));
- Opal.cdecl($scope, 'RUBY_ENGINE_JRUBY', ($scope.get('RUBY_ENGINE')['$==']("jruby")));
- Opal.cdecl($scope, 'RUBY_MIN_VERSION_1_9', ($rb_ge($scope.get('RUBY_VERSION'), "1.9")));
- Opal.cdecl($scope, 'RUBY_MIN_VERSION_2', ($rb_ge($scope.get('RUBY_VERSION'), "2")));
- self.$require("set");
- if ($scope.get('RUBY_ENGINE')['$==']("opal")) {
- self.$require("asciidoctor/opal_ext")};
- $gvars[":"].$unshift($scope.get('File').$dirname("asciidoctor"));
- (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope, $a, $b, TMP_1, quote_subs = nil, compat_quote_subs = nil;
-
- Opal.cdecl($scope, 'RUBY_ENGINE', Opal.get('RUBY_ENGINE'));
-
- (function($base) {
- var self = $module($base, 'SafeMode');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.cdecl($scope, 'UNSAFE', 0);
-
- Opal.cdecl($scope, 'SAFE', 1);
-
- Opal.cdecl($scope, 'SERVER', 10);
-
- Opal.cdecl($scope, 'SECURE', 20);
- })($scope.base);
-
- (function($base) {
- var self = $module($base, 'Compliance');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.keys = Opal.get('Set').$new();
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- return self.$attr("keys")
- })(Opal.get_singleton_class(self));
-
- Opal.defs(self, '$define', function(key, value) {
- var self = this;
- if (self.keys == null) self.keys = nil;
-
- self.$instance_variable_set("@" + (key), value);
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- return self
- })(Opal.get_singleton_class(self)).$send("attr_accessor", key);
- self.keys['$<<'](key);
- return nil;
- });
-
- self.$define("block_terminates_paragraph", true);
-
- self.$define("strict_verbatim_paragraphs", true);
-
- self.$define("underline_style_section_titles", true);
-
- self.$define("unwrap_standalone_preamble", true);
-
- self.$define("attribute_missing", "skip");
-
- self.$define("attribute_undefined", "drop-line");
-
- self.$define("shorthand_property_syntax", true);
-
- self.$define("unique_id_start_index", 2);
-
- self.$define("markdown_syntax", true);
- })($scope.base);
-
- Opal.cdecl($scope, 'ROOT_PATH', Opal.get('File').$dirname(Opal.get('File').$dirname(Opal.get('File').$expand_path("asciidoctor"))));
-
- Opal.cdecl($scope, 'LIB_PATH', Opal.get('File').$join($scope.get('ROOT_PATH'), "lib"));
-
- Opal.cdecl($scope, 'DATA_PATH', Opal.get('File').$join($scope.get('ROOT_PATH'), "data"));
-
- try {
- Opal.cdecl($scope, 'USER_HOME', Opal.get('Dir').$home())
- } catch ($err) {if (true) {
- try {
- Opal.cdecl($scope, 'USER_HOME', ((($a = Opal.get('ENV')['$[]']("HOME")) !== false && $a !== nil) ? $a : Opal.get('Dir').$pwd()))
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
-
- Opal.cdecl($scope, 'COERCE_ENCODING', ($a = Opal.get('RUBY_ENGINE_OPAL')['$!'](), $a !== false && $a !== nil ?Opal.get('RUBY_MIN_VERSION_1_9') : $a));
-
- Opal.cdecl($scope, 'FORCE_ENCODING', ($a = $scope.get('COERCE_ENCODING'), $a !== false && $a !== nil ?Opal.get('Encoding').$default_external()['$!='](((Opal.get('Encoding')).$$scope.get('UTF_8'))) : $a));
-
- Opal.cdecl($scope, 'BOM_BYTES_UTF_8', "\xEF\xBB\xBF".$bytes().$to_a());
-
- Opal.cdecl($scope, 'BOM_BYTES_UTF_16LE', "\xFF\xFE".$bytes().$to_a());
-
- Opal.cdecl($scope, 'BOM_BYTES_UTF_16BE', "\xFE\xFF".$bytes().$to_a());
-
- Opal.cdecl($scope, 'FORCE_UNICODE_LINE_LENGTH', Opal.get('RUBY_MIN_VERSION_1_9')['$!']());
-
- Opal.cdecl($scope, 'SUPPORTS_GSUB_RESULT_HASH', ($a = Opal.get('RUBY_MIN_VERSION_1_9'), $a !== false && $a !== nil ?Opal.get('RUBY_ENGINE_OPAL')['$!']() : $a));
-
- Opal.cdecl($scope, 'EOL', "\n");
-
- Opal.cdecl($scope, 'NULL', "\x00");
-
- Opal.cdecl($scope, 'TAB', "\t");
-
- Opal.cdecl($scope, 'DEFAULT_DOCTYPE', "article");
-
- Opal.cdecl($scope, 'DEFAULT_BACKEND', "html5");
-
- Opal.cdecl($scope, 'DEFAULT_STYLESHEET_KEYS', ["", "DEFAULT"].$to_set());
-
- Opal.cdecl($scope, 'DEFAULT_STYLESHEET_NAME', "asciidoctor.css");
-
- Opal.cdecl($scope, 'BACKEND_ALIASES', $hash2(["html", "docbook"], {"html": "html5", "docbook": "docbook5"}));
-
- Opal.cdecl($scope, 'DEFAULT_PAGE_WIDTHS', $hash2(["docbook"], {"docbook": 425}));
-
- Opal.cdecl($scope, 'DEFAULT_EXTENSIONS', $hash2(["html", "docbook", "pdf", "epub", "asciidoc"], {"html": ".html", "docbook": ".xml", "pdf": ".pdf", "epub": ".epub", "asciidoc": ".adoc"}));
-
- Opal.cdecl($scope, 'ASCIIDOC_EXTENSIONS', $hash2([".asciidoc", ".adoc", ".ad", ".asc", ".txt"], {".asciidoc": true, ".adoc": true, ".ad": true, ".asc": true, ".txt": true}));
-
- Opal.cdecl($scope, 'SECTION_LEVELS', $hash2(["=", "-", "~", "^", "+"], {"=": 0, "-": 1, "~": 2, "^": 3, "+": 4}));
-
- Opal.cdecl($scope, 'ADMONITION_STYLES', ["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"].$to_set());
-
- Opal.cdecl($scope, 'PARAGRAPH_STYLES', ["comment", "example", "literal", "listing", "normal", "pass", "quote", "sidebar", "source", "verse", "abstract", "partintro"].$to_set());
-
- Opal.cdecl($scope, 'VERBATIM_STYLES', ["literal", "listing", "source", "verse"].$to_set());
-
- Opal.cdecl($scope, '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", Opal.get('Set').$new()], "____": ["quote", ["verse"].$to_set()], "\"\"": ["quote", ["verse"].$to_set()], "++++": ["pass", ["stem", "latexmath", "asciimath"].$to_set()], "|===": ["table", Opal.get('Set').$new()], ",===": ["table", Opal.get('Set').$new()], ":===": ["table", Opal.get('Set').$new()], "!===": ["table", Opal.get('Set').$new()], "////": ["comment", Opal.get('Set').$new()], "```": ["fenced_code", Opal.get('Set').$new()]}));
-
- Opal.cdecl($scope, 'DELIMITED_BLOCK_LEADERS', ($a = ($b = $scope.get('DELIMITED_BLOCKS').$keys()).$map, $a.$$p = (TMP_1 = function(key){var self = TMP_1.$$s || this;
-if (key == null) key = nil;
- return key['$[]']($range(0, 1, false))}, TMP_1.$$s = self, TMP_1), $a).call($b).$to_set());
-
- Opal.cdecl($scope, 'LAYOUT_BREAK_LINES', $hash2(["'", "-", "*", "_", "<"], {"'": "thematic_break", "-": "thematic_break", "*": "thematic_break", "_": "thematic_break", "<": "page_break"}));
-
- Opal.cdecl($scope, 'NESTABLE_LIST_CONTEXTS', ["ulist", "olist", "dlist"]);
-
- Opal.cdecl($scope, 'ORDERED_LIST_STYLES', ["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"]);
-
- Opal.cdecl($scope, 'ORDERED_LIST_KEYWORDS', $hash2(["loweralpha", "lowerroman", "upperalpha", "upperroman"], {"loweralpha": "a", "lowerroman": "i", "upperalpha": "A", "upperroman": "I"}));
-
- Opal.cdecl($scope, 'LIST_CONTINUATION', "+");
-
- Opal.cdecl($scope, 'LINE_BREAK', " +");
-
- Opal.cdecl($scope, 'LINE_CONTINUATION', " \\");
-
- Opal.cdecl($scope, 'LINE_CONTINUATION_LEGACY', " +");
-
- Opal.cdecl($scope, 'BLOCK_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\[", "\\]"]}));
-
- Opal.cdecl($scope, 'INLINE_MATH_DELIMITERS', $hash2(["asciimath", "latexmath"], {"asciimath": ["\\$", "\\$"], "latexmath": ["\\(", "\\)"]}));
-
- Opal.cdecl($scope, 'FLEXIBLE_ATTRIBUTES', ["sectnums"]);
-
- if ($scope.get('RUBY_ENGINE')['$==']("opal")) {
- Opal.cdecl($scope, 'CC_ALPHA', "a-zA-Z");
-
- Opal.cdecl($scope, 'CG_ALPHA', "[a-zA-Z]");
-
- Opal.cdecl($scope, 'CC_ALNUM', "a-zA-Z0-9");
-
- Opal.cdecl($scope, 'CG_ALNUM', "[a-zA-Z0-9]");
-
- Opal.cdecl($scope, 'CG_BLANK', "[ \\t]");
-
- Opal.cdecl($scope, 'CC_EOL', "(?=\\n|$)");
-
- Opal.cdecl($scope, 'CG_GRAPH', "[\\x21-\\x7E]");
-
- Opal.cdecl($scope, 'CC_ALL', "[\\s\\S]");
-
- Opal.cdecl($scope, 'CC_WORD', "a-zA-Z0-9_");
-
- Opal.cdecl($scope, 'CG_WORD', "[a-zA-Z0-9_]");};
-
- Opal.cdecl($scope, 'AuthorInfoLineRx', (new RegExp("^(" + $scope.get('CG_WORD') + "[" + $scope.get('CC_WORD') + "\\-'.]*)(?: +(" + $scope.get('CG_WORD') + "[" + $scope.get('CC_WORD') + "\\-'.]*))?(?: +(" + $scope.get('CG_WORD') + "[" + $scope.get('CC_WORD') + "\\-'.]*))?(?: +<([^>]+)>)?$")));
-
- Opal.cdecl($scope, 'RevisionInfoLineRx', /^(?:\D*(.*?),)?(?:\s*(?!:)(.*?))(?:\s*(?!^):\s*(.*))?$/);
-
- Opal.cdecl($scope, 'ManpageTitleVolnumRx', /^(.*)\((.*)\)$/);
-
- Opal.cdecl($scope, 'ManpageNamePurposeRx', (new RegExp("^(.*?)" + $scope.get('CG_BLANK') + "+-" + $scope.get('CG_BLANK') + "+(.*)$")));
-
- Opal.cdecl($scope, 'ConditionalDirectiveRx', /^\\?(ifdef|ifndef|ifeval|endif)::(\S*?(?:([,\+])\S+?)?)\[(.+)?\]$/);
-
- Opal.cdecl($scope, 'EvalExpressionRx', (new RegExp("^(\\S.*?)" + $scope.get('CG_BLANK') + "*(==|!=|<=|>=|<|>)" + $scope.get('CG_BLANK') + "*(\\S.*)$")));
-
- Opal.cdecl($scope, 'IncludeDirectiveRx', /^\\?include::([^\[]+)\[(.*?)\]$/);
-
- Opal.cdecl($scope, 'TagDirectiveRx', /\b(?:tag|end)::\S+\[\]$/);
-
- Opal.cdecl($scope, 'AttributeEntryRx', (new RegExp("^:(!?\\w.*?):(?:" + $scope.get('CG_BLANK') + "+(.*))?$")));
-
- Opal.cdecl($scope, 'InvalidAttributeNameCharsRx', /[^\w\-]/);
-
- Opal.cdecl($scope, 'AttributeEntryPassMacroRx', /^pass:([a-z,]*)\[(.*)\]$/);
-
- Opal.cdecl($scope, 'AttributeReferenceRx', /(\\)?\{((set|counter2?):.+?|\w+(?:[\-]\w+)*)(\\)?\}/);
-
- Opal.cdecl($scope, 'BlockAnchorRx', (new RegExp("^\\[\\[(?:|([" + $scope.get('CC_ALPHA') + ":_][" + $scope.get('CC_WORD') + ":.-]*)(?:," + $scope.get('CG_BLANK') + "*(\\S.*))?)\\]\\]$")));
-
- Opal.cdecl($scope, 'BlockAttributeListRx', (new RegExp("^\\[(|" + $scope.get('CG_BLANK') + "*[" + $scope.get('CC_WORD') + "\\{,.#\"'%].*)\\]$")));
-
- Opal.cdecl($scope, 'BlockAttributeLineRx', (new RegExp("^\\[(|" + $scope.get('CG_BLANK') + "*[" + $scope.get('CC_WORD') + "\\{,.#\"'%].*|\\[(?:|[" + $scope.get('CC_ALPHA') + ":_][" + $scope.get('CC_WORD') + ":.-]*(?:," + $scope.get('CG_BLANK') + "*\\S.*)?)\\])\\]$")));
-
- Opal.cdecl($scope, 'BlockTitleRx', /^\.([^\s.].*)$/);
-
- Opal.cdecl($scope, 'AdmonitionParagraphRx', (new RegExp("^(" + $rb_times($scope.get('ADMONITION_STYLES').$to_a(), "|") + "):" + $scope.get('CG_BLANK'))));
-
- Opal.cdecl($scope, 'LiteralParagraphRx', (new RegExp("^(" + $scope.get('CG_BLANK') + "+.*)$")));
-
- Opal.cdecl($scope, 'CommentBlockRx', /^\/{4,}$/);
-
- Opal.cdecl($scope, 'CommentLineRx', /^\/\/(?:[^\/]|$)/);
-
- Opal.cdecl($scope, 'AtxSectionRx', (new RegExp("^((?:=|#){1,6})" + $scope.get('CG_BLANK') + "+(\\S.*?)(?:" + $scope.get('CG_BLANK') + "+\\1)?$")));
-
- Opal.cdecl($scope, 'SetextSectionTitleRx', (new RegExp("^((?=.*" + $scope.get('CG_WORD') + "+.*)[^.].*?)$")));
-
- Opal.cdecl($scope, 'SetextSectionLineRx', /^(?:=|-|~|\^|\+)+$/);
-
- Opal.cdecl($scope, 'InlineSectionAnchorRx', (new RegExp("^(.*?)" + $scope.get('CG_BLANK') + "+(\\\\)?\\[\\[([" + $scope.get('CC_ALPHA') + ":_][" + $scope.get('CC_WORD') + ":.-]*)(?:," + $scope.get('CG_BLANK') + "*(\\S.*?))?\\]\\]$")));
-
- Opal.cdecl($scope, 'InvalidSectionIdCharsRx', (new RegExp("&(?:[a-zA-Z]{2,}|#\\d{2,5}|#x[a-fA-F0-9]{2,4});|[^" + $scope.get('CC_WORD') + "]+?")));
-
- Opal.cdecl($scope, 'FloatingTitleStyleRx', /^(?:float|discrete)\b/);
-
- Opal.cdecl($scope, 'AnyListRx', (new RegExp("^(?:\\d+>" + $scope.get('CG_BLANK') + "+" + $scope.get('CG_GRAPH') + "|" + $scope.get('CG_BLANK') + "*(?:-|(?:\\*|\\.|\\u2022){1,5}|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))" + $scope.get('CG_BLANK') + "+" + $scope.get('CG_GRAPH') + "|" + $scope.get('CG_BLANK') + "*.*?(?::{2,4}|;;)(?:" + $scope.get('CG_BLANK') + "+" + $scope.get('CG_GRAPH') + "|$))")));
-
- Opal.cdecl($scope, 'UnorderedListRx', (new RegExp("^" + $scope.get('CG_BLANK') + "*(-|\\*{1,5}|\\u2022{1,5})" + $scope.get('CG_BLANK') + "+(.*)$")));
-
- Opal.cdecl($scope, 'OrderedListRx', (new RegExp("^" + $scope.get('CG_BLANK') + "*(\\.{1,5}|\\d+\\.|[a-zA-Z]\\.|[IVXivx]+\\))" + $scope.get('CG_BLANK') + "+(.*)$")));
-
- Opal.cdecl($scope, 'OrderedListMarkerRxMap', $hash2(["arabic", "loweralpha", "lowerroman", "upperalpha", "upperroman"], {"arabic": /\d+[.>]/, "loweralpha": /[a-z]\./, "lowerroman": /[ivx]+\)/, "upperalpha": /[A-Z]\./, "upperroman": /[IVX]+\)/}));
-
- Opal.cdecl($scope, 'DefinitionListRx', (new RegExp("^(?!\\/\\/)" + $scope.get('CG_BLANK') + "*(.*?)(:{2,4}|;;)(?:" + $scope.get('CG_BLANK') + "+(.*))?$")));
-
- Opal.cdecl($scope, 'DefinitionListSiblingRx', $hash2(["::", ":::", "::::", ";;"], {"::": (new RegExp("^(?!\\/\\/)" + $scope.get('CG_BLANK') + "*((?:.*[^:])?)(::)(?:" + $scope.get('CG_BLANK') + "+(.*))?$")), ":::": (new RegExp("^(?!\\/\\/)" + $scope.get('CG_BLANK') + "*((?:.*[^:])?)(:::)(?:" + $scope.get('CG_BLANK') + "+(.*))?$")), "::::": (new RegExp("^(?!\\/\\/)" + $scope.get('CG_BLANK') + "*((?:.*[^:])?)(::::)(?:" + $scope.get('CG_BLANK') + "+(.*))?$")), ";;": (new RegExp("^(?!\\/\\/)" + $scope.get('CG_BLANK') + "*(.*)(;;)(?:" + $scope.get('CG_BLANK') + "+(.*))?$"))}));
-
- Opal.cdecl($scope, 'CalloutListRx', (new RegExp("^(\\d+)>" + $scope.get('CG_BLANK') + "+(.*)")));
-
- Opal.cdecl($scope, 'CalloutExtractRx', /(?:(?:\/\/|#|--|;;) ?)?(\\)?(?=(?: ?\\?)*$)/);
-
- Opal.cdecl($scope, 'CalloutExtractRxt', "(\\\\)?<()(\\d+)>(?=(?: ?\\\\?<\\d+>)*$)");
-
- Opal.cdecl($scope, 'CalloutQuickScanRx', (new RegExp("\\\\?(?=(?: ?\\\\?)*" + $scope.get('CC_EOL') + ")")));
-
- Opal.cdecl($scope, 'CalloutSourceRx', (new RegExp("(?:(?:\\/\\/|#|--|;;) ?)?(\\\\)?<!?(--|)(\\d+)\\2>(?=(?: ?\\\\?<!?\\2\\d+\\2>)*" + $scope.get('CC_EOL') + ")")));
-
- Opal.cdecl($scope, 'CalloutSourceRxt', "(\\\\)?<()(\\d+)>(?=(?: ?\\\\?<\\d+>)*" + ($scope.get('CC_EOL')) + ")");
-
- Opal.cdecl($scope, 'ListRxMap', $hash2(["ulist", "olist", "dlist", "colist"], {"ulist": $scope.get('UnorderedListRx'), "olist": $scope.get('OrderedListRx'), "dlist": $scope.get('DefinitionListRx'), "colist": $scope.get('CalloutListRx')}));
-
- Opal.cdecl($scope, 'ColumnSpecRx', /^(?:(\d+)\*)?([<^>](?:\.[<^>]?)?|(?:[<^>]?\.)?[<^>])?(\d+%?)?([a-z])?$/);
-
- Opal.cdecl($scope, 'CellSpecStartRx', (new RegExp("^" + $scope.get('CG_BLANK') + "*(?:(\\d+(?:\\.\\d*)?|(?:\\d*\\.)?\\d+)([*+]))?([<^>](?:\\.[<^>]?)?|(?:[<^>]?\\.)?[<^>])?([a-z])?$")));
-
- Opal.cdecl($scope, 'CellSpecEndRx', (new RegExp("" + $scope.get('CG_BLANK') + "+(?:(\\d+(?:\\.\\d*)?|(?:\\d*\\.)?\\d+)([*+]))?([<^>](?:\\.[<^>]?)?|(?:[<^>]?\\.)?[<^>])?([a-z])?$")));
-
- Opal.cdecl($scope, 'GenericBlockMacroRx', (new RegExp("^(" + $scope.get('CG_WORD') + "+)::(\\S*?)\\[((?:\\\\\\]|[^\\]])*?)\\]$")));
-
- Opal.cdecl($scope, 'MediaBlockMacroRx', /^(image|video|audio)::(\S+?)\[((?:\\\]|[^\]])*?)\]$/);
-
- Opal.cdecl($scope, 'TocBlockMacroRx', /^toc::\[(.*?)\]$/);
-
- Opal.cdecl($scope, 'InlineAnchorRx', (new RegExp("\\\\?(?:\\[\\[([" + $scope.get('CC_ALPHA') + ":_][" + $scope.get('CC_WORD') + ":.-]*)(?:," + $scope.get('CG_BLANK') + "*(\\S.*?))?\\]\\]|anchor:(\\S+)\\[(.*?[^\\\\])?\\])")));
-
- Opal.cdecl($scope, 'InlineBiblioAnchorRx', (new RegExp("\\\\?\\[\\[\\[([" + $scope.get('CC_WORD') + ":][" + $scope.get('CC_WORD') + ":.-]*?)\\]\\]\\]")));
-
- Opal.cdecl($scope, 'EmailInlineMacroRx', (new RegExp("([\\\\>:\\/])?" + $scope.get('CG_WORD') + "[" + $scope.get('CC_WORD') + ".%+-]*@" + $scope.get('CG_ALNUM') + "[" + $scope.get('CC_ALNUM') + ".-]*\\." + $scope.get('CG_ALPHA') + "{2,4}\\b")));
-
- Opal.cdecl($scope, 'FootnoteInlineMacroRx', (new RegExp("\\\\?(footnote(?:ref)?):\\[(" + $scope.get('CC_ALL') + "*?[^\\\\])\\]")));
-
- Opal.cdecl($scope, 'ImageInlineMacroRx', /\\?(?:image|icon):([^:\[][^\[]*)\[((?:\\\]|[^\]])*?)\]/);
-
- Opal.cdecl($scope, 'IndextermInlineMacroRx', (new RegExp("\\\\?(?:(indexterm2?):\\[(" + $scope.get('CC_ALL') + "*?[^\\\\])\\]|\\(\\((" + $scope.get('CC_ALL') + "+?)\\)\\)(?!\\)))")));
-
- Opal.cdecl($scope, 'KbdBtnInlineMacroRx', /\\?(?:kbd|btn):\[((?:\\\]|[^\]])+?)\]/);
-
- Opal.cdecl($scope, 'KbdDelimiterRx', (new RegExp("(?:\\+|,)(?=" + $scope.get('CG_BLANK') + "*[^\\1])")));
-
- Opal.cdecl($scope, 'LinkInlineRx', /(^|link:|<|[\s>\(\)\[\];])(\\?(?:https?|file|ftp|irc):\/\/[^\s\[\]<]*[^\s.,\[\]<])(?:\[((?:\\\]|[^\]])*?)\])?/);
-
- Opal.cdecl($scope, 'LinkInlineMacroRx', /\\?(?:link|mailto):([^\s\[]+)(?:\[((?:\\\]|[^\]])*?)\])/);
-
- Opal.cdecl($scope, 'StemInlineMacroRx', (new RegExp("\\\\?(stem|(?:latex|ascii)math):([a-z,]*)\\[(" + $scope.get('CC_ALL') + "*?[^\\\\])\\]")));
-
- Opal.cdecl($scope, 'MenuInlineMacroRx', (new RegExp("\\\\?menu:(" + $scope.get('CG_WORD') + "|" + $scope.get('CG_WORD') + ".*?\\S)\\[" + $scope.get('CG_BLANK') + "*(.+?)?\\]")));
-
- Opal.cdecl($scope, 'MenuInlineRx', (new RegExp("\\\\?\"(" + $scope.get('CG_WORD') + "[^\"]*?" + $scope.get('CG_BLANK') + "*>" + $scope.get('CG_BLANK') + "*[^\" \\t][^\"]*)\"")));
-
- Opal.cdecl($scope, 'PassInlineRx', $hash(false, ["+", "`", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:])(?:\\[([^\\]]+?)\\])?(\\\\?(\\+|`)(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)\\4)(?!" + $scope.get('CG_WORD') + ")"))], true, ["`", nil, (new RegExp("(^|[^`" + $scope.get('CC_WORD') + "])(?:\\[([^\\]]+?)\\])?(\\\\?(`)([^`\\s]|[^`\\s]" + $scope.get('CC_ALL') + "*?\\S)\\4)(?![`" + $scope.get('CC_WORD') + "])"))]));
-
- Opal.cdecl($scope, 'PassInlineMacroRx', (new RegExp("(?:(?:(\\\\?)\\[([^\\]]+?)\\])?(\\\\{0,2})(\\+{2,3}|\\${2})(" + $scope.get('CC_ALL') + "*?)\\4|(\\\\?)pass:([a-z,]*)\\[(" + $scope.get('CC_ALL') + "*?[^\\\\])\\])")));
-
- Opal.cdecl($scope, 'XrefInlineMacroRx', (new RegExp("\\\\?(?:<<([" + $scope.get('CC_WORD') + "\":.\\/]" + $scope.get('CC_ALL') + "*?)>>|xref:([" + $scope.get('CC_WORD') + "\":.\\/]" + $scope.get('CC_ALL') + "*?)\\[(" + $scope.get('CC_ALL') + "*?)\\])")));
-
- if ($scope.get('RUBY_ENGINE')['$==']("opal")) {
- Opal.cdecl($scope, 'LineBreakRx', /^(.*)[ \t]\+$/m)};
-
- Opal.cdecl($scope, 'LayoutBreakLineRx', /^('|<){3,}$/);
-
- Opal.cdecl($scope, 'LayoutBreakLinePlusRx', /^(?:'|<){3,}$|^ {0,3}([-\*_])( *)\1\2\1$/);
-
- Opal.cdecl($scope, 'BlankLineRx', (new RegExp("^" + $scope.get('CG_BLANK') + "*\\n")));
-
- Opal.cdecl($scope, 'DataDelimiterRx', /,|;/);
-
- Opal.cdecl($scope, 'DoubleQuotedRx', /^("|)(.*)\1$/);
-
- Opal.cdecl($scope, 'DoubleQuotedMultiRx', (new RegExp("^(\"|)(" + $scope.get('CC_ALL') + "*)\\1$")));
-
- Opal.cdecl($scope, 'TrailingDigitsRx', /\d+$/);
-
- Opal.cdecl($scope, 'EscapedSpaceRx', (new RegExp("\\\\(" + $scope.get('CG_BLANK') + ")")));
-
- Opal.cdecl($scope, 'SpaceDelimiterRx', (new RegExp("([^\\\\])" + $scope.get('CG_BLANK') + "+")));
-
- Opal.cdecl($scope, 'SubModifierSniffRx', /[+-]/);
-
- Opal.cdecl($scope, 'UnicodeCharScanRx', (function() {if ($scope.get('RUBY_ENGINE')['$==']("opal")) {
- return nil}; return nil; })());
-
- Opal.cdecl($scope, 'UriSniffRx', (new RegExp("^" + $scope.get('CG_ALPHA') + "[" + $scope.get('CC_ALNUM') + ".+-]+:/{0,2}")));
-
- Opal.cdecl($scope, 'UriTerminator', /[);:]$/);
-
- Opal.cdecl($scope, 'XmlSanitizeRx', /<[^>]+>/);
-
- Opal.cdecl($scope, '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", "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": "¦", "cpp": "C++", "amp": "&", "lt": "<", "gt": ">"}));
-
- quote_subs = [["strong", "unconstrained", (new RegExp("\\\\?(?:\\[([^\\]]+?)\\])?\\*\\*(" + $scope.get('CC_ALL') + "+?)\\*\\*"))], ["strong", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?\\*(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)\\*(?!" + $scope.get('CG_WORD') + ")"))], ["double", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?\"`(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)`\"(?!" + $scope.get('CG_WORD') + ")"))], ["single", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:`}])(?:\\[([^\\]]+?)\\])?'`(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)`'(?!" + $scope.get('CG_WORD') + ")"))], ["monospaced", "unconstrained", (new RegExp("\\\\?(?:\\[([^\\]]+?)\\])?``(" + $scope.get('CC_ALL') + "+?)``"))], ["monospaced", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:\"'`}])(?:\\[([^\\]]+?)\\])?`(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)`(?![" + $scope.get('CC_WORD') + "\"'`])"))], ["emphasis", "unconstrained", (new RegExp("\\\\?(?:\\[([^\\]]+?)\\])?__(" + $scope.get('CC_ALL') + "+?)__"))], ["emphasis", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?_(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)_(?!" + $scope.get('CG_WORD') + ")"))], ["mark", "unconstrained", (new RegExp("\\\\?(?:\\[([^\\]]+?)\\])?##(" + $scope.get('CC_ALL') + "+?)##"))], ["mark", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + "&;:}])(?:\\[([^\\]]+?)\\])?#(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)#(?!" + $scope.get('CG_WORD') + ")"))], ["superscript", "unconstrained", /\\?(?:\[([^\]]+?)\])?\^(\S+?)\^/], ["subscript", "unconstrained", /\\?(?:\[([^\]]+?)\])?~(\S+?)~/]];
-
- compat_quote_subs = quote_subs.$dup();
-
- compat_quote_subs['$[]='](2, ["double", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?``(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)''(?!" + $scope.get('CG_WORD') + ")"))]);
-
- compat_quote_subs['$[]='](3, ["single", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?`(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)'(?!" + $scope.get('CG_WORD') + ")"))]);
-
- compat_quote_subs['$[]='](4, ["monospaced", "unconstrained", (new RegExp("\\\\?(?:\\[([^\\]]+?)\\])?\\+\\+(" + $scope.get('CC_ALL') + "+?)\\+\\+"))]);
-
- compat_quote_subs['$[]='](5, ["monospaced", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?\\+(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)\\+(?!" + $scope.get('CG_WORD') + ")"))]);
-
- compat_quote_subs.$insert(3, ["emphasis", "constrained", (new RegExp("(^|[^" + $scope.get('CC_WORD') + ";:}])(?:\\[([^\\]]+?)\\])?'(\\S|\\S" + $scope.get('CC_ALL') + "*?\\S)'(?!" + $scope.get('CG_WORD') + ")"))]);
-
- Opal.cdecl($scope, 'QUOTE_SUBS', $hash(false, quote_subs, true, compat_quote_subs));
-
- quote_subs = nil;
-
- compat_quote_subs = nil;
-
- Opal.cdecl($scope, 'REPLACEMENTS', [[/\\?\(C\)/, "©", "none"], [/\\?\(R\)/, "®", "none"], [/\\?\(TM\)/, "™", "none"], [/(^|\n| |\\)--( |\n|$)/, " — ", "none"], [(new RegExp("(" + $scope.get('CG_WORD') + ")\\\\?--(?=" + $scope.get('CG_WORD') + ")")), "—", "leading"], [/\\?\.\.\./, "…", "leading"], [/\\?`'/, "’", "none"], [(new RegExp("(" + $scope.get('CG_ALNUM') + ")\\\\?'(?=" + $scope.get('CG_ALPHA') + ")")), "’", "leading"], [/\\?->/, "→", "none"], [/\\?=>/, "⇒", "none"], [/\\?<-/, "←", "none"], [/\\?<=/, "⇐", "none"], [/\\?(&)amp;((?:[a-zA-Z]+|#\d{2,5}|#x[a-fA-F0-9]{2,4});)/, "", "bounding"]]);
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- Opal.defn(self, '$load', function(input, options) {
- var $a, $b, $c, TMP_2, TMP_3, $d, TMP_4, $e, $f, self = this, timings = nil, attributes = nil, attrs = nil, capture_1 = nil, original_attrs = nil, lines = nil, input_path = nil, input_mtime = nil, docdate = nil, doctime = nil, doc = nil, ex = nil, context = nil, wrapped_ex = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- try {
- options = options.$dup();
- if ((($a = (timings = options['$[]']("timings"))) !== nil && (!$a.$$is_boolean || $a == true))) {
- timings.$start("read")};
- attributes = options['$[]=']("attributes", (function() {if ((($a = ((attrs = options['$[]']("attributes")))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $hash2([], {})
- } else if ((($a = ((($b = Opal.get('Hash')['$==='](attrs)) !== false && $b !== nil) ? $b : (($c = Opal.get('RUBY_ENGINE_JRUBY'), $c !== false && $c !== nil ?((((Opal.get('Java')).$$scope.get('JavaUtil'))).$$scope.get('Map'))['$==='](attrs) : $c)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return attrs.$dup()
- } else if ((($a = Opal.get('Array')['$==='](attrs)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = ($b = attrs).$inject, $a.$$p = (TMP_2 = function(accum, entry){var self = TMP_2.$$s || this, $a, k = nil, v = nil;
-if (accum == null) accum = nil;if (entry == null) entry = nil;
- $a = Opal.to_ary(entry.$split("=", 2)), k = ($a[0] == null ? nil : $a[0]), v = ($a[1] == null ? nil : $a[1]);
- accum['$[]='](k, ((($a = v) !== false && $a !== nil) ? $a : ""));
- return accum;}, TMP_2.$$s = self, TMP_2), $a).call($b, $hash2([], {}))
- } else if ((($a = Opal.get('String')['$==='](attrs)) !== nil && (!$a.$$is_boolean || $a == true))) {
- capture_1 = "\\1";
- attrs = attrs.$gsub($scope.get('SpaceDelimiterRx'), "" + (capture_1) + ($scope.get('NULL'))).$gsub($scope.get('EscapedSpaceRx'), capture_1);
- return ($a = ($c = attrs.$split($scope.get('NULL'))).$inject, $a.$$p = (TMP_3 = function(accum, entry){var self = TMP_3.$$s || this, $a, k = nil, v = nil;
-if (accum == null) accum = nil;if (entry == null) entry = nil;
- $a = Opal.to_ary(entry.$split("=", 2)), k = ($a[0] == null ? nil : $a[0]), v = ($a[1] == null ? nil : $a[1]);
- accum['$[]='](k, ((($a = v) !== false && $a !== nil) ? $a : ""));
- return accum;}, TMP_3.$$s = self, TMP_3), $a).call($c, $hash2([], {}));
- } else if ((($a = ($d = (attrs['$respond_to?']("keys")), $d !== false && $d !== nil ?(attrs['$respond_to?']("[]")) : $d)) !== nil && (!$a.$$is_boolean || $a == true))) {
- original_attrs = attrs;
- attrs = $hash2([], {});
- ($a = ($d = original_attrs.$keys()).$each, $a.$$p = (TMP_4 = function(key){var self = TMP_4.$$s || this;
-if (key == null) key = nil;
- return attrs['$[]='](key, original_attrs['$[]'](key))}, TMP_4.$$s = self, TMP_4), $a).call($d);
- return attrs;
- } else {
- return self.$raise(Opal.get('ArgumentError'), "illegal type for attributes option: " + (attrs.$class().$ancestors()))
- }; return nil; })());
- lines = nil;
- if ((($a = Opal.get('File')['$==='](input)) !== nil && (!$a.$$is_boolean || $a == true))) {
- input_path = Opal.get('File').$expand_path(input.$path());
- input_mtime = input.$mtime();
- lines = input.$readlines();
- attributes['$[]=']("docfile", input_path);
- attributes['$[]=']("docdir", Opal.get('File').$dirname(input_path));
- attributes['$[]=']("docname", $scope.get('Helpers').$basename(input_path, true));
- docdate = (($a = "docdate", $e = attributes, ((($f = $e['$[]']($a)) !== false && $f !== nil) ? $f : $e['$[]=']($a, input_mtime.$strftime("%Y-%m-%d")))));
- doctime = (($a = "doctime", $e = attributes, ((($f = $e['$[]']($a)) !== false && $f !== nil) ? $f : $e['$[]=']($a, input_mtime.$strftime("%H:%M:%S %Z")))));
- attributes['$[]=']("docdatetime", "" + (docdate) + " " + (doctime));
- } else if ((($a = input['$respond_to?']("readlines")) !== nil && (!$a.$$is_boolean || $a == true))) {
- try {
- input.$rewind()
- } catch ($err) {if (true) {
- try {
- nil
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- lines = input.$readlines();
- } else if ((($a = Opal.get('String')['$==='](input)) !== nil && (!$a.$$is_boolean || $a == true))) {
- lines = input.$lines().$entries()
- } else if ((($a = Opal.get('Array')['$==='](input)) !== nil && (!$a.$$is_boolean || $a == true))) {
- lines = input.$dup()
- } else {
- self.$raise(Opal.get('ArgumentError'), "unsupported input type: " + (input.$class()))
- };
- if (timings !== false && timings !== nil) {
- timings.$record("read");
- timings.$start("parse");};
- if (options['$[]']("parse")['$=='](false)) {
- doc = $scope.get('Document').$new(lines, options)
- } else {
- doc = ($scope.get('Document').$new(lines, options)).$parse()
- };
- if (timings !== false && timings !== nil) {
- timings.$record("parse")};
- return doc;
- } catch ($err) {if (true) {ex = $err;
- try {
- try {
- context = "asciidoctor: FAILED: " + (((($a = attributes['$[]']("docfile")) !== false && $a !== nil) ? $a : "")) + ": Failed to load AsciiDoc document";
- if ((($a = ex['$respond_to?']("exception")) !== nil && (!$a.$$is_boolean || $a == true))) {
- wrapped_ex = ex.$exception("" + (context) + " - " + (ex.$message()));
- wrapped_ex.$set_backtrace(ex.$backtrace());
- } else {
- wrapped_ex = ex.$class().$new(context, ex);
- (($a = [ex.$stack_trace()]), $e = wrapped_ex, $e['$stack_trace='].apply($e, $a), $a[$a.length-1]);
- };
- } catch ($err) {if (true) {
- try {
- wrapped_ex = ex
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- return self.$raise(wrapped_ex);
- } finally {
- Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil;
- }
- }else { throw $err; }
- };
- });
- Opal.defn(self, '$load_file', function(filename, options) {
- var $a, self = this;
-
- if (options == null) {
- options = $hash2([], {})
- }
- return self.$load(Opal.get('File').$new(((($a = filename) !== false && $a !== nil) ? $a : "")), options);
- });
- Opal.defn(self, '$convert', function(input, options) {
- var $a, $b, $c, $d, $e, $f, TMP_5, self = this, to_file = nil, to_dir = nil, mkdirs = nil, timings = nil, $case = nil, write_to_same_dir = nil, stream_output = nil, write_to_target = nil, input_path = nil, outdir = nil, doc = nil, outfile = nil, working_dir = nil, jail = nil, opts = nil, output = nil, stylesdir = nil, copy_asciidoctor_stylesheet = nil, copy_user_stylesheet = nil, stylesheet = nil, copy_coderay_stylesheet = nil, copy_pygments_stylesheet = nil, stylesoutdir = nil, stylesheet_src = nil, stylesheet_dst = nil, stylesheet_content = nil;
-
- if (options == null) {
- options = $hash2([], {})
- }
- options = options.$dup();
- options.$delete("parse");
- to_file = options.$delete("to_file");
- to_dir = options.$delete("to_dir");
- mkdirs = ((($a = options.$delete("mkdirs")) !== false && $a !== nil) ? $a : false);
- timings = options['$[]']("timings");
- $case = to_file;if (true['$===']($case) || nil['$===']($case)) {write_to_same_dir = ($a = to_dir['$!'](), $a !== false && $a !== nil ?Opal.get('File')['$==='](input) : $a);
- stream_output = false;
- write_to_target = to_dir;
- to_file = nil;}else if (false['$===']($case)) {write_to_same_dir = false;
- stream_output = false;
- write_to_target = false;
- to_file = nil;}else if ("/dev/null"['$===']($case)) {return self.$load(input, options)}else {write_to_same_dir = false;
- stream_output = to_file['$respond_to?']("write");
- write_to_target = (function() {if (stream_output !== false && stream_output !== nil) {
- return false
- } else {
- return to_file
- }; return nil; })();};
- if ((($a = options['$key?']("header_footer")) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if ((($a = ((($b = write_to_same_dir) !== false && $b !== nil) ? $b : write_to_target)) !== nil && (!$a.$$is_boolean || $a == true))) {
- options['$[]=']("header_footer", true)};
- if (write_to_same_dir !== false && write_to_same_dir !== nil) {
- input_path = Opal.get('File').$expand_path(input.$path());
- options['$[]=']("to_dir", (outdir = Opal.get('File').$dirname(input_path)));
- } else if (write_to_target !== false && write_to_target !== nil) {
- if (to_dir !== false && to_dir !== nil) {
- if (to_file !== false && to_file !== nil) {
- options['$[]=']("to_dir", Opal.get('File').$dirname(Opal.get('File').$expand_path(Opal.get('File').$join(to_dir, to_file))))
- } else {
- options['$[]=']("to_dir", Opal.get('File').$expand_path(to_dir))
- }
- } else if (to_file !== false && to_file !== nil) {
- options['$[]=']("to_dir", Opal.get('File').$dirname(Opal.get('File').$expand_path(to_file)))}
- } else {
- options['$[]=']("to_dir", nil)
- };
- doc = self.$load(input, options);
- if (write_to_same_dir !== false && write_to_same_dir !== nil) {
- outfile = Opal.get('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix()));
- if (outfile['$=='](input_path)) {
- self.$raise(Opal.get('IOError'), "input file and output file cannot be the same: " + (outfile))};
- } else if (write_to_target !== false && write_to_target !== nil) {
- working_dir = (function() {if ((($a = options['$has_key?']("base_dir")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return Opal.get('File').$expand_path(options['$[]']("base_dir"))
- } else {
- return Opal.get('File').$expand_path(Opal.get('Dir').$pwd())
- }; return nil; })();
- jail = (function() {if ($rb_ge(doc.$safe(), (($scope.get('SafeMode')).$$scope.get('SAFE')))) {
- return working_dir
- } else {
- return nil
- }; return nil; })();
- if (to_dir !== false && to_dir !== nil) {
- outdir = doc.$normalize_system_path(to_dir, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
- if (to_file !== false && to_file !== nil) {
- outfile = doc.$normalize_system_path(to_file, outdir, nil, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
- outdir = Opal.get('File').$dirname(outfile);
- } else {
- outfile = Opal.get('File').$join(outdir, "" + (doc.$attributes()['$[]']("docname")) + (doc.$outfilesuffix()))
- };
- } else if (to_file !== false && to_file !== nil) {
- outfile = doc.$normalize_system_path(to_file, working_dir, jail, $hash2(["target_name", "recover"], {"target_name": "to_dir", "recover": false}));
- outdir = Opal.get('File').$dirname(outfile);};
- if ((($a = Opal.get('File')['$directory?'](outdir)) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else if (mkdirs !== false && mkdirs !== nil) {
- Opal.get('FileUtils').$mkdir_p(outdir)
- } else {
- self.$raise(Opal.get('IOError'), "target directory does not exist: " + (to_dir))
- };
- } else {
- outfile = to_file;
- outdir = nil;
- };
- if (timings !== false && timings !== nil) {
- timings.$start("convert")};
- opts = (function() {if ((($a = (($b = outfile !== false && outfile !== nil) ? stream_output['$!']() : outfile)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return $hash2(["outfile", "outdir"], {"outfile": outfile, "outdir": outdir})
- } else {
- return $hash2([], {})
- }; return nil; })();
- output = doc.$convert(opts);
- if (timings !== false && timings !== nil) {
- timings.$record("convert")};
- if (outfile !== false && outfile !== nil) {
- if (timings !== false && timings !== nil) {
- timings.$start("write")};
- doc.$write(output, outfile);
- if (timings !== false && timings !== nil) {
- timings.$record("write")};
- if ((($a = ($b = ($c = ($d = ($e = ($f = stream_output['$!'](), $f !== false && $f !== nil ?$rb_lt(doc.$safe(), (($scope.get('SafeMode')).$$scope.get('SECURE'))) : $f), $e !== false && $e !== nil ?(doc['$attr?']("linkcss")) : $e), $d !== false && $d !== nil ?(doc['$attr?']("copycss")) : $d), $c !== false && $c !== nil ?(doc['$attr?']("basebackend-html")) : $c), $b !== false && $b !== nil ?(($c = (stylesdir = (doc.$attr("stylesdir"))), $c !== false && $c !== nil ?($scope.get('Helpers')['$uriish?'](stylesdir)) : $c))['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
- copy_asciidoctor_stylesheet = false;
- copy_user_stylesheet = false;
- if ((($a = (stylesheet = (doc.$attr("stylesheet")))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = $scope.get('DEFAULT_STYLESHEET_KEYS')['$include?'](stylesheet)) !== nil && (!$a.$$is_boolean || $a == true))) {
- copy_asciidoctor_stylesheet = true
- } else if ((($a = ($scope.get('Helpers')['$uriish?'](stylesheet))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- copy_user_stylesheet = true}};
- copy_coderay_stylesheet = ($a = (doc['$attr?']("source-highlighter", "coderay")), $a !== false && $a !== nil ?(doc.$attr("coderay-css", "class"))['$==']("class") : $a);
- copy_pygments_stylesheet = ($a = (doc['$attr?']("source-highlighter", "pygments")), $a !== false && $a !== nil ?(doc.$attr("pygments-css", "class"))['$==']("class") : $a);
- if ((($a = ((($b = ((($c = ((($d = copy_asciidoctor_stylesheet) !== false && $d !== nil) ? $d : copy_user_stylesheet)) !== false && $c !== nil) ? $c : copy_coderay_stylesheet)) !== false && $b !== nil) ? $b : copy_pygments_stylesheet)) !== nil && (!$a.$$is_boolean || $a == true))) {
- stylesoutdir = doc.$normalize_system_path(stylesdir, outdir, (function() {if ($rb_ge(doc.$safe(), (($scope.get('SafeMode')).$$scope.get('SAFE')))) {
- return outdir
- } else {
- return nil
- }; return nil; })());
- if (mkdirs !== false && mkdirs !== nil) {
- $scope.get('Helpers').$mkdir_p(stylesoutdir)};
- if (copy_asciidoctor_stylesheet !== false && copy_asciidoctor_stylesheet !== nil) {
- $scope.get('Stylesheets').$instance().$write_primary_stylesheet(stylesoutdir)
- } else if (copy_user_stylesheet !== false && copy_user_stylesheet !== nil) {
- if ((($a = ((stylesheet_src = (doc.$attr("copycss"))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- stylesheet_src = doc.$normalize_system_path(stylesheet)
- } else {
- stylesheet_src = doc.$normalize_system_path(stylesheet_src)
- };
- stylesheet_dst = doc.$normalize_system_path(stylesheet, stylesoutdir, ((function() {if ($rb_ge(doc.$safe(), (($scope.get('SafeMode')).$$scope.get('SAFE')))) {
- return outdir
- } else {
- return nil
- }; return nil; })()));
- if ((($a = ((($b = stylesheet_src['$=='](stylesheet_dst)) !== false && $b !== nil) ? $b : ((stylesheet_content = doc.$read_asset(stylesheet_src)))['$nil?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- ($a = ($b = Opal.get('File')).$open, $a.$$p = (TMP_5 = function(f){var self = TMP_5.$$s || this;
-if (f == null) f = nil;
- return f.$write(stylesheet_content)}, TMP_5.$$s = self, TMP_5), $a).call($b, stylesheet_dst, "w")
- };};
- if (copy_coderay_stylesheet !== false && copy_coderay_stylesheet !== nil) {
- $scope.get('Stylesheets').$instance().$write_coderay_stylesheet(stylesoutdir)
- } else if (copy_pygments_stylesheet !== false && copy_pygments_stylesheet !== nil) {
- $scope.get('Stylesheets').$instance().$write_pygments_stylesheet(stylesoutdir, (doc.$attr("pygments-style")))};};};
- return doc;
- } else {
- return output
- };
- });
- Opal.alias(self, 'render', 'convert');
- Opal.defn(self, '$convert_file', function(filename, options) {
- var $a, self = this;
-
- if (options == null) {
- options = $hash2([], {})
- }
- return self.$convert(Opal.get('File').$new(((($a = filename) !== false && $a !== nil) ? $a : "")), options);
- });
- return Opal.alias(self, 'render_file', 'convert_file');
- })(Opal.get_singleton_class(self));
-
- if ($scope.get('RUBY_ENGINE')['$==']("opal")) {
- self.$require("asciidoctor/version");
-
- self.$require("asciidoctor/timings");};
- })($scope.base);
- self.$require("asciidoctor/core_ext");
- self.$require("asciidoctor/helpers");
- self.$require("asciidoctor/substitutors");
- self.$require("asciidoctor/abstract_node");
- self.$require("asciidoctor/abstract_block");
- self.$require("asciidoctor/attribute_list");
- self.$require("asciidoctor/block");
- self.$require("asciidoctor/callouts");
- self.$require("asciidoctor/converter");
- if ((($a = $scope.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) {
- self.$require("asciidoctor/converter/html5")};
- self.$require("asciidoctor/document");
- self.$require("asciidoctor/inline");
- self.$require("asciidoctor/list");
- self.$require("asciidoctor/parser");
- self.$require("asciidoctor/path_resolver");
- self.$require("asciidoctor/reader");
- self.$require("asciidoctor/section");
- self.$require("asciidoctor/stylesheets");
- return self.$require("asciidoctor/table");
-})(Opal);
-
-/* Generated by Opal 0.9.0.beta2 */
-(function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;
-
- return nil
-})(Opal);
-
-/* Generated by Opal 0.9.0.beta2 */
-(function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- function $rb_plus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
- }
- function $rb_lt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs);
- }
- function $rb_gt(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs);
- }
- function $rb_minus(lhs, rhs) {
- return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
- }
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $hash2 = Opal.hash2, $range = Opal.range, $hash = Opal.hash;
-
- Opal.add_stubs(['$[]=', '$config', '$nil_or_empty?', '$name', '$grep', '$constants', '$include', '$const_get', '$extend', '$attr_reader', '$merge', '$class', '$update', '$raise', '$new', '$create_block', '$is_a?', '$has_more_lines?', '$next_block', '$<<', '$each', '$define_method', '$send', '$insert', '$dup', '$call', '$attr_accessor', '$[]', '$option', '$===', '$to_set', '$flatten', '$resolve_regexp', '$==', '$attr', '$method', '$register', '$arity', '$instance_exec', '$to_proc', '$activate', '$+', '$values', '$groups', '$add_document_processor', '$!', '$find', '$select', '$add_syntax_processor', '$to_sym', '$include?', '$private', '$tr', '$to_s', '$join', '$map', '$upcase', '$chr', '$split', '$instance_variable_get', '$instance_variable_set', '$resolve_args', '$freeze', '$process_block_given?', '$source_location', '$class_for_name', '$<', '$update_config', '$unshift', '$as_symbol', '$name=', '$pop', '$size', '$>', '$-', '$fill', '$-@', '$next_auto_id', '$generate_name', '$length', '$empty?', '$const_defined?']);
- return (function($base) {
- var self = $module($base, 'Asciidoctor');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base) {
- var self = $module($base, 'Extensions');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function($base, $super) {
- function $Processor(){};
- var self = $Processor = $klass($base, $super, 'Processor', $Processor);
-
- var def = self.$$proto, $scope = self.$$scope, $a, $b, TMP_1;
-
- def.config = nil;
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- Opal.defn(self, '$config', function() {
- var $a, self = this;
- if (self.config == null) self.config = nil;
-
- return ((($a = self.config) !== false && $a !== nil) ? $a : self.config = $hash2([], {}));
- });
- Opal.defn(self, '$option', function(key, default_value) {
- var self = this;
-
- return self.$config()['$[]='](key, default_value);
- });
- Opal.defn(self, '$use_dsl', function() {
- var $a, self = this;
-
- if ((($a = self.$name()['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = self.$constants().$grep("DSL")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$include(self.$const_get("DSL"))
- } else {
- return nil
- }
- } else if ((($a = self.$constants().$grep("DSL")) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$extend(self.$const_get("DSL"))
- } else {
- return nil
- };
- });
- Opal.alias(self, 'extend_dsl', 'use_dsl');
- return Opal.alias(self, 'include_dsl', 'use_dsl');
- })(Opal.get_singleton_class(self));
-
- self.$attr_reader("config");
-
- Opal.defn(self, '$initialize', function(config) {
- var self = this;
-
- if (config == null) {
- config = $hash2([], {})
- }
- return self.config = self.$class().$config().$merge(config);
- });
-
- Opal.defn(self, '$update_config', function(config) {
- var self = this;
-
- return self.config.$update(config);
- });
-
- Opal.defn(self, '$process', function() {
- var self = this;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- return self.$raise(Opal.get('NotImplementedError'));
- });
-
- Opal.defn(self, '$create_block', function(parent, context, source, attrs, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- return $scope.get('Block').$new(parent, context, $hash2(["source", "attributes"], {"source": source, "attributes": attrs}).$merge(opts));
- });
-
- Opal.defn(self, '$create_image_block', function(parent, attrs, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- return self.$create_block(parent, "image", nil, attrs, opts);
- });
-
- Opal.defn(self, '$create_inline', function(parent, context, text, opts) {
- var self = this;
-
- if (opts == null) {
- opts = $hash2([], {})
- }
- return $scope.get('Inline').$new(parent, context, text, opts);
- });
-
- Opal.defn(self, '$parse_content', function(parent, content, attributes) {
- var $a, $b, self = this, reader = nil, block = nil;
-
- if (attributes == null) {
- attributes = $hash2([], {})
- }
- reader = (function() {if ((($a = (content['$is_a?']($scope.get('Reader')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return content
- } else {
- return ($scope.get('Reader').$new(content))
- }; return nil; })();
- while ((($b = reader['$has_more_lines?']()) !== nil && (!$b.$$is_boolean || $b == true))) {
- block = $scope.get('Parser').$next_block(reader, parent, attributes);
- if (block !== false && block !== nil) {
- parent['$<<'](block)};};
- return nil;
- });
-
- return ($a = ($b = [["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"]]).$each, $a.$$p = (TMP_1 = function(method_name, delegate_method_name, context){var self = TMP_1.$$s || this, $a, $b, TMP_2;
-if (method_name == null) method_name = nil;if (delegate_method_name == null) delegate_method_name = nil;if (context == null) context = nil;
- return ($a = ($b = self).$define_method, $a.$$p = (TMP_2 = function(args){var self = TMP_2.$$s || this, $a;
-args = $slice.call(arguments, 0);
- return ($a = self).$send.apply($a, [delegate_method_name].concat(Opal.to_a(args.$dup().$insert(1, context))))}, TMP_2.$$s = self, TMP_2), $a).call($b, method_name)}, TMP_1.$$s = self, TMP_1), $a).call($b);
- })($scope.base, null);
-
- (function($base) {
- var self = $module($base, 'ProcessorDsl');
-
- var def = self.$$proto, $scope = self.$$scope, TMP_3;
-
- Opal.defn(self, '$option', function(key, value) {
- var self = this;
-
- return self.$config()['$[]='](key, value);
- });
-
- Opal.defn(self, '$process', TMP_3 = function() {
- var $a, self = this, $iter = TMP_3.$$p, block = $iter || nil;
- if (self.process_block == null) self.process_block = nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_3.$$p = null;
- if ((block !== nil)) {
- return self.process_block = block
- } else if ((($a = self.process_block) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ($a = self.process_block).$call.apply($a, Opal.to_a(args))
- } else {
- return self.$raise(Opal.get('NotImplementedError'))
- };
- });
-
- Opal.defn(self, '$process_block_given?', function() {
- var $a, self = this;
-
- return (($a = self['process_block'], $a != null && $a !== nil) ? 'instance-variable' : nil);
- });
- })($scope.base);
-
- (function($base, $super) {
- function $Preprocessor(){};
- var self = $Preprocessor = $klass($base, $super, 'Preprocessor', $Preprocessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- return (Opal.defn(self, '$process', function(document, reader) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process'
- })($scope.base, $scope.get('Processor'));
-
- Opal.casgn($scope.get('Preprocessor'), 'DSL', $scope.get('ProcessorDsl'));
-
- (function($base, $super) {
- function $Treeprocessor(){};
- var self = $Treeprocessor = $klass($base, $super, 'Treeprocessor', $Treeprocessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- return (Opal.defn(self, '$process', function(document) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process'
- })($scope.base, $scope.get('Processor'));
-
- Opal.casgn($scope.get('Treeprocessor'), 'DSL', $scope.get('ProcessorDsl'));
-
- (function($base, $super) {
- function $Postprocessor(){};
- var self = $Postprocessor = $klass($base, $super, 'Postprocessor', $Postprocessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- return (Opal.defn(self, '$process', function(document, output) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process'
- })($scope.base, $scope.get('Processor'));
-
- Opal.casgn($scope.get('Postprocessor'), 'DSL', $scope.get('ProcessorDsl'));
-
- (function($base, $super) {
- function $IncludeProcessor(){};
- var self = $IncludeProcessor = $klass($base, $super, 'IncludeProcessor', $IncludeProcessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- Opal.defn(self, '$process', function(document, reader, target, attributes) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- });
-
- return (Opal.defn(self, '$handles?', function(target) {
- var self = this;
-
- return true;
- }), nil) && 'handles?';
- })($scope.base, $scope.get('Processor'));
-
- Opal.casgn($scope.get('IncludeProcessor'), 'DSL', $scope.get('ProcessorDsl'));
-
- (function($base, $super) {
- function $DocinfoProcessor(){};
- var self = $DocinfoProcessor = $klass($base, $super, 'DocinfoProcessor', $DocinfoProcessor);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_4;
-
- def.config = nil;
- self.$attr_accessor("location");
-
- Opal.defn(self, '$initialize', TMP_4 = function(config) {
- var $a, $b, $c, self = this, $iter = TMP_4.$$p, $yield = $iter || nil;
-
- if (config == null) {
- config = $hash2([], {})
- }
- TMP_4.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_4, null).apply(self, [config]);
- return ($a = "location", $b = self.config, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "head")));
- });
-
- return (Opal.defn(self, '$process', function(document) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process';
- })($scope.base, $scope.get('Processor'));
-
- (function($base) {
- var self = $module($base, 'DocinfoProcessorDsl');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$include($scope.get('ProcessorDsl'));
-
- Opal.defn(self, '$at_location', function(value) {
- var self = this;
-
- return self.$option("location", value);
- });
- })($scope.base);
-
- Opal.casgn($scope.get('DocinfoProcessor'), 'DSL', $scope.get('DocinfoProcessorDsl'));
-
- (function($base, $super) {
- function $BlockProcessor(){};
- var self = $BlockProcessor = $klass($base, $super, 'BlockProcessor', $BlockProcessor);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_5;
-
- def.config = nil;
- self.$attr_accessor("name");
-
- Opal.defn(self, '$initialize', TMP_5 = function(name, config) {
- var $a, $b, $c, self = this, $iter = TMP_5.$$p, $yield = $iter || nil, $case = nil;
-
- if (name == null) {
- name = nil
- }
- if (config == null) {
- config = $hash2([], {})
- }
- TMP_5.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_5, null).apply(self, [config]);
- self.name = ((($a = name) !== false && $a !== nil) ? $a : self.config['$[]']("name"));
- $case = self.config['$[]']("contexts");if (Opal.get('NilClass')['$===']($case)) {($a = "contexts", $b = self.config, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, ["open", "paragraph"].$to_set())))}else if (Opal.get('Symbol')['$===']($case)) {self.config['$[]=']("contexts", [self.config['$[]']("contexts")].$to_set())}else {self.config['$[]=']("contexts", self.config['$[]']("contexts").$to_set())};
- return ($a = "content_model", $b = self.config, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "compound")));
- });
-
- return (Opal.defn(self, '$process', function(parent, reader, attributes) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process';
- })($scope.base, $scope.get('Processor'));
-
- (function($base) {
- var self = $module($base, 'BlockProcessorDsl');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$include($scope.get('ProcessorDsl'));
-
- Opal.defn(self, '$named', function(value) {
- var $a, self = this;
-
- if ((($a = self['$is_a?']($scope.get('Processor'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.name = value
- } else {
- return self.$option("name", value)
- };
- });
-
- Opal.alias(self, 'match_name', 'named');
-
- Opal.alias(self, 'bind_to', 'named');
-
- Opal.defn(self, '$contexts', function() {
- var self = this;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var value = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- value[arg_index] = arguments[arg_index + 0];
- }
- return self.$option("contexts", value.$flatten());
- });
-
- Opal.alias(self, 'on_contexts', 'contexts');
-
- Opal.alias(self, 'on_context', 'contexts');
-
- Opal.defn(self, '$content_model', function(value) {
- var self = this;
-
- return self.$option("content_model", value);
- });
-
- Opal.alias(self, 'parse_content_as', 'content_model');
-
- Opal.defn(self, '$positional_attributes', function() {
- var self = this;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var value = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- value[arg_index] = arguments[arg_index + 0];
- }
- return self.$option("pos_attrs", value.$flatten());
- });
-
- Opal.alias(self, 'pos_attrs', 'positional_attributes');
-
- Opal.alias(self, 'name_attributes', 'positional_attributes');
-
- Opal.alias(self, 'name_positional_attributes', 'positional_attributes');
-
- Opal.defn(self, '$default_attrs', function(value) {
- var self = this;
-
- return self.$option("default_attrs", value);
- });
-
- Opal.alias(self, 'seed_attributes_with', 'default_attrs');
- })($scope.base);
-
- Opal.casgn($scope.get('BlockProcessor'), 'DSL', $scope.get('BlockProcessorDsl'));
-
- (function($base, $super) {
- function $MacroProcessor(){};
- var self = $MacroProcessor = $klass($base, $super, 'MacroProcessor', $MacroProcessor);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_6;
-
- def.config = nil;
- self.$attr_accessor("name");
-
- Opal.defn(self, '$initialize', TMP_6 = function(name, config) {
- var $a, $b, $c, self = this, $iter = TMP_6.$$p, $yield = $iter || nil;
-
- if (name == null) {
- name = nil
- }
- if (config == null) {
- config = $hash2([], {})
- }
- TMP_6.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_6, null).apply(self, [config]);
- self.name = ((($a = name) !== false && $a !== nil) ? $a : self.config['$[]']("name"));
- return ($a = "content_model", $b = self.config, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "attributes")));
- });
-
- return (Opal.defn(self, '$process', function(parent, target, attributes) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'process';
- })($scope.base, $scope.get('Processor'));
-
- (function($base) {
- var self = $module($base, 'MacroProcessorDsl');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$include($scope.get('ProcessorDsl'));
-
- Opal.defn(self, '$named', function(value) {
- var $a, self = this;
-
- if ((($a = self['$is_a?']($scope.get('Processor'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.name = value
- } else {
- return self.$option("name", value)
- };
- });
-
- Opal.alias(self, 'match_name', 'named');
-
- Opal.alias(self, 'bind_to', 'named');
-
- Opal.defn(self, '$content_model', function(value) {
- var self = this;
-
- return self.$option("content_model", value);
- });
-
- Opal.alias(self, 'parse_content_as', 'content_model');
-
- Opal.defn(self, '$positional_attributes', function() {
- var self = this;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var value = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- value[arg_index] = arguments[arg_index + 0];
- }
- return self.$option("pos_attrs", value.$flatten());
- });
-
- Opal.alias(self, 'pos_attrs', 'positional_attributes');
-
- Opal.alias(self, 'name_attributes', 'positional_attributes');
-
- Opal.alias(self, 'name_positional_attributes', 'positional_attributes');
-
- Opal.defn(self, '$default_attrs', function(value) {
- var self = this;
-
- return self.$option("default_attrs", value);
- });
-
- Opal.alias(self, 'seed_attributes_with', 'default_attrs');
- })($scope.base);
-
- (function($base, $super) {
- function $BlockMacroProcessor(){};
- var self = $BlockMacroProcessor = $klass($base, $super, 'BlockMacroProcessor', $BlockMacroProcessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- return nil;
- })($scope.base, $scope.get('MacroProcessor'));
-
- Opal.casgn($scope.get('BlockMacroProcessor'), 'DSL', $scope.get('MacroProcessorDsl'));
-
- (function($base, $super) {
- function $InlineMacroProcessor(){};
- var self = $InlineMacroProcessor = $klass($base, $super, 'InlineMacroProcessor', $InlineMacroProcessor);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- def.config = def.name = nil;
- Opal.defn(self, '$regexp', function() {
- var $a, $b, $c, self = this;
-
- return ($a = "regexp", $b = self.config, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, (self.$resolve_regexp(self.name, self.config['$[]']("format"))))));
- });
-
- return (Opal.defn(self, '$resolve_regexp', function(name, format) {
- var self = this;
-
- if (format['$==']("short")) {
- return (new RegExp("\\\\?" + name + ":\\[((?:\\\\\\]|[^\\]])*?)\\]"))
- } else {
- return (new RegExp("\\\\?" + name + ":(\\S+?)\\[((?:\\\\\\]|[^\\]])*?)\\]"))
- };
- }), nil) && 'resolve_regexp';
- })($scope.base, $scope.get('MacroProcessor'));
-
- (function($base) {
- var self = $module($base, 'InlineMacroProcessorDsl');
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$include($scope.get('MacroProcessorDsl'));
-
- Opal.defn(self, '$using_format', function(value) {
- var self = this;
-
- return self.$option("format", value);
- });
-
- Opal.defn(self, '$match', function(value) {
- var self = this;
-
- return self.$option("regexp", value);
- });
- })($scope.base);
-
- Opal.casgn($scope.get('InlineMacroProcessor'), 'DSL', $scope.get('InlineMacroProcessorDsl'));
-
- (function($base, $super) {
- function $Extension(){};
- var self = $Extension = $klass($base, $super, 'Extension', $Extension);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- self.$attr("kind");
-
- self.$attr("config");
-
- self.$attr("instance");
-
- return (Opal.defn(self, '$initialize', function(kind, instance, config) {
- var self = this;
-
- self.kind = kind;
- self.instance = instance;
- return self.config = config;
- }), nil) && 'initialize';
- })($scope.base, null);
-
- (function($base, $super) {
- function $ProcessorExtension(){};
- var self = $ProcessorExtension = $klass($base, $super, 'ProcessorExtension', $ProcessorExtension);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_7;
-
- self.$attr("process_method");
-
- return (Opal.defn(self, '$initialize', TMP_7 = function(kind, instance, process_method) {
- var $a, self = this, $iter = TMP_7.$$p, $yield = $iter || nil;
-
- if (process_method == null) {
- process_method = nil
- }
- TMP_7.$$p = null;
- Opal.find_super_dispatcher(self, 'initialize', TMP_7, null).apply(self, [kind, instance, instance.$config()]);
- return self.process_method = ((($a = process_method) !== false && $a !== nil) ? $a : (instance.$method("process")));
- }), nil) && 'initialize';
- })($scope.base, $scope.get('Extension'));
-
- (function($base, $super) {
- function $Group(){};
- var self = $Group = $klass($base, $super, 'Group', $Group);
-
- var def = self.$$proto, $scope = self.$$scope;
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto;
-
- return (Opal.defn(self, '$register', function(name) {
- var self = this;
-
- if (name == null) {
- name = nil
- }
- return $scope.get('Extensions').$register(name, self);
- }), nil) && 'register'
- })(Opal.get_singleton_class(self));
-
- return (Opal.defn(self, '$activate', function(registry) {
- var self = this;
-
- return self.$raise(Opal.get('NotImplementedError'));
- }), nil) && 'activate';
- })($scope.base, null);
-
- (function($base, $super) {
- function $Registry(){};
- var self = $Registry = $klass($base, $super, 'Registry', $Registry);
-
- var def = self.$$proto, $scope = self.$$scope, TMP_9, TMP_10, TMP_11, TMP_12, TMP_13, TMP_16, TMP_17, TMP_18, TMP_19, TMP_21;
-
- def.groups = def.preprocessor_extensions = def.treeprocessor_extensions = def.postprocessor_extensions = def.include_processor_extensions = def.docinfo_processor_extensions = def.block_extensions = def.block_macro_extensions = def.inline_macro_extensions = nil;
- self.$attr_reader("document");
-
- self.$attr_reader("groups");
-
- Opal.defn(self, '$initialize', function(groups) {
- var self = this;
-
- if (groups == null) {
- groups = $hash2([], {})
- }
- self.groups = groups;
- self.preprocessor_extensions = self.treeprocessor_extensions = self.postprocessor_extensions = self.include_processor_extensions = self.docinfo_processor_extensions = nil;
- self.block_extensions = self.block_macro_extensions = self.inline_macro_extensions = nil;
- return self.document = nil;
- });
-
- Opal.defn(self, '$activate', function(document) {
- var $a, $b, TMP_8, self = this;
-
- self.document = document;
- ($a = ($b = ($rb_plus($scope.get('Extensions').$groups().$values(), self.groups.$values()))).$each, $a.$$p = (TMP_8 = function(group){var self = TMP_8.$$s || this, $a, $b, $case = nil;
-if (group == null) group = nil;
- return (function() {$case = group;if (Opal.get('Proc')['$===']($case)) {return (function() {$case = group.$arity();if ((0)['$===']($case) || (-1)['$===']($case)) {return ($a = ($b = self).$instance_exec, $a.$$p = group.$to_proc(), $a).call($b)}else if ((1)['$===']($case)) {return group.$call(self)}else { return nil }})()}else if (Opal.get('Class')['$===']($case)) {return group.$new().$activate(self)}else {return group.$activate(self)}})()}, TMP_8.$$s = self, TMP_8), $a).call($b);
- return self;
- });
-
- Opal.defn(self, '$preprocessor', TMP_9 = function() {
- var $a, $b, self = this, $iter = TMP_9.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_9.$$p = null;
- return ($a = ($b = self).$add_document_processor, $a.$$p = block.$to_proc(), $a).call($b, "preprocessor", args);
- });
-
- Opal.defn(self, '$preprocessors?', function() {
- var self = this;
-
- return self.preprocessor_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$preprocessors', function() {
- var self = this;
-
- return self.preprocessor_extensions;
- });
-
- Opal.defn(self, '$treeprocessor', TMP_10 = function() {
- var $a, $b, self = this, $iter = TMP_10.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_10.$$p = null;
- return ($a = ($b = self).$add_document_processor, $a.$$p = block.$to_proc(), $a).call($b, "treeprocessor", args);
- });
-
- Opal.defn(self, '$treeprocessors?', function() {
- var self = this;
-
- return self.treeprocessor_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$treeprocessors', function() {
- var self = this;
-
- return self.treeprocessor_extensions;
- });
-
- Opal.defn(self, '$postprocessor', TMP_11 = function() {
- var $a, $b, self = this, $iter = TMP_11.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_11.$$p = null;
- return ($a = ($b = self).$add_document_processor, $a.$$p = block.$to_proc(), $a).call($b, "postprocessor", args);
- });
-
- Opal.defn(self, '$postprocessors?', function() {
- var self = this;
-
- return self.postprocessor_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$postprocessors', function() {
- var self = this;
-
- return self.postprocessor_extensions;
- });
-
- Opal.defn(self, '$include_processor', TMP_12 = function() {
- var $a, $b, self = this, $iter = TMP_12.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_12.$$p = null;
- return ($a = ($b = self).$add_document_processor, $a.$$p = block.$to_proc(), $a).call($b, "include_processor", args);
- });
-
- Opal.defn(self, '$include_processors?', function() {
- var self = this;
-
- return self.include_processor_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$include_processors', function() {
- var self = this;
-
- return self.include_processor_extensions;
- });
-
- Opal.defn(self, '$docinfo_processor', TMP_13 = function() {
- var $a, $b, self = this, $iter = TMP_13.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_13.$$p = null;
- return ($a = ($b = self).$add_document_processor, $a.$$p = block.$to_proc(), $a).call($b, "docinfo_processor", args);
- });
-
- Opal.defn(self, '$docinfo_processors?', function(location) {
- var $a, $b, TMP_14, self = this;
-
- if (location == null) {
- location = nil
- }
- if ((($a = self.docinfo_processor_extensions) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (location !== false && location !== nil) {
- return ($a = ($b = self.docinfo_processor_extensions).$find, $a.$$p = (TMP_14 = function(ext){var self = TMP_14.$$s || this;
-if (ext == null) ext = nil;
- return ext.$config()['$[]']("location")['$=='](location)}, TMP_14.$$s = self, TMP_14), $a).call($b)
- } else {
- return true
- }
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$docinfo_processors', function(location) {
- var $a, $b, TMP_15, self = this;
-
- if (location == null) {
- location = nil
- }
- if ((($a = self.docinfo_processor_extensions) !== nil && (!$a.$$is_boolean || $a == true))) {
- if (location !== false && location !== nil) {
- return ($a = ($b = self.docinfo_processor_extensions).$select, $a.$$p = (TMP_15 = function(ext){var self = TMP_15.$$s || this;
-if (ext == null) ext = nil;
- return ext.$config()['$[]']("location")['$=='](location)}, TMP_15.$$s = self, TMP_15), $a).call($b)
- } else {
- return self.docinfo_processor_extensions
- }
- } else {
- return nil
- };
- });
-
- Opal.defn(self, '$block', TMP_16 = function() {
- var $a, $b, self = this, $iter = TMP_16.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_16.$$p = null;
- return ($a = ($b = self).$add_syntax_processor, $a.$$p = block.$to_proc(), $a).call($b, "block", args);
- });
-
- Opal.defn(self, '$blocks?', function() {
- var self = this;
-
- return self.block_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$registered_for_block?', function(name, context) {
- var $a, self = this, ext = nil;
-
- if ((($a = (ext = self.block_extensions['$[]'](name.$to_sym()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = (ext.$config()['$[]']("contexts")['$include?'](context))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ext
- } else {
- return false
- }
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$find_block_extension', function(name) {
- var self = this;
-
- return self.block_extensions['$[]'](name.$to_sym());
- });
-
- Opal.defn(self, '$block_macro', TMP_17 = function() {
- var $a, $b, self = this, $iter = TMP_17.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_17.$$p = null;
- return ($a = ($b = self).$add_syntax_processor, $a.$$p = block.$to_proc(), $a).call($b, "block_macro", args);
- });
-
- Opal.defn(self, '$block_macros?', function() {
- var self = this;
-
- return self.block_macro_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$registered_for_block_macro?', function(name) {
- var $a, self = this, ext = nil;
-
- if ((($a = (ext = self.block_macro_extensions['$[]'](name.$to_sym()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ext
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$find_block_macro_extension', function(name) {
- var self = this;
-
- return self.block_macro_extensions['$[]'](name.$to_sym());
- });
-
- Opal.defn(self, '$inline_macro', TMP_18 = function() {
- var $a, $b, self = this, $iter = TMP_18.$$p, block = $iter || nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_18.$$p = null;
- return ($a = ($b = self).$add_syntax_processor, $a.$$p = block.$to_proc(), $a).call($b, "inline_macro", args);
- });
-
- Opal.defn(self, '$inline_macros?', function() {
- var self = this;
-
- return self.inline_macro_extensions['$!']()['$!']();
- });
-
- Opal.defn(self, '$registered_for_inline_macro?', function(name) {
- var $a, self = this, ext = nil;
-
- if ((($a = (ext = self.inline_macro_extensions['$[]'](name.$to_sym()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return ext
- } else {
- return false
- };
- });
-
- Opal.defn(self, '$find_inline_macro_extension', function(name) {
- var self = this;
-
- return self.inline_macro_extensions['$[]'](name.$to_sym());
- });
-
- Opal.defn(self, '$inline_macros', function() {
- var self = this;
-
- return self.inline_macro_extensions.$values();
- });
-
- self.$private();
-
- Opal.defn(self, '$add_document_processor', TMP_19 = function(kind, args) {
- var $a, $b, TMP_20, $c, $d, $e, self = this, $iter = TMP_19.$$p, block = $iter || nil, kind_name = nil, kind_class_symbol = nil, kind_class = nil, kind_java_class = nil, kind_store = nil, extension = nil, config = nil, processor = nil, processor_instance = nil;
-
- TMP_19.$$p = null;
- kind_name = kind.$to_s().$tr("_", " ");
- kind_class_symbol = ($a = ($b = kind_name.$split(" ")).$map, $a.$$p = (TMP_20 = function(word){var self = TMP_20.$$s || this;
-if (word == null) word = nil;
- return "" + (word.$chr().$upcase()) + (word['$[]']($range(1, -1, false)))}, TMP_20.$$s = self, TMP_20), $a).call($b).$join().$to_sym();
- kind_class = $scope.get('Extensions').$const_get(kind_class_symbol);
- kind_java_class = (function() {if ((($a = ((Opal.Object.$$scope.AsciidoctorJ == null ? nil : 'constant'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (((Opal.get('AsciidoctorJ')).$$scope.get('Extensions')).$const_get(kind_class_symbol))
- } else {
- return nil
- }; return nil; })();
- kind_store = ((($a = self.$instance_variable_get(((("@") + (kind)) + "_extensions").$to_sym())) !== false && $a !== nil) ? $a : self.$instance_variable_set(((("@") + (kind)) + "_extensions").$to_sym(), []));
- extension = (function() {if ((block !== nil)) {
- config = self.$resolve_args(args, 1);
- processor = kind_class.$new(config);
- if ((($a = kind_class.$constants().$grep("DSL")) !== nil && (!$a.$$is_boolean || $a == true))) {
- processor.$extend(kind_class.$const_get("DSL"))};
- ($a = ($c = processor).$instance_exec, $a.$$p = block.$to_proc(), $a).call($c);
- processor.$freeze();
- if ((($a = processor['$process_block_given?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("No block specified to process " + (kind_name) + " extension at " + (block.$source_location())))
- };
- return $scope.get('ProcessorExtension').$new(kind, processor);
- } else {
- $a = Opal.to_ary(self.$resolve_args(args, 2)), processor = ($a[0] == null ? nil : $a[0]), config = ($a[1] == null ? nil : $a[1]);
- if ((($a = ((($d = (processor['$is_a?'](Opal.get('Class')))) !== false && $d !== nil) ? $d : (($e = (processor['$is_a?'](Opal.get('String'))), $e !== false && $e !== nil ?(processor = $scope.get('Extensions').$class_for_name(processor)) : $e)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ((($d = $rb_lt(processor, kind_class)) !== false && $d !== nil) ? $d : ((($e = kind_java_class !== false && kind_java_class !== nil) ? $rb_lt(processor, kind_java_class) : kind_java_class)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("Invalid type for " + (kind_name) + " extension: " + (processor)))
- };
- processor_instance = processor.$new(config);
- processor_instance.$freeze();
- return $scope.get('ProcessorExtension').$new(kind, processor_instance);
- } else if ((($a = ((($d = (processor['$is_a?'](kind_class))) !== false && $d !== nil) ? $d : ((($e = kind_java_class !== false && kind_java_class !== nil) ? (processor['$is_a?'](kind_java_class)) : kind_java_class)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- processor.$update_config(config);
- processor.$freeze();
- return $scope.get('ProcessorExtension').$new(kind, processor);
- } else {
- return self.$raise(Opal.get('ArgumentError').$new("Invalid arguments specified for registering " + (kind_name) + " extension: " + (args)))
- };
- }; return nil; })();
- if (extension.$config()['$[]']("position")['$=='](">>")) {
- return kind_store.$unshift(extension)
- } else {
- return kind_store['$<<'](extension)
- };
- });
-
- Opal.defn(self, '$add_syntax_processor', TMP_21 = function(kind, args) {
- var $a, $b, TMP_22, $c, $d, $e, self = this, $iter = TMP_21.$$p, block = $iter || nil, kind_name = nil, kind_class_basename = nil, kind_class_symbol = nil, kind_class = nil, kind_java_class = nil, kind_store = nil, name = nil, config = nil, processor = nil, processor_instance = nil;
-
- TMP_21.$$p = null;
- kind_name = kind.$to_s().$tr("_", " ");
- kind_class_basename = ($a = ($b = kind_name.$split(" ")).$map, $a.$$p = (TMP_22 = function(word){var self = TMP_22.$$s || this;
-if (word == null) word = nil;
- return "" + (word.$chr().$upcase()) + (word['$[]']($range(1, -1, false)))}, TMP_22.$$s = self, TMP_22), $a).call($b).$join();
- kind_class_symbol = ((("") + (kind_class_basename)) + "Processor").$to_sym();
- kind_class = $scope.get('Extensions').$const_get(kind_class_symbol);
- kind_java_class = (function() {if ((($a = ((Opal.Object.$$scope.AsciidoctorJ == null ? nil : 'constant'))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return (((Opal.get('AsciidoctorJ')).$$scope.get('Extensions')).$const_get(kind_class_symbol))
- } else {
- return nil
- }; return nil; })();
- kind_store = ((($a = self.$instance_variable_get(((("@") + (kind)) + "_extensions").$to_sym())) !== false && $a !== nil) ? $a : self.$instance_variable_set(((("@") + (kind)) + "_extensions").$to_sym(), $hash2([], {})));
- if ((block !== nil)) {
- $a = Opal.to_ary(self.$resolve_args(args, 2)), name = ($a[0] == null ? nil : $a[0]), config = ($a[1] == null ? nil : $a[1]);
- processor = kind_class.$new(self.$as_symbol(name), config);
- if ((($a = kind_class.$constants().$grep("DSL")) !== nil && (!$a.$$is_boolean || $a == true))) {
- processor.$extend(kind_class.$const_get("DSL"))};
- if (block.$arity()['$=='](1)) {
- if (Opal.yield1(block, processor) === $breaker) return $breaker.$v
- } else {
- ($a = ($c = processor).$instance_exec, $a.$$p = block.$to_proc(), $a).call($c)
- };
- if ((($a = (name = self.$as_symbol(processor.$name()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("No name specified for " + (kind_name) + " extension at " + (block.$source_location())))
- };
- if ((($a = processor['$process_block_given?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('NoMethodError').$new("No block specified to process " + (kind_name) + " extension at " + (block.$source_location())))
- };
- processor.$freeze();
- return kind_store['$[]='](name, $scope.get('ProcessorExtension').$new(kind, processor));
- } else {
- $a = Opal.to_ary(self.$resolve_args(args, 3)), processor = ($a[0] == null ? nil : $a[0]), name = ($a[1] == null ? nil : $a[1]), config = ($a[2] == null ? nil : $a[2]);
- if ((($a = ((($d = (processor['$is_a?'](Opal.get('Class')))) !== false && $d !== nil) ? $d : (($e = (processor['$is_a?'](Opal.get('String'))), $e !== false && $e !== nil ?(processor = $scope.get('Extensions').$class_for_name(processor)) : $e)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- if ((($a = ((($d = $rb_lt(processor, kind_class)) !== false && $d !== nil) ? $d : ((($e = kind_java_class !== false && kind_java_class !== nil) ? $rb_lt(processor, kind_java_class) : kind_java_class)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("Class specified for " + (kind_name) + " extension does not inherit from " + (kind_class) + ": " + (processor)))
- };
- processor_instance = processor.$new(self.$as_symbol(name), config);
- if ((($a = (name = self.$as_symbol(processor_instance.$name()))) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("No name specified for " + (kind_name) + " extension: " + (processor)))
- };
- processor.$freeze();
- return kind_store['$[]='](name, $scope.get('ProcessorExtension').$new(kind, processor_instance));
- } else if ((($a = ((($d = (processor['$is_a?'](kind_class))) !== false && $d !== nil) ? $d : ((($e = kind_java_class !== false && kind_java_class !== nil) ? (processor['$is_a?'](kind_java_class)) : kind_java_class)))) !== nil && (!$a.$$is_boolean || $a == true))) {
- processor.$update_config(config);
- if ((($a = (name = (function() {if (name !== false && name !== nil) {
- return ((($d = [self.$as_symbol(name)]), $e = processor, $e['$name='].apply($e, $d), $d[$d.length-1]))
- } else {
- return (self.$as_symbol(processor.$name()))
- }; return nil; })())) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("No name specified for " + (kind_name) + " extension: " + (processor)))
- };
- processor.$freeze();
- return kind_store['$[]='](name, $scope.get('ProcessorExtension').$new(kind, processor));
- } else {
- return self.$raise(Opal.get('ArgumentError').$new("Invalid arguments specified for registering " + (kind_name) + " extension: " + (args)))
- };
- };
- });
-
- Opal.defn(self, '$resolve_args', function(args, expect) {
- var $a, self = this, opts = nil, num_args = nil, missing = nil;
-
- opts = (function() {if ((($a = (args['$[]'](-1)['$is_a?'](Opal.get('Hash')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return args.$pop()
- } else {
- return $hash2([], {})
- }; return nil; })();
- if (expect['$=='](1)) {
- return opts};
- num_args = args.$size();
- if ($rb_gt((missing = $rb_minus($rb_minus(expect, 1), num_args)), 0)) {
- args.$fill(nil, num_args, missing)
- } else if ($rb_lt(missing, 0)) {
- args.$pop(missing['$-@']())};
- args['$<<'](opts);
- return args;
- });
-
- return (Opal.defn(self, '$as_symbol', function(name) {
- var $a, self = this;
-
- if (name !== false && name !== nil) {
- return ((function() {if ((($a = (name['$is_a?'](Opal.get('Symbol')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return name
- } else {
- return name.$to_sym()
- }; return nil; })())
- } else {
- return nil
- };
- }), nil) && 'as_symbol';
- })($scope.base, null);
-
- (function(self) {
- var $scope = self.$$scope, def = self.$$proto, TMP_23, TMP_24;
-
- Opal.defn(self, '$generate_name', function() {
- var self = this;
-
- return "extgrp" + (self.$next_auto_id());
- });
- Opal.defn(self, '$next_auto_id', function() {
- var $a, self = this;
- if (self.auto_id == null) self.auto_id = nil;
-
- ((($a = self.auto_id) !== false && $a !== nil) ? $a : self.auto_id = -1);
- return self.auto_id = $rb_plus(self.auto_id, 1);
- });
- Opal.defn(self, '$groups', function() {
- var $a, self = this;
- if (self.groups == null) self.groups = nil;
-
- return ((($a = self.groups) !== false && $a !== nil) ? $a : self.groups = $hash2([], {}));
- });
- Opal.defn(self, '$build_registry', TMP_23 = function(name) {
- var $a, self = this, $iter = TMP_23.$$p, block = $iter || nil;
-
- if (name == null) {
- name = nil
- }
- TMP_23.$$p = null;
- if ((block !== nil)) {
- ((($a = name) !== false && $a !== nil) ? $a : name = self.$generate_name());
- return $scope.get('Registry').$new($hash(name, block));
- } else {
- return $scope.get('Registry').$new()
- };
- });
- Opal.defn(self, '$register', TMP_24 = function() {
- var $a, self = this, $iter = TMP_24.$$p, block = $iter || nil, argc = nil, resolved_group = nil, group = nil, $case = nil, name = nil;
-
- var array_size = arguments.length - 0;
- if(array_size < 0) array_size = 0;
- var args = new Array(array_size);
- for(var arg_index = 0; arg_index < array_size; arg_index++) {
- args[arg_index] = arguments[arg_index + 0];
- }
- TMP_24.$$p = null;
- argc = args.$length();
- resolved_group = (function() {if ((block !== nil)) {
- return block
- } else if ((($a = ((group = args.$pop()))['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return self.$raise(Opal.get('ArgumentError').$new("Extension group to register not specified"))
- } else {
- return (function() {$case = group;if (Opal.get('Class')['$===']($case)) {return group}else if (Opal.get('String')['$===']($case)) {return self.$class_for_name(group)}else if (Opal.get('Symbol')['$===']($case)) {return self.$class_for_name(group.$to_s())}else {return group}})()
- }; return nil; })();
- name = ((($a = args.$pop()) !== false && $a !== nil) ? $a : self.$generate_name());
- if ((($a = args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- } else {
- self.$raise(Opal.get('ArgumentError').$new("Wrong number of arguments (" + (argc) + " for 1..2)"))
- };
- return self.$groups()['$[]='](name, resolved_group);
- });
- Opal.defn(self, '$unregister_all', function() {
- var self = this;
-
- return self.groups = $hash2([], {});
- });
- Opal.defn(self, '$resolve_class', function(object) {
- var $a, self = this;
-
- if ((($a = (object['$is_a?'](Opal.get('Class')))) !== nil && (!$a.$$is_boolean || $a == true))) {
- return object
- } else {
- return (self.$class_for_name(object.$to_s()))
- };
- });
- return (Opal.defn(self, '$class_for_name', function(qualified_name) {
- var $a, $b, TMP_25, self = this, resolved_class = nil;
-
- resolved_class = Opal.get('Object');
- ($a = ($b = qualified_name.$split("::")).$each, $a.$$p = (TMP_25 = function(name){var self = TMP_25.$$s || this, $a;
-if (name == null) name = nil;
- if ((($a = name['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
- return nil
- } else if ((($a = resolved_class['$const_defined?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
- return resolved_class = resolved_class.$const_get(name)
- } else {
- return self.$raise("Could not resolve class for name: " + (qualified_name))
- }}, TMP_25.$$s = self, TMP_25), $a).call($b);
- return resolved_class;
- }), nil) && 'class_for_name';
- })(Opal.get_singleton_class(self));
- })($scope.base)
- })($scope.base)
-})(Opal);
-
-/* Generated by Opal 0.9.0.beta2 */
-(function(Opal) {
- Opal.dynamic_require_severity = "ignore";
- var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true };
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;
-
- return nil
-})(Opal);
diff --git a/js/marked.js b/js/marked.js
deleted file mode 100644
index 03251f3..0000000
--- a/js/marked.js
+++ /dev/null
@@ -1,1285 +0,0 @@
-/**
- * marked - a markdown parser
- * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
- * https://github.com/chjj/marked
- */
-
-;(function() {
-
-/**
- * Block-Level Grammar
- */
-
-var block = {
- newline: /^\n+/,
- code: /^( {4}[^\n]+\n*)+/,
- fences: noop,
- hr: /^( *[-*_]){3,} *(?:\n+|$)/,
- heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
- nptable: noop,
- lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
- blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
- list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
- html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
- def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
- table: noop,
- paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
- text: /^[^\n]+/
-};
-
-block.bullet = /(?:[*+-]|\d+\.)/;
-block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
-block.item = replace(block.item, 'gm')
- (/bull/g, block.bullet)
- ();
-
-block.list = replace(block.list)
- (/bull/g, block.bullet)
- ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
- ('def', '\\n+(?=' + block.def.source + ')')
- ();
-
-block.blockquote = replace(block.blockquote)
- ('def', block.def)
- ();
-
-block._tag = '(?!(?:'
- + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
- + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
- + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
-
-block.html = replace(block.html)
- ('comment', //)
- ('closed', /<(tag)[\s\S]+?<\/\1>/)
- ('closing', /])*?>/)
- (/tag/g, block._tag)
- ();
-
-block.paragraph = replace(block.paragraph)
- ('hr', block.hr)
- ('heading', block.heading)
- ('lheading', block.lheading)
- ('blockquote', block.blockquote)
- ('tag', '<' + block._tag)
- ('def', block.def)
- ();
-
-/**
- * Normal Block Grammar
- */
-
-block.normal = merge({}, block);
-
-/**
- * GFM Block Grammar
- */
-
-block.gfm = merge({}, block.normal, {
- fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
- paragraph: /^/,
- heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
-});
-
-block.gfm.paragraph = replace(block.paragraph)
- ('(?!', '(?!'
- + block.gfm.fences.source.replace('\\1', '\\2') + '|'
- + block.list.source.replace('\\1', '\\3') + '|')
- ();
-
-/**
- * GFM + Tables Block Grammar
- */
-
-block.tables = merge({}, block.gfm, {
- nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
- table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
-});
-
-/**
- * Block Lexer
- */
-
-function Lexer(options) {
- this.tokens = [];
- this.tokens.links = {};
- this.options = options || marked.defaults;
- this.rules = block.normal;
-
- if (this.options.gfm) {
- if (this.options.tables) {
- this.rules = block.tables;
- } else {
- this.rules = block.gfm;
- }
- }
-}
-
-/**
- * Expose Block Rules
- */
-
-Lexer.rules = block;
-
-/**
- * Static Lex Method
- */
-
-Lexer.lex = function(src, options) {
- var lexer = new Lexer(options);
- return lexer.lex(src);
-};
-
-/**
- * Preprocessing
- */
-
-Lexer.prototype.lex = function(src) {
- src = src
- .replace(/\r\n|\r/g, '\n')
- .replace(/\t/g, ' ')
- .replace(/\u00a0/g, ' ')
- .replace(/\u2424/g, '\n');
-
- return this.token(src, true);
-};
-
-/**
- * Lexing
- */
-
-Lexer.prototype.token = function(src, top, bq) {
- var src = src.replace(/^ +$/gm, '')
- , next
- , loose
- , cap
- , bull
- , b
- , item
- , space
- , i
- , l;
-
- while (src) {
- // newline
- if (cap = this.rules.newline.exec(src)) {
- src = src.substring(cap[0].length);
- if (cap[0].length > 1) {
- this.tokens.push({
- type: 'space'
- });
- }
- }
-
- // code
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- cap = cap[0].replace(/^ {4}/gm, '');
- this.tokens.push({
- type: 'code',
- text: !this.options.pedantic
- ? cap.replace(/\n+$/, '')
- : cap
- });
- continue;
- }
-
- // fences (gfm)
- if (cap = this.rules.fences.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'code',
- lang: cap[2],
- text: cap[3] || ''
- });
- continue;
- }
-
- // heading
- if (cap = this.rules.heading.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'heading',
- depth: cap[1].length,
- text: cap[2]
- });
- continue;
- }
-
- // table no leading pipe (gfm)
- if (top && (cap = this.rules.nptable.exec(src))) {
- src = src.substring(cap[0].length);
-
- item = {
- type: 'table',
- header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
- cells: cap[3].replace(/\n$/, '').split('\n')
- };
-
- for (i = 0; i < item.align.length; i++) {
- if (/^ *-+: *$/.test(item.align[i])) {
- item.align[i] = 'right';
- } else if (/^ *:-+: *$/.test(item.align[i])) {
- item.align[i] = 'center';
- } else if (/^ *:-+ *$/.test(item.align[i])) {
- item.align[i] = 'left';
- } else {
- item.align[i] = null;
- }
- }
-
- for (i = 0; i < item.cells.length; i++) {
- item.cells[i] = item.cells[i].split(/ *\| */);
- }
-
- this.tokens.push(item);
-
- continue;
- }
-
- // lheading
- if (cap = this.rules.lheading.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'heading',
- depth: cap[2] === '=' ? 1 : 2,
- text: cap[1]
- });
- continue;
- }
-
- // hr
- if (cap = this.rules.hr.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'hr'
- });
- continue;
- }
-
- // blockquote
- if (cap = this.rules.blockquote.exec(src)) {
- src = src.substring(cap[0].length);
-
- this.tokens.push({
- type: 'blockquote_start'
- });
-
- cap = cap[0].replace(/^ *> ?/gm, '');
-
- // Pass `top` to keep the current
- // "toplevel" state. This is exactly
- // how markdown.pl works.
- this.token(cap, top, true);
-
- this.tokens.push({
- type: 'blockquote_end'
- });
-
- continue;
- }
-
- // list
- if (cap = this.rules.list.exec(src)) {
- src = src.substring(cap[0].length);
- bull = cap[2];
-
- this.tokens.push({
- type: 'list_start',
- ordered: bull.length > 1
- });
-
- // Get each top-level item.
- cap = cap[0].match(this.rules.item);
-
- next = false;
- l = cap.length;
- i = 0;
-
- for (; i < l; i++) {
- item = cap[i];
-
- // Remove the list item's bullet
- // so it is seen as the next token.
- space = item.length;
- item = item.replace(/^ *([*+-]|\d+\.) +/, '');
-
- // Outdent whatever the
- // list item contains. Hacky.
- if (~item.indexOf('\n ')) {
- space -= item.length;
- item = !this.options.pedantic
- ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
- : item.replace(/^ {1,4}/gm, '');
- }
-
- // Determine whether the next list item belongs here.
- // Backpedal if it does not belong in this list.
- if (this.options.smartLists && i !== l - 1) {
- b = block.bullet.exec(cap[i + 1])[0];
- if (bull !== b && !(bull.length > 1 && b.length > 1)) {
- src = cap.slice(i + 1).join('\n') + src;
- i = l - 1;
- }
- }
-
- // Determine whether item is loose or not.
- // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
- // for discount behavior.
- loose = next || /\n\n(?!\s*$)/.test(item);
- if (i !== l - 1) {
- next = item.charAt(item.length - 1) === '\n';
- if (!loose) loose = next;
- }
-
- this.tokens.push({
- type: loose
- ? 'loose_item_start'
- : 'list_item_start'
- });
-
- // Recurse.
- this.token(item, false, bq);
-
- this.tokens.push({
- type: 'list_item_end'
- });
- }
-
- this.tokens.push({
- type: 'list_end'
- });
-
- continue;
- }
-
- // html
- if (cap = this.rules.html.exec(src)) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: this.options.sanitize
- ? 'paragraph'
- : 'html',
- pre: !this.options.sanitizer
- && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
- text: cap[0]
- });
- continue;
- }
-
- // def
- if ((!bq && top) && (cap = this.rules.def.exec(src))) {
- src = src.substring(cap[0].length);
- this.tokens.links[cap[1].toLowerCase()] = {
- href: cap[2],
- title: cap[3]
- };
- continue;
- }
-
- // table (gfm)
- if (top && (cap = this.rules.table.exec(src))) {
- src = src.substring(cap[0].length);
-
- item = {
- type: 'table',
- header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
- align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
- cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
- };
-
- for (i = 0; i < item.align.length; i++) {
- if (/^ *-+: *$/.test(item.align[i])) {
- item.align[i] = 'right';
- } else if (/^ *:-+: *$/.test(item.align[i])) {
- item.align[i] = 'center';
- } else if (/^ *:-+ *$/.test(item.align[i])) {
- item.align[i] = 'left';
- } else {
- item.align[i] = null;
- }
- }
-
- for (i = 0; i < item.cells.length; i++) {
- item.cells[i] = item.cells[i]
- .replace(/^ *\| *| *\| *$/g, '')
- .split(/ *\| */);
- }
-
- this.tokens.push(item);
-
- continue;
- }
-
- // top-level paragraph
- if (top && (cap = this.rules.paragraph.exec(src))) {
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'paragraph',
- text: cap[1].charAt(cap[1].length - 1) === '\n'
- ? cap[1].slice(0, -1)
- : cap[1]
- });
- continue;
- }
-
- // text
- if (cap = this.rules.text.exec(src)) {
- // Top-level should never reach here.
- src = src.substring(cap[0].length);
- this.tokens.push({
- type: 'text',
- text: cap[0]
- });
- continue;
- }
-
- if (src) {
- throw new
- Error('Infinite loop on byte: ' + src.charCodeAt(0));
- }
- }
-
- return this.tokens;
-};
-
-/**
- * Inline-Level Grammar
- */
-
-var inline = {
- escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
- autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
- url: noop,
- tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
- link: /^!?\[(inside)\]\(href\)/,
- reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
- nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
- strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
- em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
- code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
- br: /^ {2,}\n(?!\s*$)/,
- del: noop,
- text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;
-
-inline.link = replace(inline.link)
- ('inside', inline._inside)
- ('href', inline._href)
- ();
-
-inline.reflink = replace(inline.reflink)
- ('inside', inline._inside)
- ();
-
-/**
- * Normal Inline Grammar
- */
-
-inline.normal = merge({}, inline);
-
-/**
- * Pedantic Inline Grammar
- */
-
-inline.pedantic = merge({}, inline.normal, {
- strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
- em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
-});
-
-/**
- * GFM Inline Grammar
- */
-
-inline.gfm = merge({}, inline.normal, {
- escape: replace(inline.escape)('])', '~|])')(),
- url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
- del: /^~~(?=\S)([\s\S]*?\S)~~/,
- text: replace(inline.text)
- (']|', '~]|')
- ('|', '|https?://|')
- ()
-});
-
-/**
- * GFM + Line Breaks Inline Grammar
- */
-
-inline.breaks = merge({}, inline.gfm, {
- br: replace(inline.br)('{2,}', '*')(),
- text: replace(inline.gfm.text)('{2,}', '*')()
-});
-
-/**
- * Inline Lexer & Compiler
- */
-
-function InlineLexer(links, options) {
- this.options = options || marked.defaults;
- this.links = links;
- this.rules = inline.normal;
- this.renderer = this.options.renderer || new Renderer;
- this.renderer.options = this.options;
-
- if (!this.links) {
- throw new
- Error('Tokens array requires a `links` property.');
- }
-
- if (this.options.gfm) {
- if (this.options.breaks) {
- this.rules = inline.breaks;
- } else {
- this.rules = inline.gfm;
- }
- } else if (this.options.pedantic) {
- this.rules = inline.pedantic;
- }
-}
-
-/**
- * Expose Inline Rules
- */
-
-InlineLexer.rules = inline;
-
-/**
- * Static Lexing/Compiling Method
- */
-
-InlineLexer.output = function(src, links, options) {
- var inline = new InlineLexer(links, options);
- return inline.output(src);
-};
-
-/**
- * Lexing/Compiling
- */
-
-InlineLexer.prototype.output = function(src) {
- var out = ''
- , link
- , text
- , href
- , cap;
-
- while (src) {
- // escape
- if (cap = this.rules.escape.exec(src)) {
- src = src.substring(cap[0].length);
- out += cap[1];
- continue;
- }
-
- // autolink
- if (cap = this.rules.autolink.exec(src)) {
- src = src.substring(cap[0].length);
- if (cap[2] === '@') {
- text = cap[1].charAt(6) === ':'
- ? this.mangle(cap[1].substring(7))
- : this.mangle(cap[1]);
- href = this.mangle('mailto:') + text;
- } else {
- text = escape(cap[1]);
- href = text;
- }
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // url (gfm)
- if (!this.inLink && (cap = this.rules.url.exec(src))) {
- src = src.substring(cap[0].length);
- text = escape(cap[1]);
- href = text;
- out += this.renderer.link(href, null, text);
- continue;
- }
-
- // tag
- if (cap = this.rules.tag.exec(src)) {
- if (!this.inLink && /^/i.test(cap[0])) {
- this.inLink = false;
- }
- src = src.substring(cap[0].length);
- out += this.options.sanitize
- ? this.options.sanitizer
- ? this.options.sanitizer(cap[0])
- : escape(cap[0])
- : cap[0]
- continue;
- }
-
- // link
- if (cap = this.rules.link.exec(src)) {
- src = src.substring(cap[0].length);
- this.inLink = true;
- out += this.outputLink(cap, {
- href: cap[2],
- title: cap[3]
- });
- this.inLink = false;
- continue;
- }
-
- // reflink, nolink
- if ((cap = this.rules.reflink.exec(src))
- || (cap = this.rules.nolink.exec(src))) {
- src = src.substring(cap[0].length);
- link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
- link = this.links[link.toLowerCase()];
- if (!link || !link.href) {
- out += cap[0].charAt(0);
- src = cap[0].substring(1) + src;
- continue;
- }
- this.inLink = true;
- out += this.outputLink(cap, link);
- this.inLink = false;
- continue;
- }
-
- // strong
- if (cap = this.rules.strong.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.strong(this.output(cap[2] || cap[1]));
- continue;
- }
-
- // em
- if (cap = this.rules.em.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.em(this.output(cap[2] || cap[1]));
- continue;
- }
-
- // code
- if (cap = this.rules.code.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.codespan(escape(cap[2], true));
- continue;
- }
-
- // br
- if (cap = this.rules.br.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.br();
- continue;
- }
-
- // del (gfm)
- if (cap = this.rules.del.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.del(this.output(cap[1]));
- continue;
- }
-
- // text
- if (cap = this.rules.text.exec(src)) {
- src = src.substring(cap[0].length);
- out += this.renderer.text(escape(this.smartypants(cap[0])));
- continue;
- }
-
- if (src) {
- throw new
- Error('Infinite loop on byte: ' + src.charCodeAt(0));
- }
- }
-
- return out;
-};
-
-/**
- * Compile Link
- */
-
-InlineLexer.prototype.outputLink = function(cap, link) {
- var href = escape(link.href)
- , title = link.title ? escape(link.title) : null;
-
- return cap[0].charAt(0) !== '!'
- ? this.renderer.link(href, title, this.output(cap[1]))
- : this.renderer.image(href, title, escape(cap[1]));
-};
-
-/**
- * Smartypants Transformations
- */
-
-InlineLexer.prototype.smartypants = function(text) {
- if (!this.options.smartypants) return text;
- return text
- // em-dashes
- .replace(/---/g, '\u2014')
- // en-dashes
- .replace(/--/g, '\u2013')
- // opening singles
- .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
- // closing singles & apostrophes
- .replace(/'/g, '\u2019')
- // opening doubles
- .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
- // closing doubles
- .replace(/"/g, '\u201d')
- // ellipses
- .replace(/\.{3}/g, '\u2026');
-};
-
-/**
- * Mangle Links
- */
-
-InlineLexer.prototype.mangle = function(text) {
- if (!this.options.mangle) return text;
- var out = ''
- , l = text.length
- , i = 0
- , ch;
-
- for (; i < l; i++) {
- ch = text.charCodeAt(i);
- if (Math.random() > 0.5) {
- ch = 'x' + ch.toString(16);
- }
- out += '' + ch + ';';
- }
-
- return out;
-};
-
-/**
- * Renderer
- */
-
-function Renderer(options) {
- this.options = options || {};
-}
-
-Renderer.prototype.code = function(code, lang, escaped) {
- if (this.options.highlight) {
- var out = this.options.highlight(code, lang);
- if (out != null && out !== code) {
- escaped = true;
- code = out;
- }
- }
-
- if (!lang) {
- return ''
- + (escaped ? code : escape(code, true))
- + '\n
';
- }
-
- return ''
- + (escaped ? code : escape(code, true))
- + '\n
\n';
-};
-
-Renderer.prototype.blockquote = function(quote) {
- return '\n' + quote + ' \n';
-};
-
-Renderer.prototype.html = function(html) {
- return html;
-};
-
-Renderer.prototype.heading = function(text, level, raw) {
- return '\n';
-};
-
-Renderer.prototype.hr = function() {
- return this.options.xhtml ? ' \n' : ' \n';
-};
-
-Renderer.prototype.list = function(body, ordered) {
- var type = ordered ? 'ol' : 'ul';
- return '<' + type + '>\n' + body + '' + type + '>\n';
-};
-
-Renderer.prototype.listitem = function(text) {
- return '' + text + ' \n';
-};
-
-Renderer.prototype.paragraph = function(text) {
- return '' + text + '
\n';
-};
-
-Renderer.prototype.table = function(header, body) {
- return ' \n'
- + '\n'
- + header
- + ' \n'
- + '\n'
- + body
- + ' \n'
- + '
\n';
-};
-
-Renderer.prototype.tablerow = function(content) {
- return '\n' + content + ' \n';
-};
-
-Renderer.prototype.tablecell = function(content, flags) {
- var type = flags.header ? 'th' : 'td';
- var tag = flags.align
- ? '<' + type + ' style="text-align:' + flags.align + '">'
- : '<' + type + '>';
- return tag + content + '' + type + '>\n';
-};
-
-// span level renderer
-Renderer.prototype.strong = function(text) {
- return '' + text + ' ';
-};
-
-Renderer.prototype.em = function(text) {
- return '' + text + ' ';
-};
-
-Renderer.prototype.codespan = function(text) {
- return '' + text + '
';
-};
-
-Renderer.prototype.br = function() {
- return this.options.xhtml ? ' ' : ' ';
-};
-
-Renderer.prototype.del = function(text) {
- return '' + text + '';
-};
-
-Renderer.prototype.link = function(href, title, text) {
- if (this.options.sanitize) {
- try {
- var prot = decodeURIComponent(unescape(href))
- .replace(/[^\w:]/g, '')
- .toLowerCase();
- } catch (e) {
- return '';
- }
- if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
- return '';
- }
- }
- var out = '' + text + ' ';
- return out;
-};
-
-Renderer.prototype.image = function(href, title, text) {
- var out = ' ' : '>';
- return out;
-};
-
-Renderer.prototype.text = function(text) {
- return text;
-};
-
-/**
- * Parsing & Compiling
- */
-
-function Parser(options) {
- this.tokens = [];
- this.token = null;
- this.options = options || marked.defaults;
- this.options.renderer = this.options.renderer || new Renderer;
- this.renderer = this.options.renderer;
- this.renderer.options = this.options;
-}
-
-/**
- * Static Parse Method
- */
-
-Parser.parse = function(src, options, renderer) {
- var parser = new Parser(options, renderer);
- return parser.parse(src);
-};
-
-/**
- * Parse Loop
- */
-
-Parser.prototype.parse = function(src) {
- this.inline = new InlineLexer(src.links, this.options, this.renderer);
- this.tokens = src.reverse();
-
- var out = '';
- while (this.next()) {
- out += this.tok();
- }
-
- return out;
-};
-
-/**
- * Next Token
- */
-
-Parser.prototype.next = function() {
- return this.token = this.tokens.pop();
-};
-
-/**
- * Preview Next Token
- */
-
-Parser.prototype.peek = function() {
- return this.tokens[this.tokens.length - 1] || 0;
-};
-
-/**
- * Parse Text Tokens
- */
-
-Parser.prototype.parseText = function() {
- var body = this.token.text;
-
- while (this.peek().type === 'text') {
- body += '\n' + this.next().text;
- }
-
- return this.inline.output(body);
-};
-
-/**
- * Parse Current Token
- */
-
-Parser.prototype.tok = function() {
- switch (this.token.type) {
- case 'space': {
- return '';
- }
- case 'hr': {
- return this.renderer.hr();
- }
- case 'heading': {
- return this.renderer.heading(
- this.inline.output(this.token.text),
- this.token.depth,
- this.token.text);
- }
- case 'code': {
- return this.renderer.code(this.token.text,
- this.token.lang,
- this.token.escaped);
- }
- case 'table': {
- var header = ''
- , body = ''
- , i
- , row
- , cell
- , flags
- , j;
-
- // header
- cell = '';
- for (i = 0; i < this.token.header.length; i++) {
- flags = { header: true, align: this.token.align[i] };
- cell += this.renderer.tablecell(
- this.inline.output(this.token.header[i]),
- { header: true, align: this.token.align[i] }
- );
- }
- header += this.renderer.tablerow(cell);
-
- for (i = 0; i < this.token.cells.length; i++) {
- row = this.token.cells[i];
-
- cell = '';
- for (j = 0; j < row.length; j++) {
- cell += this.renderer.tablecell(
- this.inline.output(row[j]),
- { header: false, align: this.token.align[j] }
- );
- }
-
- body += this.renderer.tablerow(cell);
- }
- return this.renderer.table(header, body);
- }
- case 'blockquote_start': {
- var body = '';
-
- while (this.next().type !== 'blockquote_end') {
- body += this.tok();
- }
-
- return this.renderer.blockquote(body);
- }
- case 'list_start': {
- var body = ''
- , ordered = this.token.ordered;
-
- while (this.next().type !== 'list_end') {
- body += this.tok();
- }
-
- return this.renderer.list(body, ordered);
- }
- case 'list_item_start': {
- var body = '';
-
- while (this.next().type !== 'list_item_end') {
- body += this.token.type === 'text'
- ? this.parseText()
- : this.tok();
- }
-
- return this.renderer.listitem(body);
- }
- case 'loose_item_start': {
- var body = '';
-
- while (this.next().type !== 'list_item_end') {
- body += this.tok();
- }
-
- return this.renderer.listitem(body);
- }
- case 'html': {
- var html = !this.token.pre && !this.options.pedantic
- ? this.inline.output(this.token.text)
- : this.token.text;
- return this.renderer.html(html);
- }
- case 'paragraph': {
- return this.renderer.paragraph(this.inline.output(this.token.text));
- }
- case 'text': {
- return this.renderer.paragraph(this.parseText());
- }
- }
-};
-
-/**
- * Helpers
- */
-
-function escape(html, encode) {
- return html
- .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
- .replace(//g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''');
-}
-
-function unescape(html) {
- return html.replace(/&([#\w]+);/g, function(_, n) {
- n = n.toLowerCase();
- if (n === 'colon') return ':';
- if (n.charAt(0) === '#') {
- return n.charAt(1) === 'x'
- ? String.fromCharCode(parseInt(n.substring(2), 16))
- : String.fromCharCode(+n.substring(1));
- }
- return '';
- });
-}
-
-function replace(regex, opt) {
- regex = regex.source;
- opt = opt || '';
- return function self(name, val) {
- if (!name) return new RegExp(regex, opt);
- val = val.source || val;
- val = val.replace(/(^|[^\[])\^/g, '$1');
- regex = regex.replace(name, val);
- return self;
- };
-}
-
-function noop() {}
-noop.exec = noop;
-
-function merge(obj) {
- var i = 1
- , target
- , key;
-
- for (; i < arguments.length; i++) {
- target = arguments[i];
- for (key in target) {
- if (Object.prototype.hasOwnProperty.call(target, key)) {
- obj[key] = target[key];
- }
- }
- }
-
- return obj;
-}
-
-
-/**
- * Marked
- */
-
-function marked(src, opt, callback) {
- if (callback || typeof opt === 'function') {
- if (!callback) {
- callback = opt;
- opt = null;
- }
-
- opt = merge({}, marked.defaults, opt || {});
-
- var highlight = opt.highlight
- , tokens
- , pending
- , i = 0;
-
- try {
- tokens = Lexer.lex(src, opt)
- } catch (e) {
- return callback(e);
- }
-
- pending = tokens.length;
-
- var done = function(err) {
- if (err) {
- opt.highlight = highlight;
- return callback(err);
- }
-
- var out;
-
- try {
- out = Parser.parse(tokens, opt);
- } catch (e) {
- err = e;
- }
-
- opt.highlight = highlight;
-
- return err
- ? callback(err)
- : callback(null, out);
- };
-
- if (!highlight || highlight.length < 3) {
- return done();
- }
-
- delete opt.highlight;
-
- if (!pending) return done();
-
- for (; i < tokens.length; i++) {
- (function(token) {
- if (token.type !== 'code') {
- return --pending || done();
- }
- return highlight(token.text, token.lang, function(err, code) {
- if (err) return done(err);
- if (code == null || code === token.text) {
- return --pending || done();
- }
- token.text = code;
- token.escaped = true;
- --pending || done();
- });
- })(tokens[i]);
- }
-
- return;
- }
- try {
- if (opt) opt = merge({}, marked.defaults, opt);
- return Parser.parse(Lexer.lex(src, opt), opt);
- } catch (e) {
- e.message += '\nPlease report this to https://github.com/chjj/marked.';
- if ((opt || marked.defaults).silent) {
- return 'An error occured:
'
- + escape(e.message + '', true)
- + ' ';
- }
- throw e;
- }
-}
-
-/**
- * Options
- */
-
-marked.options =
-marked.setOptions = function(opt) {
- merge(marked.defaults, opt);
- return marked;
-};
-
-marked.defaults = {
- gfm: true,
- tables: true,
- breaks: false,
- pedantic: false,
- sanitize: false,
- sanitizer: null,
- mangle: true,
- smartLists: false,
- silent: false,
- highlight: null,
- langPrefix: 'lang-',
- smartypants: false,
- headerPrefix: '',
- renderer: new Renderer,
- xhtml: false
-};
-
-/**
- * Expose
- */
-
-marked.Parser = Parser;
-marked.parser = Parser.parse;
-
-marked.Renderer = Renderer;
-
-marked.Lexer = Lexer;
-marked.lexer = Lexer.lex;
-
-marked.InlineLexer = InlineLexer;
-marked.inlineLexer = InlineLexer.output;
-
-marked.parse = marked;
-
-if (typeof module !== 'undefined' && typeof exports === 'object') {
- module.exports = marked;
-} else if (typeof define === 'function' && define.amd) {
- define(function() { return marked; });
-} else {
- this.marked = marked;
-}
-
-}).call(function() {
- return this || (typeof window !== 'undefined' ? window : global);
-}());
diff --git a/js/require.js b/js/require.js
deleted file mode 100644
index 23ddb4e..0000000
--- a/js/require.js
+++ /dev/null
@@ -1,2142 +0,0 @@
-/** vim: et:ts=4:sw=4:sts=4
- * @license RequireJS 2.2.0 Copyright jQuery Foundation and other contributors.
- * Released under MIT license, http://github.com/requirejs/requirejs/LICENSE
- */
-//Not using strict: uneven strict support in browsers, #392, and causes
-//problems with requirejs.exec()/transpiler plugins that may not be strict.
-/*jslint regexp: true, nomen: true, sloppy: true */
-/*global window, navigator, document, importScripts, setTimeout, opera */
-
-var requirejs, require, define;
-(function (global) {
- var req, s, head, baseElement, dataMain, src,
- interactiveScript, currentlyAddingScript, mainScript, subPath,
- version = '2.2.0',
- commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
- cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
- jsSuffixRegExp = /\.js$/,
- currDirRegExp = /^\.\//,
- op = Object.prototype,
- ostring = op.toString,
- hasOwn = op.hasOwnProperty,
- isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
- isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
- //PS3 indicates loaded and complete, but need to wait for complete
- //specifically. Sequence is 'loading', 'loaded', execution,
- // then 'complete'. The UA check is unfortunate, but not sure how
- //to feature test w/o causing perf issues.
- readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
- /^complete$/ : /^(complete|loaded)$/,
- defContextName = '_',
- //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
- isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
- contexts = {},
- cfg = {},
- globalDefQueue = [],
- useInteractive = false;
-
- //Could match something like ')//comment', do not lose the prefix to comment.
- function commentReplace(match, multi, multiText, singlePrefix) {
- return singlePrefix || '';
- }
-
- function isFunction(it) {
- return ostring.call(it) === '[object Function]';
- }
-
- function isArray(it) {
- return ostring.call(it) === '[object Array]';
- }
-
- /**
- * Helper function for iterating over an array. If the func returns
- * a true value, it will break out of the loop.
- */
- function each(ary, func) {
- if (ary) {
- var i;
- for (i = 0; i < ary.length; i += 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- /**
- * Helper function for iterating over an array backwards. If the func
- * returns a true value, it will break out of the loop.
- */
- function eachReverse(ary, func) {
- if (ary) {
- var i;
- for (i = ary.length - 1; i > -1; i -= 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- function hasProp(obj, prop) {
- return hasOwn.call(obj, prop);
- }
-
- function getOwn(obj, prop) {
- return hasProp(obj, prop) && obj[prop];
- }
-
- /**
- * Cycles over properties in an object and calls a function for each
- * property value. If the function returns a truthy value, then the
- * iteration is stopped.
- */
- function eachProp(obj, func) {
- var prop;
- for (prop in obj) {
- if (hasProp(obj, prop)) {
- if (func(obj[prop], prop)) {
- break;
- }
- }
- }
- }
-
- /**
- * Simple function to mix in properties from source into target,
- * but only if target does not already have a property of the same name.
- */
- function mixin(target, source, force, deepStringMixin) {
- if (source) {
- eachProp(source, function (value, prop) {
- if (force || !hasProp(target, prop)) {
- if (deepStringMixin && typeof value === 'object' && value &&
- !isArray(value) && !isFunction(value) &&
- !(value instanceof RegExp)) {
-
- if (!target[prop]) {
- target[prop] = {};
- }
- mixin(target[prop], value, force, deepStringMixin);
- } else {
- target[prop] = value;
- }
- }
- });
- }
- return target;
- }
-
- //Similar to Function.prototype.bind, but the 'this' object is specified
- //first, since it is easier to read/figure out what 'this' will be.
- function bind(obj, fn) {
- return function () {
- return fn.apply(obj, arguments);
- };
- }
-
- function scripts() {
- return document.getElementsByTagName('script');
- }
-
- function defaultOnError(err) {
- throw err;
- }
-
- //Allow getting a global that is expressed in
- //dot notation, like 'a.b.c'.
- function getGlobal(value) {
- if (!value) {
- return value;
- }
- var g = global;
- each(value.split('.'), function (part) {
- g = g[part];
- });
- return g;
- }
-
- /**
- * Constructs an error with a pointer to an URL with more information.
- * @param {String} id the error ID that maps to an ID on a web page.
- * @param {String} message human readable error.
- * @param {Error} [err] the original error, if there is one.
- *
- * @returns {Error}
- */
- function makeError(id, msg, err, requireModules) {
- var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
- e.requireType = id;
- e.requireModules = requireModules;
- if (err) {
- e.originalError = err;
- }
- return e;
- }
-
- if (typeof define !== 'undefined') {
- //If a define is already in play via another AMD loader,
- //do not overwrite.
- return;
- }
-
- if (typeof requirejs !== 'undefined') {
- if (isFunction(requirejs)) {
- //Do not overwrite an existing requirejs instance.
- return;
- }
- cfg = requirejs;
- requirejs = undefined;
- }
-
- //Allow for a require config object
- if (typeof require !== 'undefined' && !isFunction(require)) {
- //assume it is a config object.
- cfg = require;
- require = undefined;
- }
-
- function newContext(contextName) {
- var inCheckLoaded, Module, context, handlers,
- checkLoadedTimeoutId,
- config = {
- //Defaults. Do not set a default for map
- //config to speed up normalize(), which
- //will run faster if there is no default.
- waitSeconds: 7,
- baseUrl: './',
- paths: {},
- bundles: {},
- pkgs: {},
- shim: {},
- config: {}
- },
- registry = {},
- //registry of just enabled modules, to speed
- //cycle breaking code when lots of modules
- //are registered, but not activated.
- enabledRegistry = {},
- undefEvents = {},
- defQueue = [],
- defined = {},
- urlFetched = {},
- bundlesMap = {},
- requireCounter = 1,
- unnormalizedCounter = 1;
-
- /**
- * Trims the . and .. from an array of path segments.
- * It will keep a leading path segment if a .. will become
- * the first path segment, to help with module name lookups,
- * which act like paths, but can be remapped. But the end result,
- * all paths that use this function should look normalized.
- * NOTE: this method MODIFIES the input array.
- * @param {Array} ary the array of path segments.
- */
- function trimDots(ary) {
- var i, part;
- for (i = 0; i < ary.length; i++) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- // If at the start, or previous value is still ..,
- // keep them so that when converted to a path it may
- // still work when converted to a path, even though
- // as an ID it is less than ideal. In larger point
- // releases, may be better to just kick out an error.
- if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
- continue;
- } else if (i > 0) {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- }
-
- /**
- * Given a relative module name, like ./something, normalize it to
- * a real name that can be mapped to a path.
- * @param {String} name the relative name
- * @param {String} baseName a real name that the name arg is relative
- * to.
- * @param {Boolean} applyMap apply the map config to the value. Should
- * only be done if this normalization is for a dependency ID.
- * @returns {String} normalized name
- */
- function normalize(name, baseName, applyMap) {
- var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
- foundMap, foundI, foundStarMap, starI, normalizedBaseParts,
- baseParts = (baseName && baseName.split('/')),
- map = config.map,
- starMap = map && map['*'];
-
- //Adjust any relative paths.
- if (name) {
- name = name.split('/');
- lastIndex = name.length - 1;
-
- // If wanting node ID compatibility, strip .js from end
- // of IDs. Have to do this here, and not in nameToUrl
- // because node allows either .js or non .js to map
- // to same file.
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
- }
-
- // Starts with a '.' so need the baseName
- if (name[0].charAt(0) === '.' && baseParts) {
- //Convert baseName to array, and lop off the last part,
- //so that . matches that 'directory' and not name of the baseName's
- //module. For instance, baseName of 'one/two/three', maps to
- //'one/two/three.js', but we want the directory, 'one/two' for
- //this normalization.
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
- name = normalizedBaseParts.concat(name);
- }
-
- trimDots(name);
- name = name.join('/');
- }
-
- //Apply map config if available.
- if (applyMap && map && (baseParts || starMap)) {
- nameParts = name.split('/');
-
- outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
- nameSegment = nameParts.slice(0, i).join('/');
-
- if (baseParts) {
- //Find the longest baseName segment match in the config.
- //So, do joins on the biggest to smallest lengths of baseParts.
- for (j = baseParts.length; j > 0; j -= 1) {
- mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
-
- //baseName segment has config, find if it has one for
- //this name.
- if (mapValue) {
- mapValue = getOwn(mapValue, nameSegment);
- if (mapValue) {
- //Match, update name to the new value.
- foundMap = mapValue;
- foundI = i;
- break outerLoop;
- }
- }
- }
- }
-
- //Check for a star map match, but just hold on to it,
- //if there is a shorter segment match later in a matching
- //config, then favor over this star map.
- if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
- foundStarMap = getOwn(starMap, nameSegment);
- starI = i;
- }
- }
-
- if (!foundMap && foundStarMap) {
- foundMap = foundStarMap;
- foundI = starI;
- }
-
- if (foundMap) {
- nameParts.splice(0, foundI, foundMap);
- name = nameParts.join('/');
- }
- }
-
- // If the name points to a package's name, use
- // the package main instead.
- pkgMain = getOwn(config.pkgs, name);
-
- return pkgMain ? pkgMain : name;
- }
-
- function removeScript(name) {
- if (isBrowser) {
- each(scripts(), function (scriptNode) {
- if (scriptNode.getAttribute('data-requiremodule') === name &&
- scriptNode.getAttribute('data-requirecontext') === context.contextName) {
- scriptNode.parentNode.removeChild(scriptNode);
- return true;
- }
- });
- }
- }
-
- function hasPathFallback(id) {
- var pathConfig = getOwn(config.paths, id);
- if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
- //Pop off the first array value, since it failed, and
- //retry
- pathConfig.shift();
- context.require.undef(id);
-
- //Custom require that does not do map translation, since
- //ID is "absolute", already mapped/resolved.
- context.makeRequire(null, {
- skipMap: true
- })([id]);
-
- return true;
- }
- }
-
- //Turns a plugin!resource to [plugin, resource]
- //with the plugin being undefined if the name
- //did not have a plugin prefix.
- function splitPrefix(name) {
- var prefix,
- index = name ? name.indexOf('!') : -1;
- if (index > -1) {
- prefix = name.substring(0, index);
- name = name.substring(index + 1, name.length);
- }
- return [prefix, name];
- }
-
- /**
- * Creates a module mapping that includes plugin prefix, module
- * name, and path. If parentModuleMap is provided it will
- * also normalize the name via require.normalize()
- *
- * @param {String} name the module name
- * @param {String} [parentModuleMap] parent module map
- * for the module name, used to resolve relative names.
- * @param {Boolean} isNormalized: is the ID already normalized.
- * This is true if this call is done for a define() module ID.
- * @param {Boolean} applyMap: apply the map config to the ID.
- * Should only be true if this map is for a dependency.
- *
- * @returns {Object}
- */
- function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
- var url, pluginModule, suffix, nameParts,
- prefix = null,
- parentName = parentModuleMap ? parentModuleMap.name : null,
- originalName = name,
- isDefine = true,
- normalizedName = '';
-
- //If no name, then it means it is a require call, generate an
- //internal name.
- if (!name) {
- isDefine = false;
- name = '_@r' + (requireCounter += 1);
- }
-
- nameParts = splitPrefix(name);
- prefix = nameParts[0];
- name = nameParts[1];
-
- if (prefix) {
- prefix = normalize(prefix, parentName, applyMap);
- pluginModule = getOwn(defined, prefix);
- }
-
- //Account for relative paths if there is a base name.
- if (name) {
- if (prefix) {
- if (pluginModule && pluginModule.normalize) {
- //Plugin is loaded, use its normalize method.
- normalizedName = pluginModule.normalize(name, function (name) {
- return normalize(name, parentName, applyMap);
- });
- } else {
- // If nested plugin references, then do not try to
- // normalize, as it will not normalize correctly. This
- // places a restriction on resourceIds, and the longer
- // term solution is not to normalize until plugins are
- // loaded and all normalizations to allow for async
- // loading of a loader plugin. But for now, fixes the
- // common uses. Details in #1131
- normalizedName = name.indexOf('!') === -1 ?
- normalize(name, parentName, applyMap) :
- name;
- }
- } else {
- //A regular module.
- normalizedName = normalize(name, parentName, applyMap);
-
- //Normalized name may be a plugin ID due to map config
- //application in normalize. The map config values must
- //already be normalized, so do not need to redo that part.
- nameParts = splitPrefix(normalizedName);
- prefix = nameParts[0];
- normalizedName = nameParts[1];
- isNormalized = true;
-
- url = context.nameToUrl(normalizedName);
- }
- }
-
- //If the id is a plugin id that cannot be determined if it needs
- //normalization, stamp it with a unique ID so two matching relative
- //ids that may conflict can be separate.
- suffix = prefix && !pluginModule && !isNormalized ?
- '_unnormalized' + (unnormalizedCounter += 1) :
- '';
-
- return {
- prefix: prefix,
- name: normalizedName,
- parentMap: parentModuleMap,
- unnormalized: !!suffix,
- url: url,
- originalName: originalName,
- isDefine: isDefine,
- id: (prefix ?
- prefix + '!' + normalizedName :
- normalizedName) + suffix
- };
- }
-
- function getModule(depMap) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (!mod) {
- mod = registry[id] = new context.Module(depMap);
- }
-
- return mod;
- }
-
- function on(depMap, name, fn) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (hasProp(defined, id) &&
- (!mod || mod.defineEmitComplete)) {
- if (name === 'defined') {
- fn(defined[id]);
- }
- } else {
- mod = getModule(depMap);
- if (mod.error && name === 'error') {
- fn(mod.error);
- } else {
- mod.on(name, fn);
- }
- }
- }
-
- function onError(err, errback) {
- var ids = err.requireModules,
- notified = false;
-
- if (errback) {
- errback(err);
- } else {
- each(ids, function (id) {
- var mod = getOwn(registry, id);
- if (mod) {
- //Set error on module, so it skips timeout checks.
- mod.error = err;
- if (mod.events.error) {
- notified = true;
- mod.emit('error', err);
- }
- }
- });
-
- if (!notified) {
- req.onError(err);
- }
- }
- }
-
- /**
- * Internal method to transfer globalQueue items to this context's
- * defQueue.
- */
- function takeGlobalQueue() {
- //Push all the globalDefQueue items into the context's defQueue
- if (globalDefQueue.length) {
- each(globalDefQueue, function(queueItem) {
- var id = queueItem[0];
- if (typeof id === 'string') {
- context.defQueueMap[id] = true;
- }
- defQueue.push(queueItem);
- });
- globalDefQueue = [];
- }
- }
-
- handlers = {
- 'require': function (mod) {
- if (mod.require) {
- return mod.require;
- } else {
- return (mod.require = context.makeRequire(mod.map));
- }
- },
- 'exports': function (mod) {
- mod.usingExports = true;
- if (mod.map.isDefine) {
- if (mod.exports) {
- return (defined[mod.map.id] = mod.exports);
- } else {
- return (mod.exports = defined[mod.map.id] = {});
- }
- }
- },
- 'module': function (mod) {
- if (mod.module) {
- return mod.module;
- } else {
- return (mod.module = {
- id: mod.map.id,
- uri: mod.map.url,
- config: function () {
- return getOwn(config.config, mod.map.id) || {};
- },
- exports: mod.exports || (mod.exports = {})
- });
- }
- }
- };
-
- function cleanRegistry(id) {
- //Clean up machinery used for waiting modules.
- delete registry[id];
- delete enabledRegistry[id];
- }
-
- function breakCycle(mod, traced, processed) {
- var id = mod.map.id;
-
- if (mod.error) {
- mod.emit('error', mod.error);
- } else {
- traced[id] = true;
- each(mod.depMaps, function (depMap, i) {
- var depId = depMap.id,
- dep = getOwn(registry, depId);
-
- //Only force things that have not completed
- //being defined, so still in the registry,
- //and only if it has not been matched up
- //in the module already.
- if (dep && !mod.depMatched[i] && !processed[depId]) {
- if (getOwn(traced, depId)) {
- mod.defineDep(i, defined[depId]);
- mod.check(); //pass false?
- } else {
- breakCycle(dep, traced, processed);
- }
- }
- });
- processed[id] = true;
- }
- }
-
- function checkLoaded() {
- var err, usingPathFallback,
- waitInterval = config.waitSeconds * 1000,
- //It is possible to disable the wait interval by using waitSeconds of 0.
- expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
- noLoads = [],
- reqCalls = [],
- stillLoading = false,
- needCycleCheck = true;
-
- //Do not bother if this call was a result of a cycle break.
- if (inCheckLoaded) {
- return;
- }
-
- inCheckLoaded = true;
-
- //Figure out the state of all the modules.
- eachProp(enabledRegistry, function (mod) {
- var map = mod.map,
- modId = map.id;
-
- //Skip things that are not enabled or in error state.
- if (!mod.enabled) {
- return;
- }
-
- if (!map.isDefine) {
- reqCalls.push(mod);
- }
-
- if (!mod.error) {
- //If the module should be executed, and it has not
- //been inited and time is up, remember it.
- if (!mod.inited && expired) {
- if (hasPathFallback(modId)) {
- usingPathFallback = true;
- stillLoading = true;
- } else {
- noLoads.push(modId);
- removeScript(modId);
- }
- } else if (!mod.inited && mod.fetched && map.isDefine) {
- stillLoading = true;
- if (!map.prefix) {
- //No reason to keep looking for unfinished
- //loading. If the only stillLoading is a
- //plugin resource though, keep going,
- //because it may be that a plugin resource
- //is waiting on a non-plugin cycle.
- return (needCycleCheck = false);
- }
- }
- }
- });
-
- if (expired && noLoads.length) {
- //If wait time expired, throw error of unloaded modules.
- err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
- err.contextName = context.contextName;
- return onError(err);
- }
-
- //Not expired, check for a cycle.
- if (needCycleCheck) {
- each(reqCalls, function (mod) {
- breakCycle(mod, {}, {});
- });
- }
-
- //If still waiting on loads, and the waiting load is something
- //other than a plugin resource, or there are still outstanding
- //scripts, then just try back later.
- if ((!expired || usingPathFallback) && stillLoading) {
- //Something is still waiting to load. Wait for it, but only
- //if a timeout is not already in effect.
- if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
- checkLoadedTimeoutId = setTimeout(function () {
- checkLoadedTimeoutId = 0;
- checkLoaded();
- }, 50);
- }
- }
-
- inCheckLoaded = false;
- }
-
- Module = function (map) {
- this.events = getOwn(undefEvents, map.id) || {};
- this.map = map;
- this.shim = getOwn(config.shim, map.id);
- this.depExports = [];
- this.depMaps = [];
- this.depMatched = [];
- this.pluginMaps = {};
- this.depCount = 0;
-
- /* this.exports this.factory
- this.depMaps = [],
- this.enabled, this.fetched
- */
- };
-
- Module.prototype = {
- init: function (depMaps, factory, errback, options) {
- options = options || {};
-
- //Do not do more inits if already done. Can happen if there
- //are multiple define calls for the same module. That is not
- //a normal, common case, but it is also not unexpected.
- if (this.inited) {
- return;
- }
-
- this.factory = factory;
-
- if (errback) {
- //Register for errors on this module.
- this.on('error', errback);
- } else if (this.events.error) {
- //If no errback already, but there are error listeners
- //on this module, set up an errback to pass to the deps.
- errback = bind(this, function (err) {
- this.emit('error', err);
- });
- }
-
- //Do a copy of the dependency array, so that
- //source inputs are not modified. For example
- //"shim" deps are passed in here directly, and
- //doing a direct modification of the depMaps array
- //would affect that config.
- this.depMaps = depMaps && depMaps.slice(0);
-
- this.errback = errback;
-
- //Indicate this module has be initialized
- this.inited = true;
-
- this.ignore = options.ignore;
-
- //Could have option to init this module in enabled mode,
- //or could have been previously marked as enabled. However,
- //the dependencies are not known until init is called. So
- //if enabled previously, now trigger dependencies as enabled.
- if (options.enabled || this.enabled) {
- //Enable this module and dependencies.
- //Will call this.check()
- this.enable();
- } else {
- this.check();
- }
- },
-
- defineDep: function (i, depExports) {
- //Because of cycles, defined callback for a given
- //export can be called more than once.
- if (!this.depMatched[i]) {
- this.depMatched[i] = true;
- this.depCount -= 1;
- this.depExports[i] = depExports;
- }
- },
-
- fetch: function () {
- if (this.fetched) {
- return;
- }
- this.fetched = true;
-
- context.startTime = (new Date()).getTime();
-
- var map = this.map;
-
- //If the manager is for a plugin managed resource,
- //ask the plugin to load it now.
- if (this.shim) {
- context.makeRequire(this.map, {
- enableBuildCallback: true
- })(this.shim.deps || [], bind(this, function () {
- return map.prefix ? this.callPlugin() : this.load();
- }));
- } else {
- //Regular dependency.
- return map.prefix ? this.callPlugin() : this.load();
- }
- },
-
- load: function () {
- var url = this.map.url;
-
- //Regular dependency.
- if (!urlFetched[url]) {
- urlFetched[url] = true;
- context.load(this.map.id, url);
- }
- },
-
- /**
- * Checks if the module is ready to define itself, and if so,
- * define it.
- */
- check: function () {
- if (!this.enabled || this.enabling) {
- return;
- }
-
- var err, cjsModule,
- id = this.map.id,
- depExports = this.depExports,
- exports = this.exports,
- factory = this.factory;
-
- if (!this.inited) {
- // Only fetch if not already in the defQueue.
- if (!hasProp(context.defQueueMap, id)) {
- this.fetch();
- }
- } else if (this.error) {
- this.emit('error', this.error);
- } else if (!this.defining) {
- //The factory could trigger another require call
- //that would result in checking this module to
- //define itself again. If already in the process
- //of doing that, skip this work.
- this.defining = true;
-
- if (this.depCount < 1 && !this.defined) {
- if (isFunction(factory)) {
- //If there is an error listener, favor passing
- //to that instead of throwing an error. However,
- //only do it for define()'d modules. require
- //errbacks should not be called for failures in
- //their callbacks (#699). However if a global
- //onError is set, use that.
- if ((this.events.error && this.map.isDefine) ||
- req.onError !== defaultOnError) {
- try {
- exports = context.execCb(id, factory, depExports, exports);
- } catch (e) {
- err = e;
- }
- } else {
- exports = context.execCb(id, factory, depExports, exports);
- }
-
- // Favor return value over exports. If node/cjs in play,
- // then will not have a return value anyway. Favor
- // module.exports assignment over exports object.
- if (this.map.isDefine && exports === undefined) {
- cjsModule = this.module;
- if (cjsModule) {
- exports = cjsModule.exports;
- } else if (this.usingExports) {
- //exports already set the defined value.
- exports = this.exports;
- }
- }
-
- if (err) {
- err.requireMap = this.map;
- err.requireModules = this.map.isDefine ? [this.map.id] : null;
- err.requireType = this.map.isDefine ? 'define' : 'require';
- return onError((this.error = err));
- }
-
- } else {
- //Just a literal value
- exports = factory;
- }
-
- this.exports = exports;
-
- if (this.map.isDefine && !this.ignore) {
- defined[id] = exports;
-
- if (req.onResourceLoad) {
- var resLoadMaps = [];
- each(this.depMaps, function (depMap) {
- resLoadMaps.push(depMap.normalizedMap || depMap);
- });
- req.onResourceLoad(context, this.map, resLoadMaps);
- }
- }
-
- //Clean up
- cleanRegistry(id);
-
- this.defined = true;
- }
-
- //Finished the define stage. Allow calling check again
- //to allow define notifications below in the case of a
- //cycle.
- this.defining = false;
-
- if (this.defined && !this.defineEmitted) {
- this.defineEmitted = true;
- this.emit('defined', this.exports);
- this.defineEmitComplete = true;
- }
-
- }
- },
-
- callPlugin: function () {
- var map = this.map,
- id = map.id,
- //Map already normalized the prefix.
- pluginMap = makeModuleMap(map.prefix);
-
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(pluginMap);
-
- on(pluginMap, 'defined', bind(this, function (plugin) {
- var load, normalizedMap, normalizedMod,
- bundleId = getOwn(bundlesMap, this.map.id),
- name = this.map.name,
- parentName = this.map.parentMap ? this.map.parentMap.name : null,
- localRequire = context.makeRequire(map.parentMap, {
- enableBuildCallback: true
- });
-
- //If current map is not normalized, wait for that
- //normalized name to load instead of continuing.
- if (this.map.unnormalized) {
- //Normalize the ID if the plugin allows it.
- if (plugin.normalize) {
- name = plugin.normalize(name, function (name) {
- return normalize(name, parentName, true);
- }) || '';
- }
-
- //prefix and name should already be normalized, no need
- //for applying map config again either.
- normalizedMap = makeModuleMap(map.prefix + '!' + name,
- this.map.parentMap);
- on(normalizedMap,
- 'defined', bind(this, function (value) {
- this.map.normalizedMap = normalizedMap;
- this.init([], function () { return value; }, null, {
- enabled: true,
- ignore: true
- });
- }));
-
- normalizedMod = getOwn(registry, normalizedMap.id);
- if (normalizedMod) {
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(normalizedMap);
-
- if (this.events.error) {
- normalizedMod.on('error', bind(this, function (err) {
- this.emit('error', err);
- }));
- }
- normalizedMod.enable();
- }
-
- return;
- }
-
- //If a paths config, then just load that file instead to
- //resolve the plugin, as it is built into that paths layer.
- if (bundleId) {
- this.map.url = context.nameToUrl(bundleId);
- this.load();
- return;
- }
-
- load = bind(this, function (value) {
- this.init([], function () { return value; }, null, {
- enabled: true
- });
- });
-
- load.error = bind(this, function (err) {
- this.inited = true;
- this.error = err;
- err.requireModules = [id];
-
- //Remove temp unnormalized modules for this module,
- //since they will never be resolved otherwise now.
- eachProp(registry, function (mod) {
- if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
- cleanRegistry(mod.map.id);
- }
- });
-
- onError(err);
- });
-
- //Allow plugins to load other code without having to know the
- //context or how to 'complete' the load.
- load.fromText = bind(this, function (text, textAlt) {
- /*jslint evil: true */
- var moduleName = map.name,
- moduleMap = makeModuleMap(moduleName),
- hasInteractive = useInteractive;
-
- //As of 2.1.0, support just passing the text, to reinforce
- //fromText only being called once per resource. Still
- //support old style of passing moduleName but discard
- //that moduleName in favor of the internal ref.
- if (textAlt) {
- text = textAlt;
- }
-
- //Turn off interactive script matching for IE for any define
- //calls in the text, then turn it back on at the end.
- if (hasInteractive) {
- useInteractive = false;
- }
-
- //Prime the system by creating a module instance for
- //it.
- getModule(moduleMap);
-
- //Transfer any config to this other module.
- if (hasProp(config.config, id)) {
- config.config[moduleName] = config.config[id];
- }
-
- try {
- req.exec(text);
- } catch (e) {
- return onError(makeError('fromtexteval',
- 'fromText eval for ' + id +
- ' failed: ' + e,
- e,
- [id]));
- }
-
- if (hasInteractive) {
- useInteractive = true;
- }
-
- //Mark this as a dependency for the plugin
- //resource
- this.depMaps.push(moduleMap);
-
- //Support anonymous modules.
- context.completeLoad(moduleName);
-
- //Bind the value of that module to the value for this
- //resource ID.
- localRequire([moduleName], load);
- });
-
- //Use parentName here since the plugin's name is not reliable,
- //could be some weird string with no path that actually wants to
- //reference the parentName's path.
- plugin.load(map.name, localRequire, load, config);
- }));
-
- context.enable(pluginMap, this);
- this.pluginMaps[pluginMap.id] = pluginMap;
- },
-
- enable: function () {
- enabledRegistry[this.map.id] = this;
- this.enabled = true;
-
- //Set flag mentioning that the module is enabling,
- //so that immediate calls to the defined callbacks
- //for dependencies do not trigger inadvertent load
- //with the depCount still being zero.
- this.enabling = true;
-
- //Enable each dependency
- each(this.depMaps, bind(this, function (depMap, i) {
- var id, mod, handler;
-
- if (typeof depMap === 'string') {
- //Dependency needs to be converted to a depMap
- //and wired up to this module.
- depMap = makeModuleMap(depMap,
- (this.map.isDefine ? this.map : this.map.parentMap),
- false,
- !this.skipMap);
- this.depMaps[i] = depMap;
-
- handler = getOwn(handlers, depMap.id);
-
- if (handler) {
- this.depExports[i] = handler(this);
- return;
- }
-
- this.depCount += 1;
-
- on(depMap, 'defined', bind(this, function (depExports) {
- if (this.undefed) {
- return;
- }
- this.defineDep(i, depExports);
- this.check();
- }));
-
- if (this.errback) {
- on(depMap, 'error', bind(this, this.errback));
- } else if (this.events.error) {
- // No direct errback on this module, but something
- // else is listening for errors, so be sure to
- // propagate the error correctly.
- on(depMap, 'error', bind(this, function(err) {
- this.emit('error', err);
- }));
- }
- }
-
- id = depMap.id;
- mod = registry[id];
-
- //Skip special modules like 'require', 'exports', 'module'
- //Also, don't call enable if it is already enabled,
- //important in circular dependency cases.
- if (!hasProp(handlers, id) && mod && !mod.enabled) {
- context.enable(depMap, this);
- }
- }));
-
- //Enable each plugin that is used in
- //a dependency
- eachProp(this.pluginMaps, bind(this, function (pluginMap) {
- var mod = getOwn(registry, pluginMap.id);
- if (mod && !mod.enabled) {
- context.enable(pluginMap, this);
- }
- }));
-
- this.enabling = false;
-
- this.check();
- },
-
- on: function (name, cb) {
- var cbs = this.events[name];
- if (!cbs) {
- cbs = this.events[name] = [];
- }
- cbs.push(cb);
- },
-
- emit: function (name, evt) {
- each(this.events[name], function (cb) {
- cb(evt);
- });
- if (name === 'error') {
- //Now that the error handler was triggered, remove
- //the listeners, since this broken Module instance
- //can stay around for a while in the registry.
- delete this.events[name];
- }
- }
- };
-
- function callGetModule(args) {
- //Skip modules already defined.
- if (!hasProp(defined, args[0])) {
- getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
- }
- }
-
- function removeListener(node, func, name, ieName) {
- //Favor detachEvent because of IE9
- //issue, see attachEvent/addEventListener comment elsewhere
- //in this file.
- if (node.detachEvent && !isOpera) {
- //Probably IE. If not it will throw an error, which will be
- //useful to know.
- if (ieName) {
- node.detachEvent(ieName, func);
- }
- } else {
- node.removeEventListener(name, func, false);
- }
- }
-
- /**
- * Given an event from a script node, get the requirejs info from it,
- * and then removes the event listeners on the node.
- * @param {Event} evt
- * @returns {Object}
- */
- function getScriptData(evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- var node = evt.currentTarget || evt.srcElement;
-
- //Remove the listeners once here.
- removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
- removeListener(node, context.onScriptError, 'error');
-
- return {
- node: node,
- id: node && node.getAttribute('data-requiremodule')
- };
- }
-
- function intakeDefines() {
- var args;
-
- //Any defined modules in the global queue, intake them now.
- takeGlobalQueue();
-
- //Make sure any remaining defQueue items get properly processed.
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
- args[args.length - 1]));
- } else {
- //args are id, deps, factory. Should be normalized by the
- //define() function.
- callGetModule(args);
- }
- }
- context.defQueueMap = {};
- }
-
- context = {
- config: config,
- contextName: contextName,
- registry: registry,
- defined: defined,
- urlFetched: urlFetched,
- defQueue: defQueue,
- defQueueMap: {},
- Module: Module,
- makeModuleMap: makeModuleMap,
- nextTick: req.nextTick,
- onError: onError,
-
- /**
- * Set a configuration for the context.
- * @param {Object} cfg config object to integrate.
- */
- configure: function (cfg) {
- //Make sure the baseUrl ends in a slash.
- if (cfg.baseUrl) {
- if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
- cfg.baseUrl += '/';
- }
- }
-
- // Convert old style urlArgs string to a function.
- if (typeof cfg.urlArgs === 'string') {
- var urlArgs = cfg.urlArgs;
- cfg.urlArgs = function(id, url) {
- return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
- };
- }
-
- //Save off the paths since they require special processing,
- //they are additive.
- var shim = config.shim,
- objs = {
- paths: true,
- bundles: true,
- config: true,
- map: true
- };
-
- eachProp(cfg, function (value, prop) {
- if (objs[prop]) {
- if (!config[prop]) {
- config[prop] = {};
- }
- mixin(config[prop], value, true, true);
- } else {
- config[prop] = value;
- }
- });
-
- //Reverse map the bundles
- if (cfg.bundles) {
- eachProp(cfg.bundles, function (value, prop) {
- each(value, function (v) {
- if (v !== prop) {
- bundlesMap[v] = prop;
- }
- });
- });
- }
-
- //Merge shim
- if (cfg.shim) {
- eachProp(cfg.shim, function (value, id) {
- //Normalize the structure
- if (isArray(value)) {
- value = {
- deps: value
- };
- }
- if ((value.exports || value.init) && !value.exportsFn) {
- value.exportsFn = context.makeShimExports(value);
- }
- shim[id] = value;
- });
- config.shim = shim;
- }
-
- //Adjust packages if necessary.
- if (cfg.packages) {
- each(cfg.packages, function (pkgObj) {
- var location, name;
-
- pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
-
- name = pkgObj.name;
- location = pkgObj.location;
- if (location) {
- config.paths[name] = pkgObj.location;
- }
-
- //Save pointer to main module ID for pkg name.
- //Remove leading dot in main, so main paths are normalized,
- //and remove any trailing .js, since different package
- //envs have different conventions: some use a module name,
- //some use a file name.
- config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
- .replace(currDirRegExp, '')
- .replace(jsSuffixRegExp, '');
- });
- }
-
- //If there are any "waiting to execute" modules in the registry,
- //update the maps for them, since their info, like URLs to load,
- //may have changed.
- eachProp(registry, function (mod, id) {
- //If module already has init called, since it is too
- //late to modify them, and ignore unnormalized ones
- //since they are transient.
- if (!mod.inited && !mod.map.unnormalized) {
- mod.map = makeModuleMap(id, null, true);
- }
- });
-
- //If a deps array or a config callback is specified, then call
- //require with those args. This is useful when require is defined as a
- //config object before require.js is loaded.
- if (cfg.deps || cfg.callback) {
- context.require(cfg.deps || [], cfg.callback);
- }
- },
-
- makeShimExports: function (value) {
- function fn() {
- var ret;
- if (value.init) {
- ret = value.init.apply(global, arguments);
- }
- return ret || (value.exports && getGlobal(value.exports));
- }
- return fn;
- },
-
- makeRequire: function (relMap, options) {
- options = options || {};
-
- function localRequire(deps, callback, errback) {
- var id, map, requireMod;
-
- if (options.enableBuildCallback && callback && isFunction(callback)) {
- callback.__requireJsBuild = true;
- }
-
- if (typeof deps === 'string') {
- if (isFunction(callback)) {
- //Invalid call
- return onError(makeError('requireargs', 'Invalid require call'), errback);
- }
-
- //If require|exports|module are requested, get the
- //value for them from the special handlers. Caveat:
- //this only works while module is being defined.
- if (relMap && hasProp(handlers, deps)) {
- return handlers[deps](registry[relMap.id]);
- }
-
- //Synchronous access to one module. If require.get is
- //available (as in the Node adapter), prefer that.
- if (req.get) {
- return req.get(context, deps, relMap, localRequire);
- }
-
- //Normalize module name, if it contains . or ..
- map = makeModuleMap(deps, relMap, false, true);
- id = map.id;
-
- if (!hasProp(defined, id)) {
- return onError(makeError('notloaded', 'Module name "' +
- id +
- '" has not been loaded yet for context: ' +
- contextName +
- (relMap ? '' : '. Use require([])')));
- }
- return defined[id];
- }
-
- //Grab defines waiting in the global queue.
- intakeDefines();
-
- //Mark all the dependencies as needing to be loaded.
- context.nextTick(function () {
- //Some defines could have been added since the
- //require call, collect them.
- intakeDefines();
-
- requireMod = getModule(makeModuleMap(null, relMap));
-
- //Store if map config should be applied to this require
- //call for dependencies.
- requireMod.skipMap = options.skipMap;
-
- requireMod.init(deps, callback, errback, {
- enabled: true
- });
-
- checkLoaded();
- });
-
- return localRequire;
- }
-
- mixin(localRequire, {
- isBrowser: isBrowser,
-
- /**
- * Converts a module name + .extension into an URL path.
- * *Requires* the use of a module name. It does not support using
- * plain URLs like nameToUrl.
- */
- toUrl: function (moduleNamePlusExt) {
- var ext,
- index = moduleNamePlusExt.lastIndexOf('.'),
- segment = moduleNamePlusExt.split('/')[0],
- isRelative = segment === '.' || segment === '..';
-
- //Have a file extension alias, and it is not the
- //dots from a relative path.
- if (index !== -1 && (!isRelative || index > 1)) {
- ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
- moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
- }
-
- return context.nameToUrl(normalize(moduleNamePlusExt,
- relMap && relMap.id, true), ext, true);
- },
-
- defined: function (id) {
- return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
- },
-
- specified: function (id) {
- id = makeModuleMap(id, relMap, false, true).id;
- return hasProp(defined, id) || hasProp(registry, id);
- }
- });
-
- //Only allow undef on top level require calls
- if (!relMap) {
- localRequire.undef = function (id) {
- //Bind any waiting define() calls to this context,
- //fix for #408
- takeGlobalQueue();
-
- var map = makeModuleMap(id, relMap, true),
- mod = getOwn(registry, id);
-
- mod.undefed = true;
- removeScript(id);
-
- delete defined[id];
- delete urlFetched[map.url];
- delete undefEvents[id];
-
- //Clean queued defines too. Go backwards
- //in array so that the splices do not
- //mess up the iteration.
- eachReverse(defQueue, function(args, i) {
- if (args[0] === id) {
- defQueue.splice(i, 1);
- }
- });
- delete context.defQueueMap[id];
-
- if (mod) {
- //Hold on to listeners in case the
- //module will be attempted to be reloaded
- //using a different config.
- if (mod.events.defined) {
- undefEvents[id] = mod.events;
- }
-
- cleanRegistry(id);
- }
- };
- }
-
- return localRequire;
- },
-
- /**
- * Called to enable a module if it is still in the registry
- * awaiting enablement. A second arg, parent, the parent module,
- * is passed in for context, when this method is overridden by
- * the optimizer. Not shown here to keep code compact.
- */
- enable: function (depMap) {
- var mod = getOwn(registry, depMap.id);
- if (mod) {
- getModule(depMap).enable();
- }
- },
-
- /**
- * Internal method used by environment adapters to complete a load event.
- * A load event could be a script load or just a load pass from a synchronous
- * load call.
- * @param {String} moduleName the name of the module to potentially complete.
- */
- completeLoad: function (moduleName) {
- var found, args, mod,
- shim = getOwn(config.shim, moduleName) || {},
- shExports = shim.exports;
-
- takeGlobalQueue();
-
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- args[0] = moduleName;
- //If already found an anonymous module and bound it
- //to this name, then this is some other anon module
- //waiting for its completeLoad to fire.
- if (found) {
- break;
- }
- found = true;
- } else if (args[0] === moduleName) {
- //Found matching define call for this script!
- found = true;
- }
-
- callGetModule(args);
- }
- context.defQueueMap = {};
-
- //Do this after the cycle of callGetModule in case the result
- //of those calls/init calls changes the registry.
- mod = getOwn(registry, moduleName);
-
- if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
- if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
- if (hasPathFallback(moduleName)) {
- return;
- } else {
- return onError(makeError('nodefine',
- 'No define call for ' + moduleName,
- null,
- [moduleName]));
- }
- } else {
- //A script that does not call define(), so just simulate
- //the call for it.
- callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
- }
- }
-
- checkLoaded();
- },
-
- /**
- * Converts a module name to a file path. Supports cases where
- * moduleName may actually be just an URL.
- * Note that it **does not** call normalize on the moduleName,
- * it is assumed to have already been normalized. This is an
- * internal API, not a public one. Use toUrl for the public API.
- */
- nameToUrl: function (moduleName, ext, skipExt) {
- var paths, syms, i, parentModule, url,
- parentPath, bundleId,
- pkgMain = getOwn(config.pkgs, moduleName);
-
- if (pkgMain) {
- moduleName = pkgMain;
- }
-
- bundleId = getOwn(bundlesMap, moduleName);
-
- if (bundleId) {
- return context.nameToUrl(bundleId, ext, skipExt);
- }
-
- //If a colon is in the URL, it indicates a protocol is used and it is just
- //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
- //or ends with .js, then assume the user meant to use an url and not a module id.
- //The slash is important for protocol-less URLs as well as full paths.
- if (req.jsExtRegExp.test(moduleName)) {
- //Just a plain path, not module name lookup, so just return it.
- //Add extension if it is included. This is a bit wonky, only non-.js things pass
- //an extension, this method probably needs to be reworked.
- url = moduleName + (ext || '');
- } else {
- //A module that needs to be converted to a path.
- paths = config.paths;
-
- syms = moduleName.split('/');
- //For each module name segment, see if there is a path
- //registered for it. Start with most specific name
- //and work up from it.
- for (i = syms.length; i > 0; i -= 1) {
- parentModule = syms.slice(0, i).join('/');
-
- parentPath = getOwn(paths, parentModule);
- if (parentPath) {
- //If an array, it means there are a few choices,
- //Choose the one that is desired
- if (isArray(parentPath)) {
- parentPath = parentPath[0];
- }
- syms.splice(0, i, parentPath);
- break;
- }
- }
-
- //Join the path parts together, then figure out if baseUrl is needed.
- url = syms.join('/');
- url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
- url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
- }
-
- return config.urlArgs && !/^blob\:/.test(url) ?
- url + config.urlArgs(moduleName, url) : url;
- },
-
- //Delegates to req.load. Broken out as a separate function to
- //allow overriding in the optimizer.
- load: function (id, url) {
- req.load(context, id, url);
- },
-
- /**
- * Executes a module callback function. Broken out as a separate function
- * solely to allow the build system to sequence the files in the built
- * layer in the right sequence.
- *
- * @private
- */
- execCb: function (name, callback, args, exports) {
- return callback.apply(exports, args);
- },
-
- /**
- * callback for script loads, used to check status of loading.
- *
- * @param {Event} evt the event from the browser for the script
- * that was loaded.
- */
- onScriptLoad: function (evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- if (evt.type === 'load' ||
- (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
- //Reset interactive script so a script node is not held onto for
- //to long.
- interactiveScript = null;
-
- //Pull out the name of the module and the context.
- var data = getScriptData(evt);
- context.completeLoad(data.id);
- }
- },
-
- /**
- * Callback for script errors.
- */
- onScriptError: function (evt) {
- var data = getScriptData(evt);
- if (!hasPathFallback(data.id)) {
- var parents = [];
- eachProp(registry, function(value, key) {
- if (key.indexOf('_@r') !== 0) {
- each(value.depMaps, function(depMap) {
- if (depMap.id === data.id) {
- parents.push(key);
- return true;
- }
- });
- }
- });
- return onError(makeError('scripterror', 'Script error for "' + data.id +
- (parents.length ?
- '", needed by: ' + parents.join(', ') :
- '"'), evt, [data.id]));
- }
- }
- };
-
- context.require = context.makeRequire();
- return context;
- }
-
- /**
- * Main entry point.
- *
- * If the only argument to require is a string, then the module that
- * is represented by that string is fetched for the appropriate context.
- *
- * If the first argument is an array, then it will be treated as an array
- * of dependency string names to fetch. An optional function callback can
- * be specified to execute when all of those dependencies are available.
- *
- * Make a local req variable to help Caja compliance (it assumes things
- * on a require that are not standardized), and to give a short
- * name for minification/local scope use.
- */
- req = requirejs = function (deps, callback, errback, optional) {
-
- //Find the right context, use default
- var context, config,
- contextName = defContextName;
-
- // Determine if have config object in the call.
- if (!isArray(deps) && typeof deps !== 'string') {
- // deps is a config object
- config = deps;
- if (isArray(callback)) {
- // Adjust args if there are dependencies
- deps = callback;
- callback = errback;
- errback = optional;
- } else {
- deps = [];
- }
- }
-
- if (config && config.context) {
- contextName = config.context;
- }
-
- context = getOwn(contexts, contextName);
- if (!context) {
- context = contexts[contextName] = req.s.newContext(contextName);
- }
-
- if (config) {
- context.configure(config);
- }
-
- return context.require(deps, callback, errback);
- };
-
- /**
- * Support require.config() to make it easier to cooperate with other
- * AMD loaders on globally agreed names.
- */
- req.config = function (config) {
- return req(config);
- };
-
- /**
- * Execute something after the current tick
- * of the event loop. Override for other envs
- * that have a better solution than setTimeout.
- * @param {Function} fn function to execute later.
- */
- req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
- setTimeout(fn, 4);
- } : function (fn) { fn(); };
-
- /**
- * Export require as a global, but only if it does not already exist.
- */
- if (!require) {
- require = req;
- }
-
- req.version = version;
-
- //Used to filter out dependencies that are already paths.
- req.jsExtRegExp = /^\/|:|\?|\.js$/;
- req.isBrowser = isBrowser;
- s = req.s = {
- contexts: contexts,
- newContext: newContext
- };
-
- //Create default context.
- req({});
-
- //Exports some context-sensitive methods on global require.
- each([
- 'toUrl',
- 'undef',
- 'defined',
- 'specified'
- ], function (prop) {
- //Reference from contexts instead of early binding to default context,
- //so that during builds, the latest instance of the default context
- //with its config gets used.
- req[prop] = function () {
- var ctx = contexts[defContextName];
- return ctx.require[prop].apply(ctx, arguments);
- };
- });
-
- if (isBrowser) {
- head = s.head = document.getElementsByTagName('head')[0];
- //If BASE tag is in play, using appendChild is a problem for IE6.
- //When that browser dies, this can be removed. Details in this jQuery bug:
- //http://dev.jquery.com/ticket/2709
- baseElement = document.getElementsByTagName('base')[0];
- if (baseElement) {
- head = s.head = baseElement.parentNode;
- }
- }
-
- /**
- * Any errors that require explicitly generates will be passed to this
- * function. Intercept/override it if you want custom error handling.
- * @param {Error} err the error object.
- */
- req.onError = defaultOnError;
-
- /**
- * Creates the node for the load command. Only used in browser envs.
- */
- req.createNode = function (config, moduleName, url) {
- var node = config.xhtml ?
- document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
- document.createElement('script');
- node.type = config.scriptType || 'text/javascript';
- node.charset = 'utf-8';
- node.async = true;
- return node;
- };
-
- /**
- * Does the request to load a module for the browser case.
- * Make this a separate function to allow other environments
- * to override it.
- *
- * @param {Object} context the require context to find state.
- * @param {String} moduleName the name of the module.
- * @param {Object} url the URL to the module.
- */
- req.load = function (context, moduleName, url) {
- var config = (context && context.config) || {},
- node;
- if (isBrowser) {
- //In the browser so use a script tag
- node = req.createNode(config, moduleName, url);
-
- node.setAttribute('data-requirecontext', context.contextName);
- node.setAttribute('data-requiremodule', moduleName);
-
- //Set up load listener. Test attachEvent first because IE9 has
- //a subtle issue in its addEventListener and script onload firings
- //that do not match the behavior of all other browsers with
- //addEventListener support, which fire the onload event for a
- //script right after the script execution. See:
- //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
- //UNFORTUNATELY Opera implements attachEvent but does not follow the script
- //script execution mode.
- if (node.attachEvent &&
- //Check if node.attachEvent is artificially added by custom script or
- //natively supported by browser
- //read https://github.com/requirejs/requirejs/issues/187
- //if we can NOT find [native code] then it must NOT natively supported.
- //in IE8, node.attachEvent does not have toString()
- //Note the test for "[native code" with no closing brace, see:
- //https://github.com/requirejs/requirejs/issues/273
- !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
- !isOpera) {
- //Probably IE. IE (at least 6-8) do not fire
- //script onload right after executing the script, so
- //we cannot tie the anonymous define call to a name.
- //However, IE reports the script as being in 'interactive'
- //readyState at the time of the define call.
- useInteractive = true;
-
- node.attachEvent('onreadystatechange', context.onScriptLoad);
- //It would be great to add an error handler here to catch
- //404s in IE9+. However, onreadystatechange will fire before
- //the error handler, so that does not help. If addEventListener
- //is used, then IE will fire error before load, but we cannot
- //use that pathway given the connect.microsoft.com issue
- //mentioned above about not doing the 'script execute,
- //then fire the script load event listener before execute
- //next script' that other browsers do.
- //Best hope: IE10 fixes the issues,
- //and then destroys all installs of IE 6-9.
- //node.attachEvent('onerror', context.onScriptError);
- } else {
- node.addEventListener('load', context.onScriptLoad, false);
- node.addEventListener('error', context.onScriptError, false);
- }
- node.src = url;
-
- //Calling onNodeCreated after all properties on the node have been
- //set, but before it is placed in the DOM.
- if (config.onNodeCreated) {
- config.onNodeCreated(node, config, moduleName, url);
- }
-
- //For some cache cases in IE 6-8, the script executes before the end
- //of the appendChild execution, so to tie an anonymous define
- //call to the module name (which is stored on the node), hold on
- //to a reference to this node, but clear after the DOM insertion.
- currentlyAddingScript = node;
- if (baseElement) {
- head.insertBefore(node, baseElement);
- } else {
- head.appendChild(node);
- }
- currentlyAddingScript = null;
-
- return node;
- } else if (isWebWorker) {
- try {
- //In a web worker, use importScripts. This is not a very
- //efficient use of importScripts, importScripts will block until
- //its script is downloaded and evaluated. However, if web workers
- //are in play, the expectation is that a build has been done so
- //that only one script needs to be loaded anyway. This may need
- //to be reevaluated if other use cases become common.
-
- // Post a task to the event loop to work around a bug in WebKit
- // where the worker gets garbage-collected after calling
- // importScripts(): https://webkit.org/b/153317
- setTimeout(function() {}, 0);
- importScripts(url);
-
- //Account for anonymous modules
- context.completeLoad(moduleName);
- } catch (e) {
- context.onError(makeError('importscripts',
- 'importScripts failed for ' +
- moduleName + ' at ' + url,
- e,
- [moduleName]));
- }
- }
- };
-
- function getInteractiveScript() {
- if (interactiveScript && interactiveScript.readyState === 'interactive') {
- return interactiveScript;
- }
-
- eachReverse(scripts(), function (script) {
- if (script.readyState === 'interactive') {
- return (interactiveScript = script);
- }
- });
- return interactiveScript;
- }
-
- //Look for a data-main script attribute, which could also adjust the baseUrl.
- if (isBrowser && !cfg.skipDataMain) {
- //Figure out baseUrl. Get it from the script tag with require.js in it.
- eachReverse(scripts(), function (script) {
- //Set the 'head' where we can append children by
- //using the script's parent.
- if (!head) {
- head = script.parentNode;
- }
-
- //Look for a data-main attribute to set main script for the page
- //to load. If it is there, the path to data main becomes the
- //baseUrl, if it is not already set.
- dataMain = script.getAttribute('data-main');
- if (dataMain) {
- //Preserve dataMain in case it is a path (i.e. contains '?')
- mainScript = dataMain;
-
- //Set final baseUrl if there is not already an explicit one,
- //but only do so if the data-main value is not a loader plugin
- //module ID.
- if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {
- //Pull off the directory of data-main for use as the
- //baseUrl.
- src = mainScript.split('/');
- mainScript = src.pop();
- subPath = src.length ? src.join('/') + '/' : './';
-
- cfg.baseUrl = subPath;
- }
-
- //Strip off any trailing .js since mainScript is now
- //like a module name.
- mainScript = mainScript.replace(jsSuffixRegExp, '');
-
- //If mainScript is still a path, fall back to dataMain
- if (req.jsExtRegExp.test(mainScript)) {
- mainScript = dataMain;
- }
-
- //Put the data-main script in the files to load.
- cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
-
- return true;
- }
- });
- }
-
- /**
- * The function that handles definitions of modules. Differs from
- * require() in that a string for the module should be the first argument,
- * and the function to execute after dependencies are loaded should
- * return a value to define the module corresponding to the first argument's
- * name.
- */
- define = function (name, deps, callback) {
- var node, context;
-
- //Allow for anonymous modules
- if (typeof name !== 'string') {
- //Adjust args appropriately
- callback = deps;
- deps = name;
- name = null;
- }
-
- //This module may not have dependencies
- if (!isArray(deps)) {
- callback = deps;
- deps = null;
- }
-
- //If no name, and callback is a function, then figure out if it a
- //CommonJS thing with dependencies.
- if (!deps && isFunction(callback)) {
- deps = [];
- //Remove comments from the callback string,
- //look for require calls, and pull them into the dependencies,
- //but only if there are function args.
- if (callback.length) {
- callback
- .toString()
- .replace(commentRegExp, commentReplace)
- .replace(cjsRequireRegExp, function (match, dep) {
- deps.push(dep);
- });
-
- //May be a CommonJS thing even without require calls, but still
- //could use exports, and module. Avoid doing exports and module
- //work though if it just needs require.
- //REQUIRES the function to expect the CommonJS variables in the
- //order listed below.
- deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
- }
- }
-
- //If in IE 6-8 and hit an anonymous define() call, do the interactive
- //work.
- if (useInteractive) {
- node = currentlyAddingScript || getInteractiveScript();
- if (node) {
- if (!name) {
- name = node.getAttribute('data-requiremodule');
- }
- context = contexts[node.getAttribute('data-requirecontext')];
- }
- }
-
- //Always save off evaluating the def call until the script onload handler.
- //This allows multiple modules to be in a file without prematurely
- //tracing dependencies, and allows for anonymous module support,
- //where the module name is not known until the script onload event
- //occurs. If no context, use the global queue, and get it processed
- //in the onscript load callback.
- if (context) {
- context.defQueue.push([name, deps, callback]);
- context.defQueueMap[name] = true;
- } else {
- globalDefQueue.push([name, deps, callback]);
- }
- };
-
- define.amd = {
- jQuery: true
- };
-
- /**
- * Executes the text. Normally just uses eval, but can be modified
- * to use a better, environment-specific call. Only used for transpiling
- * loader plugins, not for plain JS modules.
- * @param {String} text the text to execute/evaluate.
- */
- req.exec = function (text) {
- /*jslint evil: true */
- return eval(text);
- };
-
- //Set up with config info.
- req(cfg);
-}(this));
diff --git a/js/textile.js b/js/textile.js
deleted file mode 100644
index e2af69a..0000000
--- a/js/textile.js
+++ /dev/null
@@ -1,1537 +0,0 @@
-/***
- * Textile parser for JavaScript
- *
- * Copyright (c) 2012 Borgar Þorsteinsson (MIT License).
- *
- */
-/*jshint
- laxcomma:true
- laxbreak:true
- eqnull:true
- loopfunc:true
- sub:true
-*/
-;(function(){
-"use strict";
-
- /***
- * Regular Expression helper methods
- *
- * This provides the `re` object, which contains several helper
- * methods for working with big regular expressions (soup).
- *
- */
- var re = {
- _cache: {}
- , pattern: {
- 'punct': "[!-/:-@\\[\\\\\\]-`{-~]"
- , 'space': '\\s'
- }
- , escape: function ( src ) {
- return src.replace( /[\-\[\]\{\}\(\)\*\+\?\.\,\\\^\$\|\#\s]/g, "\\$&" );
- }
- , collapse: function ( src ) {
- return src.replace( /(?:#.*?(?:\n|$))/g, '' )
- .replace( /\s+/g, '' )
- ;
- }
- , expand_patterns: function ( src ) {
- // TODO: provide escape for patterns: \[:pattern:] ?
- return src.replace( /\[\:\s*(\w+)\s*\:\]/g, function ( m, k ) {
- return ( k in re.pattern )
- ? re.expand_patterns( re.pattern[ k ] )
- : k
- ;
- })
- ;
- }
- , isRegExp: function ( r ) {
- return Object.prototype.toString.call( r ) === "[object RegExp]";
- }
- , compile: function ( src, flags ) {
- if ( re.isRegExp( src ) ) {
- if ( arguments.length === 1 ) { // no flags arg provided, use the RegExp one
- flags = ( src.global ? 'g' : '' ) +
- ( src.ignoreCase ? 'i' : '' ) +
- ( src.multiline ? 'm' : '' );
- }
- src = src.source;
- }
- // don't do the same thing twice
- var ckey = src + ( flags || '' );
- if ( ckey in re._cache ) { return re._cache[ ckey ]; }
- // allow classes
- var rx = re.expand_patterns( src );
- // allow verbose expressions
- if ( flags && /x/.test( flags ) ) {
- rx = re.collapse( rx );
- }
- // allow dotall expressions
- if ( flags && /s/.test( flags ) ) {
- rx = rx.replace( /([^\\])\./g, '$1[^\\0]' );
- }
- // TODO: test if MSIE and add replace \s with [\s\u00a0] if it is?
- // clean flags and output new regexp
- flags = ( flags || '' ).replace( /[^gim]/g, '' );
- return ( re._cache[ ckey ] = new RegExp( rx, flags ) );
- }
- };
-
-
-
-
- /***
- * JSONML helper methods - http://www.jsonml.org/
- *
- * This provides the `JSONML` object, which contains helper
- * methods for rendering JSONML to HTML.
- *
- * Note that the tag ! is taken to mean comment, this is however
- * not specified in the JSONML spec.
- *
- */
- var JSONML = {
- escape: function ( text, esc_quotes ) {
- return text.replace( /&(?!(#\d{2,}|#x[\da-fA-F]{2,}|[a-zA-Z][a-zA-Z1-4]{1,6});)/g, "&" )
- .replace( //g, ">" )
- .replace( /"/g, esc_quotes ? """ : '"' )
- .replace( /'/g, esc_quotes ? "'" : "'" )
- ;
- }
- , toHTML: function ( jsonml ) {
-
- jsonml = jsonml.concat();
-
- // basic case
- if ( typeof jsonml === "string" ) {
- return JSONML.escape( jsonml );
- }
-
- var tag = jsonml.shift()
- , attributes = {}
- , content = []
- , tag_attrs = ""
- , a
- ;
- if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !_isArray( jsonml[ 0 ] ) ) {
- attributes = jsonml.shift();
- }
-
- while ( jsonml.length ) {
- content.push( JSONML.toHTML( jsonml.shift() ) );
- }
-
- for ( a in attributes ) {
- tag_attrs += ( attributes[ a ] == null )
- ? " " + a
- : " " + a + '="' + JSONML.escape( String( attributes[ a ] ), true ) + '"'
- ;
- }
-
- // be careful about adding whitespace here for inline elements
- if ( tag == "!" ) {
- return "";
- }
- else if ( tag in html_singletons ) {
- return "<" + tag + tag_attrs + " />";
- }
- else {
- return "<" + tag + tag_attrs + ">" + content.join( "" ) + "" + tag + ">";
- }
- }
- };
-
-
- // merge object b properties into obect a
- function merge ( a, b ) {
- if ( b ) {
- for ( var k in b ) {
- a[ k ] = b[ k ];
- }
- }
- return a;
- }
-
-
- var _isArray = Array.isArray || function ( a ) { return Object.prototype.toString.call(a) === '[object Array]'; };
-
- /* expressions */
- re.pattern[ 'blocks' ] = '(?:b[qc]|div|notextile|pre|h[1-6]|fn\\d+|p|###)';
- re.pattern[ 'pba_class' ] = '\\([^\\)]+\\)';
- re.pattern[ 'pba_style' ] = '\\{[^\\}]+\\}';
- re.pattern[ 'pba_lang' ] = '\\[[^\\[\\]]+\\]';
- re.pattern[ 'pba_align' ] = '(?:<>|<|>|=)';
- re.pattern[ 'pba_pad' ] = '[\\(\\)]+';
- re.pattern[ 'pba_attr' ] = '(?:[:pba_class:]|[:pba_style:]|[:pba_lang:]|[:pba_align:]|[:pba_pad:])*';
- re.pattern[ 'url_punct' ] = '[.,«»″‹›!?]';
- re.pattern[ 'html_id' ] = '[a-zA-Z][a-zA-Z\\d:]*';
- re.pattern[ 'html_attr' ] = '(?:"[^"]+"|\'[^\']+\'|[^>\\s]+)';
- re.pattern[ 'tx_urlch' ] = '[\\w"$\\-_.+!*\'(),";\\/?:@=&%#{}|\\\\^~\\[\\]`]';
- re.pattern[ 'tx_cite' ] = ':((?:[^\\s()]|\\([^\\s()]+\\)|[()])+?)(?=[!-\\.:-@\\[\\\\\\]-`{-~]+(?:$|\\s)|$|\\s)';
- re.pattern[ 'listhd' ] = '[\\t ]*[\\#\\*]*(\\*|\\#(?:_|\\d+)?)[:pba_attr:](?: \\S|\\.\\s*(?=\\S|\\n))';
- re.pattern[ 'ucaps' ] = "A-Z"+
- // Latin extended À-Þ
- "\u00c0-\u00d6\u00d8-\u00de"+
- // Latin caps with embelishments and ligatures...
- "\u0100\u0102\u0104\u0106\u0108\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130\u0132\u0134\u0136\u0139\u013b\u013d\u013f"+
- "\u0141\u0143\u0145\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e\u0170\u0172\u0174\u0176\u0178\u0179\u017b\u017d"+
- "\u0181\u0182\u0184\u0186\u0187\u0189-\u018b\u018e-\u0191\u0193\u0194\u0196-\u0198\u019c\u019d\u019f\u01a0\u01a2\u01a4\u01a6\u01a7\u01a9\u01ac\u01ae\u01af\u01b1-\u01b3\u01b5\u01b7\u01b8\u01bc"+
- "\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe"+
- "\u0200\u0202\u0204\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c\u022e\u0230\u0232\u023a\u023b\u023d\u023e"+
- "\u0241\u0243-\u0246\u0248\u024a\u024c\u024e"+
- "\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36\u1e38\u1e3a\u1e3c\u1e3e\u1e40"+
- "\u1e42\u1e44\u1e46\u1e48\u1e4a\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e"+
- "\u1e80\u1e82\u1e84\u1e86\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6\u1eb8\u1eba\u1ebc\u1ebe"+
- "\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe"+
- "\u2c60\u2c62-\u2c64\u2c67\u2c69\u2c6b\u2c6d-\u2c70\u2c72\u2c75\u2c7e\u2c7f"+
- "\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736\ua738\ua73a\ua73c\ua73e"+
- "\ua740\ua742\ua744\ua746\ua748\ua74a\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b\ua77d\ua77e"+
- "\ua780\ua782\ua784\ua786\ua78b\ua78d\ua790\ua792\ua7a0\ua7a2\ua7a4\ua7a6\ua7a8\ua7aa";
-
- var re_block = re.compile( /^([:blocks:])/ )
- , re_block_se = re.compile( /^[:blocks:]$/ )
- , re_block_normal = re.compile( /^(.*?)($|\r?\n(?=[:listhd:])|\r?\n(?:\s*\n|$)+)/, 's' )
- , re_block_extended = re.compile( /^(.*?)($|\r?\n(?=[:listhd:])|\r?\n+(?=[:blocks:][:pba_attr:]\.))/, 's' )
- , re_ruler = /^(\-\-\-+|\*\*\*+|___+)(\r?\n\s+|$)/
- , re_list = re.compile( /^((?:[:listhd:][^\0]*?(?:\r?\n|$))+)(\s*\n|$)/,'s' )
- , re_list_item = re.compile( /^([\#\*]+)([^\0]+?)(\n(?=[:listhd:])|$)/, 's' )
- , re_deflist = /^((?:- (?:[^\n]\n?)+?)+:=(?: *\n[^\0]+?=:(?:\n|$)|(?:[^\0]+?(?:$|\n(?=\n|- )))))+/
- , re_deflist_item = /^((?:- (?:[^\n]\n?)+?)+):=( *\n[^\0]+?=:\s*(?:\n|$)|(?:[^\0]+?(?:$|\n(?=\n|- ))))/
-
- , re_table = re.compile( /^((?:table[:pba_attr:]\.(?:\s(.+?))\s*\n)?(?:(?:[:pba_attr:]\.[^\n\S]*)?\|.*?\|[^\n\S]*(?:\n|$))+)([^\n\S]*\n)?/, 's' )
- , re_table_head = /^table(_?)([^\n]*?)\.(?:[ \t](.+?))?\s*\n/
- , re_table_row = re.compile( /^(?:\|([~\^\-][:pba_attr:])\.\s*\n)?([:pba_attr:]\.[^\n\S]*)?\|(.*?)\|[^\n\S]*(\n|$)/, 's' )
- , re_table_caption = /^\|=([^\n+]*)\n/
- , re_table_colgroup = /^\|:([^\n+]*)\|[\r\t ]*\n/
- , re_table_rowgroup = /^\|([\^\-\~])([^\n+]*)\.[ \t\r]*\n/
-
- , re_fenced_phrase = /^\[(__?|\*\*?|\?\?|[\-\+\^~@%])([^\n]+)\1\]/
- , re_phrase = /^([\[\{]?)(__?|\*\*?|\?\?|[\-\+\^~@%])/
- , re_text = re.compile( /^.+?(?=[\\(\n*)/ )
- , re_html_tag = re.compile( /^<([:html_id:])((?:\s[^=\s\/]+(?:\s*=\s*[:html_attr:])?)+)?\s*(\/?)>(\n*)/ )
- , re_html_comment = re.compile( /^/, 's' )
- , re_html_end_tag = re.compile( /^<\/([:html_id:])([^>]*)>/ )
- , re_html_attr = re.compile( /^\s*([^=\s]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/ )
- , re_entity = /&(#\d\d{2,}|#x[\da-fA-F]{2,}|[a-zA-Z][a-zA-Z1-4]{1,6});/
-
- // glyphs
- , re_dimsign = /([\d\.,]+['"]? ?)x( ?)(?=[\d\.,]['"]?)/g
- , re_emdash = /(^|[\s\w])--([\s\w]|$)/g
- , re_trademark = /(\b ?|\s|^)(?:\((?:TM|tm)\)|\[(?:TM|tm)\])/g
- , re_registered = /(\b ?|\s|^)(?:\(R\)|\[R\])/gi
- , re_copyright = /(\b ?|\s|^)(?:\(C\)|\[C\])/gi
- , re_apostrophe = /(\w)\'(\w)/g
- , re_double_prime = re.compile( /(\d*[\.,]?\d+)"(?=\s|$|[:punct:])/g )
- , re_single_prime = re.compile( /(\d*[\.,]?\d+)'(?=\s|$|[:punct:])/g )
- , re_closing_dquote = re.compile( /([^\s\[\(])"(?=$|\s|[:punct:])/g )
- , re_closing_squote = re.compile( /([^\s\[\(])'(?=$|\s|[:punct:])/g )
-
- // pba
- , re_pba_classid = /^\(([^\(\)\n]+)\)/
- , re_pba_padding_l = /^(\(+)/
- , re_pba_padding_r = /^(\)+)/
- , re_pba_align_blk = /^(<>|<|>|=)/
- , re_pba_align_img = /^(<|>|=)/
- , re_pba_valign = /^(~|\^|\-)/
- , re_pba_colspan = /^\\(\d+)/
- , re_pba_rowspan = /^\/(\d+)/
- , re_pba_styles = /^\{([^\}]*)\}/
- , re_pba_css = /^\s*([^:\s]+)\s*:\s*(.+)\s*$/
- , re_pba_lang = /^\[([^\[\]\n]+)\]/
- ;
-
- var phrase_convert = {
- '*': 'strong'
- , '**': 'b'
- , '??': 'cite'
- , '_': 'em'
- , '__': 'i'
- , '-': 'del'
- , '%': 'span'
- , '+': 'ins'
- , '~': 'sub'
- , '^': 'sup'
- , '@': 'code'
- };
-
- // area, base, basefont, bgsound, br, col, command, embed, frame, hr,
- // img, input, keygen, link, meta, param, source, track or wbr
- var html_singletons = {
- 'br': 1
- , 'hr': 1
- , 'img': 1
- , 'link': 1
- , 'meta': 1
- , 'wbr': 1
- , 'area': 1
- , 'param': 1
- , 'input': 1
- , 'option': 1
- , 'base': 1
- , 'col': 1
- };
-
- var pba_align_lookup = {
- '<': 'left'
- , '=': 'center'
- , '>': 'right'
- , '<>': 'justify'
- };
-
- var pba_valign_lookup = {
- '~':'bottom'
- , '^':'top'
- , '-':'middle'
- };
-
- // HTML tags allowed in the document (root) level that trigger HTML parsing
- var allowed_blocktags = {
- 'p': 0
- , 'hr': 0
- , 'ul': 1
- , 'ol': 0
- , 'li': 0
- , 'div': 1
- , 'pre': 0
- , 'object': 1
- , 'script': 0
- , 'noscript': 0
- , 'blockquote': 1
- , 'notextile': 1
- };
-
-
- function ribbon ( feed ) {
- var _slot = null
- , org = feed + ''
- , pos = 0
- ;
- return {
- save: function () {
- _slot = pos;
- }
- , load: function () {
- pos = _slot;
- feed = org.slice( pos );
- }
- , advance: function ( n ) {
- pos += ( typeof n === 'string' ) ? n.length : n;
- return ( feed = org.slice( pos ) );
- }
- , lookbehind: function ( nchars ) {
- nchars = nchars == null ? 1 : nchars;
- return org.slice( pos - nchars, pos );
- }
- , startsWith: function ( s ) {
- return feed.substring(0, s.length) === s;
- }
- , valueOf: function(){
- return feed;
- }
- , toString: function(){
- return feed;
- }
- };
- }
-
-
- function builder ( arr ) {
- var _arr = _isArray( arr ) ? arr : [];
- return {
- add: function ( node ) {
- if ( typeof node === 'string' &&
- typeof _arr[_arr.length - 1 ] === 'string' ) {
- // join if possible
- _arr[ _arr.length - 1 ] += node;
- }
- else if ( _isArray( node ) ) {
- var f = node.filter(function(s){ return s !== undefined; });
- _arr.push( f );
- }
- else if ( node ) {
- _arr.push( node );
- }
- return this;
- }
- , merge: function ( s ) {
- for (var i=0,l=s.length; i
- user can still create nonsensical but "well-formed" markup
- function parse_html ( src, whitelist_tags ) {
- var org = src + ''
- , list = []
- , root = list
- , _stack = []
- , m
- , oktag = whitelist_tags ? function ( tag ) { return tag in whitelist_tags; } : function () { return true; }
- , tag
- ;
- src = (typeof src === 'string') ? ribbon( src ) : src;
- // loop
- do {
-
- if ( (m = re_html_comment.exec( src )) && oktag('!') ) {
- src.advance( m[0] );
- list.push( [ '!', m[1] ] );
- }
-
- // end tag
- else if ( (m = re_html_end_tag.exec( src )) && oktag(m[1]) ) {
- tag = m[1];
- var junk = m[2];
- if ( _stack.length ) {
- for (var i=_stack.length-1; i>=0; i--) {
- var head = _stack[i];
- if ( head[0] === tag ) {
- _stack.splice( i );
- list = _stack[ _stack.length - 1 ] || root;
- break;
- }
- }
- }
- src.advance( m[0] );
- }
-
- // open/void tag
- else if ( (m = re_html_tag.exec( src )) && oktag(m[1]) ) {
- src.advance( m[0] );
- tag = m[1];
- var single = m[3] || m[1] in html_singletons
- , tail = m[4]
- , element = [ tag ]
- ;
-
- // attributes
- if ( m[2] ) { element.push( parse_html_attr( m[2] ) ); }
-
- // tag
- if ( single ) { // single tag
- // let us add the element and continue our quest...
- list.push( element );
- if ( tail ) { list.push( tail ); }
- }
- else { // open tag
- if ( tail ) { element.push( tail ); }
-
- // TODO: some things auto close other things: , , ,
- // if ( tag === 'p' && _stack.length ) {
- // var seek = /^(p)$/;
- // for (var i=_stack.length-1; i>=0; i--) {
- // var head = _stack[i];
- // if ( seek.test( head[0] ) /* === tag */ ) {
- // //src.advance( m[0] );
- // _stack.splice( i );
- // list = _stack[i] || root;
- // }
- // }
- // }
-
- // TODO: some elements can move parser into "text" mode
- // style, xmp, iframe, noembed, noframe, textarea, title, script, noscript, plaintext
- //if ( /^(script)$/.test( tag ) ) { }
-
- _stack.push( element );
- list.push( element );
- list = element;
-
- }
- }
- else {
-
- // no match, move by all "uninteresting" chars
- m = /([^<]+|[^\0])/.exec( src );
- if ( m ) {
- list.push( m[0] );
- }
- src.advance( m ? m[0].length || 1 : 1 );
-
- }
-
- }
- while ( src.valueOf() );
- return root;
- }
-
- /* attribute parser */
-
- function parse_attr ( input, element, end_token ) {
- /*
- The attr bit causes massive problems for span elements when parentheses are used.
- Parentheses are a total mess and, unsurprisingly, cause trip-ups:
-
- RC: `_{display:block}(span) span (span)_` -> `(span) span (span) `
- PHP: `_{display:block}(span) span (span)_` -> `(span) span (span) `
-
- PHP and RC seem to mostly solve this by not parsing a final attr parens on spans if the
- following character is a non-space. I've duplicated that: Class/ID is not matched on spans
- if it is followed by `end_token` or .
-
- Lang is not matched here if it is followed by the end token. Theoretically I could limit the lang
- attribute to /^\[[a-z]{2+}(\-[a-zA-Z0-9]+)*\]/ because Textile is layered on top of HTML which
- only accepts valid BCP 47 language tags, but who knows what atrocities are being preformed
- out there in the real world. So this attempts to emulate the other libraries.
- */
- input += '';
- if ( !input || element === 'notextile' ) { return undefined; }
-
- var m
- , st = {}
- , o = { 'style': st }
- , remaining = input
- , is_block = /^(?:table|t[dh]|t(?:foot|head|body))$/.test( element ) || re_block_se.test( element ) // "in" test would be better but what about fn#.?
- , is_img = element === 'img'
- , is_list = element === 'li'
- , is_phrase = !is_block && !is_img && element !== 'a'
- , re_pba_align = ( is_img ) ? re_pba_align_img : re_pba_align_blk
- ;
-
- do {
-
- if ( (m = re_pba_styles.exec( remaining )) ) {
- m[1].split(';').forEach(function(p){
- var d = p.match( re_pba_css );
- if ( d ) { st[ d[1] ] = d[2]; }
- });
- remaining = remaining.slice( m[0].length );
- continue;
- }
-
- if ( (m = re_pba_lang.exec( remaining )) ) {
- var rm = remaining.slice( m[0].length );
- if (
- ( !rm && is_phrase ) ||
- ( end_token && end_token === rm.slice(0,end_token.length) )
- ) {
- m = null;
- }
- else {
- o['lang'] = m[1];
- remaining = remaining.slice( m[0].length );
- }
- continue;
- }
-
- if ( (m = re_pba_classid.exec( remaining )) ) {
- var rm = remaining.slice( m[0].length );
- if (
- ( !rm && is_phrase ) ||
- ( end_token && (rm[0] === ' ' || end_token === rm.slice(0,end_token.length)) )
- ) {
- m = null;
- }
- else {
- var bits = m[1].split( '#' );
- if ( bits[0] ) { o['class'] = bits[0]; }
- if ( bits[1] ) { o['id'] = bits[1]; }
- remaining = rm;
- }
- continue;
- }
-
- if ( is_block || is_list ) {
- if ( (m = re_pba_padding_l.exec( remaining )) ) {
- st[ "padding-left" ] = ( m[1].length ) + "em";
- remaining = remaining.slice( m[0].length );
- continue;
- }
- if ( (m = re_pba_padding_r.exec( remaining )) ) {
- st[ "padding-right" ] = ( m[1].length ) + "em";
- remaining = remaining.slice( m[0].length );
- continue;
- }
- }
-
- // only for blocks:
- if ( is_img || is_block || is_list ) {
- if ( (m = re_pba_align.exec( remaining )) ) {
- var align = pba_align_lookup[ m[1] ];
- if ( is_img ) {
- o[ 'align' ] = align;
- }
- else {
- st[ 'text-align' ] = align;
- }
- remaining = remaining.slice( m[0].length );
- continue;
- }
- }
-
- // only for table cells
- if ( element === 'td' || element === 'tr' ) {
- if ( (m = re_pba_valign.exec( remaining )) ) {
- st[ "vertical-align" ] = pba_valign_lookup[ m[1] ];
- remaining = remaining.slice( m[0].length );
- continue;
- }
- }
- if ( element === 'td' ) {
- if ( (m = re_pba_colspan.exec( remaining )) ) {
- o[ "colspan" ] = m[1];
- remaining = remaining.slice( m[0].length );
- continue;
- }
- if ( (m = re_pba_rowspan.exec( remaining )) ) {
- o[ "rowspan" ] = m[1];
- remaining = remaining.slice( m[0].length );
- continue;
- }
- }
-
- }
- while ( m );
-
- // collapse styles
- var s = [];
- for ( var v in st ) { s.push( v + ':' + st[v] ); }
- if ( s.length ) { o.style = s.join(';'); } else { delete o.style; }
-
- return remaining == input
- ? undefined
- : [ input.length - remaining.length, o ]
- ;
- }
-
-
-
- /* glyph parser */
-
- function parse_glyphs ( src ) {
- if ( typeof src !== 'string' ) { return src; }
- // NB: order is important here ...
- return src
- // arrow
- .replace( /([^\-]|^)->/, '$1→' ) // arrow
- // dimensions
- .replace( re_dimsign, '$1×$2' ) // dimension sign
- // ellipsis
- .replace( /([^.]?)\.{3}/g, '$1…' ) // ellipsis
- // dashes
- .replace( re_emdash, '$1—$2' ) // em dash
- .replace( / - /g, ' – ' ) // en dash
- // legal marks
- .replace( re_trademark, '$1™' ) // trademark
- .replace( re_registered, '$1®' ) // registered
- .replace( re_copyright, '$1©' ) // copyright
- // double quotes
- .replace( re_double_prime, '$1″' ) // double prime
- .replace( re_closing_dquote, '$1”' ) // double closing quote
- .replace( /"/g, '“' ) // double opening quote
- // single quotes
- .replace( re_single_prime, '$1′' ) // single prime
- .replace( re_apostrophe, '$1’$2' ) // I'm an apostrophe
- .replace( re_closing_squote, '$1’' ) // single closing quote
- .replace( /'/g, '‘' )
- // fractions and degrees
- .replace( /[\(\[]1\/4[\]\)]/, '¼' )
- .replace( /[\(\[]1\/2[\]\)]/, '½' )
- .replace( /[\(\[]3\/4[\]\)]/, '¾' )
- .replace( /[\(\[]o[\]\)]/, '°' )
- .replace( /[\(\[]\+\/\-[\]\)]/, '±' )
- ;
- }
-
-
- /* list parser */
-
- function list_pad ( n ) {
- var s = '\n';
- while ( n-- ) { s += '\t'; }
- return s;
- }
-
- function parse_list ( src, options ) {
- src = ribbon( src.replace( /(^|\r?\n)[\t ]+/, '$1' ) );
- var stack = []
- , curr_idx = {}
- , last_idx = options._lst || {}
- , list_pba
- , item_index = 0
- , m
- , n
- , s
- ;
- while ( (m = re_list_item.exec( src )) ) {
- var item = [ 'li' ]
- , start_index = 0
- , dest_level = m[1].length
- , type = m[1].substr(-1) === '#' ? 'ol' : 'ul'
- , new_li = null
- , lst
- , par
- , pba
- , r
- ;
-
- // list starts and continuations
- if ( n = /^(_|\d+)/.exec( m[2] ) ) {
- item_index = isFinite( n[1] )
- ? parseInt( n[1], 10 )
- : last_idx[ dest_level ] || curr_idx[ dest_level ] || 1;
- m[2] = m[2].slice( n[1].length );
- }
-
- if ( pba = parse_attr( m[2], 'li' ) ) {
- m[2] = m[2].slice( pba[0] );
- pba = pba[1];
- }
-
- // list control
- if ( /^\.\s*$/.test( m[2] ) ) {
- list_pba = pba || {};
- src.advance( m[0] );
- continue;
- }
-
- // create nesting until we have correct level
- while ( stack.length < dest_level ) {
- // list always has an attribute object, this simplifies first-pba resolution
- lst = [ type, {}, list_pad( stack.length + 1 ), (new_li = [ 'li' ]) ];
- par = stack[ stack.length - 1 ];
- if ( par ) {
- par.li.push( list_pad( stack.length ) );
- par.li.push( lst );
- }
- stack.push({
- ul: lst
- , li: new_li
- , att: 0 // count pba's found per list
- });
- curr_idx[ stack.length ] = 1;
- }
-
- // remove nesting until we have correct level
- while ( stack.length > dest_level ) {
- r = stack.pop();
- r.ul.push( list_pad( stack.length ) );
- // lists have a predictable structure - move pba from listitem to list
- if ( r.att === 1 && !r.ul[3][1].substr ) {
- merge( r.ul[1], r.ul[3].splice( 1, 1 )[ 0 ] );
- }
- }
-
- // parent list
- par = stack[ stack.length - 1 ];
-
- // have list_pba or start_index?
- if ( item_index ) {
- par.ul[1].start = curr_idx[ dest_level ] = item_index;
- item_index = 0; // falsy prevents this from fireing until it is set again
- }
- if ( list_pba ) {
- par.att = 9; // "more than 1" prevent pba transfers on list close
- merge( par.ul[1], list_pba );
- list_pba = null;
- }
-
- if ( !new_li ) {
- par.ul.push( list_pad( stack.length ), item );
- par.li = item;
- }
- if ( pba ) {
- par.li.push( pba );
- par.att++;
- }
- Array.prototype.push.apply( par.li, parse_inline( m[2].trim(), options ) );
-
- src.advance( m[0] );
- curr_idx[ dest_level ] = (curr_idx[ dest_level ] || 0) + 1;
- }
-
- // remember indexes for continuations next time
- options._lst = curr_idx;
-
- while ( stack.length ) {
- s = stack.pop();
- s.ul.push( list_pad( stack.length ) );
- // lists have a predictable structure - move pba from listitem to list
- if ( s.att === 1 && !s.ul[3][1].substr ) {
- merge( s.ul[1], s.ul[3].splice( 1, 1 )[ 0 ] );
- }
- }
-
- return s.ul;
- }
-
-
- /* definitions list parser */
-
- function parse_deflist ( src, options ) {
- src = ribbon( src.trim() );
- var deflist = [ 'dl', '\n' ]
- , terms
- , def
- , m
- ;
- while ( (m = re_deflist_item.exec( src )) ) {
- // add terms
- terms = m[1].split( /(?:^|\n)\- / ).slice(1);
- while ( terms.length ) {
- deflist.push( '\t'
- , [ 'dt' ].concat( parse_inline( terms.shift().trim(), options ) )
- , '\n'
- );
- }
- // add definitions
- def = m[2].trim();
- deflist.push( '\t'
- , [ 'dd' ].concat(
- /=:$/.test( def )
- ? parse_blocks( def.slice(0,-2).trim(), options )
- : parse_inline( def, options )
- )
- , '\n'
- );
- src.advance( m[0] );
- }
- return deflist;
- }
-
-
- /* table parser */
-
- function parse_colgroup ( src ) {
- var colgroup = [ 'colgroup', {} ];
- src.split( '|' )
- .forEach(function ( s, is_col ) {
- var d = s.trim()
- , col = ( is_col ) ? {} : colgroup[ 1 ]
- , m;
- if ( d ) {
- if ( (m = /^\\(\d+)/.exec( d )) ) {
- col.span = +m[ 1 ];
- d = d.slice( m[ 0 ].length );
- }
- if ( (m = parse_attr( d, 'col' )) ) {
- merge( col, m[ 1 ] );
- d = d.slice( m[ 0 ] );
- }
- if ( (m = /\b\d+\b/.exec( d )) ) {
- col.width = +m[0];
- }
- }
- if ( is_col ) {
- colgroup.push( '\n\t\t', [ 'col', col ] );
- }
- });
- return colgroup.concat([ '\n\t' ]);
- }
-
- function parse_table ( src, options ) {
- src = ribbon( src.trim() );
- var rowgroups = []
- , colgroup
- , caption
- , t_attr = {}
- , t_curr
- , row
- , inner
- , pba
- , more
- , m
- , extended = 0
- ;
- var set_rowgroup = function ( type, pba ) {
- t_curr = [ type, pba || {} ];
- rowgroups.push( t_curr );
- };
-
- if ( (m = re_table_head.exec( src )) ) {
- // parse and apply table attr
- src.advance( m[0] );
- pba = parse_attr( m[2], 'table' );
- if ( pba ) {
- merge( t_attr, pba[1] );
- }
- if ( m[3] ) {
- t_attr.summary = m[3];
- }
- }
-
- // caption
- if ( (m = re_table_caption.exec( src )) ) {
- caption = [ 'caption' ];
- if ( (pba = parse_attr( m[1], 'caption' )) ) {
- caption.push( pba[1] );
- m[1] = m[1].slice( pba[0] );
- }
- if ( /\./.test( m[1] ) ) { // mandatory "."
- caption.push( m[1].slice( 1 ).replace( /\|\s*$/, '' ).trim() );
- extended++;
- src.advance( m[0] );
- }
- else {
- caption = null;
- }
- }
-
- do {
- // colgroup
- if ( (m = re_table_colgroup.exec( src )) ) {
- colgroup = parse_colgroup( m[1] );
- extended++;
- }
- // "rowgroup" (tbody, thead, tfoot)
- else if ( (m = re_table_rowgroup.exec( src )) ) {
- // PHP allows any amount of these in any order
- // and simply translates them straight through
- // the same is done here.
- var tag = ( m[1] === '^' ) ? 'thead' :
- ( m[1] === '~' ) ? 'tfoot' :
- ( m[1] === '-' ) ? 'tbody' : 'tbody' ;
- pba = parse_attr( m[2]+' ', tag );
- set_rowgroup( tag, pba && pba[1] );
- extended++;
- }
- // row
- else if ( (m = re_table_row.exec( src )) ) {
- if ( !t_curr ) { set_rowgroup( 'tbody' ); }
-
- row = [ 'tr' ];
-
- if ( m[2] && (pba = parse_attr( m[2], 'tr' )) ) {
- // FIXME: requires "\.\s?" -- else what ?
- row.push( pba[1] );
- }
-
- t_curr.push( '\n\t\t', row );
- inner = ribbon( m[3] );
-
- do {
- inner.save();
-
- // cell loop
- var th = inner.startsWith( '_' )
- , cell = [ th ? 'th' : 'td' ]
- ;
- if ( th ) {
- inner.advance( 1 );
- }
-
- pba = parse_attr( inner, 'td' );
- if ( pba ) {
- inner.advance( pba[0] );
- cell.push( pba[1] ); // FIXME: don't do this if next text fails
- }
-
- if ( pba || th ) {
- var p = /^\.\s*/.exec( inner );
- if ( p ) {
- inner.advance( p[0] );
- }
- else {
- cell = [ 'td' ];
- inner.load();
- }
- }
-
- var mx = /^(==.*?==|[^\|])*/.exec( inner );
- cell = cell.concat( parse_inline( mx[0], options ) );
- row.push( '\n\t\t\t', cell );
- more = inner.valueOf().charAt( mx[0].length ) === '|';
- inner.advance( mx[0].length + 1 );
-
- }
- while ( more );
-
- row.push( '\n\t\t' );
-
- }
- //
- if ( m ) {
- src.advance( m[0] );
- }
- } while ( m );
-
- // assemble table
- var table = [ 'table', t_attr ];
- if ( extended ) {
- if ( caption ) {
- table.push( '\n\t', caption )
- }
- if ( colgroup ) {
- table.push( '\n\t', colgroup )
- }
- rowgroups.forEach(function ( tbody ) {
- table.push( '\n\t', tbody.concat([ '\n\t' ]) );
- });
- }
- else {
- table = table.concat( reindent( rowgroups[0].slice(2), -1 ) );
- }
-
- table.push( '\n' );
- return table;
-
- }
-
-
- /* inline parser */
-
- function parse_inline ( src, options ) {
-
- src = ribbon( src );
- var list = builder()
- , m
- , pba
- ;
-
- // loop
- do {
- src.save();
-
- // linebreak -- having this first keeps it from messing to much with other phrases
- if ( src.startsWith( '\r\n' ) ) {
- src.advance( 1 ); // skip cartridge returns
- }
- if ( src.startsWith( '\n' ) ) {
- src.advance( 1 );
-
- if ( options.breaks ) {
- list.add( [ 'br' ] );
- }
- list.add( '\n' );
- continue;
- }
-
- // inline notextile
- if ( (m = /^==(.*?)==/.exec( src )) ) {
- src.advance( m[0] );
- list.add( m[1] );
- continue;
- }
-
- // lookbehind => /([\s>.,"'?!;:])$/
- var behind = src.lookbehind( 1 );
- var boundary = !behind || /^[\s>.,"'?!;:()]$/.test( behind );
- // FIXME: need to test right boundary for phrases as well
- if ( (m = re_phrase.exec( src )) && ( boundary || m[1] ) ) {
- src.advance( m[0] );
- var tok = m[2]
- , fence = m[1]
- , phrase_type = phrase_convert[ tok ]
- , code = phrase_type === 'code'
- ;
- if ( (pba = !code && parse_attr( src, phrase_type, tok )) ) {
- src.advance( pba[0] );
- pba = pba[1];
- }
- // FIXME: if we can't match the fence on the end, we should output fence-prefix as normal text
- // seek end
- var m_mid;
- var m_end;
- if ( fence === '[' ) {
- m_mid = '^(.*?)';
- m_end = '(?:])';
- }
- else if ( fence === '{' ) {
- m_mid = '^(.*?)';
- m_end = '(?:})';
- }
- else {
- var t1 = re.escape( tok.charAt(0) );
- m_mid = ( code )
- ? '^(\\S+|\\S+.*?\\S)'
- : '^([^\\s' + t1 + ']+|[^\\s' + t1 + '].*?\\S('+t1+'*))'
- ;
- m_end = '(?=$|[\\s.,"\'!?;:()«»„“”‚‘’])';
- }
- var rx = re.compile( m_mid + '(' + re.escape( tok ) + ')' + m_end );
- if ( (m = rx.exec( src )) && m[1] ) {
- src.advance( m[0] );
- if ( code ) {
- list.add( [ phrase_type, m[1] ] );
- }
- else {
- list.add( [ phrase_type, pba ].concat( parse_inline( m[1], options ) ) );
- }
- continue;
- }
- // else
- src.load();
- }
-
- // image
- if ( (m = re_image.exec( src )) || (m = re_image_fenced.exec( src )) ) {
- src.advance( m[0] );
-
- pba = m[1] && parse_attr( m[1], 'img' );
- var attr = pba ? pba[1] : { 'src':'' }
- , img = [ 'img', attr ]
- ;
- attr.src = m[2];
- attr.alt = m[3] ? ( attr.title = m[3] ) : '';
-
- if ( m[4] ) { // +cite causes image to be wraped with a link (or link_ref)?
- // TODO: support link_ref for image cite
- img = [ 'a', { 'href': m[4] }, img ];
- }
- list.add( img );
- continue;
- }
-
- // html comment
- if ( (m = re_html_comment.exec( src )) ) {
- src.advance( m[0] );
- list.add( [ '!', m[1] ] );
- continue;
- }
- // html tag
- // TODO: this seems to have a lot of overlap with block tags... DRY?
- if ( (m = re_html_tag.exec( src )) ) {
- src.advance( m[0] );
- var tag = m[1]
- , single = m[3] || m[1] in html_singletons
- , element = [ tag ]
- , tail = m[4]
- ;
- if ( m[2] ) {
- element.push( parse_html_attr( m[2] ) );
- }
- if ( single ) { // single tag
- list.add( element ).add( tail );
- continue;
- }
- else { // need terminator
- // gulp up the rest of this block...
- var re_end_tag = re.compile( "^(.*?)(" + tag + "\\s*>)", 's' );
- if ( (m = re_end_tag.exec( src )) ) {
- src.advance( m[0] );
- if ( tag === 'code' ) {
- element.push( tail, m[1] );
- }
- else if ( tag === 'notextile' ) {
- list.merge( parse_inline( m[1], options ) );
- continue;
- }
- else {
- element = element.concat( parse_inline( m[1], options ) );
- }
- list.add( element );
- continue;
- }
- // end tag is missing, treat tag as normal text...
- }
- src.load();
- }
-
- // footnote
- if ( (m = re_footnote.exec( src )) && /\S/.test( behind ) ) {
- src.advance( m[0] );
- list.add( [ 'sup', { 'class': 'footnote', 'id': 'fnr' + m[1] },
- ( m[2] === '!' ? m[1] // "!" suppresses the link
- : [ 'a', { href: '#fn' + m[1] }, m[1] ] )
- ] );
- continue;
- }
-
- // caps / abbr
- if ( (m = re_caps.exec( src )) ) {
- src.advance( m[0] );
- var caps = [ 'span', { 'class': 'caps' }, m[1] ];
- if ( m[2] ) {
- caps = [ 'acronym', { 'title': m[2] }, caps ]; // FIXME: use , not acronym!
- }
- list.add( caps );
- continue;
- }
-
- // links
- if ( (boundary && (m = re_link.exec( src ))) || (m = re_link_fenced.exec( src )) ) {
- src.advance( m[0] );
- var title = m[1].match( re_link_title )
- , inner = ( title ) ? m[1].slice( 0, m[1].length - title[0].length ) : m[1]
- ;
- if ( (pba = parse_attr( inner, 'a' )) ) {
- inner = inner.slice( pba[0] );
- pba = pba[1];
- }
- else {
- pba = {};
- }
- if ( title && !inner ) { inner = title[0]; title = ""; }
- pba.href = m[2];
- if ( title ) { pba.title = title[1]; }
- list.add( [ 'a', pba ].concat( parse_inline( inner.replace( /^(\.?\s*)/, '' ), options ) ) );
- continue;
- }
-
- // no match, move by all "uninteresting" chars
- m = /([a-zA-Z0-9,.':]+|[ \f\r\t\v\xA0\u2028\u2029]+|[^\0])/.exec( src );
- if ( m ) {
- list.add( m[0] );
- }
- src.advance( m ? m[0].length || 1 : 1 );
-
- }
- while ( src.valueOf() );
-
- return list.get().map( parse_glyphs );
- }
-
-
- /* block parser */
-
- function parse_blocks ( src, options ) {
-
- var list = builder()
- , paragraph = function ( s, tag, pba, linebreak ) {
- tag = tag || 'p';
- var out = [];
- s.split( /(?:\r?\n){2,}/ ).forEach(function( bit, i ) {
- if ( tag === 'p' && /^\s/.test( bit ) ) {
- // no-paragraphs
- // WTF?: Why does Textile not allow linebreaks in spaced lines
- bit = bit.replace( /\r?\n[\t ]/g, ' ' ).trim();
- out = out.concat( parse_inline( bit, options ) );
- }
- else {
- if ( linebreak && i ) { out.push( linebreak ); }
- out.push( pba ? [ tag, pba ].concat( parse_inline( bit, options ) )
- : [ tag ].concat( parse_inline( bit, options ) ) );
- }
- });
- return out;
- }
- , link_refs = {}
- , m
- ;
- src = ribbon( src.replace( /^( *\r?\n)+/, '' ) );
-
- // loop
- while ( src.valueOf() ) {
- src.save();
-
- // link_ref -- this goes first because it shouldn't trigger a linebreak
- if ( (m = re_link_ref.exec( src )) ) {
- src.advance( m[0] );
- link_refs[ m[1] ] = m[2];
- continue;
- }
-
- // add linebreak
- list.linebreak();
-
- // named block
- if ( (m = re_block.exec( src )) ) {
- src.advance( m[0] );
- var block_type = m[0]
- , pba = parse_attr( src, block_type )
- ;
- if ( pba ) {
- src.advance( pba[0] );
- pba = pba[1];
- }
- if ( (m = /^\.(\.?)(?:\s|(?=:))/.exec( src )) ) {
- // FIXME: this whole copy_pba seems rather strange?
- // slurp rest of block
- var extended = !!m[1];
- m = ( extended ? re_block_extended : re_block_normal ).exec( src.advance( m[0] ) );
- src.advance( m[0] );
- // bq | bc | notextile | pre | h# | fn# | p | ###
- if ( block_type === 'bq' ) {
- var cite, inner = m[1];
- if ( (m = /^:(\S+)\s+/.exec( inner )) ) {
- if ( !pba ) { pba = {}; }
- pba.cite = m[1];
- inner = inner.slice( m[0].length );
- }
- // RedCloth adds all attr to both: this is bad because it produces duplicate IDs
- list.add( [ 'blockquote', pba, '\n' ].concat(
- paragraph( inner, 'p', copy_pba(pba, { 'cite':1, 'id':1 }), '\n' )
- ).concat(['\n']) );
- }
- else if ( block_type === 'bc' ) {
- var sub_pba = ( pba ) ? copy_pba(pba, { 'id':1 }) : null;
- list.add( [ 'pre', pba, ( sub_pba ? [ 'code', sub_pba, m[1] ] : [ 'code', m[1] ] ) ] );
- }
- else if ( block_type === 'notextile' ) {
- list.merge( parse_html( m[1] ) );
- }
- else if ( block_type === '###' ) {
- // ignore the insides
- }
- else if ( block_type === 'pre' ) {
- // I disagree with RedCloth, but agree with PHP here:
- // "pre(foo#bar).. line1\n\nline2" prevents multiline preformat blocks
- // ...which seems like the whole point of having an extended pre block?
- list.add( [ 'pre', pba, m[1] ] );
- }
- else if ( re_footnote_def.test( block_type ) ) { // footnote
- // Need to be careful: RedCloth fails "fn1(foo#m). footnote" -- it confuses the ID
- var fnid = block_type.replace( /\D+/g, '' );
- if ( !pba ) { pba = {}; }
- pba['class'] = ( pba['class'] ? pba['class'] + ' ' : '' ) + 'footnote';
- pba['id'] = 'fn' + fnid;
- list.add( [ "p", pba, [ 'a', { 'href': '#fnr' + fnid }, [ 'sup', fnid ] ], ' ' ].concat( parse_inline( m[1], options ) ) );
- }
- else { // heading | paragraph
- list.merge( paragraph( m[1], block_type, pba, '\n' ) );
- }
- continue;
- }
- else {
- src.load();
- }
- }
-
- // HTML comment
- if ( (m = re_html_comment.exec( src )) ) {
- src.advance( m[0] + (/(?:\s*\n+)+/.exec( src ) || [])[0] );
- list.add( [ '!', m[1] ] );
- continue;
- }
-
- // block HTML
- if ( (m = re_html_tag_block.exec( src )) ) {
- var tag = m[1]
- , single = m[3] || tag in html_singletons
- , tail = m[4]
- ;
- // Unsurprisingly, all Textile implementations I have tested have trouble parsing simple HTML:
- //
- // "d"
- //
- // I simply match them here as there is no way anyone is using nested HTML today, or if they
- // are, then this will at least output less broken HTML as redundant tags will get quoted.
-
- // Is block tag? ...
- if ( tag in allowed_blocktags ) {
- src.advance( m[0] );
-
- var element = [ tag ];
-
- if ( m[2] ) {
- element.push( parse_html_attr( m[2] ) );
- }
-
- if ( single ) { // single tag
- // let us add the element and continue our quest...
- list.add( element );
- continue;
- }
- else { // block
-
- // gulp up the rest of this block...
- var re_end_tag = re.compile( "^(.*?)(\\s*)(" + tag + "\\s*>)(\\s*)", 's' );
- if ( (m = re_end_tag.exec( src )) ) {
- src.advance( m[0] );
- if ( tag === 'pre' ) {
- element.push( tail );
- element = element.concat( parse_html( m[1].replace( /(\r?\n)+$/, '' ), { 'code': 1 } ) );
- if ( m[2] ) { element.push( m[2] ); }
- list.add( element );
- }
- else if ( tag === 'notextile' ) {
- element = parse_html( m[1].trim() );
- list.merge( element );
- }
- else if ( tag === 'script' || tag === 'noscript' ) {
- //element = parse_html( m[1].trim() );
- element.push( tail + m[1] );
- list.add( element );
- }
- else {
- // These strange (and unnecessary) linebreak tests are here to get the
- // tests working perfectly. In reality, this doesn't matter one bit.
- if ( /\n/.test( tail ) ) { element.push( '\n' ); }
- if ( /\n/.test( m[1] ) ) {
- element = element.concat( parse_blocks( m[1], options ) );
- }
- else {
- element = element.concat( parse_inline( m[1].replace( /^ +/, '' ), options ) );
- }
- if ( /\n/.test( m[2] ) ) { element.push( '\n' ); }
-
- list.add( element );
- }
- continue;
- }
- /*else {
- // end tag is missing, treat tag as normal text...
- }*/
- }
- }
- src.load();
- }
-
- // ruler
- if ( (m = re_ruler.exec( src )) ) {
- src.advance( m[0] );
- list.add( [ 'hr' ] );
- continue;
- }
-
- // list
- if ( (m = re_list.exec( src )) ) {
- src.advance( m[0] );
- list.add( parse_list( m[0], options ) );
- continue;
- }
-
- // definition list
- if ( (m = re_deflist.exec( src )) ) {
- src.advance( m[0] );
- list.add( parse_deflist( m[0], options ) );
- continue;
- }
-
- // table
- if ( (m = re_table.exec( src )) ) {
- src.advance( m[0] );
- list.add( parse_table( m[1], options ) );
- continue;
- }
-
- // paragraph
- m = re_block_normal.exec( src );
- list.merge( paragraph( m[1], 'p', undefined, "\n" ) );
- src.advance( m[0] );
-
- }
-
- return list.get().map( fix_links, link_refs );
- }
-
-
- // recurse the tree and swap out any "href" attributes
- function fix_links ( jsonml ) {
- if ( _isArray( jsonml ) ) {
- if ( jsonml[0] === 'a' ) { // found a link
- var attr = jsonml[1];
- if ( typeof attr === "object" && 'href' in attr && attr.href in this ) {
- attr.href = this[ attr.href ];
- }
- }
- for (var i=1,l=jsonml.length; i by default
- };
- textile.setOptions = textile.setoptions = function ( opt ) {
- merge( textile.defaults, opt );
- return this;
- };
-
-
- textile.parse = textile.convert = textile;
- textile.html_parser = parse_html;
- textile.jsonml = function ( txt, opt ) {
- // get a throw-away copy of options
- opt = merge( merge( {}, textile.defaults ), opt || {} );
- // parse and return tree
- return [ 'html' ].concat( parse_blocks( txt, opt ) );
- };
- textile.serialize = JSONML.toHTML;
-
- if ( typeof module !== 'undefined' && module.exports ) {
- module.exports = textile;
- }
- else {
- this.textile = textile;
- }
-
-
-}).call(function() {
- return this || (typeof window !== 'undefined' ? window : global);
-}());
diff --git a/qtc-markview.pro b/qtc-markview.pro
index cede26b..f7b526f 100644
--- a/qtc-markview.pro
+++ b/qtc-markview.pro
@@ -4,27 +4,20 @@ VERSION_SUFFIX = ""
include(paths.pri)
-QT += webenginewidgets
-
# QtcMarkview files
SOURCES += \
- src/QtcMarkviewPlugin.cpp \
- src/MarkviewEditorFactory.cpp \
- src/AdapterBase.cpp \
- src/MarkviewWidget.cpp \
- src/WebViewFind.cpp \
- src/PreviewPage.cpp
+ src/markdownhighlighter.cpp \
+ src/markdowntextedit.cpp \
+ src/markdowneditorfactory.cpp \
+ src/markviewplugin.cpp
HEADERS += \
- src/Constants.h \
- src/PluginGlobal.h \
- src/QtcMarkviewPlugin.h \
- src/MarkviewEditorFactory.h \
- src/AdapterBase.h \
- src/MarkviewWidget.h \
- src/WebViewFind.h \
- src/PreviewPage.h
+ src/constants.h \
+ src/markdownhighlighter.h \
+ src/markdowntextedit.h \
+ src/markdowneditorfactory.h \
+ src/markviewplugin.h
TRANSLATIONS += \
translation/QtcMarkview_ru.ts
@@ -57,7 +50,3 @@ QTC_PLUGIN_RECOMMENDS += \
###### End _dependencies.pri contents ######
include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri)
-
-RESOURCES += \
- resources.qrc
-
diff --git a/src/AdapterBase.cpp b/src/AdapterBase.cpp
deleted file mode 100644
index ac4a746..0000000
--- a/src/AdapterBase.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "AdapterBase.h"
-
-#include
-#include
-#include
-#include
-
-using namespace QtcMarkview::Internal;
-
-namespace {
-
- QByteArray readFile (const QString &name) {
- QFile f (name);
- QByteArray result;
- if (f.open (QFile::ReadOnly)) {
- result = f.readAll ();
- f.close ();
- }
- else {
- qCritical () << "Error opening file" << name;
- }
- return result;
- }
-
- //! Prepare string to be passed to js script.
- QString toJsString (const QString &source) {
- QString result = source;
- result = result
- .replace (QStringLiteral ("\n"), QStringLiteral ("\\n")) // support multiline
- .replace (QStringLiteral ("\""), QStringLiteral ("\\\"")) // support internal quotes
- .replace (QStringLiteral (""),QStringLiteral ("</script>"));
- return QStringLiteral ("\"") + result + QStringLiteral ("\"");
- }
-
-}
-
-AdapterBase::AdapterBase (const QString helpFileName, const QString htmlFileName, bool isCustom)
- : helpFileName_ (helpFileName), htmlFileName_ (htmlFileName), isCustom_ (isCustom) {
-
-}
-
-AdapterBase::~AdapterBase () {
-
-}
-
-void AdapterBase::initView (const QString &plainText, const QString &baseDir,
- QWebEngineView *view) const {
- QString html;
- if (htmlFileName_.isEmpty ()) {
- html = plainText;
- }
- else {
- html = QString::fromLocal8Bit (readFile (htmlFileName_.toHtmlEscaped ()));
- html = html.arg (toJsString (plainText));
- }
-
- view->setHtml (html, QUrl::fromLocalFile (baseDir + QStringLiteral ("/")));
-}
-
-void AdapterBase::updateView (const QString &plainText, const QString &baseDir,
- QWebEngineView *view) const {
- if (htmlFileName_.isEmpty ()) {
- view->setHtml (plainText, QUrl::fromLocalFile (baseDir + QStringLiteral ("/")));
- }
- else {
- QString preprocessed = toJsString (plainText);
- QString updateScript = QString (QStringLiteral ("update (%1);")).arg (preprocessed);
- QWebEnginePage *mainFrame = view->page ();
- mainFrame->runJavaScript (updateScript);
- }
-}
-
-QString AdapterBase::helpMessage () const {
- QString message;
- if (!helpFileName_.isEmpty ()) {
- message = QString::fromLocal8Bit (readFile (helpFileName_));
- }
- return message;
-}
-
-bool AdapterBase::isHelpAvailable () const {
- return !helpFileName_.isEmpty ();
-}
-
-bool AdapterBase::isCustom () const {
- return isCustom_;
-}
-
-QString AdapterBase::htmlFileName () const {
- return htmlFileName_;
-}
diff --git a/src/AdapterBase.h b/src/AdapterBase.h
deleted file mode 100644
index be6158d..0000000
--- a/src/AdapterBase.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef ADAPTERBASE_H
-#define ADAPTERBASE_H
-
-#include
-
-class QWebEngineView;
-
-namespace QtcMarkview {
- namespace Internal {
-
- class AdapterBase {
- public:
- AdapterBase (const QString helpFileName = QString (),
- const QString htmlFileName = QString (),
- bool isCustom = false);
- virtual ~AdapterBase ();
-
- virtual void initView (const QString &plainText, const QString &baseDir,
- QWebEngineView *view) const;
- virtual void updateView (const QString &plainText, const QString &baseDir,
- QWebEngineView *view) const;
-
- QString helpMessage () const;
- bool isHelpAvailable () const;
-
- bool isCustom () const;
- QString htmlFileName () const;
-
- protected:
- QString helpFileName_;
- QString htmlFileName_;
- bool isCustom_;
- };
-
- } // namespace Internal
-} // namespace QtcMarkview
-
-#endif // ADAPTERBASE_H
diff --git a/src/MarkviewEditorFactory.cpp b/src/MarkviewEditorFactory.cpp
deleted file mode 100644
index 9e21400..0000000
--- a/src/MarkviewEditorFactory.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "MarkviewEditorFactory.h"
-#include "Constants.h"
-#include "MarkviewWidget.h"
-#include "AdapterBase.h"
-
-#include
-#include
-
-#include
-#include
-#include
-
-using namespace QtcMarkview::Internal;
-
-namespace {
- Adapters adapters;
- const QString group = "QtcMarkview";
- const QString field = "adapters";
-}
-
-MarkviewEditorFactory::MarkviewEditorFactory () {
- setId (Constants::QTCMARKVIEW_ID);
- setDisplayName (QCoreApplication::translate ("OpenWith::Editors",
- Constants::QTCMARKVIEW_DISPLAY_NAME));
- addMimeType ("text/plain");
-
- adapters.insert (tr ("Plain"), nullptr);
- adapters.insert (tr ("Markdown"), new AdapterBase (QStringLiteral (":/help/markdown.md"),
- QStringLiteral (":/html/markdown.html")));
- adapters.insert (tr ("Asciidoctor"), new AdapterBase (QStringLiteral (":/help/asciidoctor.adoc"),
- QStringLiteral (":/html/asciidoctor.html")));
- adapters.insert (tr ("Textile"), new AdapterBase (QStringLiteral (":/help/textile.textile"),
- QStringLiteral (":/html/textile.html")));
- adapters.insert (tr ("Html"), new AdapterBase (QStringLiteral (":/help/html.html")));
-
- loadCustomAdapters ();
-
- setDocumentCreator ([]() {
- return new TextEditor::TextDocument (Constants::QTCMARKVIEW_ID);
- });
- setEditorCreator ([]() {
- return new TextEditor::BaseTextEditor;
- });
- setEditorWidgetCreator ([]() {
- return new MarkviewWidget (adapters);
- });
- setIndenterCreator ([]() {
- return new TextEditor::NormalIndenter;
- });
-}
-
-MarkviewEditorFactory::~MarkviewEditorFactory () {
- saveCustomAdapters ();
- qDeleteAll (adapters.values ());
- adapters.clear ();
-}
-
-void MarkviewEditorFactory::loadCustomAdapters () {
- Q_ASSERT (Core::ICore::settings () != NULL);
- QSettings &settings = *(Core::ICore::settings ());
- settings.beginGroup (group);
- auto custom = settings.value (field).toString ().split (",");
- settings.endGroup ();
-
- for (const auto &i: custom) {
- auto parts = i.split (":::");
- if (parts.size () < 2) {
- continue;
- }
- adapters.insert (parts[0], new AdapterBase ({}, parts[1], true));
- }
-}
-
-void MarkviewEditorFactory::saveCustomAdapters () {
- QStringList custom;
- for (const auto &name: adapters.keys ()) {
- auto adapter = adapters[name];
- if (adapter && adapter->isCustom ()) {
- custom << QString ("%1:::%2").arg (name, adapter->htmlFileName ());
- }
- }
-
- Q_ASSERT (Core::ICore::settings () != NULL);
- QSettings &settings = *(Core::ICore::settings ());
- settings.beginGroup (group);
- settings.setValue (field, custom.join (","));
- settings.endGroup ();
-}
diff --git a/src/MarkviewEditorFactory.h b/src/MarkviewEditorFactory.h
deleted file mode 100644
index 51440d8..0000000
--- a/src/MarkviewEditorFactory.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef MARKVIEWEDITORFACTORY_H
-#define MARKVIEWEDITORFACTORY_H
-
-#include
-
-namespace QtcMarkview {
- namespace Internal {
-
- class MarkviewEditorFactory : public TextEditor::TextEditorFactory {
- Q_OBJECT
-
- public:
- MarkviewEditorFactory ();
- ~MarkviewEditorFactory ();
-
- private:
- void loadCustomAdapters ();
- void saveCustomAdapters ();
- };
-
- } // namespace Internal
-} // namespace QtcMarkview
-
-
-#endif // MARKVIEWEDITORFACTORY_H
diff --git a/src/MarkviewWidget.cpp b/src/MarkviewWidget.cpp
deleted file mode 100644
index 48e5364..0000000
--- a/src/MarkviewWidget.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "MarkviewWidget.h"
-#include "AdapterBase.h"
-#include "Constants.h"
-#include "WebViewFind.h"
-#include "PreviewPage.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-using namespace QtcMarkview::Internal;
-
-
-MarkviewWidget::MarkviewWidget (Adapters &adapters)
- : webView_ (nullptr),adapterCombo_ (new QComboBox (this)),
- adapters_ (adapters), currentAdapter_ (nullptr) {
-
- QToolButton *removeButton = new QToolButton (this);
- removeButton->setIcon (QIcon (QStringLiteral (":icons/list-remove.png")));
- removeButton->setToolTip (QStringLiteral ("Remove custom editor"));
- connect (removeButton, &QToolButton::clicked, this, &MarkviewWidget::removeCustomEditor);
- connect (this, &MarkviewWidget::isCustomEditorChanged, removeButton, &QToolButton::setEnabled);
- insertExtraToolBarWidget (Left, removeButton);
-
- QToolButton *addButton = new QToolButton (this);
- addButton->setIcon (QIcon (QStringLiteral (":icons/list-add.png")));
- addButton->setToolTip (QStringLiteral ("Add custom editor"));
- connect (addButton, &QToolButton::clicked, this, &MarkviewWidget::addCustomEditor);
- insertExtraToolBarWidget (Left, addButton);
-
- QToolButton *helpButton = new QToolButton (this);
- helpButton->setIcon (QIcon (QStringLiteral (":icons/question1.png")));
- helpButton->setToolTip (QStringLiteral ("Show format help"));
- connect (helpButton, &QToolButton::clicked, this, &MarkviewWidget::showHelp);
- connect (this, &MarkviewWidget::helpAvailabilityChanged, helpButton, &QToolButton::setEnabled);
- insertExtraToolBarWidget (Left, helpButton);
-
- QStringList adapterNames = adapters_.keys ();
- adapterNames.sort ();
- adapterCombo_->addItems (adapterNames);
- QString plainName = adapters_.key (nullptr);
- adapterCombo_->setCurrentText (plainName); // required if plain is not first
- currentAdapterChanged (plainName);
- connect (adapterCombo_, &QComboBox::currentTextChanged, this, &MarkviewWidget::currentAdapterChanged);
- insertExtraToolBarWidget (Left, adapterCombo_);
-}
-
-MarkviewWidget::~MarkviewWidget () {
- delete webView_;
-}
-
-void MarkviewWidget::finalizeInitialization () {
- textDocument ()->setMimeType (QLatin1String (TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
-
- setupGenericHighlighter ();
- configureGenericHighlighter ();
-
- Q_ASSERT (textDocument ());
- connect (textDocument (), &TextEditor::TextDocument::contentsChanged,
- this, &MarkviewWidget::update);
-}
-
-void MarkviewWidget::currentAdapterChanged (const QString &newAdapterName) {
- currentAdapter_ = adapters_.value (newAdapterName, nullptr);
- emit helpAvailabilityChanged (currentAdapter_ && currentAdapter_->isHelpAvailable ());
- emit isCustomEditorChanged (currentAdapter_ && currentAdapter_->isCustom ());
- currentAdapterName_ = newAdapterName;
- changeView ();
- init ();
-}
-
-void MarkviewWidget::changeView () {
- // Create webView and place on top of base editor (not viewport).
- if (currentAdapter_ && !webView_) {
- webView_ = new QWebEngineView (this);
- webView_->setPage (new PreviewPage (webView_));
- webView_->setStyleSheet (QStringLiteral ("QWebEngineView {background: #FFFFFF;}"));
-#ifndef QT_DEBUG
- webView_->setContextMenuPolicy (Qt::NoContextMenu);
-#endif
- QVBoxLayout *layout = new QVBoxLayout (this);
- layout->setMargin (0);
- layout->addWidget (webView_);
-
- // Search support
- Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
- WebViewFind *webViewFind = new WebViewFind (webView_);
- aggregate->add (webViewFind);
- aggregate->add (webView_);
- }
-
- if (currentAdapter_) {
- hide ();
- setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
- horizontalScrollBar ()->setMaximumWidth (0);
- verticalScrollBar ()->setMaximumHeight (0);
- show ();
- webView_->show ();
- }
- else {
- setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded);
- setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
- horizontalScrollBar ()->setMaximumWidth (999);
- verticalScrollBar ()->setMaximumHeight (999);
- if (webView_) {
- webView_->hide ();
- }
- }
-}
-
-void MarkviewWidget::init () {
- if (currentAdapter_) {
- Q_ASSERT (webView_);
- Q_ASSERT (textDocument ());
- QFileInfo info (textDocument ()->filePath ().toString ());
- currentAdapter_->initView (textDocument ()->plainText (), info.absolutePath (), webView_);
- }
-}
-
-void MarkviewWidget::update () {
- if (currentAdapter_) {
- Q_ASSERT (webView_);
- Q_ASSERT (textDocument ());
- QFileInfo info (textDocument ()->filePath ().toString ());
- currentAdapter_->updateView (textDocument ()->plainText (), info.absolutePath (), webView_);
- }
-}
-
-void MarkviewWidget::showHelp () {
- if (!currentAdapter_ || !currentAdapter_->isHelpAvailable ()) {
- return;
- }
- QString helpText = currentAdapter_->helpMessage ();
- QString titlePattern = QString (QStringLiteral ("%1 help")).arg (currentAdapterName_);
- Core::EditorManager::openEditorWithContents (Constants::QTCMARKVIEW_ID, &titlePattern,
- helpText.toUtf8 ());
-}
-
-void MarkviewWidget::addCustomEditor () {
- auto file = QFileDialog::getOpenFileName (nullptr, tr ("Select conversion script"),
- {}, "*.html");
- if (file.isEmpty () && QFile::exists (file)) {
- return;
- }
- auto name = QFileInfo (file).fileName ();
- if (adapters_.contains (name)) {
- return;
- }
- adapters_.insert (name, new AdapterBase ({}, file, true));
- adapterCombo_->addItem (name);
- adapterCombo_->setCurrentText (name);
-}
-
-void MarkviewWidget::removeCustomEditor () {
- if (QMessageBox::question (this, {}, tr ("Remove %1?").arg (currentAdapterName_))
- == QMessageBox::Yes) {
- adapters_.remove (currentAdapterName_);
- adapterCombo_->removeItem (adapterCombo_->currentIndex ());
- }
-}
diff --git a/src/MarkviewWidget.h b/src/MarkviewWidget.h
deleted file mode 100644
index a1679e9..0000000
--- a/src/MarkviewWidget.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef MARKVIEWWIDGET_H
-#define MARKVIEWWIDGET_H
-
-#include
-
-class QWebEngineView;
-class QComboBox;
-
-namespace QtcMarkview {
- namespace Internal {
-
- class AdapterBase;
- typedef QHash Adapters;
-
- class MarkviewWidget : public TextEditor::TextEditorWidget {
- Q_OBJECT
-
- public:
- MarkviewWidget (Adapters &adapters);
- ~MarkviewWidget ();
-
- void finalizeInitialization ();
-
- signals:
- void helpAvailabilityChanged (bool gotHelp);
- void isCustomEditorChanged (bool gotHelp);
-
- private slots:
- void currentAdapterChanged (const QString &newAdapterName);
- void changeView ();
- void init ();
- void update ();
- void showHelp ();
- void addCustomEditor ();
- void removeCustomEditor ();
-
- private:
- QWebEngineView *webView_;
- QComboBox *adapterCombo_;
-
- Adapters &adapters_;
- const AdapterBase *currentAdapter_;
- QString currentAdapterName_;
-
- };
-
-
- } // namespace Internal
-} // namespace QtcMarkview
-
-
-#endif // MARKVIEWWIDGET_H
diff --git a/src/PluginGlobal.h b/src/PluginGlobal.h
deleted file mode 100644
index 2415101..0000000
--- a/src/PluginGlobal.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef QTCMARKVIEW_GLOBAL_H
-#define QTCMARKVIEW_GLOBAL_H
-
-#include
-
-#if defined(QTCMARKVIEW_LIBRARY)
-# define QTCMARKVIEWSHARED_EXPORT Q_DECL_EXPORT
-#else
-# define QTCMARKVIEWSHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-#endif // QTCMARKVIEW_GLOBAL_H
-
diff --git a/src/PreviewPage.cpp b/src/PreviewPage.cpp
deleted file mode 100644
index da50e83..0000000
--- a/src/PreviewPage.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include
-
-#include "PreviewPage.h"
-
-PreviewPage::PreviewPage (QObject *parent) : QWebEnginePage (parent) {
-}
-
-bool PreviewPage::acceptNavigationRequest (const QUrl &url, QWebEnginePage::NavigationType /*type*/,
- bool /*isMainFrame*/) {
- QDesktopServices::openUrl (url);
- return false;
-}
diff --git a/src/PreviewPage.h b/src/PreviewPage.h
deleted file mode 100644
index 09b19d4..0000000
--- a/src/PreviewPage.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef PREVIEWPAGE_H
-#define PREVIEWPAGE_H
-
-#include
-
-class PreviewPage : public QWebEnginePage {
- Q_OBJECT
-
- public:
- explicit PreviewPage (QObject *parent = nullptr);
-
- protected:
- bool acceptNavigationRequest (const QUrl &url, NavigationType type, bool isMainFrame);
-};
-
-#endif // PREVIEWPAGE_H
diff --git a/src/WebViewFind.cpp b/src/WebViewFind.cpp
deleted file mode 100644
index f1ce7e0..0000000
--- a/src/WebViewFind.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "WebViewFind.h"
-
-#include
-#include
-
-using namespace Core;
-
-QWebEnginePage::FindFlags toWebPageFlags (FindFlags flags) {
- QWebEnginePage::FindFlags result = 0;
- result = (flags & FindBackward) ? (result | QWebEnginePage::FindBackward) : result;
- result = (flags & FindCaseSensitively) ? (result | QWebEnginePage::FindCaseSensitively) : result;
- return result;
-}
-
-
-WebViewFind::WebViewFind (QWebEngineView *view)
- : view_ (view) {
-}
-
-bool WebViewFind::supportsReplace () const {
- return true;
-}
-
-FindFlags WebViewFind::supportedFindFlags () const {
- return FindBackward | FindCaseSensitively | FindWholeWords
- | FindRegularExpression | FindPreserveCase;
-}
-
-void WebViewFind::resetIncrementalSearch () {
- Q_ASSERT (!view_.isNull ());
- view_->findText (QString (), toWebPageFlags (0));
-}
-
-void WebViewFind::clearHighlights () {
- Q_ASSERT (!view_.isNull ());
- view_->findText (QString (), toWebPageFlags (0));
-}
-
-QString WebViewFind::currentFindString () const {
- Q_ASSERT (!view_.isNull ());
- return view_->selectedText ();
-}
-
-QString WebViewFind::completedFindString () const {
- Q_ASSERT (!view_.isNull ());
- return view_->selectedText ();
-}
-
-WebViewFind::Result WebViewFind::findIncremental (const QString &txt, FindFlags findFlags) {
- Q_ASSERT (!view_.isNull ());
- view_->findText (QString (), toWebPageFlags (0));
- view_->findText (txt, toWebPageFlags (findFlags));
- return NotFound;
-}
-
-WebViewFind::Result WebViewFind::findStep (const QString &txt, FindFlags findFlags) {
- Q_ASSERT (!view_.isNull ());
- view_->findText (txt, toWebPageFlags (findFlags));
- return NotFound;
-}
diff --git a/src/WebViewFind.h b/src/WebViewFind.h
deleted file mode 100644
index e3e6867..0000000
--- a/src/WebViewFind.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef WEBVIEWFIND_H
-#define WEBVIEWFIND_H
-
-#include
-
-#include
-
-class QWebEngineView;
-
-class WebViewFind : public Core::IFindSupport {
- Q_OBJECT
-
- public:
- WebViewFind (QWebEngineView *view);
-
- bool supportsReplace () const;
- Core::FindFlags supportedFindFlags () const;
- void resetIncrementalSearch ();
- void clearHighlights ();
- QString currentFindString () const;
- QString completedFindString () const;
- Result findIncremental (const QString &txt, Core::FindFlags findFlags);
- Result findStep (const QString &txt, Core::FindFlags findFlags);
-
- private:
- QPointer view_;
-};
-
-#endif // WEBVIEWFIND_H
diff --git a/src/Constants.h b/src/constants.h
similarity index 55%
rename from src/Constants.h
rename to src/constants.h
index 9692aab..fb804a9 100644
--- a/src/Constants.h
+++ b/src/constants.h
@@ -4,8 +4,8 @@
namespace QtcMarkview {
namespace Constants {
- const char QTCMARKVIEW_ID[] = "QtcMarkview.Editor";
- const char QTCMARKVIEW_DISPLAY_NAME[] = QT_TRANSLATE_NOOP ("OpenWith::Editors", "Markview");
+ const char MARKDOWN_EDITOR_ID[] = "QtcMarkview.MarkdownEditor";
+ const char MARKDOWN_EDITOR_NAME[] = QT_TRANSLATE_NOOP ("OpenWith::Editors", "Markdown");
} // namespace QtcMarkview
} // namespace Constants
diff --git a/src/markdowneditorfactory.cpp b/src/markdowneditorfactory.cpp
new file mode 100644
index 0000000..16efe02
--- /dev/null
+++ b/src/markdowneditorfactory.cpp
@@ -0,0 +1,36 @@
+#include "markdowneditorfactory.h"
+#include "constants.h"
+
+#include "markdowntextedit.h"
+
+#include
+#include
+
+namespace QtcMarkview {
+ namespace Internal {
+
+ MarkdownEditorFactory::MarkdownEditorFactory (QObject *parent) :
+ TextEditor::TextEditorFactory (parent) {
+ setId (Constants::MARKDOWN_EDITOR_ID);
+ setDisplayName (QCoreApplication::translate ("OpenWith::Editors",
+ Constants::MARKDOWN_EDITOR_NAME));
+ addMimeType ("text/plain");
+ addMimeType ("text/markdown");
+
+ setDocumentCreator ([]() {
+ return new TextEditor::TextDocument (Constants::MARKDOWN_EDITOR_ID);
+ });
+ setEditorCreator ([]() {
+ return new TextEditor::BaseTextEditor;
+ });
+ setEditorWidgetCreator ([]() {
+ return new QMarkdownTextEdit;
+ });
+ setIndenterCreator ([]() {
+ return new TextEditor::NormalIndenter;
+ });
+ // setSyntaxHighlighterCreator()
+ }
+
+ } // namespace Internal
+} // namespace QtcMarkview
diff --git a/src/markdowneditorfactory.h b/src/markdowneditorfactory.h
new file mode 100644
index 0000000..a421a56
--- /dev/null
+++ b/src/markdowneditorfactory.h
@@ -0,0 +1,19 @@
+#ifndef MARKDOWNEDITORFACTORY_H
+#define MARKDOWNEDITORFACTORY_H
+
+#include
+
+namespace QtcMarkview {
+ namespace Internal {
+
+ class MarkdownEditorFactory : public TextEditor::TextEditorFactory {
+ Q_OBJECT
+
+ public:
+ explicit MarkdownEditorFactory (QObject *parent = nullptr);
+ };
+
+ } // namespace Internal
+} // namespace QtcMarkview
+
+#endif // MARKDOWNEDITORFACTORY_H
diff --git a/src/markdownhighlighter.cpp b/src/markdownhighlighter.cpp
new file mode 100644
index 0000000..b711c28
--- /dev/null
+++ b/src/markdownhighlighter.cpp
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2014-2018 Patrizio Bekerle -- http://www.bekerle.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * QPlainTextEdit markdown highlighter
+ */
+
+#include
+#include
+#include "markdownhighlighter.h"
+#include
+#include
+#include
+
+#include
+#include
+
+
+/**
+ * Markdown syntax highlighting
+ *
+ * markdown syntax:
+ * http://daringfireball.net/projects/markdown/syntax
+ *
+ * @param parent
+ * @return
+ */
+MarkdownHighlighter::MarkdownHighlighter (
+ QTextDocument *parent, HighlightingOptions highlightingOptions)
+ : TextEditor::SyntaxHighlighter (parent) {
+ _highlightingOptions = highlightingOptions;
+ _timer = new QTimer (this);
+ QObject::connect (_timer, SIGNAL (timeout ()),
+ this, SLOT (timerTick ()));
+ _timer->start (1000);
+
+ // initialize the highlighting rules
+ initHighlightingRules ();
+
+ // initialize the text formats
+ initTextFormats ();
+}
+
+/**
+ * Does jobs every second
+ */
+void MarkdownHighlighter::timerTick () {
+ // qDebug() << "timerTick: " << this << ", " << this->parent()->parent()->parent()->objectName();
+
+ // re-highlight all dirty blocks
+ reHighlightDirtyBlocks ();
+
+ // emit a signal every second if there was some highlighting done
+ if (_highlightingFinished) {
+ _highlightingFinished = false;
+ emit (highlightingFinished ());
+ }
+}
+
+/**
+ * Re-highlights all dirty blocks
+ */
+void MarkdownHighlighter::reHighlightDirtyBlocks () {
+ while (_dirtyTextBlocks.count () > 0) {
+ QTextBlock block = _dirtyTextBlocks.at (0);
+ rehighlightBlock (block);
+ _dirtyTextBlocks.removeFirst ();
+ }
+}
+
+/**
+ * Clears the dirty blocks vector
+ */
+void MarkdownHighlighter::clearDirtyBlocks () {
+ _dirtyTextBlocks.clear ();
+}
+
+/**
+ * Adds a dirty block to the list if it doesn't already exist
+ *
+ * @param block
+ */
+void MarkdownHighlighter::addDirtyBlock (QTextBlock block) {
+ if (!_dirtyTextBlocks.contains (block)) {
+ _dirtyTextBlocks.append (block);
+ }
+}
+
+/**
+ * Initializes the highlighting rules
+ *
+ * regexp tester:
+ * https://regex101.com
+ *
+ * other examples:
+ * /usr/share/kde4/apps/katepart/syntax/markdown.xml
+ */
+void MarkdownHighlighter::initHighlightingRules () {
+ HighlightingRule rule;
+
+ // highlight the reference of reference links
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("^\\[.+?\\]: \\w+://.+$");
+ rule.state = HighlighterState::MaskedSyntax;
+ _highlightingRulesPre.append (rule);
+
+ // highlight unordered lists
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("^\\s*[-*+]\\s");
+ rule.state = HighlighterState::List;
+ rule.useStateAsCurrentBlockState = true;
+ _highlightingRulesPre.append (rule);
+
+ // highlight ordered lists
+ rule.pattern = QRegularExpression ("^\\s*\\d+\\.\\s");
+ _highlightingRulesPre.append (rule);
+
+ // highlight block quotes
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression (
+ _highlightingOptions.testFlag (
+ HighlightingOption::FullyHighlightedBlockQuote) ?
+ QStringLiteral ("^\\s*(>\\s*.+)") :
+ QStringLiteral ("^\\s*(>\\s*)+"));
+ rule.state = HighlighterState::BlockQuote;
+ _highlightingRulesPre.append (rule);
+
+ // highlight horizontal rulers
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("^([*\\-_]\\s?){3,}$");
+ rule.state = HighlighterState::HorizontalRuler;
+ _highlightingRulesPre.append (rule);
+
+ // highlight tables without starting |
+ // we drop that for now, it's far too messy to deal with
+ // rule = HighlightingRule();
+ // rule.pattern = QRegularExpression("^.+? \\| .+? \\| .+$");
+ // rule.state = HighlighterState::Table;
+ // _highlightingRulesPre.append(rule);
+
+ /*
+ * highlight italic
+ * this goes before bold so that bold can overwrite italic
+ *
+ * text to test:
+ * **bold** normal **bold**
+ * *start of line* normal
+ * normal *end of line*
+ * * list item *italic*
+ */
+ rule = HighlightingRule ();
+ // we don't allow a space after the starting * to prevent problems with
+ // unordered lists starting with a *
+ rule.pattern = QRegularExpression (
+ "(^|[^\\*\\b])(\\*([^\\* ][^\\*]*?)\\*)([^\\*\\b]|$)");
+ rule.state = HighlighterState::Italic;
+ rule.maskedGroup = 2;
+ rule.capturingGroup = 3;
+ _highlightingRulesAfter.append (rule);
+
+ rule.maskedGroup = 0;
+ rule.capturingGroup = 1;
+ rule.pattern = QRegularExpression ("\\b_([^_]+)_\\b");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight bold
+ rule.pattern = QRegularExpression ("\\B\\*{2}(.+?)\\*{2}\\B");
+ rule.state = HighlighterState::Bold;
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+ rule.pattern = QRegularExpression ("\\b__(.+?)__\\b");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight urls
+ rule = HighlightingRule ();
+ rule.state = HighlighterState::Link;
+
+ // highlight urls without any other markup
+ rule.pattern = QRegularExpression ("\\b\\w+?:\\/\\/[^\\s]+");
+ rule.capturingGroup = 0;
+ _highlightingRulesAfter.append (rule);
+
+ // rule.pattern = QRegularExpression("<(.+?:\\/\\/.+?)>");
+ rule.pattern = QRegularExpression ("<([^\\s`][^`]*?[^\\s`])>");
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight urls with title
+ // rule.pattern = QRegularExpression("\\[(.+?)\\]\\(.+?://.+?\\)");
+ // rule.pattern = QRegularExpression("\\[(.+?)\\]\\(.+\\)\\B");
+ rule.pattern = QRegularExpression ("\\[([^\\[\\]]+)\\]\\((\\S+|.+?)\\)\\B");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight urls with empty title
+ // rule.pattern = QRegularExpression("\\[\\]\\((.+?://.+?)\\)");
+ rule.pattern = QRegularExpression ("\\[\\]\\((.+?)\\)");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight email links
+ rule.pattern = QRegularExpression ("<(.+?@.+?)>");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight reference links
+ rule.pattern = QRegularExpression ("\\[(.+?)\\]\\s?\\[.+?\\]");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight images with text
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("!\\[(.+?)\\]\\(.+?\\)");
+ rule.state = HighlighterState::Image;
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight images without text
+ rule.pattern = QRegularExpression ("!\\[\\]\\((.+?)\\)");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight images links
+ rule = HighlightingRule ();
+ rule.state = HighlighterState::Link;
+ rule.pattern = QRegularExpression ("\\[!\\[(.+?)\\]\\(.+?\\)\\]\\(.+?\\)");
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight images links without text
+ rule.pattern = QRegularExpression ("\\[!\\[\\]\\(.+?\\)\\]\\((.+?)\\)");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight inline code
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("`(.+?)`");
+ rule.state = HighlighterState::InlineCodeBlock;
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight code blocks with four spaces or tabs in front of them
+ // and no list character after that
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("^((\\t)|( {4,})).+$");
+ rule.state = HighlighterState::CodeBlock;
+ rule.disableIfCurrentStateIsSet = true;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight inline comments
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("");
+ rule.state = HighlighterState::Comment;
+ rule.capturingGroup = 1;
+ _highlightingRulesAfter.append (rule);
+
+ // highlight comments for Rmarkdown for academic papers
+ rule.pattern = QRegularExpression ("^\\[.+?\\]: # \\(.+?\\)$");
+ _highlightingRulesAfter.append (rule);
+
+ // highlight tables with starting |
+ rule = HighlightingRule ();
+ rule.pattern = QRegularExpression ("^\\|.+?\\|$");
+ rule.state = HighlighterState::Table;
+ _highlightingRulesAfter.append (rule);
+}
+
+/**
+ * Initializes the text formats
+ *
+ * @param defaultFontSize
+ */
+void MarkdownHighlighter::initTextFormats (int defaultFontSize) {
+ QTextCharFormat format;
+
+ auto fonts = TextEditor::TextEditorSettings::fontSettings ();
+ using Style = TextEditor::TextStyle;
+ // set character formats for headlines
+ format = fonts.toTextCharFormat ({Style::C_LABEL, {}});
+ format.setFontWeight (QFont::Bold);
+ format.setFontPointSize (defaultFontSize * 1.6);
+ _formats[H1] = format;
+ format.setFontPointSize (defaultFontSize * 1.5);
+ _formats[H2] = format;
+ format.setFontPointSize (defaultFontSize * 1.4);
+ _formats[H3] = format;
+ format.setFontPointSize (defaultFontSize * 1.3);
+ _formats[H4] = format;
+ format.setFontPointSize (defaultFontSize * 1.2);
+ _formats[H5] = format;
+ format.setFontPointSize (defaultFontSize * 1.1);
+ _formats[H6] = format;
+ format.setFontPointSize (defaultFontSize);
+
+ // set character format for horizontal rulers
+ format = fonts.toTextCharFormat ({Style::C_CURRENT_LINE, {}});
+ _formats[HorizontalRuler] = format;
+
+ // set character format for lists
+ format = fonts.toTextCharFormat ({Style::C_NUMBER, {}});
+ _formats[List] = format;
+
+ // set character format for links
+ format = fonts.toTextCharFormat ({Style::C_LINK, {}});
+ format.setUnderlineStyle (QTextCharFormat::SingleUnderline);
+ _formats[Link] = format;
+
+ // set character format for images
+ format = fonts.toTextCharFormat ({Style::C_OCCURRENCES, {}});
+ _formats[Image] = format;
+
+ // set character format for code blocks
+ format = fonts.toTextCharFormat ({Style::C_PREPROCESSOR, {}});
+ _formats[CodeBlock] = format;
+ _formats[InlineCodeBlock] = format;
+
+ // set character format for italic
+ format = fonts.toTextCharFormat ({Style::C_STRING, {}});
+ format.setProperty (QTextCharFormat::FontItalic, true);
+ _formats[Italic] = format;
+
+ // set character format for bold
+ format = fonts.toTextCharFormat ({Style::C_STRING, {}});
+ format.setFontWeight (QFont::Bold);
+ _formats[Bold] = format;
+
+ // set character format for comments
+ format = fonts.toTextCharFormat ({Style::C_COMMENT, {}});
+ _formats[Comment] = format;
+
+ // set character format for masked syntax
+ format = fonts.toTextCharFormat ({Style::C_KEYWORD, {}});
+ _formats[MaskedSyntax] = format;
+
+ // set character format for tables
+ format = fonts.toTextCharFormat ({Style::C_TEXT, {}});
+ _formats[Table] = format;
+
+ // set character format for block quotes
+ format = fonts.toTextCharFormat ({Style::C_OCCURRENCES, {}});
+ _formats[BlockQuote] = format;
+}
+
+/**
+ * Sets the text formats
+ *
+ * @param formats
+ */
+void MarkdownHighlighter::setTextFormats (
+ QHash formats) {
+ _formats = formats;
+}
+
+/**
+ * Sets a text format
+ *
+ * @param formats
+ */
+void MarkdownHighlighter::setTextFormat (HighlighterState state,
+ QTextCharFormat format) {
+ _formats[state] = format;
+}
+
+/**
+ * Does the markdown highlighting
+ *
+ * @param text
+ */
+void MarkdownHighlighter::highlightBlock (const QString &text) {
+ setCurrentBlockState (HighlighterState::NoState);
+ currentBlock ().setUserState (HighlighterState::NoState);
+ highlightMarkdown (text);
+ _highlightingFinished = true;
+}
+
+void MarkdownHighlighter::highlightMarkdown (QString text) {
+ if (!text.isEmpty ()) {
+ highlightAdditionalRules (_highlightingRulesPre, text);
+
+ // needs to be called after the horizontal ruler highlighting
+ highlightHeadline (text);
+
+ highlightAdditionalRules (_highlightingRulesAfter, text);
+ }
+
+ highlightCommentBlock (text);
+ highlightCodeBlock (text);
+}
+
+/**
+ * Highlight headlines
+ *
+ * @param text
+ */
+void MarkdownHighlighter::highlightHeadline (QString text) {
+ QRegularExpression regex ("^(#+)\\s+(.+?)$");
+ QRegularExpressionMatch match = regex.match (text);
+ QTextCharFormat &maskedFormat = _formats[HighlighterState::MaskedSyntax];
+
+ // check for headline blocks with # in front of them
+ if (match.hasMatch ()) {
+ int count = match.captured (1).count ();
+
+ // we just have H1 to H6
+ count = qMin (count, 6);
+
+ HighlighterState state = HighlighterState (
+ HighlighterState::H1 + count - 1);
+
+ QTextCharFormat &format = _formats[state];
+ QTextCharFormat ¤tMaskedFormat = maskedFormat;
+
+ // set the font size from the current rule's font format
+ maskedFormat.setFontPointSize (format.fontPointSize ());
+
+ // first highlight everything as MaskedSyntax
+ setFormat (match.capturedStart (), match.capturedLength (),
+ currentMaskedFormat);
+
+ // then highlight with the real format
+ setFormat (match.capturedStart (2), match.capturedLength (2),
+ _formats[state]);
+
+ // set a margin for the current block
+ setCurrentBlockMargin (state);
+
+ setCurrentBlockState (state);
+ currentBlock ().setUserState (state);
+ return;
+ }
+
+ // take care of ==== and ---- headlines
+ QRegularExpression patternH1 = QRegularExpression ("^=+$");
+ QRegularExpression patternH2 = QRegularExpression ("^-+$");
+ QTextBlock previousBlock = currentBlock ().previous ();
+ QString previousText = previousBlock.text ();
+ previousText.trimmed ().remove (QRegularExpression ("[=-]"));
+
+ // check for ===== after a headline text and highlight as H1
+ if (patternH1.match (text).hasMatch ()) {
+ if (((previousBlockState () == HighlighterState::H1) ||
+ (previousBlockState () == HighlighterState::NoState)) &&
+ (previousText.length () > 0)) {
+ // set the font size from the current rule's font format
+ maskedFormat.setFontPointSize (
+ _formats[HighlighterState::H1].fontPointSize ());
+
+ setFormat (0, text.length (), maskedFormat);
+ setCurrentBlockState (HighlighterState::HeadlineEnd);
+ previousBlock.setUserState (HighlighterState::H1);
+
+ // set a margin for the current block
+ setCurrentBlockMargin (HighlighterState::H1);
+
+ // we want to re-highlight the previous block
+ // this must not done directly, but with a queue, otherwise it
+ // will crash
+ // setting the character format of the previous text, because this
+ // causes text to be formatted the same way when writing after
+ // the text
+ addDirtyBlock (previousBlock);
+ }
+
+ return;
+ }
+
+ // check for ----- after a headline text and highlight as H2
+ if (patternH2.match (text).hasMatch ()) {
+ if (((previousBlockState () == HighlighterState::H2) ||
+ (previousBlockState () == HighlighterState::NoState)) &&
+ (previousText.length () > 0)) {
+ // set the font size from the current rule's font format
+ maskedFormat.setFontPointSize (
+ _formats[HighlighterState::H2].fontPointSize ());
+
+ setFormat (0, text.length (), maskedFormat);
+ setCurrentBlockState (HighlighterState::HeadlineEnd);
+ previousBlock.setUserState (HighlighterState::H2);
+
+ // set a margin for the current block
+ setCurrentBlockMargin (HighlighterState::H2);
+
+ // we want to re-highlight the previous block
+ addDirtyBlock (previousBlock);
+ }
+
+ return;
+ }
+
+ QTextBlock nextBlock = currentBlock ().next ();
+ QString nextBlockText = nextBlock.text ();
+
+ // highlight as H1 if next block is =====
+ if (patternH1.match (nextBlockText).hasMatch () ||
+ patternH2.match (nextBlockText).hasMatch ()) {
+ setFormat (0, text.length (), _formats[HighlighterState::H1]);
+ setCurrentBlockState (HighlighterState::H1);
+ currentBlock ().setUserState (HighlighterState::H1);
+ }
+
+ // highlight as H2 if next block is -----
+ if (patternH2.match (nextBlockText).hasMatch ()) {
+ setFormat (0, text.length (), _formats[HighlighterState::H2]);
+ setCurrentBlockState (HighlighterState::H2);
+ currentBlock ().setUserState (HighlighterState::H2);
+ }
+}
+
+/**
+ * Sets a margin for the current block
+ *
+ * @param state
+ */
+void MarkdownHighlighter::setCurrentBlockMargin (
+ MarkdownHighlighter::HighlighterState state) {
+ // this is currently disabled because it causes multiple problems:
+ // - it prevents "undo" in headlines
+ // https://github.com/pbek/QOwnNotes/issues/520
+ // - invisible lines at the end of a note
+ // https://github.com/pbek/QOwnNotes/issues/667
+ // - a crash when reaching the invisible lines when the current line is
+ // highlighted
+ // https://github.com/pbek/QOwnNotes/issues/701
+ return;
+
+ qreal margin;
+
+ switch (state) {
+ case HighlighterState::H1:
+ margin = 5;
+ break;
+ case HighlighterState::H2:
+ case HighlighterState::H3:
+ case HighlighterState::H4:
+ case HighlighterState::H5:
+ case HighlighterState::H6:
+ margin = 3;
+ break;
+ default:
+ return;
+ }
+
+ QTextBlockFormat blockFormat = currentBlock ().blockFormat ();
+ blockFormat.setTopMargin (2);
+ blockFormat.setBottomMargin (margin);
+
+ // this prevents "undo" in headlines!
+ QTextCursor *myCursor = new QTextCursor (currentBlock ());
+ myCursor->setBlockFormat (blockFormat);
+}
+
+/**
+ * Highlight multi-line code blocks
+ *
+ * @param text
+ */
+void MarkdownHighlighter::highlightCodeBlock (QString text) {
+ QRegularExpression regex ("^```\\w*?$");
+ QRegularExpressionMatch match = regex.match (text);
+
+ if (match.hasMatch ()) {
+ setCurrentBlockState (
+ previousBlockState () == HighlighterState::CodeBlock ?
+ HighlighterState::CodeBlockEnd : HighlighterState::CodeBlock);
+ // set the font size from the current rule's font format
+ QTextCharFormat &maskedFormat =
+ _formats[HighlighterState::MaskedSyntax];
+ maskedFormat.setFontPointSize (
+ _formats[HighlighterState::CodeBlock].fontPointSize ());
+
+ setFormat (0, text.length (), maskedFormat);
+ }
+ else if (previousBlockState () == HighlighterState::CodeBlock) {
+ setCurrentBlockState (HighlighterState::CodeBlock);
+ setFormat (0, text.length (), _formats[HighlighterState::CodeBlock]);
+ }
+}
+
+/**
+ * Highlight multi-line comments
+ *
+ * @param text
+ */
+void MarkdownHighlighter::highlightCommentBlock (QString text) {
+ bool highlight = false;
+ text.trimmed ();
+ QString startText = "";
+
+ // we will skip this case because that is an inline comment and causes
+ // troubles here
+ if (text.startsWith (startText) && text.contains (endText)) {
+ return;
+ }
+
+ if (text.startsWith (startText) ||
+ (!text.endsWith (endText) &&
+ (previousBlockState () == HighlighterState::Comment))) {
+ setCurrentBlockState (HighlighterState::Comment);
+ highlight = true;
+ }
+ else if (text.endsWith (endText)) {
+ highlight = true;
+ }
+
+ if (highlight) {
+ setFormat (0, text.length (), _formats[HighlighterState::Comment]);
+ }
+}
+
+/**
+ * Highlights the rules from the _highlightingRules list
+ *
+ * @param text
+ */
+void MarkdownHighlighter::highlightAdditionalRules (
+ QVector &rules, QString text) {
+ QTextCharFormat &maskedFormat = _formats[HighlighterState::MaskedSyntax];
+
+ foreach (const HighlightingRule &rule, rules) {
+ // continue if an other current block state was already set if
+ // disableIfCurrentStateIsSet is set
+ if (rule.disableIfCurrentStateIsSet &&
+ (currentBlockState () != HighlighterState::NoState)) {
+ continue;
+ }
+
+ QRegularExpression expression (rule.pattern);
+ QRegularExpressionMatchIterator iterator = expression.globalMatch (text);
+ int capturingGroup = rule.capturingGroup;
+ int maskedGroup = rule.maskedGroup;
+ QTextCharFormat &format = _formats[rule.state];
+
+ // store the current block state if useStateAsCurrentBlockState
+ // is set
+ if (iterator.hasNext () && rule.useStateAsCurrentBlockState) {
+ setCurrentBlockState (rule.state);
+ }
+
+ // find and format all occurrences
+ while (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+
+ // if there is a capturingGroup set then first highlight
+ // everything as MaskedSyntax and highlight capturingGroup
+ // with the real format
+ if (capturingGroup > 0) {
+ QTextCharFormat ¤tMaskedFormat = maskedFormat;
+ // set the font size from the current rule's font format
+ maskedFormat.setFontPointSize (format.fontPointSize ());
+
+ setFormat (match.capturedStart (maskedGroup),
+ match.capturedLength (maskedGroup),
+ currentMaskedFormat);
+ }
+
+ setFormat (match.capturedStart (capturingGroup),
+ match.capturedLength (capturingGroup),
+ format);
+ }
+ }
+}
+
+void MarkdownHighlighter::setHighlightingOptions (HighlightingOptions options) {
+ _highlightingOptions = options;
+}
diff --git a/src/markdownhighlighter.h b/src/markdownhighlighter.h
new file mode 100644
index 0000000..b42dac3
--- /dev/null
+++ b/src/markdownhighlighter.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2014-2018 Patrizio Bekerle -- http://www.bekerle.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * QPlainTextEdit markdown highlighter
+ */
+
+
+#pragma once
+
+#include
+#include
+#include
+
+#include
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+
+QT_END_NAMESPACE
+
+class MarkdownHighlighter : public TextEditor::SyntaxHighlighter {
+ Q_OBJECT
+
+ public:
+ enum HighlightingOption {
+ None = 0,
+ FullyHighlightedBlockQuote = 0x01
+ };
+ Q_DECLARE_FLAGS (HighlightingOptions, HighlightingOption);
+
+ MarkdownHighlighter (QTextDocument *parent = 0,
+ HighlightingOptions highlightingOptions =
+ HighlightingOption::None);
+
+ // we use some predefined numbers here to be compatible with
+ // the peg-markdown parser
+ enum HighlighterState {
+ NoState = -1,
+ Link = 0,
+ Image = 3,
+ CodeBlock,
+ Italic = 7,
+ Bold,
+ List,
+ Comment = 11,
+ H1,
+ H2,
+ H3,
+ H4,
+ H5,
+ H6,
+ BlockQuote,
+ HorizontalRuler = 21,
+ Table,
+ InlineCodeBlock,
+ MaskedSyntax,
+ CurrentLineBackgroundColor,
+ BrokenLink,
+
+ // internal
+ CodeBlockEnd = 100,
+ HeadlineEnd
+ };
+
+ // enum BlockState {
+ // NoBlockState = 0,
+ // H1,
+ // H2,
+ // H3,
+ // Table,
+ // CodeBlock,
+ // CodeBlockEnd
+ // };
+
+ void setTextFormats (QHash formats);
+ void setTextFormat (HighlighterState state, QTextCharFormat format);
+ void clearDirtyBlocks ();
+ void setHighlightingOptions (HighlightingOptions options);
+ void initHighlightingRules ();
+
+ signals:
+ void highlightingFinished ();
+
+ protected slots:
+ void timerTick ();
+
+ protected:
+ struct HighlightingRule {
+ QRegularExpression pattern;
+ HighlighterState state;
+ int capturingGroup;
+ int maskedGroup;
+ bool useStateAsCurrentBlockState;
+ bool disableIfCurrentStateIsSet;
+ };
+
+ void highlightBlock (const QString &text) Q_DECL_OVERRIDE;
+
+ void initTextFormats (int defaultFontSize = 12);
+
+ void highlightMarkdown (QString text);
+
+ void highlightHeadline (QString text);
+
+ void highlightAdditionalRules (QVector &rules,
+ QString text);
+
+ void highlightCodeBlock (QString text);
+
+ void highlightCommentBlock (QString text);
+
+ void addDirtyBlock (QTextBlock block);
+
+ void reHighlightDirtyBlocks ();
+
+ QVector _highlightingRulesPre;
+ QVector _highlightingRulesAfter;
+ QVector _dirtyTextBlocks;
+ QHash _formats;
+ QTimer *_timer;
+ bool _highlightingFinished;
+ HighlightingOptions _highlightingOptions;
+
+ void setCurrentBlockMargin (HighlighterState state);
+};
diff --git a/src/markdowntextedit.cpp b/src/markdowntextedit.cpp
new file mode 100644
index 0000000..e7d83a9
--- /dev/null
+++ b/src/markdowntextedit.cpp
@@ -0,0 +1,893 @@
+/*
+ * Copyright (c) 2014-2018 Patrizio Bekerle -- http://www.bekerle.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ */
+
+#include "markdowntextedit.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+
+QMarkdownTextEdit::QMarkdownTextEdit (QWidget *parent)
+ : TextEditor::TextEditorWidget (parent) {
+ installEventFilter (this);
+ viewport ()->installEventFilter (this);
+ _autoTextOptions = AutoTextOption::None;
+ _openingCharacters = QStringList () << "(" << "[" << "{" << "<" << "*"
+ << "\"" << "'" << "_" << "~";
+ _closingCharacters = QStringList () << ")" << "]" << "}" << ">" << "*"
+ << "\"" << "'" << "_" << "~";
+
+ QFont font = this->font ();
+
+ // set the tab stop to the width of 4 spaces in the editor
+ const int tabStop = 4;
+ QFontMetrics metrics (font);
+ setTabStopWidth (tabStop * metrics.width (' '));
+
+ // add shortcuts for duplicating text
+ // new QShortcut( QKeySequence( "Ctrl+D" ), this, SLOT( duplicateText() ) );
+ // new QShortcut( QKeySequence( "Ctrl+Alt+Down" ), this, SLOT( duplicateText() ) );
+
+ // add a layout to the widget
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins (0, 0, 0, 0);
+ layout->setMargin (0);
+ layout->addStretch ();
+ this->setLayout (layout);
+
+ QObject::connect (this, SIGNAL (textChanged ()),
+ this, SLOT (adjustRightMargin ()));
+
+ // workaround for disabled signals up initialization
+ QTimer::singleShot (300, this, SLOT (adjustRightMargin ()));
+}
+
+/**
+ * Leave a little space on the right side if the document is too long, so
+ * that the search buttons don't get visually blocked by the scroll bar
+ */
+void QMarkdownTextEdit::adjustRightMargin () {
+ QMargins margins = layout ()->contentsMargins ();
+ int rightMargin = document ()->size ().height () >
+ viewport ()->size ().height () ? 24 : 0;
+ margins.setRight (rightMargin);
+ layout ()->setContentsMargins (margins);
+}
+
+bool QMarkdownTextEdit::eventFilter (QObject *obj, QEvent *event) {
+ //qDebug() << event->type();
+ if (event->type () == QEvent::HoverMove) {
+ QMouseEvent *mouseEvent = static_cast(event);
+
+ QWidget *viewPort = this->viewport ();
+ // toggle cursor when control key has been pressed or released
+ viewPort->setCursor (mouseEvent->modifiers ().testFlag (
+ Qt::ControlModifier) ?
+ Qt::PointingHandCursor :
+ Qt::IBeamCursor);
+ }
+ else if (event->type () == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast(event);
+
+ // set cursor to pointing hand if control key was pressed
+ if (keyEvent->modifiers ().testFlag (Qt::ControlModifier)) {
+ QWidget *viewPort = this->viewport ();
+ viewPort->setCursor (Qt::PointingHandCursor);
+ }
+
+ // disallow keys if text edit hasn't focus
+ if (!this->hasFocus ()) {
+ return true;
+ }
+
+ if ((keyEvent->key () == Qt::Key_Tab) ||
+ (keyEvent->key () == Qt::Key_Backtab)) {
+ // handle entered tab and reverse tab keys
+ return handleTabEntered (
+ keyEvent->key () == Qt::Key_Backtab);
+ }
+ else if (keyEvent->key () == Qt::Key_Backspace) {
+ return handleBracketRemoval ();
+ }
+ else if (keyEvent->key () == Qt::Key_Asterisk) {
+ return handleBracketClosing (QString ("*"));
+ }
+ else if (keyEvent->key () == Qt::Key_QuoteDbl) {
+ return handleBracketClosing ("\"");
+ // apostrophe bracket closing is temporary disabled because
+ // apostrophes are used in different contexts
+ // } else if (keyEvent->key() == Qt::Key_Apostrophe) {
+ // return handleBracketClosing("'");
+ // underline bracket closing is temporary disabled because
+ // underlines are used in different contexts
+ // } else if (keyEvent->key() == Qt::Key_Underscore) {
+ // return handleBracketClosing("_");
+ }
+ else if (keyEvent->key () == Qt::Key_AsciiTilde) {
+ return handleBracketClosing ("~");
+ }
+ else if (keyEvent->key () == Qt::Key_ParenLeft) {
+ return handleBracketClosing ("(", ")");
+ }
+ else if (keyEvent->key () == Qt::Key_BraceLeft) {
+ return handleBracketClosing ("{", "}");
+ }
+ else if (keyEvent->key () == Qt::Key_BracketLeft) {
+ return handleBracketClosing ("[", "]");
+ }
+ else if (keyEvent->key () == Qt::Key_Less) {
+ return handleBracketClosing ("<", ">");
+ }
+ else if (keyEvent->key () == Qt::Key_ParenRight) {
+ return bracketClosingCheck ("(", ")");
+ }
+ else if (keyEvent->key () == Qt::Key_BraceRight) {
+ return bracketClosingCheck ("{", "}");
+ }
+ else if (keyEvent->key () == Qt::Key_BracketRight) {
+ return bracketClosingCheck ("[", "]");
+ }
+ else if ((keyEvent->key () == Qt::Key_Down) &&
+ keyEvent->modifiers ().testFlag (Qt::ControlModifier) &&
+ keyEvent->modifiers ().testFlag (Qt::AltModifier)) {
+ // duplicate text with `Ctrl + Alt + Down`
+ duplicateText ();
+ return true;
+ }
+ else if ((keyEvent->key () == Qt::Key_Down) &&
+ keyEvent->modifiers ().testFlag (Qt::ControlModifier)) {
+ // scroll the page down
+ auto *scrollBar = verticalScrollBar ();
+ scrollBar->setSliderPosition (scrollBar->sliderPosition () + 1);
+ return true;
+ }
+ else if ((keyEvent->key () == Qt::Key_Up) &&
+ keyEvent->modifiers ().testFlag (Qt::ControlModifier)) {
+ // scroll the page up
+ auto *scrollBar = verticalScrollBar ();
+ scrollBar->setSliderPosition (scrollBar->sliderPosition () - 1);
+ return true;
+ }
+ else if ((keyEvent->key () == Qt::Key_Down) &&
+ keyEvent->modifiers ().testFlag (Qt::NoModifier)) {
+ // if you are in the last line and press cursor down the cursor will
+ // jump to the end of the line
+ QTextCursor cursor = textCursor ();
+ if (cursor.position () >= document ()->lastBlock ().position ()) {
+ cursor.movePosition (QTextCursor::EndOfLine);
+ setTextCursor (cursor);
+ }
+ return false;
+ }
+ else if ((keyEvent->key () == Qt::Key_Up) &&
+ keyEvent->modifiers ().testFlag (Qt::NoModifier)) {
+ // if you are in the first line and press cursor up the cursor will
+ // jump to the start of the line
+ QTextCursor cursor = textCursor ();
+ QTextBlock block = document ()->firstBlock ();
+ int endOfFirstLinePos = block.position () + block.length ();
+
+ if (cursor.position () <= endOfFirstLinePos) {
+ cursor.movePosition (QTextCursor::StartOfLine);
+ setTextCursor (cursor);
+ }
+ return false;
+ }
+ else if (keyEvent->key () == Qt::Key_Return) {
+ return handleReturnEntered ();
+ }
+
+ return false;
+ }
+ else if (event->type () == QEvent::KeyRelease) {
+ QKeyEvent *keyEvent = static_cast(event);
+
+ // reset cursor if control key was released
+ if (keyEvent->key () == Qt::Key_Control) {
+ resetMouseCursor ();
+ }
+
+ return false;
+ }
+ else if (event->type () == QEvent::MouseButtonRelease) {
+ QMouseEvent *mouseEvent = static_cast(event);
+
+ // track `Ctrl + Click` in the text edit
+ if ((obj == this->viewport ()) &&
+ (mouseEvent->button () == Qt::LeftButton) &&
+ (QGuiApplication::keyboardModifiers () == Qt::ExtraButton24)) {
+ // open the link (if any) at the current position
+ // in the noteTextEdit
+ openLinkAtCursorPosition ();
+ return true;
+ }
+ }
+
+ return QPlainTextEdit::eventFilter (obj, event);
+}
+
+/**
+ * Resets the cursor to Qt::IBeamCursor
+ */
+void QMarkdownTextEdit::resetMouseCursor () const {
+ QWidget *viewPort = viewport ();
+ viewPort->setCursor (Qt::IBeamCursor);
+}
+
+void QMarkdownTextEdit::finalizeInitialization () {
+ setMarksVisible (true);
+ setLineSeparatorsAllowed (true);
+
+ // setupGenericHighlighter ();
+
+ if (_highlighter) {
+ delete _highlighter;
+ }
+ _highlighter = new MarkdownHighlighter;
+
+ textDocument ()->setSyntaxHighlighter (_highlighter);
+
+ setCodeFoldingSupported (false);
+}
+
+/**
+ * Resets the cursor to Qt::IBeamCursor if the widget looses the focus
+ */
+void QMarkdownTextEdit::focusOutEvent (QFocusEvent *event) {
+ resetMouseCursor ();
+ QPlainTextEdit::focusOutEvent (event);
+}
+
+/**
+ * Enters a closing character after an opening character if needed
+ *
+ * @param openingCharacter
+ * @param closingCharacter
+ * @return
+ */
+bool QMarkdownTextEdit::handleBracketClosing (QString openingCharacter,
+ QString closingCharacter) {
+ // check if bracket closing is enabled
+ if (!(_autoTextOptions & AutoTextOption::BracketClosing)) {
+ return false;
+ }
+
+ QTextCursor cursor = textCursor ();
+
+ // get the current text from the block (inserted character not included)
+ QString text = cursor.block ().text ();
+
+ if (closingCharacter.isEmpty ()) {
+ closingCharacter = openingCharacter;
+ }
+
+ QString selectedText = cursor.selectedText ();
+
+ // When user currently has text selected, we prepend the openingCharacter
+ // and append the closingCharacter. E.g. 'text' -> '(text)'. We keep the
+ // current selectedText selected.
+ //
+ // TODO(sanderboom): how to make ctrl-z keep the selectedText selected?
+ if (selectedText != "") {
+ // Insert. The selectedText is overwritten.
+ cursor.insertText (openingCharacter);
+ cursor.insertText (selectedText);
+ cursor.insertText (closingCharacter);
+
+ // Re-select the selectedText.
+ int selectionEnd = cursor.position () - 1;
+ int selectionStart = selectionEnd - selectedText.length ();
+ cursor.setPosition (selectionStart);
+ cursor.setPosition (selectionEnd, QTextCursor::KeepAnchor);
+ this->setTextCursor (cursor);
+
+ return true;
+ }
+ else {
+ // if not text was selected check if we are inside the text
+ int positionInBlock = cursor.position () - cursor.block ().position ();
+
+ // only allow the closing if the cursor was at the end of a block
+ // we are making a special allowance for openingCharacter == *
+ if ((positionInBlock != text.count ()) &&
+ !((openingCharacter == "*") &&
+ (positionInBlock == (text.count () - 1)))) {
+ return false;
+ }
+ }
+
+
+ // Remove whitespace at start of string (e.g. in multilevel-lists).
+ text = text.remove (QRegExp ("^\\s+"));
+
+ // Default positions to move the cursor back.
+ int cursorSubtract = 1;
+
+ // Special handling for `*` opening character, as this could be:
+ // - start of a list (or sublist);
+ // - start of a bold text;
+ if (openingCharacter == "*") {
+ // User wants: '*'.
+ // This could be the start of a list, don't autocomplete.
+ if (text == "") {
+ return false;
+ }
+ // User wants: '**'.
+ // Not the start of a list, probably bold text. We autocomplete with
+ // extra closingCharacter and cursorSubtract to 'catchup'.
+ else if (text == "*") {
+ closingCharacter = "**";
+ cursorSubtract = 2;
+ }
+ // User wants: '* *'.
+ // We are in a list already, proceed as normal (autocomplete).
+ else if (text == "* ") {
+ // no-op.
+ }
+ }
+
+ cursor.insertText (openingCharacter);
+ cursor.insertText (closingCharacter);
+ cursor.setPosition (cursor.position () - cursorSubtract);
+ setTextCursor (cursor);
+ return true;
+}
+
+/**
+ * Checks if the closing character should be output or not
+ *
+ * @param openingCharacter
+ * @param closingCharacter
+ * @return
+ */
+bool QMarkdownTextEdit::bracketClosingCheck (QString openingCharacter,
+ QString closingCharacter) {
+ // check if bracket closing is enabled
+ if (!(_autoTextOptions & AutoTextOption::BracketClosing)) {
+ return false;
+ }
+
+ QTextCursor cursor = textCursor ();
+ int positionInBlock = cursor.position () - cursor.block ().position ();
+
+ // get the current text from the block
+ QString text = cursor.block ().text ();
+ int textLength = text.length ();
+
+ // if we are at the end of the line we just want to enter the character
+ if (positionInBlock >= textLength) {
+ return false;
+ }
+
+ QString currentChar = text.at (positionInBlock);
+
+ // if the current character is not the closing character we just want to
+ // enter the character
+ if (currentChar != closingCharacter) {
+ return false;
+ }
+
+ QString leftText = text.left (positionInBlock);
+ int openingCharacterCount = leftText.count (openingCharacter);
+ int closingCharacterCount = leftText.count (closingCharacter);
+
+ // if there were enough opening characters just enter the character
+ if (openingCharacterCount < (closingCharacterCount + 1)) {
+ return false;
+ }
+
+ // move the cursor to the right and don't enter the character
+ cursor.movePosition (QTextCursor::Right);
+ setTextCursor (cursor);
+ return true;
+}
+
+/**
+ * Handles removing of matching brackets and other markdown characters
+ * Only works with backspace to remove text
+ *
+ * @return
+ */
+bool QMarkdownTextEdit::handleBracketRemoval () {
+ // check if bracket removal is enabled
+ if (!(_autoTextOptions & AutoTextOption::BracketRemoval)) {
+ return false;
+ }
+
+ QTextCursor cursor = textCursor ();
+
+ // return if some text was selected
+ if (!cursor.selectedText ().isEmpty ()) {
+ return false;
+ }
+
+ int position = cursor.position ();
+ int positionInBlock = position - cursor.block ().position ();
+
+ // return if backspace was pressed at the beginning of a block
+ if (positionInBlock == 0) {
+ return false;
+ }
+
+ // get the current text from the block
+ QString text = cursor.block ().text ();
+ QString charInFront = text.at (positionInBlock - 1);
+ int openingCharacterIndex = _openingCharacters.indexOf (charInFront);
+
+ // return if the character in front of the cursor is no opening character
+ if (openingCharacterIndex == -1) {
+ return false;
+ }
+
+ QString closingCharacter = _closingCharacters.at (openingCharacterIndex);
+
+ // remove everything in front of the cursor
+ text.remove (0, positionInBlock);
+ int closingCharacterIndex = text.indexOf (closingCharacter);
+
+ // return if no closing character was found in the text after the cursor
+ if (closingCharacterIndex == -1) {
+ return false;
+ }
+
+ // removing the closing character
+ cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor,
+ closingCharacterIndex);
+ cursor.movePosition (QTextCursor::Right, QTextCursor::KeepAnchor);
+ cursor.removeSelectedText ();
+
+ // moving the cursor back to the old position so the previous character
+ // can be removed
+ cursor.setPosition (position);
+ setTextCursor (cursor);
+ return false;
+}
+
+/**
+ * Increases (or decreases) the indention of the selected text
+ * (if there is a text selected) in the noteTextEdit
+ * @return
+ */
+bool QMarkdownTextEdit::increaseSelectedTextIndention (bool reverse) {
+ QTextCursor cursor = this->textCursor ();
+ QString selectedText = cursor.selectedText ();
+
+ if (selectedText != "") {
+ // we need this strange newline character we are getting in the
+ // selected text for newlines
+ QString newLine = QString::fromUtf8 (QByteArray::fromHex ("e280a9"));
+ QString newText;
+
+ if (reverse) {
+ // un-indent text
+
+ // remove strange newline characters
+ newText = selectedText.replace (
+ QRegularExpression (newLine + "[\\t ]"), "\n");
+
+ // remove leading \t or space
+ newText.remove (QRegularExpression ("^[\\t ]"));
+ }
+ else {
+ // indent text
+ newText = selectedText.replace (newLine, "\n\t").prepend ("\t");
+
+ // remove trailing \t
+ newText.replace (QRegularExpression ("\\t$"), "");
+ }
+
+ // insert the new text
+ cursor.insertText (newText);
+
+ // update the selection to the new text
+ cursor.setPosition (cursor.position () - newText.size (), QTextCursor::KeepAnchor);
+ this->setTextCursor (cursor);
+
+ return true;
+ }
+ else if (reverse) {
+ // if nothing was selected but we want to reverse the indention check
+ // if there is a \t in front or after the cursor and remove it if so
+ int position = cursor.position ();
+
+ if (!cursor.atStart ()) {
+ // get character in front of cursor
+ cursor.setPosition (position - 1, QTextCursor::KeepAnchor);
+ }
+
+ // check for \t or space in front of cursor
+ QRegularExpression re ("[\\t ]");
+ QRegularExpressionMatch match = re.match (cursor.selectedText ());
+
+ if (!match.hasMatch ()) {
+ // (select to) check for \t or space after the cursor
+ cursor.setPosition (position);
+
+ if (!cursor.atEnd ()) {
+ cursor.setPosition (position + 1, QTextCursor::KeepAnchor);
+ }
+ }
+
+ match = re.match (cursor.selectedText ());
+
+ if (match.hasMatch ()) {
+ cursor.removeSelectedText ();
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * @brief Opens the link (if any) at the current cursor position
+ */
+bool QMarkdownTextEdit::openLinkAtCursorPosition () {
+ QTextCursor cursor = this->textCursor ();
+ int clickedPosition = cursor.position ();
+
+ // select the text in the clicked block and find out on
+ // which position we clicked
+ cursor.movePosition (QTextCursor::StartOfBlock);
+ int positionFromStart = clickedPosition - cursor.position ();
+ cursor.movePosition (QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+
+ QString selectedText = cursor.selectedText ();
+
+ // find out which url in the selected text was clicked
+ QString urlString = getMarkdownUrlAtPosition (selectedText,
+ positionFromStart);
+ QUrl url = QUrl (urlString);
+ bool isRelativeFileUrl = urlString.startsWith ("file://..");
+
+ qDebug () << __func__ << " - 'emit urlClicked( urlString )': "
+ << urlString;
+
+ emit urlClicked (urlString);
+
+ if ((url.isValid () && isValidUrl (urlString)) || isRelativeFileUrl) {
+ // ignore some schemata
+ if (!(_ignoredClickUrlSchemata.contains (url.scheme ()) ||
+ isRelativeFileUrl)) {
+ // open the url
+ openUrl (urlString);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Checks if urlString is a valid url
+ *
+ * @param urlString
+ * @return
+ */
+bool QMarkdownTextEdit::isValidUrl (QString urlString) {
+ QRegularExpressionMatch match =
+ QRegularExpression ("^\\w+:\\/\\/.+").match (urlString);
+ return match.hasMatch ();
+}
+
+/**
+ * Handles clicked urls
+ *
+ * examples:
+ * - opens the webpage
+ * - opens the file
+ * "/path/to/my/file/QOwnNotes.pdf" if the operating system supports that
+ * handler
+ */
+void QMarkdownTextEdit::openUrl (QString urlString) {
+ qDebug () << "QMarkdownTextEdit " << __func__ << " - 'urlString': "
+ << urlString;
+
+ QDesktopServices::openUrl (QUrl (urlString));
+}
+
+/**
+ * @brief Sets url schemata that will be ignored when clicked on
+ * @param urlSchemes
+ */
+void QMarkdownTextEdit::setIgnoredClickUrlSchemata (
+ QStringList ignoredUrlSchemata) {
+ _ignoredClickUrlSchemata = ignoredUrlSchemata;
+}
+
+/**
+ * @brief Returns a map of parsed markdown urls with their link texts as key
+ *
+ * @param text
+ * @return parsed urls
+ */
+QMap QMarkdownTextEdit::parseMarkdownUrlsFromText (
+ QString text) {
+ QMap urlMap;
+ QRegularExpression regex;
+ QRegularExpressionMatchIterator iterator;
+
+ // match urls like this:
+ // re = QRegularExpression("(<(.+?:\\/\\/.+?)>)");
+ regex = QRegularExpression ("(<(.+?)>)");
+ iterator = regex.globalMatch (text);
+ while (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+ QString linkText = match.captured (1);
+ QString url = match.captured (2);
+ urlMap[linkText] = url;
+ }
+
+ // match urls like this: [this url](http://mylink)
+ // QRegularExpression re("(\\[.*?\\]\\((.+?:\\/\\/.+?)\\))");
+ regex = QRegularExpression ("(\\[.*?\\]\\((.+?)\\))");
+ iterator = regex.globalMatch (text);
+ while (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+ QString linkText = match.captured (1);
+ QString url = match.captured (2);
+ urlMap[linkText] = url;
+ }
+
+ // match urls like this: http://mylink
+ regex = QRegularExpression ("\\b\\w+?:\\/\\/[^\\s]+[^\\s>\\)]");
+ iterator = regex.globalMatch (text);
+ while (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+ QString url = match.captured (0);
+ urlMap[url] = url;
+ }
+
+ // match reference urls like this: [this url][1] with this later:
+ // [1]: http://domain
+ regex = QRegularExpression ("\\[(.*?)\\]\\s?\\[(.+?)\\]");
+ iterator = regex.globalMatch (text);
+ while (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+ QString linkText = match.captured (1);
+ QString referenceId = match.captured (2);
+
+ // search for the referenced url in the whole text edit
+ // QRegularExpression refRegExp(
+ // "\\[" + QRegularExpression::escape(referenceId) +
+ // "\\]: (.+?:\\/\\/.+)");
+ QRegularExpression refRegExp (
+ "\\[" + QRegularExpression::escape (referenceId) + "\\]: (.+?)");
+ QRegularExpressionMatch urlMatch = refRegExp.match (toPlainText ());
+
+ if (urlMatch.hasMatch ()) {
+ QString url = urlMatch.captured (1);
+ urlMap[linkText] = url;
+ }
+ }
+
+ return urlMap;
+}
+
+/**
+ * @brief Returns the markdown url at position
+ * @param text
+ * @param position
+ * @return url string
+ */
+QString QMarkdownTextEdit::getMarkdownUrlAtPosition (
+ QString text, int position) {
+ QString url;
+
+ // get a map of parsed markdown urls with their link texts as key
+ QMap urlMap = parseMarkdownUrlsFromText (text);
+
+ QMapIterator iterator (urlMap);
+ while (iterator.hasNext ()) {
+ iterator.next ();
+ QString linkText = iterator.key ();
+ QString urlString = iterator.value ();
+
+ int foundPositionStart = text.indexOf (linkText);
+
+ if (foundPositionStart >= 0) {
+ // calculate end position of found linkText
+ int foundPositionEnd = foundPositionStart + linkText.size ();
+
+ // check if position is in found string range
+ if ((position >= foundPositionStart) &&
+ (position <= foundPositionEnd)) {
+ url = urlString;
+ }
+ }
+ }
+
+ return url;
+}
+
+/**
+ * @brief Duplicates the text in the text edit
+ */
+void QMarkdownTextEdit::duplicateText () {
+ QTextCursor cursor = this->textCursor ();
+ QString selectedText = cursor.selectedText ();
+
+ // duplicate line if no text was selected
+ if (selectedText == "") {
+ int position = cursor.position ();
+
+ // select the whole line
+ cursor.movePosition (QTextCursor::StartOfLine);
+ cursor.movePosition (QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+
+ int positionDiff = cursor.position () - position;
+ selectedText = "\n" + cursor.selectedText ();
+
+ // insert text with new line at end of the selected line
+ cursor.setPosition (cursor.selectionEnd ());
+ cursor.insertText (selectedText);
+
+ // set the position to same position it was in the duplicated line
+ cursor.setPosition (cursor.position () - positionDiff);
+ }
+ else {
+ // duplicate selected text
+ cursor.setPosition (cursor.selectionEnd ());
+ int selectionStart = cursor.position ();
+
+ // insert selected text
+ cursor.insertText (selectedText);
+ int selectionEnd = cursor.position ();
+
+ // select the inserted text
+ cursor.setPosition (selectionStart);
+ cursor.setPosition (selectionEnd, QTextCursor::KeepAnchor);
+ }
+
+ this->setTextCursor (cursor);
+}
+
+/**
+ * Handles an entered return key
+ */
+bool QMarkdownTextEdit::handleReturnEntered () {
+ QTextCursor cursor = this->textCursor ();
+ int position = cursor.position ();
+
+ cursor.movePosition (QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
+ QString currentLineText = cursor.selectedText ();
+
+ // if return is pressed and there is just a list symbol then we want to
+ // remove the list symbol
+ // Valid listCharacters: '+ ', '-' , '* ', '+ [ ] ', '+ [x] ', '- [ ] ', '- [x] ', '* [ ] ', '* [x] '.
+ QRegularExpression regex ("^(\\s*)([+|\\-|\\*] \\[(x| )\\]|[+\\-\\*])(\\s+)$");
+ QRegularExpressionMatchIterator iterator = regex.globalMatch (currentLineText);
+ if (iterator.hasNext ()) {
+ cursor.removeSelectedText ();
+ return true;
+ }
+
+ // Check if we are in a list.
+ // We are in a list when we have '* ', '- ' or '+ ', possibly with preceding
+ // whitespace. If e.g. user has entered '**text**' and pressed enter - we
+ // don't want do anymore list-stuff.
+ QChar char0 = currentLineText.trimmed ()[0];
+ QChar char1 = currentLineText.trimmed ()[1];
+ bool inList = ((char0 == '*' || char0 == '-' || char0 == '+') && char1 == ' ');
+
+ if (inList) {
+ // if the current line starts with a list character (possibly after
+ // whitespaces) add the whitespaces at the next line too
+ // Valid listCharacters: '+ ', '-' , '* ', '+ [ ] ', '+ [x] ', '- [ ] ', '- [x] ', '* [ ] ', '* [x] '.
+ regex = QRegularExpression ("^(\\s*)([+|\\-|\\*] \\[(x| )\\]|[+\\-\\*])(\\s+)");
+ iterator = regex.globalMatch (currentLineText);
+ if (iterator.hasNext ()) {
+ QRegularExpressionMatch match = iterator.next ();
+ QString whitespaces = match.captured (1);
+ QString listCharacter = match.captured (2);
+ QString whitespaceCharacter = match.captured (4);
+
+ cursor.setPosition (position);
+ cursor.insertText ("\n" + whitespaces + listCharacter + whitespaceCharacter);
+
+ // scroll to the cursor if we are at the bottom of the document
+ ensureCursorVisible ();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Handles entered tab or reverse tab keys
+ */
+bool QMarkdownTextEdit::handleTabEntered (bool reverse) {
+ QTextCursor cursor = this->textCursor ();
+
+ // only check for lists if we haven't a text selected
+ if (cursor.selectedText ().isEmpty ()) {
+ cursor.movePosition (QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
+ QString currentLineText = cursor.selectedText ();
+
+ // check if we want to indent or un-indent a list
+ // Valid listCharacters: '+ ', '-' , '* ', '+ [ ] ', '+ [x] ', '- [ ] ', '- [x] ', '* [ ] ', '* [x] '.
+ QRegularExpression re ("^(\\s*)([+|\\-|\\*] \\[(x| )\\]|[+\\-\\*])(\\s+)$");
+ QRegularExpressionMatchIterator i = re.globalMatch (currentLineText);
+
+ if (i.hasNext ()) {
+ QRegularExpressionMatch match = i.next ();
+ QString whitespaces = match.captured (1);
+ QString listCharacter = match.captured (2);
+ QString whitespaceCharacter = match.captured (4);
+
+ // add or remove one tabulator key
+ if (reverse) {
+ whitespaces.chop (1);
+ }
+ else {
+ whitespaces += "\t";
+ }
+
+ cursor.insertText (whitespaces + listCharacter + whitespaceCharacter);
+ return true;
+ }
+ }
+
+ // check if we want to intent the whole text
+ return increaseSelectedTextIndention (reverse);
+}
+
+/**
+ * Sets the auto text options
+ */
+void QMarkdownTextEdit::setAutoTextOptions (AutoTextOptions options) {
+ _autoTextOptions = options;
+}
+
+/**
+ * Overrides QPlainTextEdit::paintEvent to fix the RTL bug of QPlainTextEdit
+ *
+ * @param e
+ */
+void QMarkdownTextEdit::paintEvent (QPaintEvent *e) {
+ QTextBlock block = firstVisibleBlock ();
+
+ while (block.isValid ()) {
+ QTextLayout *layout = block.layout ();
+
+ // this fixes the RTL bug of QPlainTextEdit
+ // https://bugreports.qt.io/browse/QTBUG-7516
+ if (block.text ().isRightToLeft ()) {
+ QTextOption opt = document ()->defaultTextOption ();
+ opt = QTextOption (Qt::AlignRight);
+ opt.setTextDirection (Qt::RightToLeft);
+ layout->setTextOption (opt);
+ }
+
+ block = block.next ();
+ }
+
+ QPlainTextEdit::paintEvent (e);
+}
diff --git a/src/markdowntextedit.h b/src/markdowntextedit.h
new file mode 100644
index 0000000..6633e21
--- /dev/null
+++ b/src/markdowntextedit.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014-2018 Patrizio Bekerle -- http://www.bekerle.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ */
+
+#pragma once
+
+#include
+#include
+#include "markdownhighlighter.h"
+
+#include
+
+
+class QMarkdownTextEdit : public TextEditor::TextEditorWidget {
+ Q_OBJECT
+
+ public:
+ enum AutoTextOption {
+ None = 0x0000,
+
+ // inserts closing characters for brackets and markdown characters
+ BracketClosing = 0x0001,
+
+ // removes matching brackets and markdown characters
+ BracketRemoval = 0x0002
+ };
+
+ Q_DECLARE_FLAGS (AutoTextOptions, AutoTextOption)
+
+ explicit QMarkdownTextEdit (QWidget *parent = nullptr);
+ void setIgnoredClickUrlSchemata (QStringList ignoredUrlSchemata);
+ virtual void openUrl (QString urlString);
+ QString getMarkdownUrlAtPosition (QString text, int position);
+ void setAutoTextOptions (AutoTextOptions options);
+ static bool isValidUrl (QString urlString);
+ void resetMouseCursor () const;
+
+ void finalizeInitialization ();
+
+ public slots:
+ void duplicateText ();
+ void adjustRightMargin ();
+ bool openLinkAtCursorPosition ();
+ bool handleBracketRemoval ();
+
+ protected:
+ QPointer _highlighter;
+ QStringList _ignoredClickUrlSchemata;
+ QWidget *_searchFrame;
+ AutoTextOptions _autoTextOptions;
+ QStringList _openingCharacters;
+ QStringList _closingCharacters;
+
+ bool eventFilter (QObject *obj, QEvent *event);
+ bool increaseSelectedTextIndention (bool reverse);
+ bool handleTabEntered (bool reverse);
+ QMap parseMarkdownUrlsFromText (QString text);
+ bool handleReturnEntered ();
+ bool handleBracketClosing (QString openingCharacter,
+ QString closingCharacter = {});
+ bool bracketClosingCheck (QString openingCharacter,
+ QString closingCharacter);
+ void focusOutEvent (QFocusEvent *event);
+ void paintEvent (QPaintEvent *e);
+
+ signals:
+ void urlClicked (QString url);
+};
diff --git a/src/QtcMarkviewPlugin.cpp b/src/markviewplugin.cpp
similarity index 75%
rename from src/QtcMarkviewPlugin.cpp
rename to src/markviewplugin.cpp
index 0c8576b..28a7b49 100644
--- a/src/QtcMarkviewPlugin.cpp
+++ b/src/markviewplugin.cpp
@@ -1,6 +1,6 @@
-#include "QtcMarkviewPlugin.h"
-#include "Constants.h"
-#include "MarkviewEditorFactory.h"
+#include "markviewplugin.h"
+#include "constants.h"
+#include "markdowneditorfactory.h"
#include
#include
@@ -11,17 +11,17 @@
using namespace QtcMarkview::Internal;
-QtcMarkviewPlugin::QtcMarkviewPlugin () :
+MarkviewPlugin::MarkviewPlugin () :
IPlugin () {
// Create your members
}
-QtcMarkviewPlugin::~QtcMarkviewPlugin () {
+MarkviewPlugin::~MarkviewPlugin () {
// Unregister objects from the plugin manager's object pool
// Delete members
}
-bool QtcMarkviewPlugin::initialize (const QStringList &arguments, QString *errorString) {
+bool MarkviewPlugin::initialize (const QStringList &arguments, QString *errorString) {
// Register objects in the plugin manager's object pool
// Load settings
// Add actions to menus
@@ -34,12 +34,12 @@ bool QtcMarkviewPlugin::initialize (const QStringList &arguments, QString *error
initLanguage ();
- addAutoReleasedObject (new MarkviewEditorFactory);
+ new MarkdownEditorFactory (this);
return true;
}
-void QtcMarkviewPlugin::initLanguage () {
+void MarkviewPlugin::initLanguage () {
const QString &language = Core::ICore::userInterfaceLanguage ();
if (!language.isEmpty ()) {
QStringList paths;
@@ -55,13 +55,13 @@ void QtcMarkviewPlugin::initLanguage () {
}
}
-void QtcMarkviewPlugin::extensionsInitialized () {
+void MarkviewPlugin::extensionsInitialized () {
// Retrieve objects from the plugin manager's object pool
// In the extensionsInitialized function, a plugin can be sure that all
// plugins that depend on it are completely initialized.
}
-ExtensionSystem::IPlugin::ShutdownFlag QtcMarkviewPlugin::aboutToShutdown () {
+ExtensionSystem::IPlugin::ShutdownFlag MarkviewPlugin::aboutToShutdown () {
// Save settings
// Disconnect from signals that are not needed during shutdown
// Hide UI (if you add UI that is not in the main window directly)
diff --git a/src/QtcMarkviewPlugin.h b/src/markviewplugin.h
similarity index 78%
rename from src/QtcMarkviewPlugin.h
rename to src/markviewplugin.h
index 1c9103f..4fe43a2 100644
--- a/src/QtcMarkviewPlugin.h
+++ b/src/markviewplugin.h
@@ -1,20 +1,18 @@
#ifndef QTCMARKVIEW_H
#define QTCMARKVIEW_H
-#include "PluginGlobal.h"
-
#include
namespace QtcMarkview {
namespace Internal {
- class QtcMarkviewPlugin : public ExtensionSystem::IPlugin {
+ class MarkviewPlugin : public ExtensionSystem::IPlugin {
Q_OBJECT
Q_PLUGIN_METADATA (IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QtcMarkview.json")
public:
- QtcMarkviewPlugin ();
- ~QtcMarkviewPlugin ();
+ MarkviewPlugin ();
+ ~MarkviewPlugin ();
bool initialize (const QStringList &arguments, QString *errorString);
void extensionsInitialized ();