diff --git a/README.md b/README.md index ffeeecd..bac7885 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,7 @@ Plugin performs preview of documents written in some markup languages. ![Screen](util/screen.png?raw=true) ## Supported languages -* [Asciidoctor](http://asciidoctor.org/) -* Html * [Markdown](http://daringfireball.net/projects/markdown/) -* [Textile](http://txstyle.org/) - -## Usage -1. Right click on document (via project explorer or editor) and choose `Open with->Markview`. -2. Open same document in another split. -3. Change view format in editor's menu. -4. Click on `?` icon near format selector to view some syntax help for selected format. ## Downloads Binaries can be downloaded [here](https://sourceforge.net/projects/qtc-markview/files/ "Sourceforge") diff --git a/css/asciidoctor.css b/css/asciidoctor.css deleted file mode 100644 index 36590bf..0000000 --- a/css/asciidoctor.css +++ /dev/null @@ -1,407 +0,0 @@ -/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */ -/* Remove comment around @import statement below when using as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/ -article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block} -audio,canvas,video{display:inline-block} -audio:not([controls]){display:none;height:0} -[hidden],template{display:none} -script{display:none!important} -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%} -body{margin:0} -a{background:transparent} -a:focus{outline:thin dotted} -a:active,a:hover{outline:0} -h1{font-size:2em;margin:.67em 0} -abbr[title]{border-bottom:1px dotted} -b,strong{font-weight:bold} -dfn{font-style:italic} -hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0} -mark{background:#ff0;color:#000} -code,kbd,pre,samp{font-family:monospace;font-size:1em} -pre{white-space:pre-wrap} -q{quotes:"\201C" "\201D" "\2018" "\2019"} -small{font-size:80%} -sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} -sup{top:-.5em} -sub{bottom:-.25em} -img{border:0} -svg:not(:root){overflow:hidden} -figure{margin:0} -fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em} -legend{border:0;padding:0} -button,input,select,textarea{font-family:inherit;font-size:100%;margin:0} -button,input{line-height:normal} -button,select{text-transform:none} -button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} -button[disabled],html input[disabled]{cursor:default} -input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0} -input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} -input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none} -button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0} -textarea{overflow:auto;vertical-align:top} -table{border-collapse:collapse;border-spacing:0} -*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box} -html,body{font-size:100%} -body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto} -a:hover{cursor:pointer} -img,object,embed{max-width:100%;height:auto} -object,embed{height:100%} -img{-ms-interpolation-mode:bicubic} -.left{float:left!important} -.right{float:right!important} -.text-left{text-align:left!important} -.text-right{text-align:right!important} -.text-center{text-align:center!important} -.text-justify{text-align:justify!important} -.hide{display:none} -body{-webkit-font-smoothing:antialiased} -img,object,svg{display:inline-block;vertical-align:middle} -textarea{height:auto;min-height:50px} -select{width:100%} -.center{margin-left:auto;margin-right:auto} -.spread{width:100%} -p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6} -.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em} -div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr} -a{color:#2156a5;text-decoration:underline;line-height:inherit} -a:hover,a:focus{color:#1d4b8f} -a img{border:none} -p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility} -p aside{font-size:.875em;line-height:1.35;font-style:italic} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em} -h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0} -h1{font-size:2.125em} -h2{font-size:1.6875em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em} -h4,h5{font-size:1.125em} -h6{font-size:1em} -hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0} -em,i{font-style:italic;line-height:inherit} -strong,b{font-weight:bold;line-height:inherit} -small{font-size:60%;line-height:inherit} -code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} -ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} -ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em} -ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em} -ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} -ul.square{list-style-type:square} -ul.circle{list-style-type:circle} -ul.disc{list-style-type:disc} -ul.no-bullet{list-style:none} -ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} -dl dt{margin-bottom:.3125em;font-weight:bold} -dl dd{margin-bottom:1.25em} -abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help} -abbr{text-transform:none} -blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} -blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} -blockquote cite:before{content:"\2014 \0020"} -blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} -blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} -@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2} -h1{font-size:2.75em} -h2{font-size:2.3125em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em} -h4{font-size:1.4375em}} -table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} -table thead,table tfoot{background:#f7f8f7;font-weight:bold} -table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} -table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} -table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} -table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} -body{tab-size:4} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em} -h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400} -.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table} -.clearfix:after,.float-group:after{clear:both} -*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed} -pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed} -.keyseq{color:rgba(51,51,51,.8)} -kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap} -.keyseq kbd:first-child{margin-left:0} -.keyseq kbd:last-child{margin-right:0} -.menuseq,.menu{color:rgba(0,0,0,.8)} -b.button:before,b.button:after{position:relative;top:-1px;font-weight:400} -b.button:before{content:"[";padding:0 3px 0 2px} -b.button:after{content:"]";padding:0 2px 0 3px} -p a>code:hover{color:rgba(0,0,0,.9)} -#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em} -#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table} -#header:after,#content:after,#footnotes:after,#footer:after{clear:both} -#content{margin-top:1.25em} -#content:before{content:none} -#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0} -#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8} -#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px} -#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap} -#header .details span:first-child{margin-left:-.125em} -#header .details span.email a{color:rgba(0,0,0,.85)} -#header .details br{display:none} -#header .details br+span:before{content:"\00a0\2013\00a0"} -#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)} -#header .details br+span#revremark:before{content:"\00a0|\00a0"} -#header #revnumber{text-transform:capitalize} -#header #revnumber:after{content:"\00a0"} -#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem} -#toc{border-bottom:1px solid #efefed;padding-bottom:.5em} -#toc>ul{margin-left:.125em} -#toc ul.sectlevel0>li>a{font-style:italic} -#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0} -#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none} -#toc li{line-height:1.3334;margin-top:.3334em} -#toc a{text-decoration:none} -#toc a:active{text-decoration:underline} -#toctitle{color:#7a2518;font-size:1.2em} -@media only screen and (min-width:768px){#toctitle{font-size:1.375em} -body.toc2{padding-left:15em;padding-right:0} -#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto} -#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em} -#toc.toc2>ul{font-size:.9em;margin-bottom:0} -#toc.toc2 ul ul{margin-left:0;padding-left:1em} -#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em} -body.toc2.toc-right{padding-left:0;padding-right:15em} -body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}} -@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0} -#toc.toc2{width:20em} -#toc.toc2 #toctitle{font-size:1.375em} -#toc.toc2>ul{font-size:.95em} -#toc.toc2 ul ul{padding-left:1.25em} -body.toc2.toc-right{padding-left:0;padding-right:20em}} -#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -#content #toc>:first-child{margin-top:0} -#content #toc>:last-child{margin-bottom:0} -#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em} -#footer-text{color:rgba(255,255,255,.8);line-height:1.44} -.sect1{padding-bottom:.625em} -@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}} -.sect1+.sect1{border-top:1px solid #efefed} -#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400} -#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em} -#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} -#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} -#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221} -.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} -.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} -table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0} -.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)} -table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit} -.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%} -.admonitionblock>table td.icon{text-align:center;width:80px} -.admonitionblock>table td.icon img{max-width:none} -.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase} -.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)} -.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0} -.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px} -.exampleblock>.content>:first-child{margin-top:0} -.exampleblock>.content>:last-child{margin-bottom:0} -.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -.sidebarblock>:first-child{margin-top:0} -.sidebarblock>:last-child{margin-bottom:0} -.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center} -.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0} -.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8} -.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1} -.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em} -.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal} -@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}} -@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}} -.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)} -.listingblock pre.highlightjs{padding:0} -.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px} -.listingblock pre.prettyprint{border-width:0} -.listingblock>.content{position:relative} -.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999} -.listingblock:hover code[data-lang]:before{display:block} -.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999} -.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"} -table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none} -table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45} -table.pyhltable td.code{padding-left:.75em;padding-right:0} -pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8} -pre.pygments .lineno{display:inline-block;margin-right:.25em} -table.pyhltable .linenodiv{background:none!important;padding-right:0!important} -.quoteblock{margin:0 1em 1.25em 1.5em;display:table} -.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} -.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} -.quoteblock blockquote{margin:0;padding:0;border:0} -.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} -.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} -.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} -.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} -.quoteblock .quoteblock blockquote{padding:0 0 0 .75em} -.quoteblock .quoteblock blockquote:before{display:none} -.verseblock{margin:0 1em 1.25em 1em} -.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility} -.verseblock pre strong{font-weight:400} -.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex} -.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} -.quoteblock .attribution br,.verseblock .attribution br{display:none} -.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)} -.quoteblock.abstract{margin:0 0 1.25em 0;display:block} -.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} -.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} -table.tableblock{max-width:100%;border-collapse:separate} -table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} -table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} -table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} -table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} -table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} -table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} -table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} -table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} -table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} -table.frame-all{border-width:1px} -table.frame-sides{border-width:0 1px} -table.frame-topbot{border-width:1px 0} -th.halign-left,td.halign-left{text-align:left} -th.halign-right,td.halign-right{text-align:right} -th.halign-center,td.halign-center{text-align:center} -th.valign-top,td.valign-top{vertical-align:top} -th.valign-bottom,td.valign-bottom{vertical-align:bottom} -th.valign-middle,td.valign-middle{vertical-align:middle} -table thead th,table tfoot th{font-weight:bold} -tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} -tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} -p.tableblock>code:only-child{background:none;padding:0} -p.tableblock{font-size:1em} -td>div.verse{white-space:pre} -ol{margin-left:1.75em} -ul li ol{margin-left:1.5em} -dl dd{margin-left:1.125em} -dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} -ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} -ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} -ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} -ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em} -ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px} -ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} -ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} -ul.inline>li>*{display:block} -.unstyled dl dt{font-weight:400;font-style:normal} -ol.arabic{list-style-type:decimal} -ol.decimal{list-style-type:decimal-leading-zero} -ol.loweralpha{list-style-type:lower-alpha} -ol.upperalpha{list-style-type:upper-alpha} -ol.lowerroman{list-style-type:lower-roman} -ol.upperroman{list-style-type:upper-roman} -ol.lowergreek{list-style-type:lower-greek} -.hdlist>table,.colist>table{border:0;background:none} -.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} -td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em} -td.hdlist1{font-weight:bold;padding-bottom:1.25em} -.literalblock+.colist,.listingblock+.colist{margin-top:-.5em} -.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1} -.colist>table tr>td:last-of-type{padding:.25em 0} -.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd} -.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0} -.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em} -.imageblock>.title{margin-bottom:0} -.imageblock.thumb,.imageblock.th{border-width:6px} -.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em} -.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0} -.image.left{margin-right:.625em} -.image.right{margin-left:.625em} -a.image{text-decoration:none;display:inline-block} -a.image object{pointer-events:none} -sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super} -sup.footnote a,sup.footnoteref a{text-decoration:none} -sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline} -#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em} -#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0} -#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;text-indent:-1.05em;margin-bottom:.2em} -#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none} -#footnotes .footnote:last-of-type{margin-bottom:0} -#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} -.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} -.gist .file-data>table td.line-data{width:99%} -div.unbreakable{page-break-inside:avoid} -.big{font-size:larger} -.small{font-size:smaller} -.underline{text-decoration:underline} -.overline{text-decoration:overline} -.line-through{text-decoration:line-through} -.aqua{color:#00bfbf} -.aqua-background{background-color:#00fafa} -.black{color:#000} -.black-background{background-color:#000} -.blue{color:#0000bf} -.blue-background{background-color:#0000fa} -.fuchsia{color:#bf00bf} -.fuchsia-background{background-color:#fa00fa} -.gray{color:#606060} -.gray-background{background-color:#7d7d7d} -.green{color:#006000} -.green-background{background-color:#007d00} -.lime{color:#00bf00} -.lime-background{background-color:#00fa00} -.maroon{color:#600000} -.maroon-background{background-color:#7d0000} -.navy{color:#000060} -.navy-background{background-color:#00007d} -.olive{color:#606000} -.olive-background{background-color:#7d7d00} -.purple{color:#600060} -.purple-background{background-color:#7d007d} -.red{color:#bf0000} -.red-background{background-color:#fa0000} -.silver{color:#909090} -.silver-background{background-color:#bcbcbc} -.teal{color:#006060} -.teal-background{background-color:#007d7d} -.white{color:#bfbfbf} -.white-background{background-color:#fafafa} -.yellow{color:#bfbf00} -.yellow-background{background-color:#fafa00} -span.icon>.fa{cursor:default} -.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default} -.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c} -.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111} -.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900} -.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400} -.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000} -.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold} -.conum[data-value] *{color:#fff!important} -.conum[data-value]+b{display:none} -.conum[data-value]:after{content:attr(data-value)} -pre .conum[data-value]{position:relative;top:-.125em} -b.conum *{color:inherit!important} -.conum:not([data-value]):empty{display:none} -dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility} -h1,h2,p,td.content,span.alt{letter-spacing:-.01em} -p strong,td.content strong,div.footnote strong{letter-spacing:-.005em} -p,blockquote,dt,td.content,span.alt{font-size:1.0625rem} -p{margin-bottom:1.25rem} -.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em} -.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc} -.print-only{display:none!important} -@media print{@page{margin:1.25cm .75cm} -*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important} -a{color:inherit!important;text-decoration:underline!important} -a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important} -a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em} -abbr[title]:after{content:" (" attr(title) ")"} -pre,blockquote,tr,img,object,svg{page-break-inside:avoid} -thead{display:table-header-group} -svg{max-width:100%} -p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3} -h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid} -#toc,.sidebarblock,.exampleblock>.content{background:none!important} -#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important} -.sect1{padding-bottom:0!important} -.sect1+.sect1{border:0!important} -#header>h1:first-child{margin-top:1.25rem} -body.book #header{text-align:center} -body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0} -body.book #header .details{border:0!important;display:block;padding:0!important} -body.book #header .details span:first-child{margin-left:0!important} -body.book #header .details br{display:block} -body.book #header .details br+span:before{content:none!important} -body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important} -body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always} -.listingblock code[data-lang]:before{display:block} -#footer{background:none!important;padding:0 .9375em} -#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em} -.hide-on-print{display:none!important} -.print-only{display:block!important} -.hide-for-print{display:none!important} -.show-for-print{display:inherit!important}} diff --git a/help/asciidoctor.adoc b/help/asciidoctor.adoc deleted file mode 100644 index e781d3c..0000000 --- a/help/asciidoctor.adoc +++ /dev/null @@ -1,2443 +0,0 @@ -= AsciiDoc Syntax Quick Reference -Dan Allen; Sarah White -v1.0.3, 2014-12-28 -:description: This guide is a quick reference for the common formatting markup and document elements in the AsciiDoc syntax. -:keywords: AsciiDoc, Asciidoctor, syntax, reference, cheatsheet -:imagesdir: images -:experimental: -:table-caption!: -:example-caption!: -:figure-caption!: -:idprefix: -:idseparator: - -:linkattrs: -:docref: http://asciidoctor.org/docs -:user-ref: {docref}/user-manual -:fontawesome-ref: http://fortawesome.github.io/Font-Awesome -:icon-inline: {user-ref}/#inline-icons -:icon-attribute: {user-ref}/#size-rotate-and-flip -:video-ref: {user-ref}/#video -:checklist-ref: {user-ref}/#checklists -:list-marker: {user-ref}/#custom-markers -:list-number: {user-ref}/#numbering-styles -:imagesdir-ref: {user-ref}/#imagesdir -:image-attributes: {user-ref}/#put-images-in-their-place -:toc-ref: {user-ref}/#table-of-contents -:para-ref: {user-ref}/#paragraph -:literal-ref: {user-ref}/#literal-text-and-blocks -:admon-ref: {user-ref}/#admonition -:bold-ref: {user-ref}/#bold-and-italic -:quote-ref: {user-ref}/#quotation-marks-and-apostrophes -:sub-ref: {user-ref}/#subscript-and-superscript -:mono-ref: {user-ref}/#monospace -:css-ref: {user-ref}/#custom-styling-with-attributes -:pass-ref: {user-ref}/#passthrough-macros -:mailinglist: http://discuss.asciidoctor.org - -AsciiDoc is a mature, lightweight markup language for authoring notes, articles, documentation, books, web pages, slide decks and man pages in plain text. -{description} - -[NOTE] -==== -Several examples focus on the output generated by the HTML backend. -AsciiDoc produces complementary output when generating DocBook. - -Most features labeled "`Asciidoctor only`" can be made available to the native AsciiDoc processor by using https://github.com/asciidoctor/asciidoctor/blob/master/compat/asciidoc.conf[this AsciiDoc configuration file] from the Asciidoctor project. -==== - -== Paragraphs - -.Normal ----- -Paragraphs don't require any special markup in AsciiDoc. -A paragraph is just one or more lines of consecutive text. - -To begin a new paragraph, separate it by at least one blank line. ----- - -[.result] -==== -Paragraphs don't require any special markup in AsciiDoc. -A paragraph is just one or more lines of consecutive text. - -To begin a new paragraph, separate it by at least one blank line. -==== - -.Line breaks ----- -To preserve a line break, end the line in a space followed by a plus sign. + -This results in a visible line break (e.g., `
`) between the lines. ----- - -[.result] -==== -To preserve a line break, end the line in a space followed by a plus sign. + -This results in a visible line break (e.g., `
`) between the lines. -==== - -.Literal ----- -A normal paragraph. - - A sequence of lines that begin with at least one space is a literal paragraph. - Literal paragraphs are treated as preformatted text. - The text is shown in a fixed-width font - and endlines are preserved. - -Another normal paragraph. ----- - -[.result] -==== -A normal paragraph. - - A sequence of lines that begin with at least one space is a literal paragraph. - Literal paragraphs are treated as preformatted text. - The text is shown in a fixed-width font - and endlines are preserved. - -Another normal paragraph. -==== - -.Admonition ----- -NOTE: An admonition paragraph draws the reader's attention to -auxiliary information. -Its purpose is determined by the label -at the beginning of the paragraph. - -Here are the other built-in admonition types: - -TIP: Pro tip... - -IMPORTANT: Don't forget... - -WARNING: Watch out for... - -CAUTION: Ensure that... ----- - -[.result] -==== -NOTE: An admonition paragraph draws the reader's attention to -auxiliary information. -Its purpose is determined by the label -at the beginning of the paragraph. - -Here are the other built-in admonition types: - -TIP: Pro tip... - -IMPORTANT: Don't forget... - -WARNING: Watch out for... - -CAUTION: Ensure that... -==== - -NOTE: You can also create <>. - -.Lead paragraph ----- -[.lead] -This text will be styled as a lead paragraph (i.e., larger font). ----- - -[.result] -==== -[.lead] -This text will be styled as a lead paragraph (i.e., larger font). -==== - -NOTE: The default Asciidoctor stylesheet automatically styles the first paragraph of the preamble as a lead paragraph. - -.More Paragraph, Admonition and Literal Block Examples -**** -See these sections in the Asciidoctor User Manual for more information and examples. - -* {para-ref}[Paragraphs] -* {literal-ref}[Literal Text and Blocks] -* {admon-ref}[Admonitions] -**** - -== Formatted Text - -.Bold, Italic, and Monospace ----- -_italic phrase_ - -__i__talic le__tt__ers - -*bold phrase* - -**b**old le**tt**ers - -*_bold italic phrase_* - -**__b__**old italic le**__tt__**ers - -`monospace phrase` and le``tt``ers - -`_monospace italic phrase_` and le``__tt__``ers - -`*monospace bold phrase*` and le``**tt**``ers - -`*_monospace bold italic phrase_*` and le``**__tt__**``ers - -`+inline literal passthrough+` (monospace text without substitutions) ----- - -[.result] -==== -_italic phrase_ - -__i__talic le__tt__ers - -*bold phrase* - -**b**old le**tt**ers - -*_bold italic phrase_* - -**__b__**old italic le**__tt__**ers - -`monospace phrase` and le``tt``ers - -`_monospace italic phrase_` and le``__tt__``ers - -`*monospace bold phrase*` and le``**tt**``ers - -`*_monospace bold italic phrase_*` and le``**__tt__**``ers - -`+inline literal passthrough+` (monospace text without substitutions) -==== - -.Custom Styling ----- -Do werewolves believe in [small]#small print#? - -[big]##O##nce upon an infinite loop. ----- - -[.result] -==== -Do werewolves believe in [small]#small print#? - -[big]##O##nce upon an infinite loop. -==== - -.Superscript and Subscript ----- -^super^script phrase - -~sub~script phrase ----- - -[.result] -==== -^super^script phrase - -~sub~script phrase -==== - -.Curved Quotes ----- -'`single smart quotes`' - -"`double smart quotes`" ----- - -[.result] -==== -'`single smart quotes`' - -"`double smart quotes`" -==== - -.More Text Formatting Examples -**** -See these sections in the Asciidoctor User Manual for more information and examples. - -* {bold-ref}[Bold and Italic Formatting] -* {quote-ref}[Quotation Marks and Apostrophes] -* {sub-ref}[Subscript and Superscript] -* {mono-ref}[Monospace Formatting] -* {css-ref}[Custom Styling with Attributes] -* {pass-ref}[Passthrough Macros] -**** - -== Document Header - -IMPORTANT: A header is optional. -When you do add a header to your document, the only required element is a title. - -CAUTION: The header may not contain blank lines and must be offset from the content by at least one blank line. - -.Title only -----//toc::[] - -= My Document's Title - -My document provides... ----- - -.Title and author line ----- -= My Document's Title -Doc Writer - -My document provides... ----- - -.Title, author line and revision line ----- -= My Document's Title -Doc Writer -v1.0, 2014-01-01 - -My document provides... ----- - -IMPORTANT: You cannot have a revision line without an author line. - -.Document header with attributes ----- -= My Document's Title -Doc Writer -v1.0, 2014-01-01 -:toc: -:imagesdir: assets/images -:homepage: http://asciidoctor.org - -My document provides... ----- - -[[section-titles]] -== Section Titles (Headers) - -.Article doctype ----- -= Document Title (Level 0) - -== Level 1 Section - -=== Level 2 Section - -==== Level 3 Section - -===== Level 4 Section - -====== Level 5 Section - -== Another Level 1 Section ----- - -[.result] -==== -// float is required to create plain headers -[float] -= Document Title (Level 0) - -[float] -== Section Level 1 - -[float] -=== Section Level 2 - -[float] -==== Section Level 3 - -[float] -===== Section Level 4 - -[float] -====== Section Level 5 -==== - -WARNING: When using the article doctype (the default), you can only have one level-0 section title (i.e., the document title) and it must be in the document header. - -NOTE: The number of equal signs matches the heading level in the HTML output. -For example, _Section Level 1_ becomes an `

` heading. - -.Book doctype ----- -= Document Title (Level 0) - -== Section Level 1 - -=== Section Level 2 - -==== Section Level 3 - -===== Section Level 4 - -====== Section Level 5 - -= Section Level 0 ----- - -[.result] -==== -// float is required to create plain headers -[float] -= Document Title (Level 0) - -[float] -== Section Level 1 - -[float] -=== Section Level 2 - -[float] -==== Section Level 3 - -[float] -===== Section Level 4 - -[float] -====== Section Level 5 - -[float] -= Section Level 0 -==== - -//// -IMPORTANT: There are two other ways to define a section title. -_Their omission is intentional_. -They both require more markup and are therefore unnecessary. -The http://en.wikipedia.org/wiki/Setext[setext] title syntax (underlined text) is especially wasteful, hard to remember, hard to maintain and error prone. -The reader never sees the extra markup, so why type it? -*Be frugal!* -//// - -.Explicit id ----- -[[primitives-nulls]] -== Primitive types and null values ----- - -.Section anchors and links (Asciidoctor only) - -`sectanchors`:: -When this document attribute is set, a section icon anchor appears in front of the section title. - -`sectlinks`:: -When this document attribute is set, the section titles become links. - -NOTE: Section title anchors depend on the default Asciidoctor stylesheet to render properly. - -== Include Files - -.Document parts ----- -= Reference Documentation -Lead Developer - -This is documentation for project X. - -\include::basics.adoc[] - -\include::installation.adoc[] - -\include::example.adoc[] ----- - -CAUTION: Asciidoctor does not insert blank lines between adjacent include statements to keep the content separated. -Be sure to add a blank line in the source document to avoid unexpected results, such as a section title being swallowed. - -.Include content from a URI ----- -:asciidoctor-source: https://raw.github.com/asciidoctor/asciidoctor/master - -\include::{asciidoctor-source}/README.adoc[] ----- - -NOTE: Including content from a URI is potentially dangerous, so it's disabled if the safe mode is SECURE or greater. -Assuming the safe mode is less than SECURE, you must also set the `allow-uri-read` attribute to permit Asciidoctor to read content from a URI. - -== Horizontal Rules and Page Breaks - -.Horizontal rule ----- -''' ----- - -[.result] -==== -''' -==== - -.Page break ----- -<<< ----- - -== Lists - -.Unordered, basic ----- -* Edgar Allen Poe -* Sheri S. Tepper -* Bill Bryson - -//^ - -* Kevin Spacey -* Jeremy Piven ----- - -[.result] -==== -* Edgar Allen Poe -* Sheri S. Tepper -* Bill Bryson - -//^ - -* Kevin Spacey -* Jeremy Piven -==== - -NOTE: Blank lines are required before and after a list. - -TIP: You can force two lists apart with a line comment, as the previous example demonstrates. -The text in the comment, (`^`), is optional, but serves as a hint to other authors that this line serves as an "end of list" marker. -//toc::[] - -.Unordered, max nesting ----- -* level 1 -** level 2 -*** level 3 -**** level 4 -***** level 5 -* level 1 ----- - -[.result] -==== -* level 1 -** level 2 -*** level 3 -**** level 4 -***** level 5 -* level 1 -==== - -TIP: The unordered list marker can be changed using {list-marker}[block styles]. - -.Checklist ----- -- [*] checked -- [x] also checked -- [ ] not checked -- normal list item ----- - -[.result] -==== -- [*] checked -- [x] also checked -- [ ] not checked -- normal list item -==== - -TIP: Checklists can use {checklist-ref}[font-based icons and be interactive]. - -.Ordered, basic ----- -. Step 1 -. Step 2 -. Step 3 ----- - -[.result] -==== -. Step 1 -. Step 2 -. Step 3 -==== - -.Ordered, nested ----- -. Step 1 -. Step 2 -.. Step 2a -.. Step 2b -. Step 3 ----- - -[.result] -==== -. Step 1 -. Step 2 -.. Step 2a -.. Step 2b -. Step 3 -==== - -.Ordered, max nesting ----- -. level 1 -.. level 2 -... level 3 -.... level 4 -..... level 5 -. level 1 ----- - -[.result] -==== -. level 1 -.. level 2 -... level 3 -.... level 4 -..... level 5 -. level 1 -==== - -TIP: For ordered lists, Asciidoctor supports {list-number}[numeration styles] such as `lowergreek` and `decimal-leading-zero`. - -.Labeled, single-line ----- -first term:: definition of first term -section term:: definition of second term ----- - -[.result] -==== -first term:: definition of first term -section term:: definition of second term -====//toc::[] - - -.Labeled, multi-line ----- -first term:: -definition of first term -section term:: -definition of second term ----- - -[.result] -==== -first term:: -definition of first term -section term:: -definition of second term -==== - -.Q&A ----- -[qanda] -What is Asciidoctor?:: - An implementation of the AsciiDoc processor in Ruby. -What is the answer to the Ultimate Question?:: 42 ----- - -[.result] -==== -[qanda] -What is Asciidoctor?:: - An implementation of the AsciiDoc processor in Ruby. -What is the answer to the Ultimate Question?:: 42 -==== - -.Mixed ----- -Operating Systems:: - Linux::: - . Fedora - * Desktop - . Ubuntu - * Desktop - * Server - BSD::: - . FreeBSD - . NetBSD - -Cloud Providers:: - PaaS::: - . OpenShift - . CloudBees - IaaS::: - . Amazon EC2 - . Rackspace ----- - -[.result] -==== -Operating Systems:: - Linux::: - . Fedora - * Desktop - . Ubuntu - * Desktop - * Server - BSD::: - . FreeBSD - . NetBSD - -Cloud Providers:: - PaaS::: - . OpenShift - . CloudBees - IaaS::: - . Amazon EC2 - . Rackspace -==== - -TIP: Lists can be indented. -Leading whitespace is not significant. - -.Complex content in outline lists ----- -* Every list item has at least one paragraph of content, - which may be wrapped, even using a hanging indent. -+ -Additional paragraphs or blocks are adjoined by putting -a list continuation on a line adjacent to both blocks. -+ -list continuation:: a plus sign (+) on a line by itself - -* A literal paragraph does not require a list continuation. - - $ gem install asciidoctor - -* AsciiDoc lists may contain any complex content. -+ -[cols="2", options="header"] -|=== -|Application -|Language - -|AsciiDoc -|Python - -|Asciidoctor -|Ruby -|=== ----- - -[.result] -==== -* Every list item has at least one paragraph of content, - which may be wrapped, even using a hanging indent. -+ -Additional paragraphs or blocks are adjoined by putting -a list continuation on a line adjacent to both blocks. -+ -list continuation:: a plus sign (+) on a line by itself - -* A literal paragraph does not require a list continuation. - - $ gem install asciidoctor - -* AsciiDoc lists may contain any complex content. -+ -[cols="2", options="header"] -|=== -|Application -|Language - -|AsciiDoc -|Python - -|Asciidoctor -|Ruby -|=== -==== - -== Links - -.External ----- -http://asciidoctor.org - automatic! - -http://asciidoctor.org[Asciidoctor] - -https://github.com/asciidoctor[Asciidoctor @ *GitHub*] ----- - -[.result] -==== -http://asciidoctor.org - automatic! - -http://asciidoctor.org[Asciidoctor] - -https://github.com/asciidoctor[Asciidoctor @ *GitHub*] -==== - -.Relative ----- -link:index.html[Docs] ----- - -[.result] -==== -link:index.html[Docs] -==== - -.Email and IRC ----- -devel@discuss.arquillian.org - -mailto:devel@discuss.arquillian.org[Discuss Arquillian] - -mailto:devel-join@discuss.arquillian.org[Subscribe, Subscribe me, I want to join!] - -irc://irc.freenode.org/#asciidoctor ----- - -[.result] -==== -devel@discuss.arquillian.org - -mailto:devel@discuss.arquillian.org[Discuss Arquillian] - -mailto:devel-join@discuss.arquillian.org[Subscribe, Subscribe me, I want to join!] - -irc://irc.freenode.org/#asciidoctor -==== - -.Link with attributes (Asciidoctor only) ----- -http://discuss.asciidoctor.org[Discuss Asciidoctor, role="external", window="_blank"] - -http://discuss.asciidoctor.org[Discuss Asciidoctor^] - -http://search.example.com["Google, Yahoo, Bing^", role="teal"] ----- - -[.result] -==== -http://discuss.asciidoctor.org[Discuss Asciidoctor, role="external", window="_blank"] - -http://discuss.asciidoctor.org[Discuss Asciidoctor^] - -http://search.example.com["Google, Yahoo, Bing^", role="teal"] -==== - -NOTE: Links with attributes (including the subject and body segments on mailto links) are a feature unique to Asciidoctor. -To enable them, you must set the `linkattrs` attribute on the document. -When they are enabled, you must quote the link text if it contains a comma. - -.Inline anchors ----- -[[bookmark-a]]Inline anchors make arbitrary content referenceable. - -anchor:bookmark-b[]Use a cross reference to link to this location. ----- - -[.result] -==== -[[bookmark-a]]Inline anchors make arbitrary content referenceable. - -anchor:bookmark-b[]Use a cross reference to link to this location. -==== - -.Internal cross references ----- -See <> to learn how to write paragraphs. - -Learn how to organize the document into <>. ----- - -[.result] -==== -See <> to learn how to write paragraphs. - -Learn how to organize the document into <>. -==== - -.Inter-document cross references (Asciidoctor only) ----- -Refer to <> for more information. - -See you when you get back from <>! ----- - -== Images - -.Block ----- -image::sunset.jpg[] - -image::sunset.jpg[Sunset] - -[[img-sunset]] -.A mountain sunset -image::sunset.jpg[Sunset, 300, 200, link="http://www.flickr.com/photos/javh/5448336655"] - -image::http://asciidoctor.org/images/octocat.jpg[GitHub mascot] ----- - -[.result] -==== -image::sunset.jpg[] - -image::sunset.jpg[Sunset] - -[[img-sunset]] -.A mountain sunset -image::sunset.jpg[Sunset, 300, 200, link="http://www.flickr.com/photos/javh/5448336655"] - -image::http://asciidoctor.org/images/octocat.jpg[GitHub mascot] -==== - -IMPORTANT: Images are resolved relative to the value of the {imagesdir-ref}[`imagesdir` document attribute], which defaults to an empty value. -The `imagesdir` attribute can be an absolute path, relative path or base URL. -If the image target is a URL or absolute path, the `imagesdir` prefix is _not_ added. - -TIP: You should use the `imagesdir` attribute to avoid hard coding the shared path to your images in every image macro. - -.Image macro using positioning role ----- -image:sunset.jpg[Sunset,150,150,role="right"] What a beautiful sunset! ----- - -[.result] -==== -image:sunset.jpg[Sunset,150,150,role="right"] What a beautiful sunset! -==== - -TIP: There are a variety of attributes available to {image-attributes}[position and frame images]. - -.Inline ----- -Click image:icons/play.png[Play, title="Play"] to get the party started. - -Click image:icons/pause.png[title="Pause"] when you need a break. ----- - -[.result] -==== -Click image:icons/play.png[Play, title="Play"] to get the party started. - -Click image:icons/pause.png[title="Pause"] when you need a break. -==== - -.Embedded ----- -= Document Title -:data-uri: ----- - -NOTE: When the `data-uri` attribute is set, all images in the document--including admonition icons--are embedded into the document as https://developer.mozilla.org/en-US/docs/data_URIs[data URIs]. - -TIP: Instead of declaring the `data-uri` attribute in the document, you can pass it as a command-line argument using `-a data-uri`. - -== Videos - -.Block ----- -video::video_file.mp4[] - -video::video_file.mp4[width=640, start=60, options=autoplay] ----- - -.Embedded Youtube video ----- -video::rPQoq7ThGAU[youtube] ----- - -.Embedded Vimeo video ----- -video::67480300[vimeo] ----- - -TIP: You can control the video settings using {video-ref}[additional attributes and options] on the macro. - -== Source Code - -.Inline ----- -Reference code like `types` or `methods` inline. ----- - -[.result] -==== -Reference code like `types` or `methods` inline. -==== - -.Literal line ----- - Indent the line one space to insert a code snippet ----- - -[.result] -==== - Indent the line one space to insert a code snippet -==== - -.Literal block ----- -.... -error: The requested operation returned error: 1954 Forbidden search for defensive operations manual -absolutely fatal: operation initiation lost in the dodecahedron of doom -would you like to die again? y/n -.... ----- - -[.result] -==== -.... -error: The requested operation returned error: 1954 Forbidden search for defensive operations manual -absolutely fatal: operation initiation lost in the dodecahedron of doom -would you like to die again? y/n -.... -==== - -[listing] -.Listing block with title, no syntax highlighting -.... -.Gemfile.lock ----- -GEM - remote: https://rubygems.org/ - specs: - asciidoctor (0.1.4) - -PLATFORMS - ruby - -DEPENDENCIES - asciidoctor (~> 0.1.4) ----- -.... - -[.result] -==== -.Gemfile.lock ----- -GEM - remote: https://rubygems.org/ - specs: - asciidoctor (0.1.4) - -PLATFORMS - ruby - -DEPENDENCIES - asciidoctor (~> 0.1.4) ----- -==== - -[listing] -.Code block with title and syntax highlighting -.... -[source,ruby] -.app.rb ----- -require 'sinatra' - -get '/hi' do - "Hello World!" -end ----- -.... - -[.result] -==== -[source,ruby] -.app.rb ----- -require 'sinatra' - -get '/hi' do - "Hello World!" -end ----- -==== - -[listing, subs="specialcharacters"] -.Code block with callouts -.... -[source,ruby] ----- -require 'sinatra' <1> - -get '/hi' do <2> - "Hello World!" <3> -end ----- -<1> Library import -<2> URL mapping -<3> Content for response -.... - -[.result] -==== -[source,ruby] ----- -require 'sinatra' <1> - -get '/hi' do <2> - "Hello World!" <3> -end ----- -<1> Library import -<2> URL mapping -<3> Content for response -==== - -[listing, subs="specialcharacters"] -.Code block with non-selectable callouts -.... ----- -line of code // <1> -line of code # <2> -line of code ;; <3> ----- -<1> A callout behind a line comment for C-style languages. -<2> A callout behind a line comment for Ruby, Python, Perl, etc. -<3> A callout behind a line comment for Clojure. -.... - -[.result] -==== ----- -line of code // <1> -line of code # <2> -line of code ;; <3> ----- -<1> A callout behind a line comment for C-style languages. -<2> A callout behind a line comment for Ruby, Python, Perl, etc. -<3> A callout behind a line comment for Clojure. -==== - -[listing, subs="specialcharacters"] -.XML code block with a non-selectable callout -.... -[source,xml] ----- -
- Section Title -
----- -<1> The section title is required. -.... - -[.result] -==== -[source,xml] ----- -
- Section Title -
----- -<1> The section title is required. -==== - -[listing] -.Code block sourced from file -.... -[source,ruby] ----- -\include::app.rb[] ----- -.... - -[listing] -.Code block sourced from file relative to source directory -.... -:sourcedir: src/main/java - -[source,java] ----- -\include::{sourcedir}/org/asciidoctor/Asciidoctor.java[] ----- -.... - -[listing] -.Strip leading indentation from source -.... -[source,ruby,indent=0] ----- -\include::lib/document.rb[lines=5..10] ----- -.... - -[NOTE] -==== -* When `indent` is 0, the leading block indent is stripped (tabs are replaced with 4 spaces). -* When `indent` is > 0, the leading block indent is first stripped (tabs are replaced with 4 spaces), then a block is indented by the number of columns equal to this value. -==== - -.Code block without delimiters (no blank lines) ----- -[source,xml] - ----- - -[.result] -==== -[source,xml] - -==== - -[IMPORTANT] -.Enabling the syntax highlighter -==== -Syntax highlighting is enabled by setting the `source-highlighter` attribute in the document header or passed as an argument. - - :source-highlighter: pygments - -The valid options for are `coderay`, `highlight.js`, `prettify`, and `pygments`. -==== - -== More Delimited Blocks - -.Sidebar ----- -.AsciiDoc history -**** -AsciiDoc was first released in Nov 2002 by Stuart Rackham. -It was designed from the start to be a shorthand syntax -for producing professional documents like DocBook and LaTeX. -**** ----- - -[.result] -==== -.AsciiDoc history -**** -AsciiDoc was first released in Nov 2002 by Stuart Rackham. -It was designed from the start to be a shorthand syntax -for producing professional documents like DocBook and LaTeX. -**** -==== - -NOTE: Any block can have a title, positioned above the block. -A block title is a line of text that starts with a dot. -The dot cannot be followed by a space. - -.Example ----- -.Sample document -==== -Here's a sample AsciiDoc document: - -[listing] -.... -= Title of Document -Doc Writer -:toc: - -This guide provides... -.... - -The document header is useful, but not required. -==== ----- - -[example.result] --- -.Sample document -==== -Here's a sample AsciiDoc document: - -[listing] -.... -= Title of Document -Doc Writer -:toc: - -This guide provides... -.... - -The document header is useful, but not required. -==== --- - -[[admon-bl]] -.Admonition ----- -[NOTE] -==== -An admonition block may contain complex content. - -.A list -- one -- two -- three - -Another paragraph. -==== ----- - -[.result] -===== -[NOTE] -==== -An admonition block may contain complex content. - -.A list -- one -- two -- three - -Another paragraph. -==== -===== - -[TIP] -.Admonition and callout icons -==== -Asciidoctor can "draw" icons using {fontawesome-ref}[Font Awesome^] and CSS. - -To use this feature, set the value of the `icons` document attribute to `font`. -Asciidoctor will then emit HTML markup that selects an appropriate font character from the Font Awesome font for each admonition block. - -Icons can also be used {icon-inline}[inline] and {icon-attribute}[styled]. -==== - -.Blockquote ----- -[quote, Abraham Lincoln, Soldiers' National Cemetery Dedication] -____ -Four score and seven years ago our fathers brought forth -on this continent a new nation... -____ - -[quote, Albert Einstein] -A person who never made a mistake never tried anything new. - -____ -A person who never made a mistake never tried anything new. -____ ----- - -[.result] -==== -[quote, Abraham Lincoln, Soldiers' National Cemetery Dedication] -____ -Four score and seven years ago our fathers brought forth -on this continent a new nation... -____ - -[quote, Albert Einstein] -A person who never made a mistake never tried anything new. - -____ -A person who never made a mistake never tried anything new. -____ -==== - -.Abbreviated blockquote (Asciidoctor only) ----- -"I hold it that a little rebellion now and then is a good thing, -and as necessary in the political world as storms in the physical." --- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11 ----- - -[.result] -==== -"I hold it that a little rebellion now and then is a good thing, -and as necessary in the political world as storms in the physical." --- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11 -==== - -.Air quotes (Asciidoctor only) - -As a tip of the hat to Dick, Asciidoctor recognizes text between "air quotes" as a quote block. -Air quotes are the best thing since fenced code blocks. - ----- -[, Richard M. Nixon] -"" -When the President does it, that means that it's not illegal. -"" ----- - -[.result] -==== -[, Richard M. Nixon] -"" -When the President does it, that means that it's not illegal. -"" -==== - -.Passthrough ----- -++++ -

-Content in a passthrough block is passed to the output unprocessed. -That means you can include raw HTML, like this embedded Gist: -

- - -++++ ----- - -[.result] -==== -++++ -

-Content in a passthrough block is passed to the output unprocessed. -That means you can include raw HTML, like this embedded Gist: -

- - -++++ -==== - -.Open ----- --- -An open block can be an anonymous container, -or it can masquerade as any other block. --- - -[source] --- -puts "I'm a source block!" --- ----- - -[.result] -==== --- -An open block can be an anonymous container, -or it can masquerade as any other block. --- - -[source] --- -puts "I'm a source block!" --- -==== - -[listing] -.Custom substitutions -.... -:version: 0.1.4 - -[source,xml] -[subs="verbatim,attributes"] ----- - - org.asciidoctor - asciidoctor-java-integration - {version} - ----- -.... - -[.result] -==== -// the attribute value is hard-coded in this result since the example depends -// on a hypothetical document attribute -[source,xml] ----- - - org.asciidoctor - asciidoctor-java-integration - 0.1.4 - ----- -==== - -== Block Id, Role and Options - -.Traditional markup method for assigning block `id` and `role` ----- -[[goals]] -[role="incremental"] -* Goal 1 -* Goal 2 ----- - -.Shorthand markup method for assigning block `id` and `role` (Asciidoctor only) ----- -[#goals.incremental] -* Goal 1 -* Goal 2 ----- - -[TIP] -==== -* To specify multiple roles using the shorthand syntax, separate them by dots. -* The order of `id` and `role` values in the shorthand syntax does not matter. -==== - -.Traditional markup method for assigning quoted text anchor (`id`) and `role` ----- -[[free_the_world]][big goal]_free the world_ ----- - -.Shorthand markup method for assigning quoted text anchor (`id`) and `role` (Asciidoctor only) ----- -[#free_the_world.big.goal]_free the world_ ----- - -.Role assigned to text enclosed in backticks ----- -[rolename]`escaped monospace text` ----- - -.Traditional markup method for assigning block `options` ----- -[options="header,footer,autowidth"] -|=== -|Cell A |Cell B -|=== ----- - -.Shorthand markup method for assigning block `options` (Asciidoctor only) ----- -[%header%footer%autowidth] -|=== -|Cell A |Cell B -|=== ----- - -== Comments - -.Line ----- -// A single-line comment. ----- - -TIP: Single-line comments can be used to divide elements, such as two adjacent lists. - -.Block ----- -//// -A multi-line comment. - -Notice it's a delimited block. -//// ----- - -== Tables - -.Table with a title, three columns, a header, and two rows of content ----- -.Table Title -|=== -|Name of Column 1 |Name of Column 2 |Name of Column 3 <1> -<2> -|Cell in column 1, row 1 -|Cell in column 2, row 1 -|Cell in column 3, row 1 - -|Cell in column 1, row 2 -|Cell in column 2, row 2 -|Cell in column 3, row 2 -|=== ----- -<1> Unless the `cols` attribute is specified, the number of columns is equal to the number of vertical bars on the first non-blank line inside the block delimiters. -<2> When a blank line follows a single line of column titles, the column titles row will be styled as a header row by default. - -[.result] -==== -.Table Title -|=== -|Name of Column 1 |Name of Column 2 |Name of Column 3 - -|Cell in column 1, row 1 -|Cell in column 2, row 1 -|Cell in column 3, row 1 - -|Cell in column 1, row 2 -|Cell in column 2, row 2 -|Cell in column 3, row 2 -|=== -==== - -.Table with two columns, a header, and two rows of content ----- -[cols="2*", options="header"] <1> -|=== -|Name of Column 1 -|Name of Column 2 - -|Cell in column 1, row 1 -|Cell in column 2, row 1 - -|Cell in column 1, row 2 -|Cell in column 2, row 2 -|=== ----- -<1> The `*` in the `cols` attribute is the repeat operator. It means repeat the column specification for the remainder of columns. In this case, it means to repeat the default formatting across 4 columns. When the header row is not defined on a single line, you must use the `cols` attribute to set the number of columns and `options` attributes to make the first row a header. - -[.result] -==== -[cols="2*", options="header"] -|=== -|Name of Column 1 -|Name of Column 2 - -|Cell in column 1, row 1 -|Cell in column 2, row 1 - -|Cell in column 1, row 2 -|Cell in column 2, row 2 -|=== -==== - -.Table with three columns, a header, and two rows of content ----- -[cols="1,1,2", options="header"] <1> -.Applications -|=== -|Name -|Category -|Description - -|Firefox -|Browser -|Mozilla Firefox is an open-source web browser. -It's designed for standards compliance, -performance, portability. - -|Arquillian -|Testing -|An innovative and highly extensible testing platform. -Empowers developers to easily create real, automated tests. -|=== ----- -<1> In this example, the `cols` attribute has two functions. It specifies that this table has three columns, and it sets their relative widths. - -[.result] -==== -[cols="1,1,2", options="header"] -.Applications -|=== -|Name -|Category -|Description - -|Firefox -|Browser -|Mozilla Firefox is an open-source web browser. -It's designed for standards compliance, -performance, portability. - -|Arquillian -|Testing -|An innovative and highly extensible testing platform. -Empowers developers to easily create real, automated tests. -|=== -==== - -.Table with column containing AsciiDoc content ----- -[cols="2,2,5a"] -|=== -|Firefox -|Browser -|Mozilla Firefox is an open-source web browser. - -It's designed for: - -* standards compliance -* performance -* portability - -http://getfirefox.com[Get Firefox]! -|=== ----- - -[.result] -==== -[cols="2,2,5a"] -|=== -|Firefox -|Browser -|Mozilla Firefox is an open-source web browser. - -It's designed for: - -* standards compliance -* performance -* portability - -http://getfirefox.com[Get Firefox]! -|=== -==== - -.Table from CSV data ----- -[format="csv", options="header"] -|=== -Artist,Track,Genre -Baauer,Harlem Shake,Hip Hop -The Lumineers,Ho Hey,Folk Rock -|=== ----- - -[.result] -==== -[format="csv", options="header"] -|=== -Artist,Track,Genre -Baauer,Harlem Shake,Hip Hop -The Lumineers,Ho Hey,Folk Rock -|=== -==== - -.Table from CSV data using shorthand (Asciidoctor only) ----- -,=== -Artist,Track,Genre - -Baauer,Harlem Shake,Hip Hop -,=== ----- - -[.result] -==== -,=== -Artist,Track,Genre - -Baauer,Harlem Shake,Hip Hop -,=== -==== - -.Table from DSV data using shorthand (Asciidoctor only) ----- -:=== -Artist:Track:Genre - -Robyn:Indestructable:Dance -:=== ----- - -[.result] -==== -:=== -Artist:Track:Genre - -Robyn:Indestructable:Dance -:=== -==== - -.Table with formatted, aligned and merged cells ----- -[cols="e,m,^,>s", width="25%"] -|=== -|1 >s|2 |3 |4 -^|5 2.2+^.^|6 .3+<.>m|7 -^|8 -|9 2+>|10 -|=== ----- - -[.result] -==== -[cols="e,m,^,>s", width="25%"] -|=== -|1 >s|2 |3 |4 -^|5 2.2+^.^|6 .3+<.>m|7 -^|8 -|9 2+>|10 -|=== -==== - -== UI Macros - -IMPORTANT: You *must* set the `experimental` attribute in the document header to enable these macros. - -.Keyboard shortcuts (inline `kbd` macro) ----- -|=== -|Shortcut |Purpose - -|kbd:[F11] -|Toggle fullscreen - -|kbd:[Ctrl+T] -|Open a new tab - -|kbd:[Ctrl+Shift+N] -|New incognito window - -|kbd:[Ctrl + +] -|Increase zoom -|=== ----- - -[.result] -==== -|=== -|Shortcut |Purpose - -|kbd:[F11] -|Toggle fullscreen - -|kbd:[Ctrl+T] -|Open a new tab - -|kbd:[Ctrl+Shift+N] -|New incognito window - -|kbd:[Ctrl + +] -|Increase zoom -|=== -==== - -.Menu selections (inline `menu` macro) ----- -To save the file, select menu:File[Save]. - -Select menu:View[Zoom > Reset] to reset the zoom level to the default setting. ----- - -[.result] -==== -To save the file, select menu:File[Save]. - -Select menu:View[Zoom > Reset] to reset the zoom level to the default setting. -==== - -.Buttons (inline `btn` macro) ----- -Press the btn:[OK] button when you are finished. - -Select a file in the file navigator and click btn:[Open]. ----- - -[.result] -==== -Press the btn:[OK] button when you are finished. - -Select a file in the file navigator and click btn:[Open]. -==== - -== Attributes and Substitutions - -.Attribute declaration and usage ----- -:homepage: http://asciidoctor.org -:docslink: http://asciidoctor.org/docs[Asciidoctor's Docs] -:desc: Asciidoctor is a mature, plain-text document format for + - writing notes, articles, documentation, books, and more. + - It's also a text processor & toolchain for translating + - documents into various output formats (i.e., backends), + - including HTML, DocBook, PDF and ePub. -:checkedbox: pass:normal[`[✔]`] - -Check out {homepage}[Asciidoctor]! - -{desc} - -Check out {docslink} too! - -{checkedbox} That's done! ----- - -[.result] -==== -// I have to use a nested doc hack here, otherwise the attributes won't resolve -[.unstyled] -|=== -a| -:homepage: http://asciidoctor.org -:docslink: http://asciidoctor.org/docs[Asciidoctor's Docs] -:desc: Asciidoctor is a mature, plain-text document format for + - writing notes, articles, documentation, books, and more. + - It's also a text processor & toolchain for translating + - documents into various output formats (i.e., backends), + - including HTML, DocBook, PDF and ePub. -:checkedbox: pass:normal[`[✔]`] - -Check out {homepage}[Asciidoctor]! - -{desc} - -Check out {docslink} too! - -{checkedbox} That's done! -|=== -==== - -.Attribute assignment precedence (highest to lowest) -- Attribute passed to the API or CLI that does not end in `@` -- Attribute defined in the document -- Attribute passed to the API or CLI that ends in `@` -- Intrinsic attribute value (default values) - -TIP: To make an attribute value that is passed to the API or CLI have a lower precedence than an assignment in the document, add an `@` symbol to the end of the attribute value. - -// Table of literal character attributes -.Built-in literal attributes -[width="70%", cols="^1l,^1l,^1"] -|=== -|Attribute reference |Replacement |Rendered - -|\{lt} -|< -|< - -|\{gt} -|> -|> - -|\{amp} -|& -|& - -|\{startsb} -|[ -|[ - -|\{endsb} -|] -|] - -|\{vbar} -|\| -|\| - -|\{caret} -|^ -|^ - -|\{asterisk} -|* -|* - -|\{tilde} -|~ -|~ - -|\{apostrophe} -|' -|' - -|\{backslash} -|\ -|\ - -|\{backtick} -|` -|` - -|\{two-colons} -|:: -|:: - -|\{two-semicolons} -|;; -|;; - -|=== - -// Table of character reference attributes -.Built-in entity attributes -[width="70%", cols="^1l,^1l,^1"] -|=== -|Attribute reference |Replacement |Rendered - -|\{empty} -|_nothing_ -|{empty} - -|\{sp}, \{space} -|_single space_ -|{sp} - -|\{nbsp} -|\  -|{nbsp} - -|\{zwsp} -|\​ -|{zwsp} - -|\{wj} -|\⁠ -|{wj} - -|\{apos} -|\' -|{apos} - -|\{quot} -|\" -|{quot} - -|\{lsquo} -|\‘ -|{lsquo} - -|\{rsquo} -|\’ -|{rsquo} - -|\{ldquo} -|\“ -|{ldquo} - -|\{rdquo} -|\” -|{rdquo} - -|\{deg} -|\° -|{deg} - -|\{plus} -|\+ -|{plus} - -|\{brvbar} -|\¦ -|{brvbar} -|=== - -// Table of built-in data attributes -.Built-in data attributes -[width="70%",cols="1m,3"] -|=== -|Attribute |Description - -|asciidoctor -|Calls the processor - -|asciidoctor-version -|Version of the processor - -|backend -|Backend used to render document - -|docdate -|Last modified date - -|docdatetime -|Last modified date and time - -|docdir -|Name of document directory - -|docfile -|Name of document file - -|doctime -|Last modified time - -|doctitle -|The title of the document - -|doctype -|Document's doctype (e.g., article) - -|localdate -|Local date when rendered - -|localdatetime -|Local date and time when rendered - -|localtime -|Local time when rendered -|=== - -.Named substitutions -[horizontal] -`none`:: Disables substitutions - -`normal`:: Performs all substitutions except for callouts - -`verbatim`:: Replaces special characters and processes callouts - -`specialcharacters`:: Replaces `<`, `>`, and `&` with their corresponding entities - -`quotes`:: Applies text formatting - -`attributes`:: Replaces attribute references - -`replacements`:: Substitutes textual and character reference replacements - -`macros`:: Processes macros - -`post_replacements`:: Replaces the line break character (`{plus}`) - -.Counter attributes ----- -[caption=""] -.Parts{counter2:index:0} -|=== -|Part Id |Description - -|PX-{counter:index} -|Description of PX-{index} - -|PX-{counter:index} -|Description of PX-{index} -|=== ----- - -[.result] -==== -[caption=""] -.Parts{counter2:index:0} -|=== -|Part Id |Description - -|PX-{counter:index} -|Description of PX-{index} - -|PX-{counter:index} -|Description of PX-{index} -|=== -==== - -== Text Replacement - -// Table of text replacements performed during replacements substitution -//// -Included in: - -- user-manual: Text Substitutions: Replacements -- quick-ref -//// - -[cols="2,^1l,^1l,^1,2"] -.Textual symbol replacements -|=== -|Name |Syntax |Unicode Replacement |Rendered |Notes - -|Copyright -|\(C) -|\© -|(C) -| - -|Registered -|\(R) -|\® -|(R) -| - -|Trademark -|\(TM) -|\™ -|(TM) -| - -|Em dash -|\-- -|\— -|{empty}--{empty} -|When space is detected on either side of the em dash, the thin space numeric character entity (`\ `) is also substituted into the document. - -|ellipses -|\... -|\… -|... -| - -|right single arrow -|\-> -|\→ -|-> -| - -|right double arrow -|\=> -|\⇒ -|=> -| - -|left single arrow -|\<- -|\← -|<- -| - -|left double arrow -|\<= -|\⇐ -|<= -| - -|apostrophe -|Sam\'s -|Sam\’s -|Sam's -|The vertical form apostrophe is replaced with the curved form apostrophe. -|=== - -TIP: Any named, numeric or hex http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references[XML entity reference] is supported. - -== Escaping Text - -.Backslash ----- -\*Stars* is not rendered as bold text. -The asterisks around the word are preserved. - -\{author} is not resolved to the author name. -The curly brackets around the word are preserved. - -The backslash character is automatically removed. ----- - -[.result] -==== -\*Stars* is not rendered as bold text. -The asterisks around the word are preserved. - -\{author} is not resolved to the author name. -The curly brackets around the word are preserved. - -The backslash character is automatically removed. -==== - -.Double dollar ----- -$$*Stars*$$ is not rendered as bold text. -The asterisks around the word are preserved. - -$$&$$ renders as an XML entity instead of &. ----- - -[.result] -==== -$$*Stars*$$ is not rendered as bold text. -The asterisks around the word are preserved. - -$$&$$ renders as an XML entity instead of &. -==== - -.Triple plus and inline passthrough macro ----- -+++underline me+++ renders as underlined text. - -pass:[underline me] also renders as underlined text. ----- - -[.result] -==== -+++underline me+++ renders as underlined text. - -pass:[underline me] also renders as underlined text. -==== - -.Backticks ----- -`Text in {backticks}` renders exactly as entered, in `monospace`. -The attribute reference is not resolved. ----- - -[.result] -==== -`Text in {backticks}` renders exactly as entered, in `monospace`. -The attribute reference is not resolved. -==== - -== Table of Contents (ToC) - -.Document with ToC ----- -= AsciiDoc Writer's Guide -Doc Writer -v1.0, 2013-01-01 -:toc: ----- - -.Document with ToC positioned on the right ----- -= AsciiDoc Writer's Guide -Doc Writer -v1.0, 2013-01-01 -:toc: right ----- - -TIP: The ToC {toc-ref}["title, levels, and positioning"] can be customized. - -== Bibliography - -.References ----- -'The Pragmatic Programmer' <> should be required reading for -all developers. - -[bibliography] -- [[[prag]]] Andy Hunt & Dave Thomas. 'The Pragmatic Programmer: - From Journeyman to Master'. Addison-Wesley. 1999. -- [[[seam]]] Dan Allen. 'Seam in Action'. Manning Publications. - 2008. ----- - -[.result] -==== -'The Pragmatic Programmer' <> should be required reading for -all developers. - -[bibliography] -- [[[prag]]] Andy Hunt & Dave Thomas. 'The Pragmatic Programmer: - From Journeyman to Master'. Addison-Wesley. 1999. -- [[[seam]]] Dan Allen. 'Seam in Action'. Manning Publications. - 2008. -==== - -[[section-footnotes]] -== Footnotes - -.Normal and reusable footnotes ----- -A statement.footnote:[Clarification about this statement.] - -A bold statement.footnoteref:[disclaimer,These opinions are my own.] - -Another bold statement.footenoteref:[disclaimer] ----- - -[.result] -==== -[.unstyled] -|=== -a| -A statement.footnote:[Clarification about this statement.] - -A bold statement.footnoteref:[disclaimer,These opinions are my own.] - -Another bold statement.footenoteref:[disclaimer] -|=== -==== - -== Markdown Compatibility - -IMPORTANT: Markdown compatibility is only available by default in Asciidoctor. -You can configure AsciiDoc (Python) to recognize this syntax by putting https://github.com/asciidoctor/asciidoctor/blob/master/compat/asciidoc.conf[the AsciiDoc compatibility file] from Asciidoctor in the same directory as the document being processed. - -.Markdown-style headings ----- -# Document Title (Level 0) - -## Section Level 1 - -### Section Level 2 - -#### Section Level 3 - -##### Section Level 4 - -###### Section Level 5 ----- - -[.result] -==== -[float] -# Document Title (Level 0) - -[float] -## Section Level 1 - -[float] -### Section Level 2 - -[float] -#### Section Level 3 - -[float] -##### Section Level 4 - -[float] -###### Section Level 5 -==== - -.Fenced code block with syntax highlighting ----- -```ruby -require 'sinatra' - -get '/hi' do - "Hello World!" -end -``` ----- - -[.result] -==== -```ruby -require 'sinatra' - -get '/hi' do - "Hello World!" -end -``` -==== - -.Markdown-style blockquote ----- -> I hold it that a little rebellion now and then is a good thing, -> and as necessary in the political world as storms in the physical. -> -- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11 ----- - -[.result] -==== -> I hold it that a little rebellion now and then is a good thing, -> and as necessary in the political world as storms in the physical. -> -- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11 -==== - -.Markdown-style blockquote with block content ----- -> > What's new? -> -> I've got Markdown in my AsciiDoc! -> -> > Like what? -> -> * Blockquotes -> * Headings -> * Fenced code blocks -> -> > Is there more? -> -> Yep. AsciiDoc and Markdown share a lot of common syntax already. ----- - -[.result] -==== -> > What's new? -> -> I've got Markdown in my AsciiDoc! -> -> > Like what? -> -> * Blockquotes -> * Headings -> * Fenced code blocks -> -> > Is there more? -> -> Yep. AsciiDoc and Markdown share a lot of common syntax already. -==== - -.Markdown-style horizontal rules ----- ---- - -- - - - -*** - -* * * ----- - -[.result] -==== ---- - -- - - - -*** - -* * * -==== - -== User Manual and Help - -To learn more about Asciidoctor and its capabilities, check out the other {docref}[Asciidoctor guides] and its {user-ref}[User Manual]. -Also, don't forget to join the {mailinglist}[Asciidoctor mailing list], where you can ask questions and leave comments. - diff --git a/help/html.html b/help/html.html deleted file mode 100644 index 2456d1f..0000000 --- a/help/html.html +++ /dev/null @@ -1,128 +0,0 @@ - -

This page is having a quick review of all the HTML tags discussed in this tutorial. If you need to know in detail about any tag then refer to HTML Tag List chapter.

-

HTML Basic Syntax:

-
    -
  • HTML Element names and attribute names are not case sensitive.

  • -
  • HTML Documents start with a <!doctype...> statement, followed by a header and a text body all enclosed in <html>...</html>.

  • -
  • HTML Header is enclosed in <head>....</head> tags.

  • -
  • HTML Body is enclosed in <body>....</body> tags.

  • -
  • HTML Comments are written as <!-- A comment -->.

  • -
-

HTML Basic Document:

-
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>Document Title like HTML Tutorial</title>
-</head>
-
-<body>
-   Document Text with other tags will come here.
-</body>
-
-</html>
-
-

Header elements:

-
    -
  • <head> - Opening tag for the head of the document. The following optional tags can be placed inside the head.

  • -
  • <title>...</title> -Document title (not part of the text), recommended maximum length 64 characters.

  • -
  • <link ...> - Relationships for the document as a whole: common attributes are rel, rev, href.

  • -
  • <base href="url"> - Specifies the base URL of the document. This is used when dereferencing relative URLs in the page.

  • -
  • <base href="url" target="..."> - Specifies the base URL of the document. This is used when dereferencing relative URLs in the page. Also specifies the base target frame that all links will default to.

  • -
  • <meta ...> - Embed meta-information as if given by the server: attributes http-equiv, name, content.
    -<meta http-equiv="refresh" content="N" > - Same page will be reloaded automatically after N seconds.
    -<meta http-equiv="refresh" content="N" url="http://www.example.com> - Same other page will refresh automatically after N seconds.
    -<meta http-equiv="expires" content="Wed, 08 Aug 2007 01:21:00 GMT" > - Specifies an expiration date for the page so that it will be reloaded after a certain date.
    -<meta http-equiv="keywords" content="keyword1, keyword2,..." > - Specifies various keywords available on the page and to be used by the search engine.
    -<meta http-equiv="description" content="A short description of the site" > - Specifies small description of the page and to be used by the search engine.
    -

  • -
  • <style type="text/css" href="URL" /> - Specifies a CSS file to be used for the web page.

  • -
  • <script type="text/scripttype" href="URL" /> - Specifies a Javascript of VBscript file to be used for the web page.

  • -
  • <noscript> ... </noscript> - Encloses anything you want displayed by browsers that do not support inline scripts. This goes inside the <script> tags.

  • -
  • </head> - Closing tag for the head of the document.

  • -
-

Body Elements:

-
    -
  • <body>...</body> - Encloses the main body of the document.

  • -
  • <hn>...</hn> - Makes the enclosed text a heading of various sizes where n is any number ranging from 1 to 6, and 1 creates the biggest heading while 6 creates the smallest.

  • -
  • <basefont size="n"> - Sets the default font properties for the entire page.

  • -
  • <isindex attributes> - Displays a text box indicating the presence of a searchable index. Simply adding this tag will not create a searchable page. The server must be set up to support it.

  • -
  • <img src="URL" attributes> - Places an inline image into the document.

  • -
  • <map attributes>...</map> - Specifies a collection of hot spots that define a client-side image map. The <area> tag can be used inside to define the hot spots.

  • -
  • <area attributes>...</area> - Specifies the shape and size of a hot spot to be used in the definition of a client-side image map. Used inside the <map> tag.

  • -
  • <marquee attributes>...</marquee> - Places a scrolling text marquee into the document.

  • -
  • <applet attributes>...</applet> - Inserts a Java applet in the HTML document. Any text placed between the opening and closing <applet> tags will be displayed by browsers that do not support JAVA.

  • -
  • <embed attributes>...</embed> - Inserts an embedded multimedia object, such as a sound file or video, into the page.

  • -
  • <a href="...">...</a> - When used with the HREF attribute, the enclosed text and/or graphic becomes a link to another document or anchor. When used with the NAME attribute, the enclosed text and/or graphic becomes an anchor.

  • -
  • <ol attributes>...</ol> - Puts the enclosed items marked with <li>, in a numbered list.

  • -
  • <ul attributes>...</ul> - Puts the enclosed items marked with <li>, in a bulleted list.

  • -
  • <dl>...</dl> - Creates a definition list. Within this container, <dt> specifies a definition term and <dd> specifies the definition.

  • -
-

Frame Elements:

-
    -
  • <frameset attributes>...</frameset> - Defines a set of frames that will make up the page. The <frame>, and <noframes> tags go inside this. The <frameset> tag is used instead of the <body> tag. You can, however, include a <body> tag inside the <noframes> tags for browsers that do not support frames.

  • -
  • <frame attributes /> - Defines a single frame within a frameset.

  • -
  • <iframe attributes>...</iframe> - Defines a floating frame. Does not need to be placed within a frameset.

  • -
  • <noframes>...</noframes> - Placed inside the <frameset>, anything between the beginning and ending of this tag is viewable only by browsers that do not support frames. This tag is used to create pages that are compatible with older browsers that do not support frames.

  • -
-

Table Elements:

-
    -
  • <table attributes>...</table> -Creates a table that can include any number of rows.

  • -
  • <caption attributes>...</caption> -Specifies the caption of the table.

  • -
  • <tr attributes>...</tr> - Specifies a table row. It can enclose the table heading and table data.

  • -
  • <th attributes>...</th> - Specifies a table heading.

  • -
  • <td attributes>...</td> - Specifies a table data cell.

  • -
  • <colgroup attributes /> - Specifies the properties of one or more columns. This tag generally goes right after the opening <table> tag.

  • -
  • <col attributes /> - Used with the <colgroup> tag, this specifies the properties of one column. This tag overrides any attributes specified in the <colgroup> tag that comes right before it.

  • -
  • <tbody>...</tbody> - Encloses the body of your table. This tag is optional unless you are using the <thead> or <tfoot> tags. It used to separate the rows in the table from those in the header or footer.

  • -
  • <tfoot>...</tfoot> - Encloses the table rows that are to be used as a footer. It is an optional tag and comes right after the ending <tbody> element.

  • -
  • <thead>...</thead> - Encloses the table rows that are to be used as a header. It is an optional tag and comes before the opening <tbody> element.

  • -
-

Form Elements:

-
    -
  • <from attributes>...</from> - Specifies a form. Forms can be used to send user input to the server in the form of NAME/VALUE pairs.

  • -
  • <input attributes /> - Specifies a control or input area for a form, from which a NAME/VALUE pair will be returned to the server. It could be Checkbox, Raidobox, password, text, reset, submit, hidden and image.

  • -
  • <select attributes>...</select> - Creates a drop-down list of items. The list items are defined by the <option> tags placed inside the opening and closing <select> tag.

  • -
  • <option value="..." /> - Specifies an item in the drop down list. Placed within the opening and closing <select> tags. Any text following the <option> tag is what the user will see in the list.

  • -
  • <textarea attributes>...</textarea> - Creates a multi-lined text entry box. Any text placed in between the tags is used as the default text string that is displayed when the page is loaded.

  • -
  • <button attributes>...</button> - allows you to have push buttons on forms that more closely resemble push buttons available in Windows and other applications.

  • -
-

Text Formatting Elements:

-
    -
  • <address>.....< /address> - Encloses the signature file of the author of the page. Text is displayed in italics.

  • -
  • <acronym>.....< /acronym> - indicates an acronym in the text.

  • -
  • <b>...< /b> - Boldfaces the enclosed text.

  • -
  • <big>...< /big> - Makes the enclosed text one size larger.

  • -
  • <blink>.....< /blink> - Makes the enclosed text blink continually.

  • -
  • <blockquote>.....< /blockquote> - Encloses a long quote. Both the left and right margins are indented.

  • -
  • <br> - Inserts a line break.

  • -
  • <center>.....< /center> - Centers the enclosed elements.

  • -
  • <cite>.....< /cite> - Encloses a citation such as the title of a book or paper.

  • -
  • <code>.....< /code> - Encloses a sample of code. The text is rendered in small font.

  • -
  • <comment>.....< /comment> - Encloses a comment. Text inside the tags is ignored unless it contains HTML code.

  • -
  • <del>.....< /del> - To mark the document text that has been deleted since a previous version.

  • -
  • <dfn>.....< /dfn> - Encloses a definition. Text inside the tags is formatted to look like a definition.

  • -
  • <div>...< /div> - Specifies the alignment of the enclosed elements. Can be used to divide a document into sections that are aligned differently.

  • -
  • <em>...< /em> - Emphasis on the enclosed text (Italics).

  • -
  • <font attributes>...< /font> - Sets the font properties for the enclosed text.

  • -
  • <fieldset attributes>...< /fieldset> - Allows you can group related form fields, making your form easier to read and use.

  • -
  • <hr attributes /> - Inserts a horizontal line.

  • -
  • <i>...< /i> - The enclosed text is italics.

  • -
  • <ins>...< /ins> - To mark parts of a document that have been added since the document's last version.

  • -
  • <label>...< /label> - Allows you to lable a tag.

  • -
  • <kbd>...< /kbd> - Specifies text to be entered at the keyboard. Text is rendered as bold and fixed-width.

  • -
  • <p attributes>...< /p> - Designates the enclosed text as a plain paragraph.

  • -
  • <q>...</q> - acts much the same as the <blockquote> tag, but applies to shorter quoted sections, ones that don't need paragraph breaks.

  • -
  • <pre>.....< /pre> - Displays text in fixed-width type without collapsing spaces.

  • -
  • <s>.....< /s> - Displays text with a line through it. The <strike> tag does exactly the same.

  • -
  • <samp>...< /samp> - Indicates sample output from a form or program. Text is rendered in small font.

  • -
  • <small>...< /small> - Makes the enclosed text one size smaller.

  • -
  • <spacer attributes>...< /spacer> - Inserts blocks of spaces into HTML documents.

  • -
  • <strong>...< /strong> - Stronger emphasis on the enclosed text.

  • -
  • <sub>...< /sub> - Renders the enclosed text in subscript.

  • -
  • <sup>...< /sup> - Renders the enclosed text in superscript.

  • -
  • <tt>...< /tt> - The enclosed text is typewriter font.

  • -
  • <u>...< /u> - The enclosed text in underlined.

  • -
  • <var>...< /var> - Specifies a variable. Text is rendered in small fixed-width type.

  • -
  • <wbr> - Causes text enclosed by the NOBR tags to wrap only if necessary.

  • -
diff --git a/help/markdown.md b/help/markdown.md deleted file mode 100644 index 6913cb0..0000000 --- a/help/markdown.md +++ /dev/null @@ -1,307 +0,0 @@ -Markdown: Basics -================ - - - - -Getting the Gist of Markdown's Formatting Syntax ------------------------------------------------- - -This page offers a brief overview of what it's like to use Markdown. -The [syntax page] [s] provides complete, detailed documentation for -every feature, but Markdown should be very easy to pick up simply by -looking at a few examples of it in action. The examples on this page -are written in a before/after style, showing example syntax and the -HTML output produced by Markdown. - -It's also helpful to simply try Markdown out; the [Dingus] [d] is a -web application that allows you type your own Markdown-formatted text -and translate it to XHTML. - -**Note:** This document is itself written using Markdown; you -can [see the source for it by adding '.text' to the URL] [src]. - - [s]: /projects/markdown/syntax "Markdown Syntax" - [d]: /projects/markdown/dingus "Markdown Dingus" - [src]: /projects/markdown/basics.text - - -## Paragraphs, Headers, Blockquotes ## - -A paragraph is simply one or more consecutive lines of text, separated -by one or more blank lines. (A blank line is any line that looks like -a blank line -- a line containing nothing but spaces or tabs is -considered blank.) Normal paragraphs should not be indented with -spaces or tabs. - -Markdown offers two styles of headers: *Setext* and *atx*. -Setext-style headers for `

` and `

` are created by -"underlining" with equal signs (`=`) and hyphens (`-`), respectively. -To create an atx-style header, you put 1-6 hash marks (`#`) at the -beginning of the line -- the number of hashes equals the resulting -HTML header level. - -Blockquotes are indicated using email-style '`>`' angle brackets. - -Markdown: - - A First Level Header - ==================== - - A Second Level Header - --------------------- - - Now is the time for all good men to come to - the aid of their country. This is just a - regular paragraph. - - The quick brown fox jumped over the lazy - dog's back. - - ### Header 3 - - > This is a blockquote. - > - > This is the second paragraph in the blockquote. - > - > ## This is an H2 in a blockquote - - -Output: - -

A First Level Header

- -

A Second Level Header

- -

Now is the time for all good men to come to - the aid of their country. This is just a - regular paragraph.

- -

The quick brown fox jumped over the lazy - dog's back.

- -

Header 3

- -
-

This is a blockquote.

- -

This is the second paragraph in the blockquote.

- -

This is an H2 in a blockquote

-
- - - -### Phrase Emphasis ### - -Markdown uses asterisks and underscores to indicate spans of emphasis. - -Markdown: - - Some of these words *are emphasized*. - Some of these words _are emphasized also_. - - Use two asterisks for **strong emphasis**. - Or, if you prefer, __use two underscores instead__. - -Output: - -

Some of these words are emphasized. - Some of these words are emphasized also.

- -

Use two asterisks for strong emphasis. - Or, if you prefer, use two underscores instead.

- - - -## Lists ## - -Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, -`+`, and `-`) as list markers. These three markers are -interchangable; this: - - * Candy. - * Gum. - * Booze. - -this: - - + Candy. - + Gum. - + Booze. - -and this: - - - Candy. - - Gum. - - Booze. - -all produce the same output: - -
    -
  • Candy.
  • -
  • Gum.
  • -
  • Booze.
  • -
- -Ordered (numbered) lists use regular numbers, followed by periods, as -list markers: - - 1. Red - 2. Green - 3. Blue - -Output: - -
    -
  1. Red
  2. -
  3. Green
  4. -
  5. Blue
  6. -
- -If you put blank lines between items, you'll get `

` tags for the -list item text. You can create multi-paragraph list items by indenting -the paragraphs by 4 spaces or 1 tab: - - * A list item. - - With multiple paragraphs. - - * Another item in the list. - -Output: - -

    -
  • A list item.

    -

    With multiple paragraphs.

  • -
  • Another item in the list.

  • -
- - - -### Links ### - -Markdown supports two styles for creating links: *inline* and -*reference*. With both styles, you use square brackets to delimit the -text you want to turn into a link. - -Inline-style links use parentheses immediately after the link text. -For example: - - This is an [example link](http://example.com/). - -Output: - -

This is an - example link.

- -Optionally, you may include a title attribute in the parentheses: - - This is an [example link](http://example.com/ "With a Title"). - -Output: - -

This is an - example link.

- -Reference-style links allow you to refer to your links by names, which -you define elsewhere in your document: - - I get 10 times more traffic from [Google][1] than from - [Yahoo][2] or [MSN][3]. - - [1]: http://google.com/ "Google" - [2]: http://search.yahoo.com/ "Yahoo Search" - [3]: http://search.msn.com/ "MSN Search" - -Output: - -

I get 10 times more traffic from Google than from Yahoo or MSN.

- -The title attribute is optional. Link names may contain letters, -numbers and spaces, but are *not* case sensitive: - - I start my morning with a cup of coffee and - [The New York Times][NY Times]. - - [ny times]: http://www.nytimes.com/ - -Output: - -

I start my morning with a cup of coffee and - The New York Times.

- - -### Images ### - -Image syntax is very much like link syntax. - -Inline (titles are optional): - - ![alt text](/path/to/img.jpg "Title") - -Reference-style: - - ![alt text][id] - - [id]: /path/to/img.jpg "Title" - -Both of the above examples produce the same output: - - alt text - - - -### Code ### - -In a regular paragraph, you can create code span by wrapping text in -backtick quotes. Any ampersands (`&`) and angle brackets (`<` or -`>`) will automatically be translated into HTML entities. This makes -it easy to use Markdown to write about HTML example code: - - I strongly recommend against using any `` tags. - - I wish SmartyPants used named entities like `—` - instead of decimal-encoded entites like `—`. - -Output: - -

I strongly recommend against using any - <blink> tags.

- -

I wish SmartyPants used named entities like - &mdash; instead of decimal-encoded - entites like &#8212;.

- - -To specify an entire block of pre-formatted code, indent every line of -the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, -and `>` characters will be escaped automatically. - -Markdown: - - If you want your page to validate under XHTML 1.0 Strict, - you've got to put paragraph tags in your blockquotes: - -
-

For example.

-
- -Output: - -

If you want your page to validate under XHTML 1.0 Strict, - you've got to put paragraph tags in your blockquotes:

- -
<blockquote>
-        <p>For example.</p>
-    </blockquote>
-    
diff --git a/help/textile.textile b/help/textile.textile deleted file mode 100644 index 499b442..0000000 --- a/help/textile.textile +++ /dev/null @@ -1,157 +0,0 @@ -Textile syntax examples - -This is not an exhaustive listing of Textile's syntax. For a list of all available options in Textile 2, see - - a full reference and example list of Textile v2.0, - PHP-Textile v3.5.5 documentation with real-time conversion. - -Emphasized text - -_emphasized_ (i.e., italics) - -*strongly emphasized* (i.e., boldface) - -Personal Strengths - -* An item in a bulleted (unordered) list -* Another item in a bulleted list -** Second Level -** Second Level Items -*** Third level - -# An item in an enumerated (ordered) list xxxxxxx -# Another item in an enumerated list yyyyyy -## Another level in an enumerated list vvvvvvvv -# Enumerated list, starting by number eight -# List item No. 9 - -Some text paragraph - -#7 Continuing list item, numbered as 10 -# Item 11 - -* This is a bullet -*# this is the start of an enumerated list within a bulleted list -*# this is another item list of an enumerated list within a bulleted list -**# this is another level of an enumerated list within a bulleted list -* This is another bullet - -; Definition list term -: Definition list data item -: Another data item - -- coffee := Hot _and_ black -- tea := Also hot, but a little less black -- milk := Nourishing beverage for baby cows. -Cold drink that goes great with cookies. =: - -Tables - -A pipe character must be at the beginning and end of every row. - -|_. column name1(aaa) |_. column name2 |_. column name3 | -| laura | 111 | Cell 3 | -| Manuel | Vasquez | Cell 3 | - -In this example, the "|_." sequence causes the entry to be in bold. There must be no space after the initial pipe character. -Code - -Generic example: - -@your code here@ - -Blocks of code: - -bc.. puts "This style (notice the double dot) handles blank lines." -puts "This is the second line of code." - -puts "This is the fourth." - -End the block with p. or with another block tag. - -Or alternatively you can use this syntax for small blocks: - -bc. puts "This style (notice the single dot) stops at the first blank line." -puts "This is the second line of code." - -This is not code. - -Headings - -You must leave a blank line after each heading. - -h1(#id). An HTML first-level heading - -h2. An HTML second-level heading - -h3. An HTML third-level heading - -h4. An HTML fourth-level heading - -h5. An HTML fifth-level heading - -h6. An HTML sixth-level heading - -Blockquotes - -bq. This text will be enclosed in an HTML blockquote element. - -Notes - -Text with a link to some reference[1] - -fn1. Footnote explanation - -Text with a link to some reference[#mylabel] - -notelist. - -note#mylabel Explanation as an auto-numbered endnote - -Links - -also: Hyperlinks - -"(classname)link text(title tooltip)":link_address - -Email links - - "(classname)link text(title tooltip)":mailto:someone@example.com - -Images - -!image url! - -Formatting help table - -This table summarizes the available textile markers -Textile markers Textile Visual result -*bold text* bold text -_italic text_ italic text -*_bold italic text_* bold italic text --strikethrough text- strikethrough text -*-bold strikethrough text-* bold strikethrough text -*_-bold italic strikethrough text-_* bold italic strikethrough text -+underlined text+ underlined text -*+bold underlined text+* bold underlined text -_+italic underlined text+_ italic underlined text -*_+bold italic underlined text+_* bold italic underlined text -*_-+bold italic strikethrough underlined text+-_* bold italic strikethrough underlined text -%{font-size:18pt}font size% font size -%{color:red}text in red% text in red -# Chapter 1 -Chapter 1 -* bulleted list -** 2-level - - bulleted list - 2-level - -|Table | with two columns | -|and two | rows | -Table with two columns -and two rows -"Link to Wikipedia":http://www.wikipedia.org Link to Wikipedia -!http://commons.wikimedia.org/wiki/Special:Filepath/Wikipedia-logo-en.png! Wikipedia-logo-en.png -Brand ^TM^ Brand TM -Text ~subscript~ Text subscript \ No newline at end of file diff --git a/html/asciidoctor.html b/html/asciidoctor.html deleted file mode 100644 index 7ea46b2..0000000 --- a/html/asciidoctor.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - diff --git a/html/markdown.html b/html/markdown.html deleted file mode 100644 index b4c9567..0000000 --- a/html/markdown.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - diff --git a/html/textile.html b/html/textile.html deleted file mode 100644 index 7353d9d..0000000 --- a/html/textile.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/icons/README.md b/icons/README.md deleted file mode 100644 index a8abdda..0000000 --- a/icons/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Icons sources: - -* [question1.png](http://widepixel.deviantart.com/) -* [list-add/remove](http://tango-project.org/) diff --git a/icons/list-add.png b/icons/list-add.png deleted file mode 100644 index 2acdd8f..0000000 Binary files a/icons/list-add.png and /dev/null differ diff --git a/icons/list-remove.png b/icons/list-remove.png deleted file mode 100644 index c5524f7..0000000 Binary files a/icons/list-remove.png and /dev/null differ diff --git a/icons/question1.png b/icons/question1.png deleted file mode 100644 index 724ab4e..0000000 Binary files a/icons/question1.png and /dev/null differ diff --git a/js/README.md b/js/README.md deleted file mode 100644 index d9fbfe4..0000000 --- a/js/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Used libs: - -* [Markdown](https://github.com/chjj/marked) -* [Asciidoctor](https://github.com/asciidoctor/asciidoctor.js) -* [Textile](https://github.com/borgar/textile-js) diff --git a/js/asciidoctor-all.js b/js/asciidoctor-all.js deleted file mode 100644 index 2f50845..0000000 --- a/js/asciidoctor-all.js +++ /dev/null @@ -1,32552 +0,0 @@ -(function(undefined) { - if (typeof(this.Opal) !== 'undefined') { - console.warn('Opal already loaded. Loading twice can cause troubles, please fix your setup.'); - return this.Opal; - } - - // The Opal object that is exposed globally - var Opal = this.Opal = {}; - - // All bridged classes - keep track to donate methods from Object - var bridges = {}; - - // TopScope is used for inheriting constants from the top scope - var TopScope = function(){}; - - // Opal just acts as the top scope - TopScope.prototype = Opal; - - // To inherit scopes - Opal.constructor = TopScope; - - // List top scope constants - Opal.constants = []; - - // This is a useful reference to global object inside ruby files - Opal.global = this; - - // Minify common function calls - var $hasOwn = Opal.hasOwnProperty; - var $slice = Opal.slice = Array.prototype.slice; - - // Nil object id is always 4 - var nil_id = 4; - - // Generates even sequential numbers greater than 4 - // (nil_id) to serve as unique ids for ruby objects - var unique_id = nil_id; - - // Return next unique id - Opal.uid = function() { - unique_id += 2; - return unique_id; - }; - - // Table holds all class variables - Opal.cvars = {}; - - // Globals table - Opal.gvars = {}; - - // Exit function, this should be replaced by platform specific implementation - // (See nodejs and phantom for examples) - Opal.exit = function(status) { if (Opal.gvars.DEBUG) console.log('Exited with status '+status); }; - - // keeps track of exceptions for $! - Opal.exceptions = []; - - /** - Get a constant on the given scope. Every class and module in Opal has a - scope used to store, and inherit, constants. For example, the top level - `Object` in ruby has a scope accessible as `Opal.Object.$$scope`. - - To get the `Array` class using this scope, you could use: - - Opal.Object.$$scope.get("Array") - - If a constant with the given name cannot be found, then a dispatch to the - class/module's `#const_method` is called, which by default will raise an - error. - - @param [String] name the name of the constant to lookup - @returns [RubyObject] - */ - Opal.get = function(name) { - var constant = this[name]; - - if (constant == null) { - return this.base.$const_get(name); - } - - return constant; - }; - - /* - * Create a new constants scope for the given class with the given - * base. Constants are looked up through their parents, so the base - * scope will be the outer scope of the new klass. - */ - function create_scope(base, klass, id) { - var const_alloc = function() {}; - var const_scope = const_alloc.prototype = new base.constructor(); - - klass.$$scope = const_scope; - klass.$$base_module = base.base; - - const_scope.base = klass; - const_scope.constructor = const_alloc; - const_scope.constants = []; - - if (id) { - Opal.cdecl(base, id, klass) - } - } - - Opal.create_scope = create_scope; - - /* - * A `class Foo; end` expression in ruby is compiled to call this runtime - * method which either returns an existing class of the given name, or creates - * a new class in the given `base` scope. - * - * If a constant with the given name exists, then we check to make sure that - * it is a class and also that the superclasses match. If either of these - * fail, then we raise a `TypeError`. Note, superklass may be null if one was - * not specified in the ruby code. - * - * We pass a constructor to this method of the form `function ClassName() {}` - * simply so that classes show up with nicely formatted names inside debuggers - * in the web browser (or node/sprockets). - * - * The `base` is the current `self` value where the class is being created - * from. We use this to get the scope for where the class should be created. - * If `base` is an object (not a class/module), we simple get its class and - * use that as the base instead. - * - * @param [Object] base where the class is being created - * @param [Class] superklass superclass of the new class (may be null) - * @param [String] id the name of the class to be created - * @param [Function] constructor function to use as constructor - * @return [Class] new or existing ruby class - */ - Opal.klass = function(base, superklass, id, constructor) { - // If base is an object, use its class - if (!base.$$is_class && !base.$$is_module) { - base = base.$$class; - } - - var klass = base.$$scope[id], - bridged = typeof(superklass) === 'function'; - - // If the class exists in the scope, then we must use that - if (klass && klass.$$orig_scope === base.$$scope) { - // Make sure the existing constant is a class, or raise error - if (!klass.$$is_class) { - throw Opal.TypeError.$new(id + " is not a class"); - } - - // Make sure existing class has same superclass - if (superklass && klass.$$super !== superklass) { - throw Opal.TypeError.$new("superclass mismatch for class " + id); - } - - return klass; - } - - // Not specifying a superclass means we can assume it to be Object - if (superklass === null) { - superklass = ObjectClass; - } - - // if class doesnt exist, create a new one with given superclass - klass = bridged ? - boot_class_object(ObjectClass, superklass) : - boot_class(superklass, constructor); - - // name class using base (e.g. Foo or Foo::Baz) - klass.$$name = id; - - // mark the object as a class - klass.$$is_class = true; - - // every class gets its own constant scope, inherited from current scope - create_scope(base.$$scope, klass, id); - - // Name new class directly onto current scope (Opal.Foo.Baz = klass) - base[id] = base.$$scope[id] = klass; - - if (bridged) { - Opal.bridge(klass, superklass); - } - else { - // Copy all parent constants to child, unless parent is Object - if (superklass !== ObjectClass && superklass !== BasicObjectClass) { - donate_constants(superklass, klass); - } - - // call .inherited() hook with new class on the superclass - if (superklass.$inherited) { - superklass.$inherited(klass); - } - } - - return klass; - }; - - // Create generic class with given superclass. - function boot_class(superklass, constructor) { - var alloc = boot_class_alloc(null, constructor, superklass) - - return boot_class_object(superklass, alloc); - } - - // Make `boot_class` available to the JS-API - Opal.boot = boot_class; - - /* - * The class object itself (as in `Class.new`) - * - * @param [(Opal) Class] superklass Another class object (as in `Class.new`) - * @param [constructor] alloc The constructor that holds the prototype - * that will be used for instances of the - * newly constructed class. - */ - function boot_class_object(superklass, alloc) { - var singleton_class = function() {}; - singleton_class.prototype = superklass.constructor.prototype; - - function OpalClass() {} - OpalClass.prototype = new singleton_class(); - - var klass = new OpalClass(); - - setup_module_or_class_object(klass, OpalClass, superklass, alloc.prototype); - - // @property $$alloc This is the constructor of instances of the current - // class. Its prototype will be used for method lookup - klass.$$alloc = alloc; - - // @property $$proto.$$class Make available to instances a reference to the - // class they belong to. - klass.$$proto.$$class = klass; - - return klass; - } - - /* - * Adds common/required properties to a module or class object - * (as in `Module.new` / `Class.new`) - * - * @param module The module or class that needs to be prepared - * - * @param constructor The constructor of the module or class itself, - * usually it's already assigned by using `new`. Some - * ipothesis on why it's needed can be found below. - * - * @param superklass The superclass of the class/module object, for modules - * is `Module` (of `ModuleClass` in JS context) - * - * @param prototype The prototype on which the class/module methods will - * be stored. - */ - function setup_module_or_class_object(module, constructor, superklass, prototype) { - // @property $$id Each class is assigned a unique `id` that helps - // comparation and implementation of `#object_id` - module.$$id = Opal.uid(); - - // @property $$proto This is the prototype on which methods will be defined - module.$$proto = prototype; - - // @property constructor keeps a ref to the constructor, but apparently the - // constructor is already set on: - // - // `var module = new constructor` is called. - // - // Maybe there are some browsers not abiding (IE6?) - module.constructor = constructor; - - if (superklass === ModuleClass) { - // @property $$is_module Clearly mark this as a module - module.$$is_module = true; - module.$$class = ModuleClass; - } - else { - // @property $$is_class Clearly mark this as a class - module.$$is_class = true; - module.$$class = ClassClass; - } - - // @property $$super the superclass, doesn't get changed by module inclusions - module.$$super = superklass; - - // @property $$parent direct parent class or module - // starts with the superclass, after module inclusion is - // the last included module - module.$$parent = superklass; - - // @property $$inc included modules - module.$$inc = []; - } - - /** - Define new module (or return existing module). The given `base` is basically - the current `self` value the `module` statement was defined in. If this is - a ruby module or class, then it is used, otherwise if the base is a ruby - object then that objects real ruby class is used (e.g. if the base is the - main object, then the top level `Object` class is used as the base). - - If a module of the given name is already defined in the base, then that - instance is just returned. - - If there is a class of the given name in the base, then an error is - generated instead (cannot have a class and module of same name in same base). - - Otherwise, a new module is created in the base with the given name, and that - new instance is returned back (to be referenced at runtime). - - @param [RubyModule or Class] base class or module this definition is inside - @param [String] id the name of the new (or existing) module - @returns [RubyModule] - */ - Opal.module = function(base, id) { - var module; - - if (!base.$$is_class && !base.$$is_module) { - base = base.$$class; - } - - if ($hasOwn.call(base.$$scope, id)) { - module = base.$$scope[id]; - - if (!module.$$is_module && module !== ObjectClass) { - throw Opal.TypeError.$new(id + " is not a module"); - } - } - else { - module = boot_module_object(); - - // name module using base (e.g. Foo or Foo::Baz) - module.$$name = id; - - // mark the object as a module - module.$$is_module = true; - - // initialize dependency tracking - module.$$dep = []; - - create_scope(base.$$scope, module, id); - - // Name new module directly onto current scope (Opal.Foo.Baz = module) - base[id] = base.$$scope[id] = module; - } - - return module; - }; - - /* - * Internal function to create a new module instance. This simply sets up - * the prototype hierarchy and method tables. - */ - function boot_module_object() { - var mtor = function() {}; - mtor.prototype = ModuleClass.constructor.prototype; - - function module_constructor() {} - module_constructor.prototype = new mtor(); - - var module = new module_constructor(); - var module_prototype = {}; - - setup_module_or_class_object(module, module_constructor, ModuleClass, module_prototype); - - return module; - } - - /** - Return the singleton class for the passed object. - - If the given object alredy has a singleton class, then it will be stored on - the object as the `$$meta` property. If this exists, then it is simply - returned back. - - Otherwise, a new singleton object for the class or object is created, set on - the object at `$$meta` for future use, and then returned. - - @param [RubyObject] object the ruby object - @returns [RubyClass] the singleton class for object - */ - Opal.get_singleton_class = function(object) { - if (object.$$meta) { - return object.$$meta; - } - - if (object.$$is_class || object.$$is_module) { - return build_class_singleton_class(object); - } - - return build_object_singleton_class(object); - }; - - /** - Build the singleton class for an existing class. - - NOTE: Actually in MRI a class' singleton class inherits from its - superclass' singleton class which in turn inherits from Class. - - @param [RubyClass] klass - @returns [RubyClass] - */ - function build_class_singleton_class(klass) { - var meta = new Opal.Class.$$alloc(); - - meta.$$class = Opal.Class; - meta.$$proto = klass.constructor.prototype; - - meta.$$is_singleton = true; - meta.$$singleton_of = klass; - meta.$$inc = []; - meta.$$scope = klass.$$scope; - - return klass.$$meta = meta; - } - - /** - Build the singleton class for a Ruby (non class) Object. - - @param [RubyObject] object - @returns [RubyClass] - */ - function build_object_singleton_class(object) { - var orig_class = object.$$class, - class_id = "#>"; - - var Singleton = function () {}; - var meta = Opal.boot(orig_class, Singleton); - meta.$$name = class_id; - - meta.$$proto = object; - meta.$$class = orig_class.$$class; - meta.$$scope = orig_class.$$scope; - meta.$$parent = orig_class; - meta.$$is_singleton = true; - meta.$$singleton_of = object; - - return object.$$meta = meta; - } - - /** - The actual inclusion of a module into a class. - - ## Class `$$parent` and `iclass` - - To handle `super` calls, every class has a `$$parent`. This parent is - used to resolve the next class for a super call. A normal class would - have this point to its superclass. However, if a class includes a module - then this would need to take into account the module. The module would - also have to then point its `$$parent` to the actual superclass. We - cannot modify modules like this, because it might be included in more - then one class. To fix this, we actually insert an `iclass` as the class' - `$$parent` which can then point to the superclass. The `iclass` acts as - a proxy to the actual module, so the `super` chain can then search it for - the required method. - - @param [RubyModule] module the module to include - @param [RubyClass] klass the target class to include module into - @returns [null] - */ - function bridge() { - var target, donator, from, name, body, ancestors, id, methods, method, i, ancestor, bridged, length; - - if (arguments.length === 4) { - target = arguments[0]; - from = arguments[1]; - name = arguments[2]; - body = arguments[3]; - ancestors = target.$$bridge.$ancestors(); - - // order important here, we have to check for method presence in - // ancestors from the bridged class to the last ancestor - for (i = 0, length = ancestors.length; i < length; i++) { - ancestor = ancestors[i]; - - if ($hasOwn.call(ancestor.$$proto, name) && - ancestor.$$proto[name] && - !ancestor.$$proto[name].$$donated && - !ancestor.$$proto[name].$$stub && - ancestor !== from) { - break; - } - - if (ancestor === from) { - target.prototype[name] = body - break; - } - } - } - else { - target = arguments[0]; - donator = arguments[1]; - - if (typeof(target) === "function") { - id = donator.$__id__(); - methods = donator.$instance_methods(); - - for (i = methods.length - 1; i >= 0; i--) { - method = '$' + methods[i]; - - bridge(target, donator, method, donator.$$proto[method]); - } - - if (!bridges[id]) { - bridges[id] = []; - } - - bridges[id].push(target); - } - else { - bridged = bridges[target.$__id__()]; - - if (bridged) { - for (i = bridged.length - 1; i >= 0; i--) { - bridge(bridged[i], donator); - } - - bridges[donator.$__id__()] = bridged.slice(); - } - } - } - } - - /** - The actual inclusion of a module into a class. - - ## Class `$$parent` and `iclass` - - To handle `super` calls, every class has a `$$parent`. This parent is - used to resolve the next class for a super call. A normal class would - have this point to its superclass. However, if a class includes a module - then this would need to take into account the module. The module would - also have to then point its `$$parent` to the actual superclass. We - cannot modify modules like this, because it might be included in more - then one class. To fix this, we actually insert an `iclass` as the class' - `$$parent` which can then point to the superclass. The `iclass` acts as - a proxy to the actual module, so the `super` chain can then search it for - the required method. - - @param [RubyModule] module the module to include - @param [RubyClass] klass the target class to include module into - @returns [null] - */ - Opal.append_features = function(module, klass) { - var iclass, donator, prototype, methods, id, i; - - // check if this module is already included in the class - for (i = klass.$$inc.length - 1; i >= 0; i--) { - if (klass.$$inc[i] === module) { - return; - } - } - - klass.$$inc.push(module); - module.$$dep.push(klass); - bridge(klass, module); - - // iclass - iclass = { - $$name: module.$$name, - $$proto: module.$$proto, - $$parent: klass.$$parent, - $$module: module, - $$iclass: true - }; - - klass.$$parent = iclass; - - donator = module.$$proto; - prototype = klass.$$proto; - methods = module.$instance_methods(); - - for (i = methods.length - 1; i >= 0; i--) { - id = '$' + methods[i]; - - // if the target class already has a method of the same name defined - // and that method was NOT donated, then it must be a method defined - // by the class so we do not want to override it - if ( prototype.hasOwnProperty(id) && - !prototype[id].$$donated && - !prototype[id].$$stub) { - continue; - } - - prototype[id] = donator[id]; - prototype[id].$$donated = module; - } - - donate_constants(module, klass); - }; - - // Boot a base class (makes instances). - function boot_class_alloc(id, constructor, superklass) { - if (superklass) { - var ctor = function() {}; - ctor.prototype = superklass.$$proto || superklass.prototype; - - if (id) { - ctor.displayName = id; - } - - constructor.prototype = new ctor(); - } - - constructor.prototype.constructor = constructor; - - return constructor; - } - - /* - * Builds the class object for core classes: - * - make the class object have a singleton class - * - make the singleton class inherit from its parent singleton class - * - * @param id [String] the name of the class - * @param alloc [Function] the constructor for the core class instances - * @param superclass [Class alloc] the constructor of the superclass - */ - function boot_core_class_object(id, alloc, superclass) { - var superclass_constructor = function() {}; - superclass_constructor.prototype = superclass.prototype; - - var singleton_class = function() {}; - singleton_class.prototype = new superclass_constructor(); - - singleton_class.displayName = "#"; - - // the singleton_class acts as the class object constructor - var klass = new singleton_class(); - - setup_module_or_class_object(klass, singleton_class, superclass, alloc.prototype); - - klass.$$alloc = alloc; - klass.$$name = id; - - // Give all instances a ref to their class - alloc.prototype.$$class = klass; - - Opal[id] = klass; - Opal.constants.push(id); - - return klass; - } - - /* - * For performance, some core Ruby classes are toll-free bridged to their - * native JavaScript counterparts (e.g. a Ruby Array is a JavaScript Array). - * - * This method is used to setup a native constructor (e.g. Array), to have - * its prototype act like a normal Ruby class. Firstly, a new Ruby class is - * created using the native constructor so that its prototype is set as the - * target for th new class. Note: all bridged classes are set to inherit - * from Object. - * - * Example: - * - * Opal.bridge(self, Function); - * - * @param [Class] klass the Ruby class to bridge - * @param [Function] constructor native JavaScript constructor to use - * @return [Class] returns the passed Ruby class - */ - Opal.bridge = function(klass, constructor) { - if (constructor.$$bridge) { - throw Opal.ArgumentError.$new("already bridged"); - } - - Opal.stub_subscribers.push(constructor.prototype); - - constructor.prototype.$$class = klass; - constructor.$$bridge = klass; - - var ancestors = klass.$ancestors(); - - // order important here, we have to bridge from the last ancestor to the - // bridged class - for (var i = ancestors.length - 1; i >= 0; i--) { - bridge(constructor, ancestors[i]); - } - - for (var name in BasicObject.prototype) { - var method = BasicObject.prototype[method]; - - if (method && method.$$stub && !(name in constructor.prototype)) { - constructor.prototype[name] = method; - } - } - - return klass; - } - - - /* - * constant assign - */ - Opal.casgn = function(base_module, name, value) { - function update(klass, name) { - klass.$$name = name; - - for (name in klass.$$scope) { - var value = klass.$$scope[name]; - - if (value.$$name === nil && (value.$$is_class || value.$$is_module)) { - update(value, name) - } - } - } - - var scope = base_module.$$scope; - - if (value.$$is_class || value.$$is_module) { - // only checking ObjectClass prevents setting a const on an anonymous class that has a superclass that's not Object - if (value.$$is_class || value.$$base_module === ObjectClass) { - value.$$base_module = base_module; - } - - if (value.$$name === nil && value.$$base_module.$$name !== nil) { - update(value, name); - } - } - - scope.constants.push(name); - return scope[name] = value; - }; - - /* - * constant decl - */ - Opal.cdecl = function(base_scope, name, value) { - if ((value.$$is_class || value.$$is_module) && value.$$orig_scope == null) { - value.$$name = name; - value.$$orig_scope = base_scope; - base_scope.constructor[name] = value; - } - - base_scope.constants.push(name); - return base_scope[name] = value; - }; - - /* - * When a source module is included into the target module, we must also copy - * its constants to the target. - */ - function donate_constants(source_mod, target_mod) { - var source_constants = source_mod.$$scope.constants, - target_scope = target_mod.$$scope, - target_constants = target_scope.constants; - - for (var i = 0, length = source_constants.length; i < length; i++) { - target_constants.push(source_constants[i]); - target_scope[source_constants[i]] = source_mod.$$scope[source_constants[i]]; - } - }; - - /* - * Donate methods for a module. - */ - function donate(module, jsid) { - var included_in = module.$$dep, - body = module.$$proto[jsid], - i, length, includee, dest, current, - klass_includees, j, jj, current_owner_index, module_index; - - if (!included_in) { - return; - } - - for (i = 0, length = included_in.length; i < length; i++) { - includee = included_in[i]; - dest = includee.$$proto; - current = dest[jsid]; - - if (dest.hasOwnProperty(jsid) && !current.$$donated && !current.$$stub) { - // target class has already defined the same method name - do nothing - } - else if (dest.hasOwnProperty(jsid) && !current.$$stub) { - // target class includes another module that has defined this method - klass_includees = includee.$$inc; - - for (j = 0, jj = klass_includees.length; j < jj; j++) { - if (klass_includees[j] === current.$$donated) { - current_owner_index = j; - } - if (klass_includees[j] === module) { - module_index = j; - } - } - - // only redefine method on class if the module was included AFTER - // the module which defined the current method body. Also make sure - // a module can overwrite a method it defined before - if (current_owner_index <= module_index) { - dest[jsid] = body; - dest[jsid].$$donated = module; - } - } - else { - // neither a class, or module included by class, has defined method - dest[jsid] = body; - dest[jsid].$$donated = module; - } - - if (includee.$$dep) { - donate(includee, jsid); - } - } - }; - - /* - * Methods stubs are used to facilitate method_missing in opal. A stub is a - * placeholder function which just calls `method_missing` on the receiver. - * If no method with the given name is actually defined on an object, then it - * is obvious to say that the stub will be called instead, and then in turn - * method_missing will be called. - * - * When a file in ruby gets compiled to javascript, it includes a call to - * this function which adds stubs for every method name in the compiled file. - * It should then be safe to assume that method_missing will work for any - * method call detected. - * - * Method stubs are added to the BasicObject prototype, which every other - * ruby object inherits, so all objects should handle method missing. A stub - * is only added if the given property name (method name) is not already - * defined. - * - * Note: all ruby methods have a `$` prefix in javascript, so all stubs will - * have this prefix as well (to make this method more performant). - * - * Opal.add_stubs(["$foo", "$bar", "$baz="]); - * - * All stub functions will have a private `$$stub` property set to true so - * that other internal methods can detect if a method is just a stub or not. - * `Kernel#respond_to?` uses this property to detect a methods presence. - * - * @param [Array] stubs an array of method stubs to add - */ - Opal.add_stubs = function(stubs) { - var subscriber, subscribers = Opal.stub_subscribers, - i, ilength = stubs.length, - j, jlength = subscribers.length, - method_name, stub; - - for (i = 0; i < ilength; i++) { - method_name = stubs[i]; - stub = stub_for(method_name); - - for (j = 0; j < jlength; j++) { - subscriber = subscribers[j]; - - if (!(method_name in subscriber)) { - subscriber[method_name] = stub; - } - } - } - }; - - /* - * Keep a list of prototypes that want method_missing stubs to be added. - * - * @default [Prototype List] BasicObject.prototype - */ - Opal.stub_subscribers = [BasicObject.prototype]; - - /* - * Add a method_missing stub function to the given prototype for the - * given name. - * - * @param [Prototype] prototype the target prototype - * @param [String] stub stub name to add (e.g. "$foo") - */ - function add_stub_for(prototype, stub) { - var method_missing_stub = stub_for(stub); - prototype[stub] = method_missing_stub; - } - - /* - * Generate the method_missing stub for a given method name. - * - * @param [String] method_name The js-name of the method to stub (e.g. "$foo") - */ - function stub_for(method_name) { - function method_missing_stub() { - // Copy any given block onto the method_missing dispatcher - this.$method_missing.$$p = method_missing_stub.$$p; - - // Set block property to null ready for the next call (stop false-positives) - method_missing_stub.$$p = null; - - // call method missing with correct args (remove '$' prefix on method name) - return this.$method_missing.apply(this, [method_name.slice(1)].concat($slice.call(arguments))); - } - - method_missing_stub.$$stub = true; - - return method_missing_stub; - } - - // Expose for other parts of Opal to use - Opal.add_stub_for = add_stub_for; - - // Arity count error dispatcher - Opal.ac = function(actual, expected, object, meth) { - var inspect = ''; - if (object.$$is_class || object.$$is_module) { - inspect += object.$$name + '.'; - } - else { - inspect += object.$$class.$$name + '#'; - } - inspect += meth; - - throw Opal.ArgumentError.$new('[' + inspect + '] wrong number of arguments(' + actual + ' for ' + expected + ')'); - }; - - // Super dispatcher - Opal.find_super_dispatcher = function(obj, jsid, current_func, iter, defs) { - var dispatcher; - - if (defs) { - if (obj.$$is_class || obj.$$is_module) { - dispatcher = defs.$$super; - } - else { - dispatcher = obj.$$class.$$proto; - } - } - else { - if (obj.$$is_class || obj.$$is_module) { - dispatcher = obj.$$super; - } - else { - dispatcher = find_obj_super_dispatcher(obj, jsid, current_func); - } - } - - dispatcher = dispatcher['$' + jsid]; - dispatcher.$$p = iter; - - return dispatcher; - }; - - // Iter dispatcher for super in a block - Opal.find_iter_super_dispatcher = function(obj, jsid, current_func, iter, defs) { - if (current_func.$$def) { - return Opal.find_super_dispatcher(obj, current_func.$$jsid, current_func, iter, defs); - } - else { - return Opal.find_super_dispatcher(obj, jsid, current_func, iter, defs); - } - }; - - function find_obj_super_dispatcher(obj, jsid, current_func) { - var klass = obj.$$meta || obj.$$class; - jsid = '$' + jsid; - - while (klass) { - if (klass.$$proto[jsid] === current_func) { - // ok - break; - } - - klass = klass.$$parent; - } - - // if we arent in a class, we couldnt find current? - if (!klass) { - throw new Error("could not find current class for super()"); - } - - klass = klass.$$parent; - - // else, let's find the next one - while (klass) { - var working = klass.$$proto[jsid]; - - if (working && working !== current_func) { - // ok - break; - } - - klass = klass.$$parent; - } - - return klass.$$proto; - }; - - /* - * Used to return as an expression. Sometimes, we can't simply return from - * a javascript function as if we were a method, as the return is used as - * an expression, or even inside a block which must "return" to the outer - * method. This helper simply throws an error which is then caught by the - * method. This approach is expensive, so it is only used when absolutely - * needed. - */ - Opal.ret = function(val) { - Opal.returner.$v = val; - throw Opal.returner; - }; - - // handles yield calls for 1 yielded arg - Opal.yield1 = function(block, arg) { - if (typeof(block) !== "function") { - throw Opal.LocalJumpError.$new("no block given"); - } - - if (block.length > 1 && arg.$$is_array) { - return block.apply(null, arg); - } - else { - return block(arg); - } - }; - - // handles yield for > 1 yielded arg - Opal.yieldX = function(block, args) { - if (typeof(block) !== "function") { - throw Opal.LocalJumpError.$new("no block given"); - } - - if (block.length > 1 && args.length === 1) { - if (args[0].$$is_array) { - return block.apply(null, args[0]); - } - } - - if (!args.$$is_array) { - args = $slice.call(args); - } - - return block.apply(null, args); - }; - - // Finds the corresponding exception match in candidates. Each candidate can - // be a value, or an array of values. Returns null if not found. - Opal.rescue = function(exception, candidates) { - for (var i = 0; i < candidates.length; i++) { - var candidate = candidates[i]; - - if (candidate.$$is_array) { - var result = Opal.rescue(exception, candidate); - - if (result) { - return result; - } - } - else if (candidate['$==='](exception)) { - return candidate; - } - } - - return null; - }; - - Opal.is_a = function(object, klass) { - if (object.$$meta === klass) { - return true; - } - - var search = object.$$class; - - while (search) { - if (search === klass) { - return true; - } - - for (var i = 0, length = search.$$inc.length; i < length; i++) { - if (search.$$inc[i] === klass) { - return true; - } - } - - search = search.$$super; - } - - return false; - }; - - // Helper to convert the given object to an array - Opal.to_ary = function(value) { - if (value.$$is_array) { - return value; - } - else if (value.$to_ary && !value.$to_ary.$$stub) { - return value.$to_ary(); - } - else { - return [value]; - } - }; - - Opal.to_a = function(value) { - if (value == null || value === nil) { - return []; - } - else if (value.$to_a && !value.$to_a.$$stub) { - return value.$to_a(); - } - else { - return [value]; - } - }; - - /** - Used to get a list of rest keyword arguments. Method takes the given - keyword args, i.e. the hash literal passed to the method containing all - keyword arguemnts passed to method, as well as the used args which are - the names of required and optional arguments defined. This method then - just returns all key/value pairs which have not been used, in a new - hash literal. - - @param given_args [Hash] all kwargs given to method - @param used_args [Object] all keys used as named kwargs - @return [Hash] - */ - Opal.kwrestargs = function(given_args, used_args) { - var keys = [], - map = {}, - key = null, - given_map = given_args.smap; - - for (key in given_map) { - if (!used_args[key]) { - keys.push(key); - map[key] = given_map[key]; - } - } - - return Opal.hash2(keys, map); - }; - - /* - * Call a ruby method on a ruby object with some arguments: - * - * var my_array = [1, 2, 3, 4] - * Opal.send(my_array, 'length') # => 4 - * Opal.send(my_array, 'reverse!') # => [4, 3, 2, 1] - * - * A missing method will be forwarded to the object via - * method_missing. - * - * The result of either call with be returned. - * - * @param [Object] recv the ruby object - * @param [String] mid ruby method to call - */ - Opal.send = function(recv, mid) { - var args = $slice.call(arguments, 2), - func = recv['$' + mid]; - - if (func) { - return func.apply(recv, args); - } - - return recv.$method_missing.apply(recv, [mid].concat(args)); - }; - - Opal.block_send = function(recv, mid, block) { - var args = $slice.call(arguments, 3), - func = recv['$' + mid]; - - if (func) { - func.$$p = block; - return func.apply(recv, args); - } - - return recv.$method_missing.apply(recv, [mid].concat(args)); - }; - - /** - Used to define methods on an object. This is a helper method, used by the - compiled source to define methods on special case objects when the compiler - can not determine the destination object, or the object is a Module - instance. This can get called by `Module#define_method` as well. - - ## Modules - - Any method defined on a module will come through this runtime helper. - The method is added to the module body, and the owner of the method is - set to be the module itself. This is used later when choosing which - method should show on a class if more than 1 included modules define - the same method. Finally, if the module is in `module_function` mode, - then the method is also defined onto the module itself. - - ## Classes - - This helper will only be called for classes when a method is being - defined indirectly; either through `Module#define_method`, or by a - literal `def` method inside an `instance_eval` or `class_eval` body. In - either case, the method is simply added to the class' prototype. A special - exception exists for `BasicObject` and `Object`. These two classes are - special because they are used in toll-free bridged classes. In each of - these two cases, extra work is required to define the methods on toll-free - bridged class' prototypes as well. - - ## Objects - - If a simple ruby object is the object, then the method is simply just - defined on the object as a singleton method. This would be the case when - a method is defined inside an `instance_eval` block. - - @param [RubyObject or Class] obj the actual obj to define method for - @param [String] jsid the javascript friendly method name (e.g. '$foo') - @param [Function] body the literal javascript function used as method - @returns [null] - */ - Opal.defn = function(obj, jsid, body) { - obj.$$proto[jsid] = body; - - if (obj.$$is_module) { - donate(obj, jsid); - - if (obj.$$module_function) { - Opal.defs(obj, jsid, body); - } - } - - if (obj.$__id__ && !obj.$__id__.$$stub) { - var bridged = bridges[obj.$__id__()]; - - if (bridged) { - for (var i = bridged.length - 1; i >= 0; i--) { - bridge(bridged[i], obj, jsid, body); - } - } - } - - if (obj.$method_added && !obj.$method_added.$$stub) { - obj.$method_added(jsid.substr(1)); - } - - var singleton_of = obj.$$singleton_of; - if (singleton_of && singleton_of.$singleton_method_added && !singleton_of.$singleton_method_added.$$stub) { - singleton_of.$singleton_method_added(jsid.substr(1)); - } - - return nil; - }; - - /* - * Define a singleton method on the given object. - */ - Opal.defs = function(obj, jsid, body) { - Opal.defn(Opal.get_singleton_class(obj), jsid, body) - }; - - Opal.def = function(obj, jsid, body) { - // if instance_eval is invoked on a module/class, it sets inst_eval_mod - if (!obj.$$eval && (obj.$$is_class || obj.$$is_module)) { - Opal.defn(obj, jsid, body); - } - else { - Opal.defs(obj, jsid, body); - } - }; - - /* - * Called from #remove_method. - */ - Opal.rdef = function(obj, jsid) { - // TODO: remove from bridges as well - - if (!$hasOwn.call(obj.$$proto, jsid)) { - throw Opal.NameError.$new("method '" + jsid.substr(1) + "' not defined in " + obj.$name()); - } - - delete obj.$$proto[jsid]; - - if (obj.$$is_singleton) { - if (obj.$$proto.$singleton_method_removed && !obj.$$proto.$singleton_method_removed.$$stub) { - obj.$$proto.$singleton_method_removed(jsid.substr(1)); - } - } - else { - if (obj.$method_removed && !obj.$method_removed.$$stub) { - obj.$method_removed(jsid.substr(1)); - } - } - }; - - /* - * Called from #undef_method. - */ - Opal.udef = function(obj, jsid) { - if (!obj.$$proto[jsid] || obj.$$proto[jsid].$$stub) { - throw Opal.NameError.$new("method '" + jsid.substr(1) + "' not defined in " + obj.$name()); - } - - Opal.add_stub_for(obj.$$proto, jsid); - - if (obj.$$is_singleton) { - if (obj.$$proto.$singleton_method_undefined && !obj.$$proto.$singleton_method_undefined.$$stub) { - obj.$$proto.$singleton_method_undefined(jsid.substr(1)); - } - } - else { - if (obj.$method_undefined && !obj.$method_undefined.$$stub) { - obj.$method_undefined(jsid.substr(1)); - } - } - }; - - // This black magic is required to avoid clashes of internal special fields, - // like $$donated. - function wrap(body) { - function alias() { - body.$$p = alias.$$p; - body.$$s = alias.$$s; - - try { - return body.apply(this, $slice.call(arguments)); - } - finally { - alias.$$s = null; - alias.$$p = null; - } - } - - alias.$$target = body; - alias.$$arity = body.length; - - return alias; - } - - Opal.alias = function(obj, name, old) { - var id = '$' + name, - old_id = '$' + old, - body = obj.$$proto['$' + old]; - - // instance_eval is being run on a class/module, so that need to alias class methods - if (obj.$$eval) { - return Opal.alias(Opal.get_singleton_class(obj), name, old); - } - - if (typeof(body) !== "function" || body.$$stub) { - var ancestor = obj.$$super; - - while (typeof(body) !== "function" && ancestor) { - body = ancestor[old_id]; - ancestor = ancestor.$$super; - } - - if (typeof(body) !== "function" || body.$$stub) { - throw Opal.NameError.$new("undefined method `" + old + "' for class `" + obj.$name() + "'") - } - } - - Opal.defn(obj, id, wrap(body)); - - return obj; - }; - - Opal.alias_native = function(obj, name, native_name) { - var id = '$' + name, - body = obj.$$proto[native_name]; - - if (typeof(body) !== "function" || body.$$stub) { - throw Opal.NameError.$new("undefined native method `" + native_name + "' for class `" + obj.$name() + "'") - } - - Opal.defn(obj, id, wrap(body)); - - return obj; - }; - - Opal.hash_init = function (hash) { - hash.map = {}; - hash.smap = {}; - hash.keys = []; - }; - - Opal.hash_clone = function (from_hash, to_hash) { - to_hash.none = from_hash.none; - to_hash.proc = from_hash.proc; - - for (var i = 0, keys = from_hash.keys, length = keys.length, key, value; i < length; i++) { - key = from_hash.keys[i]; - - if (key.$$is_string) { - value = from_hash.smap[key]; - } else { - value = key.value; - key = key.key; - } - - Opal.hash_put(to_hash, key, value); - } - }; - - Opal.hash_put = function (hash, key, value) { - if (key.$$is_string) { - if (!hash.smap.hasOwnProperty(key)) { - hash.keys.push(key); - } - hash.smap[key] = value; - return; - } - - var key_hash = key.$hash(), bucket, last_bucket; - - if (!hash.map.hasOwnProperty(key_hash)) { - bucket = {key: key, key_hash: key_hash, value: value}; - hash.keys.push(bucket); - hash.map[key_hash] = bucket; - return; - } - - bucket = hash.map[key_hash]; - - while (bucket) { - if (key === bucket.key || key['$eql?'](bucket.key)) { - last_bucket = undefined; - bucket.value = value; - break; - } - last_bucket = bucket; - bucket = bucket.next; - } - - if (last_bucket) { - bucket = {key: key, key_hash: key_hash, value: value}; - hash.keys.push(bucket); - last_bucket.next = bucket; - } - }; - - Opal.hash_get = function (hash, key) { - if (key.$$is_string) { - if (hash.smap.hasOwnProperty(key)) { - return hash.smap[key]; - } - return; - } - - var key_hash = key.$hash(), bucket; - - if (hash.map.hasOwnProperty(key_hash)) { - bucket = hash.map[key_hash]; - - while (bucket) { - if (key === bucket.key || key['$eql?'](bucket.key)) { - return bucket.value; - } - bucket = bucket.next; - } - } - }; - - Opal.hash_delete = function (hash, key) { - var i, keys = hash.keys, length = keys.length, value; - - if (key.$$is_string) { - if (!hash.smap.hasOwnProperty(key)) { - return; - } - - for (i = 0; i < length; i++) { - if (keys[i] === key) { - keys.splice(i, 1); - break; - } - } - - value = hash.smap[key]; - delete hash.smap[key]; - return value; - } - - var key_hash = key.$hash(); - - if (!hash.map.hasOwnProperty(key_hash)) { - return; - } - - var bucket = hash.map[key_hash], last_bucket; - - while (bucket) { - if (key === bucket.key || key['$eql?'](bucket.key)) { - value = bucket.value; - - for (i = 0; i < length; i++) { - if (keys[i] === bucket) { - keys.splice(i, 1); - break; - } - } - - if (last_bucket && bucket.next) { - last_bucket.next = bucket.next; - } - else if (last_bucket) { - delete last_bucket.next; - } - else if (bucket.next) { - hash.map[key_hash] = bucket.next; - } - else { - delete hash.map[key_hash]; - } - - return value; - } - last_bucket = bucket; - bucket = bucket.next; - } - }; - - Opal.hash_rehash = function (hash) { - for (var i = 0, length = hash.keys.length, key_hash, bucket, last_bucket; i < length; i++) { - - if (hash.keys[i].$$is_string) { - continue; - } - - key_hash = hash.keys[i].key.$hash(); - - if (key_hash === hash.keys[i].key_hash) { - continue; - } - - bucket = hash.map[hash.keys[i].key_hash]; - last_bucket = undefined; - - while (bucket) { - if (bucket === hash.keys[i]) { - if (last_bucket && bucket.next) { - last_bucket.next = bucket.next; - } - else if (last_bucket) { - delete last_bucket.next; - } - else if (bucket.next) { - hash.map[hash.keys[i].key_hash] = bucket.next; - } - else { - delete hash.map[hash.keys[i].key_hash]; - } - break; - } - last_bucket = bucket; - bucket = bucket.next; - } - - hash.keys[i].key_hash = key_hash; - - if (!hash.map.hasOwnProperty(key_hash)) { - hash.map[key_hash] = hash.keys[i]; - continue; - } - - bucket = hash.map[key_hash]; - last_bucket = undefined; - - while (bucket) { - if (bucket === hash.keys[i]) { - last_bucket = undefined; - break; - } - last_bucket = bucket; - bucket = bucket.next; - } - - if (last_bucket) { - last_bucket.next = hash.keys[i]; - } - } - }; - - Opal.hash = function() { - var arguments_length = arguments.length, args, hash, i, length, key, value; - - if (arguments_length === 1 && arguments[0].$$is_hash) { - return arguments[0]; - } - - hash = new Opal.Hash.$$alloc(); - Opal.hash_init(hash); - - if (arguments_length === 1 && arguments[0].$$is_array) { - args = arguments[0]; - length = args.length; - - for (i = 0; i < length; i++) { - if (args[i].length !== 2) { - throw Opal.ArgumentError.$new("value not of length 2: " + args[i].$inspect()); - } - - key = args[i][0]; - value = args[i][1]; - - Opal.hash_put(hash, key, value); - } - - return hash; - } - - if (arguments_length === 1) { - args = arguments[0]; - for (key in args) { - if (args.hasOwnProperty(key)) { - value = args[key]; - - Opal.hash_put(hash, key, value); - } - } - - return hash; - } - - if (arguments_length % 2 !== 0) { - throw Opal.ArgumentError.$new("odd number of arguments for Hash"); - } - - for (i = 0; i < arguments_length; i += 2) { - key = arguments[i]; - value = arguments[i + 1]; - - Opal.hash_put(hash, key, value); - } - - return hash; - }; - - /* - * hash2 is a faster creator for hashes that just use symbols and - * strings as keys. The map and keys array can be constructed at - * compile time, so they are just added here by the constructor - * function - */ - Opal.hash2 = function(keys, smap) { - var hash = new Opal.Hash.$$alloc(); - - hash.map = {}; - hash.keys = keys; - hash.smap = smap; - - return hash; - }; - - /* - * Create a new range instance with first and last values, and whether the - * range excludes the last value. - */ - Opal.range = function(first, last, exc) { - var range = new Opal.Range.$$alloc(); - range.begin = first; - range.end = last; - range.exclude = exc; - - return range; - }; - - Opal.ivar = function(name) { - if (name === "constructor" || - name === "__proto__" || - name === "__parent__" || - name === "__noSuchMethod__" || - name === "__count__") - { - return name + "$"; - } - - if (name === "hasOwnProperty" || - name === "valueOf") - { - return name + "$"; - } - - return name; - }; - - // Require system - // -------------- - (function(Opal) { - var loaded_features = ['corelib/runtime'], - require_table = {'corelib/runtime': true}, - modules = {}; - - var current_dir = '.'; - - function normalize(path) { - var parts, part, new_parts = [], SEPARATOR = '/'; - - if (current_dir !== '.') { - path = current_dir.replace(/\/*$/, '/') + path; - } - - path = path.replace(/\.(rb|opal|js)$/, ''); - parts = path.split(SEPARATOR); - - for (var i = 0, ii = parts.length; i < ii; i++) { - part = parts[i]; - if (part === '') continue; - (part === '..') ? new_parts.pop() : new_parts.push(part) - } - - return new_parts.join(SEPARATOR); - } - - function loaded(paths) { - var i, l, path; - - for (i = 0, l = paths.length; i < l; i++) { - path = normalize(paths[i]); - - if (require_table[path]) { - return; - } - - loaded_features.push(path); - require_table[path] = true; - } - } - - function load(path) { - path = normalize(path); - - loaded([path]); - - var module = modules[path]; - - if (module) { - module(Opal); - } - else { - var severity = Opal.dynamic_require_severity || 'warning'; - var message = 'cannot load such file -- ' + path; - - if (severity === "error") { - Opal.LoadError ? Opal.LoadError.$new(message) : function(){throw message}(); - } - else if (severity === "warning") { - console.warn('WARNING: LoadError: ' + message); - } - } - - return true; - } - - function require(path) { - path = normalize(path); - - if (require_table[path]) { - return false; - } - - return load(path); - } - - Opal.modules = modules; - Opal.loaded_features = loaded_features; - Opal.loaded = loaded; - - Opal.load = load; - Opal.require = require; - })(Opal); - - // Initialization - // -------------- - - // The actual class for BasicObject - var BasicObjectClass; - - // The actual Object class - var ObjectClass; - - // The actual Module class - var ModuleClass; - - // The actual Class class - var ClassClass; - - // Constructor for instances of BasicObject - function BasicObject(){} - - // Constructor for instances of Object - function Object(){} - - // Constructor for instances of Class - function Class(){} - - // Constructor for instances of Module - function Module(){} - - // Constructor for instances of NilClass (nil) - function NilClass(){} - - // Constructors for *instances* of core objects - boot_class_alloc('BasicObject', BasicObject); - boot_class_alloc('Object', Object, BasicObject); - boot_class_alloc('Module', Module, Object); - boot_class_alloc('Class', Class, Module); - - // Constructors for *classes* of core objects - BasicObjectClass = boot_core_class_object('BasicObject', BasicObject, Class); - ObjectClass = boot_core_class_object('Object', Object, BasicObjectClass.constructor); - ModuleClass = boot_core_class_object('Module', Module, ObjectClass.constructor); - ClassClass = boot_core_class_object('Class', Class, ModuleClass.constructor); - - // Fix booted classes to use their metaclass - BasicObjectClass.$$class = ClassClass; - ObjectClass.$$class = ClassClass; - ModuleClass.$$class = ClassClass; - ClassClass.$$class = ClassClass; - - // Fix superclasses of booted classes - BasicObjectClass.$$super = null; - ObjectClass.$$super = BasicObjectClass; - ModuleClass.$$super = ObjectClass; - ClassClass.$$super = ModuleClass; - - BasicObjectClass.$$parent = null; - ObjectClass.$$parent = BasicObjectClass; - ModuleClass.$$parent = ObjectClass; - ClassClass.$$parent = ModuleClass; - - Opal.base = ObjectClass; - BasicObjectClass.$$scope = ObjectClass.$$scope = Opal; - BasicObjectClass.$$orig_scope = ObjectClass.$$orig_scope = Opal; - - ModuleClass.$$scope = ObjectClass.$$scope; - ModuleClass.$$orig_scope = ObjectClass.$$orig_scope; - ClassClass.$$scope = ObjectClass.$$scope; - ClassClass.$$orig_scope = ObjectClass.$$orig_scope; - - ObjectClass.$$proto.toString = function() { - return this.$to_s(); - }; - - ObjectClass.$$proto.$require = Opal.require; - - Opal.top = new ObjectClass.$$alloc(); - - // Nil - Opal.klass(ObjectClass, ObjectClass, 'NilClass', NilClass); - var nil = Opal.nil = new NilClass(); - nil.$$id = nil_id; - nil.call = nil.apply = function() { throw Opal.LocalJumpError.$new('no block given'); }; - - Opal.breaker = new Error('unexpected break'); - Opal.returner = new Error('unexpected return'); - - TypeError.$$super = Error; -}).call(this); - -if (typeof(global) !== 'undefined') { - global.Opal = this.Opal; - Opal.global = global; -} -if (typeof(window) !== 'undefined') { - window.Opal = this.Opal; - Opal.global = window; -} -; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/helpers"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.add_stubs(['$new', '$class', '$===', '$respond_to?', '$raise', '$type_error', '$__send__', '$coerce_to', '$nil?', '$<=>', '$inspect', '$coerce_to!']); - return (function($base) { - var self = $module($base, 'Opal'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defs(self, '$bridge', function(klass, constructor) { - var self = this; - - return Opal.bridge(klass, constructor); - }); - - Opal.defs(self, '$type_error', function(object, type, method, coerced) { - var $a, $b, self = this; - - if (method == null) { - method = nil - } - if (coerced == null) { - coerced = nil - } - if ((($a = (($b = method !== false && method !== nil) ? coerced : method)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('TypeError').$new("can't convert " + (object.$class()) + " into " + (type) + " (" + (object.$class()) + "#" + (method) + " gives " + (coerced.$class())) - } else { - return $scope.get('TypeError').$new("no implicit conversion of " + (object.$class()) + " into " + (type)) - }; - }); - - Opal.defs(self, '$coerce_to', function(object, type, method) { - var $a, self = this; - - if ((($a = type['$==='](object)) !== nil && (!$a.$$is_boolean || $a == true))) { - return object}; - if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise(self.$type_error(object, type)) - }; - return object.$__send__(method); - }); - - Opal.defs(self, '$coerce_to!', function(object, type, method) { - var $a, self = this, coerced = nil; - - coerced = self.$coerce_to(object, type, method); - if ((($a = type['$==='](coerced)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise(self.$type_error(object, type, method, coerced)) - }; - return coerced; - }); - - Opal.defs(self, '$coerce_to?', function(object, type, method) { - var $a, self = this, coerced = nil; - - if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return nil - }; - coerced = self.$coerce_to(object, type, method); - if ((($a = coerced['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - if ((($a = type['$==='](coerced)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise(self.$type_error(object, type, method, coerced)) - }; - return coerced; - }); - - Opal.defs(self, '$try_convert', function(object, type, method) { - var $a, self = this; - - if ((($a = type['$==='](object)) !== nil && (!$a.$$is_boolean || $a == true))) { - return object}; - if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) { - return object.$__send__(method) - } else { - return nil - }; - }); - - Opal.defs(self, '$compare', function(a, b) { - var $a, self = this, compare = nil; - - compare = a['$<=>'](b); - if ((($a = compare === nil) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "comparison of " + (a.$class()) + " with " + (b.$class()) + " failed")}; - return compare; - }); - - Opal.defs(self, '$destructure', function(args) { - var self = this; - - - if (args.length == 1) { - return args[0]; - } - else if (args.$$is_array) { - return args; - } - else { - return $slice.call(args); - } - - }); - - Opal.defs(self, '$respond_to?', function(obj, method) { - var self = this; - - - if (obj == null || !obj.$$class) { - return false; - } - - return obj['$respond_to?'](method); - }); - - Opal.defs(self, '$inspect', function(obj) { - var self = this; - - - if (obj === undefined) { - return "undefined"; - } - else if (obj === null) { - return "null"; - } - else if (!obj.$$class) { - return obj.toString(); - } - else { - return obj.$inspect(); - } - - }); - - Opal.defs(self, '$instance_variable_name!', function(name) { - var $a, self = this; - - name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str"); - if ((($a = /^@[a-zA-Z_][a-zA-Z0-9_]*?$/.test(name)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("'" + (name) + "' is not allowed as an instance variable name", name)) - }; - return name; - }); - })($scope.base) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/module"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$equal?', '$<', '$attr_reader', '$attr_writer', '$coerce_to!', '$raise', '$new', '$=~', '$inject', '$const_get', '$split', '$const_missing', '$to_str', '$===', '$to_proc', '$lambda', '$bind', '$call', '$class', '$append_features', '$included', '$name', '$to_s', '$__id__']); - return (function($base, $super) { - function $Module(){}; - var self = $Module = $klass($base, $super, 'Module', $Module); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_3, TMP_5, TMP_6; - - Opal.defs(self, '$new', TMP_1 = function() { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - TMP_1.$$p = null; - - function AnonModule(){} - var klass = Opal.boot(Opal.Module, AnonModule); - klass.$$name = nil; - klass.$$class = Opal.Module; - klass.$$dep = [] - klass.$$is_module = true; - klass.$$proto = {}; - - // inherit scope from parent - Opal.create_scope(Opal.Module.$$scope, klass); - - if (block !== nil) { - var block_self = block.$$s; - block.$$s = null; - block.call(klass); - block.$$s = block_self; - } - - return klass; - - }); - - Opal.defn(self, '$===', function(object) { - var $a, self = this; - - if ((($a = object == null) !== nil && (!$a.$$is_boolean || $a == true))) { - return false}; - return Opal.is_a(object, self); - }); - - Opal.defn(self, '$<', function(other) { - var self = this; - - - var working = self; - - if (working === other) { - return false; - } - - while (working) { - if (working === other) { - return true; - } - - working = working.$$parent; - } - - return false; - - }); - - Opal.defn(self, '$<=', function(other) { - var $a, self = this; - - return ((($a = self['$equal?'](other)) !== false && $a !== nil) ? $a : $rb_lt(self, other)); - }); - - Opal.defn(self, '$alias_method', function(newname, oldname) { - var self = this; - - Opal.alias(self, newname, oldname); - return self; - }); - - Opal.defn(self, '$alias_native', function(mid, jsid) { - var self = this; - - if (jsid == null) { - jsid = mid - } - Opal.alias_native(self, mid, jsid); - return self; - }); - - Opal.defn(self, '$ancestors', function() { - var self = this; - - - var parent = self, - result = []; - - while (parent) { - result.push(parent); - for (var i=0; i < parent.$$inc.length; i++) { - result = result.concat(parent.$$inc[i].$ancestors()); - } - - parent = parent.$$is_class ? parent.$$super : null; - } - - return result; - - }); - - Opal.defn(self, '$append_features', function(klass) { - var self = this; - - Opal.append_features(self, klass); - return self; - }); - - Opal.defn(self, '$attr_accessor', function() { - var $a, $b, self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var names = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - names[arg_index] = arguments[arg_index + 0]; - } - ($a = self).$attr_reader.apply($a, Opal.to_a(names)); - return ($b = self).$attr_writer.apply($b, Opal.to_a(names)); - }); - - Opal.alias(self, 'attr', 'attr_accessor'); - - Opal.defn(self, '$attr_reader', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var names = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - names[arg_index] = arguments[arg_index + 0]; - } - - var proto = self.$$proto; - - for (var i = names.length - 1; i >= 0; i--) { - var name = names[i], - id = '$' + name, - ivar = Opal.ivar(name); - - // the closure here is needed because name will change at the next - // cycle, I wish we could use let. - var body = (function(ivar) { - return function() { - if (this[ivar] == null) { - return nil; - } - else { - return this[ivar]; - } - }; - })(ivar); - - // initialize the instance variable as nil - proto[ivar] = nil; - - if (self.$$is_singleton) { - proto.constructor.prototype[id] = body; - } - else { - Opal.defn(self, id, body); - } - } - - return nil; - }); - - Opal.defn(self, '$attr_writer', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var names = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - names[arg_index] = arguments[arg_index + 0]; - } - - var proto = self.$$proto; - - for (var i = names.length - 1; i >= 0; i--) { - var name = names[i], - id = '$' + name + '=', - ivar = Opal.ivar(name); - - // the closure here is needed because name will change at the next - // cycle, I wish we could use let. - var body = (function(ivar){ - return function(value) { - return this[ivar] = value; - } - })(ivar); - - // initialize the instance variable as nil - proto[ivar] = nil; - - if (self.$$is_singleton) { - proto.constructor.prototype[id] = body; - } - else { - Opal.defn(self, id, body); - } - } - - return nil; - }); - - Opal.defn(self, '$autoload', function(const$, path) { - var self = this; - - - var autoloaders; - - if (!(autoloaders = self.$$autoload)) { - autoloaders = self.$$autoload = {}; - } - - autoloaders[const$] = path; - return nil; - ; - }); - - Opal.defn(self, '$class_variable_get', function(name) { - var $a, self = this; - - name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str"); - if ((($a = name.length < 3 || name.slice(0,2) !== '@@') !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('NameError').$new("class vars should start with @@", name))}; - - var value = Opal.cvars[name.slice(2)]; - (function() {if ((($a = value == null) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('NameError').$new("uninitialized class variable @@a in", name)) - } else { - return nil - }; return nil; })() - return value; - - }); - - Opal.defn(self, '$class_variable_set', function(name, value) { - var $a, self = this; - - name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str"); - if ((($a = name.length < 3 || name.slice(0,2) !== '@@') !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('NameError'))}; - - Opal.cvars[name.slice(2)] = value; - return value; - - }); - - Opal.defn(self, '$constants', function() { - var self = this; - - return self.$$scope.constants.slice(0); - }); - - Opal.defn(self, '$const_defined?', function(name, inherit) { - var $a, self = this; - - if (inherit == null) { - inherit = true - } - if ((($a = name['$=~'](/^[A-Z]\w*$/)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("wrong constant name " + (name), name)) - }; - - var scopes = [self.$$scope]; - - if (inherit || self === Opal.Object) { - var parent = self.$$super; - - while (parent !== Opal.BasicObject) { - scopes.push(parent.$$scope); - - parent = parent.$$super; - } - } - - for (var i = 0, length = scopes.length; i < length; i++) { - if (scopes[i].hasOwnProperty(name)) { - return true; - } - } - - return false; - - }); - - Opal.defn(self, '$const_get', function(name, inherit) { - var $a, $b, TMP_2, self = this; - - if (inherit == null) { - inherit = true - } - if ((($a = name.indexOf('::') != -1 && name != '::') !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = ($b = name.$split("::")).$inject, $a.$$p = (TMP_2 = function(o, c){var self = TMP_2.$$s || this; -if (o == null) o = nil;if (c == null) c = nil; - return o.$const_get(c)}, TMP_2.$$s = self, TMP_2), $a).call($b, self)}; - if ((($a = /^[A-Z]\w*$/.test(name)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("wrong constant name " + (name), name)) - }; - - var scopes = [self.$$scope]; - - if (inherit || self == Opal.Object) { - var parent = self.$$super; - - while (parent !== Opal.BasicObject) { - scopes.push(parent.$$scope); - - parent = parent.$$super; - } - } - - for (var i = 0, length = scopes.length; i < length; i++) { - if (scopes[i].hasOwnProperty(name)) { - return scopes[i][name]; - } - } - - return self.$const_missing(name); - - }); - - Opal.defn(self, '$const_missing', function(name) { - var self = this; - - - if (self.$$autoload) { - var file = self.$$autoload[name]; - - if (file) { - self.$require(file); - - return self.$const_get(name); - } - } - - return self.$raise($scope.get('NameError').$new("uninitialized constant " + (self) + "::" + (name), name)); - }); - - Opal.defn(self, '$const_set', function(name, value) { - var $a, self = this; - - if ((($a = name['$=~'](/^[A-Z]\w*$/)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("wrong constant name " + (name), name)) - }; - try { - name = name.$to_str() - } catch ($err) {if (true) { - try { - self.$raise($scope.get('TypeError'), "conversion with #to_str failed") - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - Opal.casgn(self, name, value); - return value; - }); - - Opal.defn(self, '$define_method', TMP_3 = function(name, method) { - var $a, $b, $c, TMP_4, self = this, $iter = TMP_3.$$p, block = $iter || nil, $case = nil; - - TMP_3.$$p = null; - if ((($a = method === undefined && block === nil) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "tried to create a Proc object without a block")}; - ((($a = block) !== false && $a !== nil) ? $a : block = (function() {$case = method;if ($scope.get('Proc')['$===']($case)) {return method}else if ($scope.get('Method')['$===']($case)) {return method.$to_proc().$$unbound;}else if ($scope.get('UnboundMethod')['$===']($case)) {return ($b = ($c = self).$lambda, $b.$$p = (TMP_4 = function(args){var self = TMP_4.$$s || this, $a, bound = nil; -args = $slice.call(arguments, 0); - bound = method.$bind(self); - return ($a = bound).$call.apply($a, Opal.to_a(args));}, TMP_4.$$s = self, TMP_4), $b).call($c)}else {return self.$raise($scope.get('TypeError'), "wrong argument type " + (block.$class()) + " (expected Proc/Method)")}})()); - - var id = '$' + name; - - block.$$jsid = name; - block.$$s = null; - block.$$def = block; - - Opal.defn(self, id, block); - - return name; - - }); - - Opal.defn(self, '$remove_method', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var names = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - names[arg_index] = arguments[arg_index + 0]; - } - - for (var i = 0, length = names.length; i < length; i++) { - Opal.rdef(self, "$" + names[i]); - } - - return self; - }); - - Opal.defn(self, '$singleton_class?', function() { - var self = this; - - return !!self.$$is_singleton; - }); - - Opal.defn(self, '$include', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var mods = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - mods[arg_index] = arguments[arg_index + 0]; - } - - for (var i = mods.length - 1; i >= 0; i--) { - var mod = mods[i]; - - if (mod === self) { - continue; - } - - (mod).$append_features(self); - (mod).$included(self); - } - - return self; - }); - - Opal.defn(self, '$include?', function(mod) { - var self = this; - - - for (var cls = self; cls; cls = cls.$$super) { - for (var i = 0; i != cls.$$inc.length; i++) { - var mod2 = cls.$$inc[i]; - if (mod === mod2) { - return true; - } - } - } - return false; - - }); - - Opal.defn(self, '$instance_method', function(name) { - var self = this; - - - var meth = self.$$proto['$' + name]; - - if (!meth || meth.$$stub) { - self.$raise($scope.get('NameError').$new("undefined method `" + (name) + "' for class `" + (self.$name()) + "'", name)); - } - - return $scope.get('UnboundMethod').$new(self, meth, name); - - }); - - Opal.defn(self, '$instance_methods', function(include_super) { - var self = this; - - if (include_super == null) { - include_super = true - } - - var methods = [], - proto = self.$$proto; - - for (var prop in proto) { - if (prop.charAt(0) !== '$') { - continue; - } - - if (typeof(proto[prop]) !== "function") { - continue; - } - - if (proto[prop].$$stub) { - continue; - } - - if (!self.$$is_module) { - if (self !== Opal.BasicObject && proto[prop] === Opal.BasicObject.$$proto[prop]) { - continue; - } - - if (!include_super && !proto.hasOwnProperty(prop)) { - continue; - } - - if (!include_super && proto[prop].$$donated) { - continue; - } - } - - methods.push(prop.substr(1)); - } - - return methods; - - }); - - Opal.defn(self, '$included', function(mod) { - var self = this; - - return nil; - }); - - Opal.defn(self, '$extended', function(mod) { - var self = this; - - return nil; - }); - - Opal.defn(self, '$method_added', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$method_removed', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$method_undefined', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$module_eval', TMP_5 = function() { - var self = this, $iter = TMP_5.$$p, block = $iter || nil; - - TMP_5.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "no block given") - }; - - var old = block.$$s, - result; - - block.$$s = null; - result = block.call(self); - block.$$s = old; - - return result; - - }); - - Opal.alias(self, 'class_eval', 'module_eval'); - - Opal.defn(self, '$module_exec', TMP_6 = function() { - var self = this, $iter = TMP_6.$$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_6.$$p = null; - - if (block === nil) { - self.$raise($scope.get('LocalJumpError'), "no block given") - } - - var block_self = block.$$s, result; - - block.$$s = null; - result = block.apply(self, args); - block.$$s = block_self; - - return result; - ; - }); - - Opal.alias(self, 'class_exec', 'module_exec'); - - Opal.defn(self, '$method_defined?', function(method) { - var self = this; - - - var body = self.$$proto['$' + method]; - return (!!body) && !body.$$stub; - - }); - - Opal.defn(self, '$module_function', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var methods = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - methods[arg_index] = arguments[arg_index + 0]; - } - - if (methods.length === 0) { - self.$$module_function = true; - } - else { - for (var i = 0, length = methods.length; i < length; i++) { - var meth = methods[i], - id = '$' + meth, - func = self.$$proto[id]; - - Opal.defs(self, id, func); - } - } - - return self; - - }); - - Opal.defn(self, '$name', function() { - var self = this; - - - if (self.$$full_name) { - return self.$$full_name; - } - - var result = [], base = self; - - while (base) { - if (base.$$name === nil) { - return result.length === 0 ? nil : result.join('::'); - } - - result.unshift(base.$$name); - - base = base.$$base_module; - - if (base === Opal.Object) { - break; - } - } - - if (result.length === 0) { - return nil; - } - - return self.$$full_name = result.join('::'); - - }); - - Opal.defn(self, '$remove_class_variable', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$remove_const', function(name) { - var self = this; - - - var old = self.$$scope[name]; - delete self.$$scope[name]; - return old; - - }); - - Opal.defn(self, '$to_s', function() { - var $a, self = this; - - return ((($a = Opal.Module.$name.call(self)) !== false && $a !== nil) ? $a : "#<" + (self.$$is_module ? 'Module' : 'Class') + ":0x" + (self.$__id__().$to_s(16)) + ">"); - }); - - return (Opal.defn(self, '$undef_method', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var names = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - names[arg_index] = arguments[arg_index + 0]; - } - - for (var i = 0, length = names.length; i < length; i++) { - Opal.udef(self, "$" + names[i]); - } - - return self; - }), nil) && 'undef_method'; - })($scope.base, null) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/class"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$raise', '$allocate']); - self.$require("corelib/module"); - return (function($base, $super) { - function $Class(){}; - var self = $Class = $klass($base, $super, 'Class', $Class); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2; - - Opal.defs(self, '$new', TMP_1 = function(sup) { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - if (sup == null) { - sup = $scope.get('Object') - } - TMP_1.$$p = null; - - if (!sup.$$is_class) { - self.$raise($scope.get('TypeError'), "superclass must be a Class"); - } - - function AnonClass(){}; - var klass = Opal.boot(sup, AnonClass) - klass.$$name = nil; - klass.$$parent = sup; - klass.$$is_class = true; - - // inherit scope from parent - Opal.create_scope(sup.$$scope, klass); - - sup.$inherited(klass); - - if (block !== nil) { - var block_self = block.$$s; - block.$$s = null; - block.call(klass); - block.$$s = block_self; - } - - return klass; - ; - }); - - Opal.defn(self, '$allocate', function() { - var self = this; - - - var obj = new self.$$alloc(); - obj.$$id = Opal.uid(); - return obj; - - }); - - Opal.defn(self, '$inherited', function(cls) { - var self = this; - - return nil; - }); - - Opal.defn(self, '$new', TMP_2 = function() { - var self = this, $iter = TMP_2.$$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_2.$$p = null; - - var obj = self.$allocate(); - - obj.$initialize.$$p = block; - obj.$initialize.apply(obj, args); - return obj; - ; - }); - - return (Opal.defn(self, '$superclass', function() { - var self = this; - - return self.$$super || nil; - }), nil) && 'superclass'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/basic_object"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$==', '$!', '$raise', '$new', '$inspect']); - return (function($base, $super) { - function $BasicObject(){}; - var self = $BasicObject = $klass($base, $super, 'BasicObject', $BasicObject); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4; - - Opal.defn(self, '$initialize', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return self === other; - }); - - Opal.defn(self, '$eql?', function(other) { - var self = this; - - return self['$=='](other); - }); - - Opal.defn(self, '$__id__', function() { - var self = this; - - return self.$$id || (self.$$id = Opal.uid()); - }); - - Opal.defn(self, '$__send__', TMP_1 = function(symbol) { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - TMP_1.$$p = null; - - var func = self['$' + symbol] - - if (func) { - if (block !== nil) { - func.$$p = block; - } - - return func.apply(self, args); - } - - if (block !== nil) { - self.$method_missing.$$p = block; - } - - return self.$method_missing.apply(self, [symbol].concat(args)); - - }); - - Opal.defn(self, '$!', function() { - var self = this; - - return false; - }); - - Opal.defn(self, '$!=', function(other) { - var self = this; - - return (self['$=='](other))['$!'](); - }); - - Opal.alias(self, 'equal?', '=='); - - Opal.defn(self, '$instance_eval', TMP_2 = function() { - var self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - if (block !== false && block !== nil) { - } else { - $scope.get('Kernel').$raise($scope.get('ArgumentError'), "no block given") - }; - - var old = block.$$s, - result; - - block.$$s = null; - - // need to pass $$eval so that method definitions know if this is being done on a class/module. Cannot be compiler driven since - // send(:instance_eval) needs to work - if (self.$$is_class || self.$$is_module) { - self.$$eval = true; - try { - result = block.call(self, self); - } - finally { - self.$$eval = false; - } - } - else { - result = block.call(self, self); - } - - block.$$s = old; - - return result; - - }); - - Opal.defn(self, '$instance_exec', TMP_3 = function() { - var self = this, $iter = TMP_3.$$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_3.$$p = null; - if (block !== false && block !== nil) { - } else { - $scope.get('Kernel').$raise($scope.get('ArgumentError'), "no block given") - }; - - var block_self = block.$$s, - result; - - block.$$s = null; - - if (self.$$is_class || self.$$is_module) { - self.$$eval = true; - try { - result = block.apply(self, args); - } - finally { - self.$$eval = false; - } - } - else { - result = block.apply(self, args); - } - - block.$$s = block_self; - - return result; - - }); - - Opal.defn(self, '$singleton_method_added', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$singleton_method_removed', function() { - var self = this; - - return nil; - }); - - Opal.defn(self, '$singleton_method_undefined', function() { - var self = this; - - return nil; - }); - - return (Opal.defn(self, '$method_missing', TMP_4 = function(symbol) { - var $a, self = this, $iter = TMP_4.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - TMP_4.$$p = null; - return $scope.get('Kernel').$raise($scope.get('NoMethodError').$new((function() {if ((($a = self.$inspect && !self.$inspect.$$stub) !== nil && (!$a.$$is_boolean || $a == true))) { - return "undefined method `" + (symbol) + "' for " + (self.$inspect()) + ":" + (self.$$class) - } else { - return "undefined method `" + (symbol) + "' for " + (self.$$class) - }; return nil; })(), symbol)); - }), nil) && 'method_missing'; - })($scope.base, null) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/kernel"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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, $gvars = Opal.gvars, $hash2 = Opal.hash2, $klass = Opal.klass; - - Opal.add_stubs(['$raise', '$new', '$inspect', '$!', '$=~', '$==', '$object_id', '$class', '$coerce_to?', '$<<', '$allocate', '$copy_instance_variables', '$copy_singleton_methods', '$initialize_clone', '$initialize_copy', '$define_method', '$to_proc', '$singleton_class', '$initialize_dup', '$for', '$each', '$reverse', '$append_features', '$extended', '$length', '$respond_to?', '$[]', '$nil?', '$to_a', '$to_int', '$fetch', '$Integer', '$Float', '$to_ary', '$to_str', '$coerce_to', '$to_s', '$__id__', '$instance_variable_name!', '$coerce_to!', '$===', '$>', '$print', '$format', '$puts', '$<=', '$empty?', '$exception', '$kind_of?', '$respond_to_missing?', '$try_convert!', '$expand_path', '$join', '$start_with?', '$sym', '$arg', '$include']); - (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_7, TMP_9, TMP_10; - - Opal.defn(self, '$method_missing', TMP_1 = function(symbol) { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - TMP_1.$$p = null; - return self.$raise($scope.get('NoMethodError').$new("undefined method `" + (symbol) + "' for " + (self.$inspect()), symbol, args)); - }); - - Opal.defn(self, '$=~', function(obj) { - var self = this; - - return false; - }); - - Opal.defn(self, '$!~', function(obj) { - var self = this; - - return (self['$=~'](obj))['$!'](); - }); - - Opal.defn(self, '$===', function(other) { - var $a, self = this; - - return ((($a = self.$object_id()['$=='](other.$object_id())) !== false && $a !== nil) ? $a : self['$=='](other)); - }); - - Opal.defn(self, '$<=>', function(other) { - var self = this; - - - // set guard for infinite recursion - self.$$comparable = true; - - var x = self['$=='](other); - - if (x && x !== nil) { - return 0; - } - - return nil; - - }); - - Opal.defn(self, '$method', function(name) { - var self = this; - - - var meth = self['$' + name]; - - if (!meth || meth.$$stub) { - self.$raise($scope.get('NameError').$new("undefined method `" + (name) + "' for class `" + (self.$class()) + "'", name)); - } - - return $scope.get('Method').$new(self, meth, name); - - }); - - Opal.defn(self, '$methods', function(all) { - var self = this; - - if (all == null) { - all = true - } - - var methods = []; - - for (var key in self) { - if (key[0] == "$" && typeof(self[key]) === "function") { - if (all == false || all === nil) { - if (!Opal.hasOwnProperty.call(self, key)) { - continue; - } - } - if (self[key].$$stub === undefined) { - methods.push(key.substr(1)); - } - } - } - - return methods; - - }); - - Opal.alias(self, 'public_methods', 'methods'); - - Opal.defn(self, '$Array', function(object) { - var self = this; - - - var coerced; - - if (object === nil) { - return []; - } - - if (object.$$is_array) { - return object; - } - - coerced = $scope.get('Opal')['$coerce_to?'](object, $scope.get('Array'), "to_ary"); - if (coerced !== nil) { return coerced; } - - coerced = $scope.get('Opal')['$coerce_to?'](object, $scope.get('Array'), "to_a"); - if (coerced !== nil) { return coerced; } - - return [object]; - - }); - - Opal.defn(self, '$at_exit', TMP_2 = function() { - var $a, self = this, $iter = TMP_2.$$p, block = $iter || nil; - if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil; - - TMP_2.$$p = null; - ((($a = $gvars.__at_exit__) !== false && $a !== nil) ? $a : $gvars.__at_exit__ = []); - return $gvars.__at_exit__['$<<'](block); - }); - - Opal.defn(self, '$caller', function() { - var self = this; - - return []; - }); - - Opal.defn(self, '$class', function() { - var self = this; - - return self.$$class; - }); - - Opal.defn(self, '$copy_instance_variables', function(other) { - var self = this; - - - for (var name in other) { - if (name.charAt(0) !== '$') { - self[name] = other[name]; - } - } - - }); - - Opal.defn(self, '$copy_singleton_methods', function(other) { - var self = this; - - - var name; - - if (other.hasOwnProperty('$$meta')) { - var other_singleton_class_proto = Opal.get_singleton_class(other).$$proto; - var self_singleton_class_proto = Opal.get_singleton_class(self).$$proto; - - for (name in other_singleton_class_proto) { - if (name.charAt(0) === '$' && other_singleton_class_proto.hasOwnProperty(name)) { - self_singleton_class_proto[name] = other_singleton_class_proto[name]; - } - } - } - - for (name in other) { - if (name.charAt(0) === '$' && name.charAt(1) !== '$' && other.hasOwnProperty(name)) { - self[name] = other[name]; - } - } - - }); - - Opal.defn(self, '$clone', function() { - var self = this, copy = nil; - - copy = self.$class().$allocate(); - copy.$copy_instance_variables(self); - copy.$copy_singleton_methods(self); - copy.$initialize_clone(self); - return copy; - }); - - Opal.defn(self, '$initialize_clone', function(other) { - var self = this; - - return self.$initialize_copy(other); - }); - - Opal.defn(self, '$define_singleton_method', TMP_3 = function(name, method) { - var $a, $b, self = this, $iter = TMP_3.$$p, block = $iter || nil; - - TMP_3.$$p = null; - return ($a = ($b = self.$singleton_class()).$define_method, $a.$$p = block.$to_proc(), $a).call($b, name, method); - }); - - Opal.defn(self, '$dup', function() { - var self = this, copy = nil; - - copy = self.$class().$allocate(); - copy.$copy_instance_variables(self); - copy.$initialize_dup(self); - return copy; - }); - - Opal.defn(self, '$initialize_dup', function(other) { - var self = this; - - return self.$initialize_copy(other); - }); - - Opal.defn(self, '$enum_for', TMP_4 = function(method) { - var $a, $b, self = this, $iter = TMP_4.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - if (method == null) { - method = "each" - } - TMP_4.$$p = null; - return ($a = ($b = $scope.get('Enumerator')).$for, $a.$$p = block.$to_proc(), $a).apply($b, [self, method].concat(Opal.to_a(args))); - }); - - Opal.alias(self, 'to_enum', 'enum_for'); - - Opal.defn(self, '$equal?', function(other) { - var self = this; - - return self === other; - }); - - Opal.defn(self, '$exit', function(status) { - var $a, $b, self = this; - if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil; - - if (status == null) { - status = true - } - if ((($a = $gvars.__at_exit__) !== nil && (!$a.$$is_boolean || $a == true))) { - ($a = ($b = $gvars.__at_exit__.$reverse()).$each, $a.$$p = "call".$to_proc(), $a).call($b)}; - if ((($a = status === true) !== nil && (!$a.$$is_boolean || $a == true))) { - status = 0}; - Opal.exit(status); - return nil; - }); - - Opal.defn(self, '$extend', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var mods = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - mods[arg_index] = arguments[arg_index + 0]; - } - - var singleton = self.$singleton_class(); - - for (var i = mods.length - 1; i >= 0; i--) { - var mod = mods[i]; - - (mod).$append_features(singleton); - (mod).$extended(self); - } - ; - return self; - }); - - Opal.defn(self, '$format', function(format_string) { - var $a, $b, self = this, ary = nil; - if ($gvars.DEBUG == null) $gvars.DEBUG = nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - if ((($a = (($b = args.$length()['$=='](1)) ? args['$[]'](0)['$respond_to?']("to_ary") : args.$length()['$=='](1))) !== nil && (!$a.$$is_boolean || $a == true))) { - ary = $scope.get('Opal')['$coerce_to?'](args['$[]'](0), $scope.get('Array'), "to_ary"); - if ((($a = ary['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - args = ary.$to_a() - };}; - - var result = '', - //used for slicing: - begin_slice = 0, - end_slice, - //used for iterating over the format string: - i, - len = format_string.length, - //used for processing field values: - arg, - str, - //used for processing %g and %G fields: - exponent, - //used for keeping track of width and precision: - width, - precision, - //used for holding temporary values: - tmp_num, - //used for processing %{} and %<> fileds: - hash_parameter_key, - closing_brace_char, - //used for processing %b, %B, %o, %x, and %X fields: - base_number, - base_prefix, - base_neg_zero_regex, - base_neg_zero_digit, - //used for processing arguments: - next_arg, - seq_arg_num = 1, - pos_arg_num = 0, - //used for keeping track of flags: - flags, - FNONE = 0, - FSHARP = 1, - FMINUS = 2, - FPLUS = 4, - FZERO = 8, - FSPACE = 16, - FWIDTH = 32, - FPREC = 64, - FPREC0 = 128; - - function CHECK_FOR_FLAGS() { - if (flags&FWIDTH) { self.$raise($scope.get('ArgumentError'), "flag after width") } - if (flags&FPREC0) { self.$raise($scope.get('ArgumentError'), "flag after precision") } - } - - function CHECK_FOR_WIDTH() { - if (flags&FWIDTH) { self.$raise($scope.get('ArgumentError'), "width given twice") } - if (flags&FPREC0) { self.$raise($scope.get('ArgumentError'), "width after precision") } - } - - function GET_NTH_ARG(num) { - if (num >= args.length) { self.$raise($scope.get('ArgumentError'), "too few arguments") } - return args[num]; - } - - function GET_NEXT_ARG() { - switch (pos_arg_num) { - case -1: self.$raise($scope.get('ArgumentError'), "unnumbered(" + (seq_arg_num) + ") mixed with numbered") - case -2: self.$raise($scope.get('ArgumentError'), "unnumbered(" + (seq_arg_num) + ") mixed with named") - } - pos_arg_num = seq_arg_num++; - return GET_NTH_ARG(pos_arg_num - 1); - } - - function GET_POS_ARG(num) { - if (pos_arg_num > 0) { - self.$raise($scope.get('ArgumentError'), "numbered(" + (num) + ") after unnumbered(" + (pos_arg_num) + ")") - } - if (pos_arg_num === -2) { - self.$raise($scope.get('ArgumentError'), "numbered(" + (num) + ") after named") - } - if (num < 1) { - self.$raise($scope.get('ArgumentError'), "invalid index - " + (num) + "$") - } - pos_arg_num = -1; - return GET_NTH_ARG(num - 1); - } - - function GET_ARG() { - return (next_arg === undefined ? GET_NEXT_ARG() : next_arg); - } - - function READ_NUM(label) { - var num, str = ''; - for (;; i++) { - if (i === len) { - self.$raise($scope.get('ArgumentError'), "malformed format string - %*[0-9]") - } - if (format_string.charCodeAt(i) < 48 || format_string.charCodeAt(i) > 57) { - i--; - num = parseInt(str, 10) || 0; - if (num > 2147483647) { - self.$raise($scope.get('ArgumentError'), "" + (label) + " too big") - } - return num; - } - str += format_string.charAt(i); - } - } - - function READ_NUM_AFTER_ASTER(label) { - var arg, num = READ_NUM(label); - if (format_string.charAt(i + 1) === '$') { - i++; - arg = GET_POS_ARG(num); - } else { - arg = GET_NEXT_ARG(); - } - return (arg).$to_int(); - } - - for (i = format_string.indexOf('%'); i !== -1; i = format_string.indexOf('%', i)) { - str = undefined; - - flags = FNONE; - width = -1; - precision = -1; - next_arg = undefined; - - end_slice = i; - - i++; - - switch (format_string.charAt(i)) { - case '%': - begin_slice = i; - case '': - case '\n': - case '\0': - i++; - continue; - } - - format_sequence: for (; i < len; i++) { - switch (format_string.charAt(i)) { - - case ' ': - CHECK_FOR_FLAGS(); - flags |= FSPACE; - continue format_sequence; - - case '#': - CHECK_FOR_FLAGS(); - flags |= FSHARP; - continue format_sequence; - - case '+': - CHECK_FOR_FLAGS(); - flags |= FPLUS; - continue format_sequence; - - case '-': - CHECK_FOR_FLAGS(); - flags |= FMINUS; - continue format_sequence; - - case '0': - CHECK_FOR_FLAGS(); - flags |= FZERO; - continue format_sequence; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - tmp_num = READ_NUM('width'); - if (format_string.charAt(i + 1) === '$') { - if (i + 2 === len) { - str = '%'; - i++; - break format_sequence; - } - if (next_arg !== undefined) { - self.$raise($scope.get('ArgumentError'), "value given twice - %" + (tmp_num) + "$") - } - next_arg = GET_POS_ARG(tmp_num); - i++; - } else { - CHECK_FOR_WIDTH(); - flags |= FWIDTH; - width = tmp_num; - } - continue format_sequence; - - case '<': - case '\{': - closing_brace_char = (format_string.charAt(i) === '<' ? '>' : '\}'); - hash_parameter_key = ''; - - i++; - - for (;; i++) { - if (i === len) { - self.$raise($scope.get('ArgumentError'), "malformed name - unmatched parenthesis") - } - if (format_string.charAt(i) === closing_brace_char) { - - if (pos_arg_num > 0) { - self.$raise($scope.get('ArgumentError'), "named " + (hash_parameter_key) + " after unnumbered(" + (pos_arg_num) + ")") - } - if (pos_arg_num === -1) { - self.$raise($scope.get('ArgumentError'), "named " + (hash_parameter_key) + " after numbered") - } - pos_arg_num = -2; - - if (args[0] === undefined || !args[0].$$is_hash) { - self.$raise($scope.get('ArgumentError'), "one hash required") - } - - next_arg = (args[0]).$fetch(hash_parameter_key); - - if (closing_brace_char === '>') { - continue format_sequence; - } else { - str = next_arg.toString(); - if (precision !== -1) { str = str.slice(0, precision); } - if (flags&FMINUS) { - while (str.length < width) { str = str + ' '; } - } else { - while (str.length < width) { str = ' ' + str; } - } - break format_sequence; - } - } - hash_parameter_key += format_string.charAt(i); - } - - case '*': - i++; - CHECK_FOR_WIDTH(); - flags |= FWIDTH; - width = READ_NUM_AFTER_ASTER('width'); - if (width < 0) { - flags |= FMINUS; - width = -width; - } - continue format_sequence; - - case '.': - if (flags&FPREC0) { - self.$raise($scope.get('ArgumentError'), "precision given twice") - } - flags |= FPREC|FPREC0; - precision = 0; - i++; - if (format_string.charAt(i) === '*') { - i++; - precision = READ_NUM_AFTER_ASTER('precision'); - if (precision < 0) { - flags &= ~FPREC; - } - continue format_sequence; - } - precision = READ_NUM('precision'); - continue format_sequence; - - case 'd': - case 'i': - case 'u': - arg = self.$Integer(GET_ARG()); - if (arg >= 0) { - str = arg.toString(); - while (str.length < precision) { str = '0' + str; } - if (flags&FMINUS) { - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && precision === -1) { - while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0)) { str = '0' + str; } - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - } else { - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - while (str.length < width) { str = ' ' + str; } - } - } - } else { - str = (-arg).toString(); - while (str.length < precision) { str = '0' + str; } - if (flags&FMINUS) { - str = '-' + str; - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && precision === -1) { - while (str.length < width - 1) { str = '0' + str; } - str = '-' + str; - } else { - str = '-' + str; - while (str.length < width) { str = ' ' + str; } - } - } - } - break format_sequence; - - case 'b': - case 'B': - case 'o': - case 'x': - case 'X': - switch (format_string.charAt(i)) { - case 'b': - case 'B': - base_number = 2; - base_prefix = '0b'; - base_neg_zero_regex = /^1+/; - base_neg_zero_digit = '1'; - break; - case 'o': - base_number = 8; - base_prefix = '0'; - base_neg_zero_regex = /^3?7+/; - base_neg_zero_digit = '7'; - break; - case 'x': - case 'X': - base_number = 16; - base_prefix = '0x'; - base_neg_zero_regex = /^f+/; - base_neg_zero_digit = 'f'; - break; - } - arg = self.$Integer(GET_ARG()); - if (arg >= 0) { - str = arg.toString(base_number); - while (str.length < precision) { str = '0' + str; } - if (flags&FMINUS) { - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && precision === -1) { - while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0) - ((flags&FSHARP && arg !== 0) ? base_prefix.length : 0)) { str = '0' + str; } - if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - } else { - if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - while (str.length < width) { str = ' ' + str; } - } - } - } else { - if (flags&FPLUS || flags&FSPACE) { - str = (-arg).toString(base_number); - while (str.length < precision) { str = '0' + str; } - if (flags&FMINUS) { - if (flags&FSHARP) { str = base_prefix + str; } - str = '-' + str; - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && precision === -1) { - while (str.length < width - 1 - (flags&FSHARP ? 2 : 0)) { str = '0' + str; } - if (flags&FSHARP) { str = base_prefix + str; } - str = '-' + str; - } else { - if (flags&FSHARP) { str = base_prefix + str; } - str = '-' + str; - while (str.length < width) { str = ' ' + str; } - } - } - } else { - str = (arg >>> 0).toString(base_number).replace(base_neg_zero_regex, base_neg_zero_digit); - while (str.length < precision - 2) { str = base_neg_zero_digit + str; } - if (flags&FMINUS) { - str = '..' + str; - if (flags&FSHARP) { str = base_prefix + str; } - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && precision === -1) { - while (str.length < width - 2 - (flags&FSHARP ? base_prefix.length : 0)) { str = base_neg_zero_digit + str; } - str = '..' + str; - if (flags&FSHARP) { str = base_prefix + str; } - } else { - str = '..' + str; - if (flags&FSHARP) { str = base_prefix + str; } - while (str.length < width) { str = ' ' + str; } - } - } - } - } - if (format_string.charAt(i) === format_string.charAt(i).toUpperCase()) { - str = str.toUpperCase(); - } - break format_sequence; - - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - arg = self.$Float(GET_ARG()); - if (arg >= 0 || isNaN(arg)) { - if (arg === Infinity) { - str = 'Inf'; - } else { - switch (format_string.charAt(i)) { - case 'f': - str = arg.toFixed(precision === -1 ? 6 : precision); - break; - case 'e': - case 'E': - str = arg.toExponential(precision === -1 ? 6 : precision); - break; - case 'g': - case 'G': - str = arg.toExponential(); - exponent = parseInt(str.split('e')[1], 10); - if (!(exponent < -4 || exponent >= (precision === -1 ? 6 : precision))) { - str = arg.toPrecision(precision === -1 ? (flags&FSHARP ? 6 : undefined) : precision); - } - break; - } - } - if (flags&FMINUS) { - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && arg !== Infinity && !isNaN(arg)) { - while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0)) { str = '0' + str; } - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - } else { - if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } - while (str.length < width) { str = ' ' + str; } - } - } - } else { - if (arg === -Infinity) { - str = 'Inf'; - } else { - switch (format_string.charAt(i)) { - case 'f': - str = (-arg).toFixed(precision === -1 ? 6 : precision); - break; - case 'e': - case 'E': - str = (-arg).toExponential(precision === -1 ? 6 : precision); - break; - case 'g': - case 'G': - str = (-arg).toExponential(); - exponent = parseInt(str.split('e')[1], 10); - if (!(exponent < -4 || exponent >= (precision === -1 ? 6 : precision))) { - str = (-arg).toPrecision(precision === -1 ? (flags&FSHARP ? 6 : undefined) : precision); - } - break; - } - } - if (flags&FMINUS) { - str = '-' + str; - while (str.length < width) { str = str + ' '; } - } else { - if (flags&FZERO && arg !== -Infinity) { - while (str.length < width - 1) { str = '0' + str; } - str = '-' + str; - } else { - str = '-' + str; - while (str.length < width) { str = ' ' + str; } - } - } - } - if (format_string.charAt(i) === format_string.charAt(i).toUpperCase() && arg !== Infinity && arg !== -Infinity && !isNaN(arg)) { - str = str.toUpperCase(); - } - str = str.replace(/([eE][-+]?)([0-9])$/, '$10$2'); - break format_sequence; - - case 'a': - case 'A': - // Not implemented because there are no specs for this field type. - self.$raise($scope.get('NotImplementedError'), "`A` and `a` format field types are not implemented in Opal yet") - - case 'c': - arg = GET_ARG(); - if ((arg)['$respond_to?']("to_ary")) { arg = (arg).$to_ary()[0]; } - if ((arg)['$respond_to?']("to_str")) { - str = (arg).$to_str(); - } else { - str = String.fromCharCode($scope.get('Opal').$coerce_to(arg, $scope.get('Integer'), "to_int")); - } - if (str.length !== 1) { - self.$raise($scope.get('ArgumentError'), "%c requires a character") - } - if (flags&FMINUS) { - while (str.length < width) { str = str + ' '; } - } else { - while (str.length < width) { str = ' ' + str; } - } - break format_sequence; - - case 'p': - str = (GET_ARG()).$inspect(); - if (precision !== -1) { str = str.slice(0, precision); } - if (flags&FMINUS) { - while (str.length < width) { str = str + ' '; } - } else { - while (str.length < width) { str = ' ' + str; } - } - break format_sequence; - - case 's': - str = (GET_ARG()).$to_s(); - if (precision !== -1) { str = str.slice(0, precision); } - if (flags&FMINUS) { - while (str.length < width) { str = str + ' '; } - } else { - while (str.length < width) { str = ' ' + str; } - } - break format_sequence; - - default: - self.$raise($scope.get('ArgumentError'), "malformed format string - %" + (format_string.charAt(i))) - } - } - - if (str === undefined) { - self.$raise($scope.get('ArgumentError'), "malformed format string - %") - } - - result += format_string.slice(begin_slice, end_slice) + str; - begin_slice = i + 1; - } - - if ($gvars.DEBUG && pos_arg_num >= 0 && seq_arg_num < args.length) { - self.$raise($scope.get('ArgumentError'), "too many arguments for format string") - } - - return result + format_string.slice(begin_slice); - ; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return "" + (self.$class()) + ":" + (self.$class().$__id__()) + ":" + (self.$__id__()); - }); - - Opal.defn(self, '$initialize_copy', function(other) { - var self = this; - - return nil; - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return self.$to_s(); - }); - - Opal.defn(self, '$instance_of?', function(klass) { - var self = this; - - - if (!klass.$$is_class && !klass.$$is_module) { - self.$raise($scope.get('TypeError'), "class or module required"); - } - - return self.$$class === klass; - ; - }); - - Opal.defn(self, '$instance_variable_defined?', function(name) { - var self = this; - - name = $scope.get('Opal')['$instance_variable_name!'](name); - return Opal.hasOwnProperty.call(self, name.substr(1)); - }); - - Opal.defn(self, '$instance_variable_get', function(name) { - var self = this; - - name = $scope.get('Opal')['$instance_variable_name!'](name); - - var ivar = self[name.substr(1)]; - - return ivar == null ? nil : ivar; - - }); - - Opal.defn(self, '$instance_variable_set', function(name, value) { - var self = this; - - name = $scope.get('Opal')['$instance_variable_name!'](name); - return self[name.substr(1)] = value; - }); - - Opal.defn(self, '$instance_variables', function() { - var self = this; - - - var result = []; - - for (var name in self) { - if (name.charAt(0) !== '$') { - if (name !== '$$class' && name !== '$$id') { - result.push('@' + name); - } - } - } - - return result; - - }); - - Opal.defn(self, '$Integer', function(value, base) { - var self = this; - - - var i, str, base_digits; - - if (!value.$$is_string) { - if (base !== undefined) { - self.$raise($scope.get('ArgumentError'), "base specified for non string value") - } - if (value === nil) { - self.$raise($scope.get('TypeError'), "can't convert nil into Integer") - } - if (value.$$is_number) { - if (value === Infinity || value === -Infinity || isNaN(value)) { - self.$raise($scope.get('FloatDomainError'), value) - } - return Math.floor(value); - } - if (value['$respond_to?']("to_int")) { - i = value.$to_int(); - if (i !== nil) { - return i; - } - } - return $scope.get('Opal')['$coerce_to!'](value, $scope.get('Integer'), "to_i"); - } - - if (base === undefined) { - base = 0; - } else { - base = $scope.get('Opal').$coerce_to(base, $scope.get('Integer'), "to_int"); - if (base === 1 || base < 0 || base > 36) { - self.$raise($scope.get('ArgumentError'), "invalid radix " + (base)) - } - } - - str = value.toLowerCase(); - - str = str.replace(/(\d)_(?=\d)/g, '$1'); - - str = str.replace(/^(\s*[+-]?)(0[bodx]?)/, function (_, head, flag) { - switch (flag) { - case '0b': - if (base === 0 || base === 2) { - base = 2; - return head; - } - case '0': - case '0o': - if (base === 0 || base === 8) { - base = 8; - return head; - } - case '0d': - if (base === 0 || base === 10) { - base = 10; - return head; - } - case '0x': - if (base === 0 || base === 16) { - base = 16; - return head; - } - } - self.$raise($scope.get('ArgumentError'), "invalid value for Integer(): \"" + (value) + "\"") - }); - - base = (base === 0 ? 10 : base); - - base_digits = '0-' + (base <= 10 ? base - 1 : '9a-' + String.fromCharCode(97 + (base - 11))); - - if (!(new RegExp('^\\s*[+-]?[' + base_digits + ']+\\s*$')).test(str)) { - self.$raise($scope.get('ArgumentError'), "invalid value for Integer(): \"" + (value) + "\"") - } - - i = parseInt(str, base); - - if (isNaN(i)) { - self.$raise($scope.get('ArgumentError'), "invalid value for Integer(): \"" + (value) + "\"") - } - - return i; - ; - }); - - Opal.defn(self, '$Float', function(value) { - var self = this; - - - var str; - - if (value === nil) { - self.$raise($scope.get('TypeError'), "can't convert nil into Float") - } - - if (value.$$is_string) { - str = value.toString(); - - str = str.replace(/(\d)_(?=\d)/g, '$1'); - - //Special case for hex strings only: - if (/^\s*[-+]?0[xX][0-9a-fA-F]+\s*$/.test(str)) { - return self.$Integer(str); - } - - if (!/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/.test(str)) { - self.$raise($scope.get('ArgumentError'), "invalid value for Float(): \"" + (value) + "\"") - } - - return parseFloat(str); - } - - return $scope.get('Opal')['$coerce_to!'](value, $scope.get('Float'), "to_f"); - - }); - - Opal.defn(self, '$Hash', function(arg) { - var $a, $b, self = this; - - if ((($a = ((($b = arg['$nil?']()) !== false && $b !== nil) ? $b : arg['$==']([]))) !== nil && (!$a.$$is_boolean || $a == true))) { - return $hash2([], {})}; - if ((($a = $scope.get('Hash')['$==='](arg)) !== nil && (!$a.$$is_boolean || $a == true))) { - return arg}; - return $scope.get('Opal')['$coerce_to!'](arg, $scope.get('Hash'), "to_hash"); - }); - - Opal.defn(self, '$is_a?', function(klass) { - var self = this; - - - if (!klass.$$is_class && !klass.$$is_module) { - self.$raise($scope.get('TypeError'), "class or module required"); - } - - return Opal.is_a(self, klass); - ; - }); - - Opal.alias(self, 'kind_of?', 'is_a?'); - - Opal.defn(self, '$lambda', TMP_5 = function() { - var self = this, $iter = TMP_5.$$p, block = $iter || nil; - - TMP_5.$$p = null; - block.$$is_lambda = true; - return block; - }); - - Opal.defn(self, '$load', function(file) { - var self = this; - - file = $scope.get('Opal')['$coerce_to!'](file, $scope.get('String'), "to_str"); - return Opal.load(file); - }); - - Opal.defn(self, '$loop', TMP_6 = function() { - var self = this, $iter = TMP_6.$$p, block = $iter || nil; - - TMP_6.$$p = null; - - while (true) { - if (block() === $breaker) { - return $breaker.$v; - } - } - - return self; - }); - - Opal.defn(self, '$nil?', function() { - var self = this; - - return false; - }); - - Opal.alias(self, 'object_id', '__id__'); - - Opal.defn(self, '$printf', function() { - var $a, 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]; - } - if ($rb_gt(args.$length(), 0)) { - self.$print(($a = self).$format.apply($a, Opal.to_a(args)))}; - return nil; - }); - - Opal.defn(self, '$proc', TMP_7 = function() { - var self = this, $iter = TMP_7.$$p, block = $iter || nil; - - TMP_7.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to create Proc object without a block") - }; - block.$$is_lambda = false; - return block; - }); - - Opal.defn(self, '$puts', function() { - var $a, self = this; - if ($gvars.stdout == null) $gvars.stdout = nil; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var strs = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - strs[arg_index] = arguments[arg_index + 0]; - } - return ($a = $gvars.stdout).$puts.apply($a, Opal.to_a(strs)); - }); - - Opal.defn(self, '$p', function() { - var $a, $b, TMP_8, 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]; - } - ($a = ($b = args).$each, $a.$$p = (TMP_8 = function(obj){var self = TMP_8.$$s || this; - if ($gvars.stdout == null) $gvars.stdout = nil; -if (obj == null) obj = nil; - return $gvars.stdout.$puts(obj.$inspect())}, TMP_8.$$s = self, TMP_8), $a).call($b); - if ($rb_le(args.$length(), 1)) { - return args['$[]'](0) - } else { - return args - }; - }); - - Opal.defn(self, '$print', function() { - var $a, self = this; - if ($gvars.stdout == null) $gvars.stdout = nil; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var strs = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - strs[arg_index] = arguments[arg_index + 0]; - } - return ($a = $gvars.stdout).$print.apply($a, Opal.to_a(strs)); - }); - - Opal.defn(self, '$warn', function() { - var $a, $b, self = this; - if ($gvars.VERBOSE == null) $gvars.VERBOSE = nil; - if ($gvars.stderr == null) $gvars.stderr = nil; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var strs = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - strs[arg_index] = arguments[arg_index + 0]; - } - if ((($a = ((($b = $gvars.VERBOSE['$nil?']()) !== false && $b !== nil) ? $b : strs['$empty?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return ($a = $gvars.stderr).$puts.apply($a, Opal.to_a(strs)) - }; - }); - - Opal.defn(self, '$raise', function(exception, string, _backtrace) { - var self = this; - if ($gvars["!"] == null) $gvars["!"] = nil; - - if (string == null) { - string = nil - } - if (_backtrace == null) { - _backtrace = nil - } - - if (exception == null && $gvars["!"] !== nil) { - throw $gvars["!"]; - } - if (exception == null) { - exception = $scope.get('RuntimeError').$new(); - } - else if (exception.$$is_string) { - exception = $scope.get('RuntimeError').$new(exception); - } - // using respond_to? and not an undefined check to avoid method_missing matching as true - else if (exception.$$is_class && exception['$respond_to?']("exception")) { - exception = exception.$exception(string); - } - else if (exception['$kind_of?']($scope.get('Exception'))) { - // exception is fine - } - else { - exception = $scope.get('TypeError').$new("exception class/object expected"); - } - - if ($gvars["!"] !== nil) { - Opal.exceptions.push($gvars["!"]); - } - - $gvars["!"] = exception; - - throw exception; - ; - }); - - Opal.alias(self, 'fail', 'raise'); - - Opal.defn(self, '$rand', function(max) { - var self = this; - - - if (max === undefined) { - return Math.random(); - } - else if (max.$$is_range) { - var min = max.begin, range = max.end - min; - if(!max.exclude) range++; - - return self.$rand(range) + min; - } - else { - return Math.floor(Math.random() * - Math.abs($scope.get('Opal').$coerce_to(max, $scope.get('Integer'), "to_int"))); - } - - }); - - Opal.defn(self, '$respond_to?', function(name, include_all) { - var $a, self = this; - - if (include_all == null) { - include_all = false - } - if ((($a = self['$respond_to_missing?'](name, include_all)) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - - var body = self['$' + name]; - - if (typeof(body) === "function" && !body.$$stub) { - return true; - } - - return false; - }); - - Opal.defn(self, '$respond_to_missing?', function(method_name, include_all) { - var self = this; - - if (include_all == null) { - include_all = false - } - return false; - }); - - Opal.defn(self, '$require', function(file) { - var self = this; - - file = $scope.get('Opal')['$coerce_to!'](file, $scope.get('String'), "to_str"); - return Opal.require(file); - }); - - Opal.defn(self, '$require_relative', function(file) { - var self = this; - - $scope.get('Opal')['$try_convert!'](file, $scope.get('String'), "to_str"); - file = $scope.get('File').$expand_path($scope.get('File').$join(Opal.current_file, "..", file)); - return Opal.require(file); - }); - - Opal.defn(self, '$require_tree', function(path) { - var self = this; - - path = $scope.get('File').$expand_path(path); - if (path['$=='](".")) { - path = ""}; - - for (var name in Opal.modules) { - if ((name)['$start_with?'](path)) { - Opal.require(name); - } - } - ; - return nil; - }); - - Opal.alias(self, 'send', '__send__'); - - Opal.alias(self, 'public_send', '__send__'); - - Opal.defn(self, '$singleton_class', function() { - var self = this; - - return Opal.get_singleton_class(self); - }); - - Opal.defn(self, '$sleep', function(seconds) { - var self = this; - - if (seconds == null) { - seconds = nil - } - - if (seconds === nil) { - self.$raise($scope.get('TypeError'), "can't convert NilClass into time interval") - } - if (!seconds.$$is_number) { - self.$raise($scope.get('TypeError'), "can't convert " + (seconds.$class()) + " into time interval") - } - if (seconds < 0) { - self.$raise($scope.get('ArgumentError'), "time interval must be positive") - } - var t = new Date(); - while (new Date() - t <= seconds * 1000); - return seconds; - ; - }); - - Opal.alias(self, 'sprintf', 'format'); - - Opal.alias(self, 'srand', 'rand'); - - Opal.defn(self, '$String', function(str) { - var $a, self = this; - - return ((($a = $scope.get('Opal')['$coerce_to?'](str, $scope.get('String'), "to_str")) !== false && $a !== nil) ? $a : $scope.get('Opal')['$coerce_to!'](str, $scope.get('String'), "to_s")); - }); - - Opal.defn(self, '$tap', TMP_9 = function() { - var self = this, $iter = TMP_9.$$p, block = $iter || nil; - - TMP_9.$$p = null; - if (Opal.yield1(block, self) === $breaker) return $breaker.$v; - return self; - }); - - Opal.defn(self, '$to_proc', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return "#<" + (self.$class()) + ":0x" + (self.$__id__().$to_s(16)) + ">"; - }); - - Opal.defn(self, '$catch', TMP_10 = function(sym) { - var $a, self = this, $iter = TMP_10.$$p, $yield = $iter || nil, e = nil; - - TMP_10.$$p = null; - try { - return $a = Opal.yieldX($yield, []), $a === $breaker ? $a : $a - } catch ($err) {if (Opal.rescue($err, [$scope.get('UncaughtThrowError')])) {e = $err; - try { - if (e.$sym()['$=='](sym)) { - return e.$arg()}; - return self.$raise(); - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - Opal.defn(self, '$throw', 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($scope.get('UncaughtThrowError').$new(args)); - }); - })($scope.base); - return (function($base, $super) { - function $Object(){}; - var self = $Object = $klass($base, $super, 'Object', $Object); - - var def = self.$$proto, $scope = self.$$scope; - - return self.$include($scope.get('Kernel')) - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/error"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module; - - Opal.add_stubs(['$new', '$clone', '$to_s', '$empty?', '$class', '$attr_reader', '$[]', '$>', '$length', '$inspect']); - (function($base, $super) { - function $Exception(){}; - var self = $Exception = $klass($base, $super, 'Exception', $Exception); - - var def = self.$$proto, $scope = self.$$scope; - - def.message = nil; - Opal.defs(self, '$new', 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]; - } - - var message = (args.length > 0) ? args[0] : nil; - var err = new self.$$alloc(message); - - if (Error.captureStackTrace) { - Error.captureStackTrace(err); - } - - err.name = self.$$name; - err.$initialize.apply(err, args); - return err; - - }); - - Opal.defs(self, '$exception', function() { - var $a, 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 ($a = self).$new.apply($a, Opal.to_a(args)); - }); - - Opal.defn(self, '$initialize', 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.message = (args.length > 0) ? args[0] : nil; - }); - - Opal.defn(self, '$backtrace', function() { - var self = this; - - - var backtrace = self.stack; - - if (typeof(backtrace) === 'string') { - return backtrace.split("\n").slice(0, 15); - } - else if (backtrace) { - return backtrace.slice(0, 15); - } - - return []; - - }); - - Opal.defn(self, '$exception', function(str) { - var self = this; - - if (str == null) { - str = nil - } - - if (str === nil || self === str) { - return self; - } - - var cloned = self.$clone(); - cloned.message = str; - return cloned; - - }); - - Opal.defn(self, '$message', function() { - var self = this; - - return self.$to_s(); - }); - - Opal.defn(self, '$inspect', function() { - var $a, self = this, as_str = nil; - - as_str = self.$to_s(); - if ((($a = as_str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$class().$to_s() - } else { - return "#<" + (self.$class().$to_s()) + ": " + (self.$to_s()) + ">" - }; - }); - - return (Opal.defn(self, '$to_s', function() { - var $a, $b, self = this; - - return ((($a = (($b = self.message, $b !== false && $b !== nil ?self.message.$to_s() : $b))) !== false && $a !== nil) ? $a : self.$class().$to_s()); - }), nil) && 'to_s'; - })($scope.base, Error); - (function($base, $super) { - function $ScriptError(){}; - var self = $ScriptError = $klass($base, $super, 'ScriptError', $ScriptError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $SyntaxError(){}; - var self = $SyntaxError = $klass($base, $super, 'SyntaxError', $SyntaxError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('ScriptError')); - (function($base, $super) { - function $LoadError(){}; - var self = $LoadError = $klass($base, $super, 'LoadError', $LoadError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('ScriptError')); - (function($base, $super) { - function $NotImplementedError(){}; - var self = $NotImplementedError = $klass($base, $super, 'NotImplementedError', $NotImplementedError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('ScriptError')); - (function($base, $super) { - function $SystemExit(){}; - var self = $SystemExit = $klass($base, $super, 'SystemExit', $SystemExit); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $NoMemoryError(){}; - var self = $NoMemoryError = $klass($base, $super, 'NoMemoryError', $NoMemoryError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $SignalException(){}; - var self = $SignalException = $klass($base, $super, 'SignalException', $SignalException); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $Interrupt(){}; - var self = $Interrupt = $klass($base, $super, 'Interrupt', $Interrupt); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $SecurityError(){}; - var self = $SecurityError = $klass($base, $super, 'SecurityError', $SecurityError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $StandardError(){}; - var self = $StandardError = $klass($base, $super, 'StandardError', $StandardError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - (function($base, $super) { - function $ZeroDivisionError(){}; - var self = $ZeroDivisionError = $klass($base, $super, 'ZeroDivisionError', $ZeroDivisionError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $NameError(){}; - var self = $NameError = $klass($base, $super, 'NameError', $NameError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $NoMethodError(){}; - var self = $NoMethodError = $klass($base, $super, 'NoMethodError', $NoMethodError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('NameError')); - (function($base, $super) { - function $RuntimeError(){}; - var self = $RuntimeError = $klass($base, $super, 'RuntimeError', $RuntimeError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $LocalJumpError(){}; - var self = $LocalJumpError = $klass($base, $super, 'LocalJumpError', $LocalJumpError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $TypeError(){}; - var self = $TypeError = $klass($base, $super, 'TypeError', $TypeError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $ArgumentError(){}; - var self = $ArgumentError = $klass($base, $super, 'ArgumentError', $ArgumentError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $IndexError(){}; - var self = $IndexError = $klass($base, $super, 'IndexError', $IndexError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $StopIteration(){}; - var self = $StopIteration = $klass($base, $super, 'StopIteration', $StopIteration); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('IndexError')); - (function($base, $super) { - function $KeyError(){}; - var self = $KeyError = $klass($base, $super, 'KeyError', $KeyError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('IndexError')); - (function($base, $super) { - function $RangeError(){}; - var self = $RangeError = $klass($base, $super, 'RangeError', $RangeError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $FloatDomainError(){}; - var self = $FloatDomainError = $klass($base, $super, 'FloatDomainError', $FloatDomainError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('RangeError')); - (function($base, $super) { - function $IOError(){}; - var self = $IOError = $klass($base, $super, 'IOError', $IOError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $SystemCallError(){}; - var self = $SystemCallError = $klass($base, $super, 'SystemCallError', $SystemCallError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base) { - var self = $module($base, 'Errno'); - - var def = self.$$proto, $scope = self.$$scope; - - (function($base, $super) { - function $EINVAL(){}; - var self = $EINVAL = $klass($base, $super, 'EINVAL', $EINVAL); - - var def = self.$$proto, $scope = self.$$scope, TMP_1; - - return (Opal.defs(self, '$new', TMP_1 = function() { - var self = this, $iter = TMP_1.$$p, $yield = $iter || nil; - - TMP_1.$$p = null; - return Opal.find_super_dispatcher(self, 'new', TMP_1, null, $EINVAL).apply(self, ["Invalid argument"]); - }), nil) && 'new' - })($scope.base, $scope.get('SystemCallError')) - })($scope.base); - (function($base, $super) { - function $UncaughtThrowError(){}; - var self = $UncaughtThrowError = $klass($base, $super, 'UncaughtThrowError', $UncaughtThrowError); - - var def = self.$$proto, $scope = self.$$scope, TMP_2; - - def.sym = nil; - self.$attr_reader("sym", "arg"); - - return (Opal.defn(self, '$initialize', TMP_2 = function(args) { - var self = this, $iter = TMP_2.$$p, $yield = $iter || nil; - - TMP_2.$$p = null; - self.sym = args['$[]'](0); - if ($rb_gt(args.$length(), 1)) { - self.arg = args['$[]'](1)}; - return Opal.find_super_dispatcher(self, 'initialize', TMP_2, null).apply(self, ["uncaught throw " + (self.sym.$inspect())]); - }), nil) && 'initialize'; - })($scope.base, $scope.get('ArgumentError')); - (function($base, $super) { - function $NameError(){}; - var self = $NameError = $klass($base, $super, 'NameError', $NameError); - - var def = self.$$proto, $scope = self.$$scope, TMP_3; - - self.$attr_reader("name"); - - return (Opal.defn(self, '$initialize', TMP_3 = function(message, name) { - var self = this, $iter = TMP_3.$$p, $yield = $iter || nil; - - if (name == null) { - name = nil - } - TMP_3.$$p = null; - Opal.find_super_dispatcher(self, 'initialize', TMP_3, null).apply(self, [message]); - return self.name = name; - }), nil) && 'initialize'; - })($scope.base, null); - return (function($base, $super) { - function $NoMethodError(){}; - var self = $NoMethodError = $klass($base, $super, 'NoMethodError', $NoMethodError); - - var def = self.$$proto, $scope = self.$$scope, TMP_4; - - self.$attr_reader("args"); - - return (Opal.defn(self, '$initialize', TMP_4 = function(message, name, args) { - var self = this, $iter = TMP_4.$$p, $yield = $iter || nil; - - if (args == null) { - args = [] - } - TMP_4.$$p = null; - Opal.find_super_dispatcher(self, 'initialize', TMP_4, null).apply(self, [message, name]); - return self.args = args; - }), nil) && 'initialize'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/constants"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.cdecl($scope, 'RUBY_PLATFORM', "opal"); - Opal.cdecl($scope, 'RUBY_ENGINE', "opal"); - Opal.cdecl($scope, 'RUBY_VERSION', "2.1.5"); - Opal.cdecl($scope, 'RUBY_ENGINE_VERSION', "0.9.0.beta2"); - Opal.cdecl($scope, 'RUBY_RELEASE_DATE', "2015-11-06"); - Opal.cdecl($scope, 'RUBY_PATCHLEVEL', 0); - Opal.cdecl($scope, 'RUBY_REVISION', 0); - Opal.cdecl($scope, 'RUBY_COPYRIGHT', "opal - Copyright (C) 2013-2015 Adam Beynon"); - return Opal.cdecl($scope, 'RUBY_DESCRIPTION', "opal " + ($scope.get('RUBY_ENGINE_VERSION')) + " (" + ($scope.get('RUBY_RELEASE_DATE')) + " revision " + ($scope.get('RUBY_REVISION')) + ")"); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["opal/base"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.add_stubs(['$require']); - self.$require("corelib/runtime"); - self.$require("corelib/helpers"); - self.$require("corelib/module"); - self.$require("corelib/class"); - self.$require("corelib/basic_object"); - self.$require("corelib/kernel"); - self.$require("corelib/error"); - return self.$require("corelib/constants"); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/nil"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; - - Opal.add_stubs(['$raise', '$class', '$new', '$>', '$length', '$Rational']); - (function($base, $super) { - function $NilClass(){}; - var self = $NilClass = $klass($base, $super, 'NilClass', $NilClass); - - var def = self.$$proto, $scope = self.$$scope; - - def.$$meta = self; - - Opal.defn(self, '$!', function() { - var self = this; - - return true; - }); - - Opal.defn(self, '$&', function(other) { - var self = this; - - return false; - }); - - Opal.defn(self, '$|', function(other) { - var self = this; - - return other !== false && other !== nil; - }); - - Opal.defn(self, '$^', function(other) { - var self = this; - - return other !== false && other !== nil; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return other === nil; - }); - - Opal.defn(self, '$dup', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't dup " + (self.$class())); - }); - - Opal.defn(self, '$clone', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't clone " + (self.$class())); - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return "nil"; - }); - - Opal.defn(self, '$nil?', function() { - var self = this; - - return true; - }); - - Opal.defn(self, '$singleton_class', function() { - var self = this; - - return $scope.get('NilClass'); - }); - - Opal.defn(self, '$to_a', function() { - var self = this; - - return []; - }); - - Opal.defn(self, '$to_h', function() { - var self = this; - - return Opal.hash(); - }); - - Opal.defn(self, '$to_i', function() { - var self = this; - - return 0; - }); - - Opal.alias(self, 'to_f', 'to_i'); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return ""; - }); - - Opal.defn(self, '$to_c', function() { - var self = this; - - return $scope.get('Complex').$new(0, 0); - }); - - Opal.defn(self, '$rationalize', 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]; - } - if ($rb_gt(args.$length(), 1)) { - self.$raise($scope.get('ArgumentError'))}; - return self.$Rational(0, 1); - }); - - return (Opal.defn(self, '$to_r', function() { - var self = this; - - return self.$Rational(0, 1); - }), nil) && 'to_r'; - })($scope.base, null); - return Opal.cdecl($scope, 'NIL', nil); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/boolean"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$raise', '$class']); - (function($base, $super) { - function $Boolean(){}; - var self = $Boolean = $klass($base, $super, 'Boolean', $Boolean); - - var def = self.$$proto, $scope = self.$$scope; - - def.$$is_boolean = true; - - def.$$meta = self; - - Opal.defn(self, '$__id__', function() { - var self = this; - - return self.valueOf() ? 2 : 0; - }); - - Opal.alias(self, 'object_id', '__id__'); - - Opal.defn(self, '$!', function() { - var self = this; - - return self != true; - }); - - Opal.defn(self, '$&', function(other) { - var self = this; - - return (self == true) ? (other !== false && other !== nil) : false; - }); - - Opal.defn(self, '$|', function(other) { - var self = this; - - return (self == true) ? true : (other !== false && other !== nil); - }); - - Opal.defn(self, '$^', function(other) { - var self = this; - - return (self == true) ? (other === false || other === nil) : (other !== false && other !== nil); - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return (self == true) === other.valueOf(); - }); - - Opal.alias(self, 'equal?', '=='); - - Opal.alias(self, 'eql?', '=='); - - Opal.defn(self, '$singleton_class', function() { - var self = this; - - return $scope.get('Boolean'); - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return (self == true) ? 'true' : 'false'; - }); - - Opal.defn(self, '$dup', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't dup " + (self.$class())); - }); - - return (Opal.defn(self, '$clone', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't clone " + (self.$class())); - }), nil) && 'clone'; - })($scope.base, Boolean); - Opal.cdecl($scope, 'TrueClass', $scope.get('Boolean')); - Opal.cdecl($scope, 'FalseClass', $scope.get('Boolean')); - Opal.cdecl($scope, 'TRUE', true); - return Opal.cdecl($scope, 'FALSE', false); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/comparable"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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; - - Opal.add_stubs(['$===', '$>', '$<', '$equal?', '$<=>', '$normalize', '$raise', '$class']); - return (function($base) { - var self = $module($base, 'Comparable'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defs(self, '$normalize', function(what) { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](what)) !== nil && (!$a.$$is_boolean || $a == true))) { - return what}; - if ($rb_gt(what, 0)) { - return 1}; - if ($rb_lt(what, 0)) { - return -1}; - return 0; - }); - - Opal.defn(self, '$==', function(other) { - var $a, self = this, cmp = nil; - - try { - if ((($a = self['$equal?'](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - - if (self["$<=>"] == Opal.Kernel["$<=>"]) { - return false; - } - - // check for infinite recursion - if (self.$$comparable) { - delete self.$$comparable; - return false; - } - - if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return false - }; - return $scope.get('Comparable').$normalize(cmp) == 0; - } catch ($err) {if (Opal.rescue($err, [$scope.get('StandardError')])) { - try { - return false - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - Opal.defn(self, '$>', function(other) { - var $a, self = this, cmp = nil; - - if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed") - }; - return $scope.get('Comparable').$normalize(cmp) > 0; - }); - - Opal.defn(self, '$>=', function(other) { - var $a, self = this, cmp = nil; - - if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed") - }; - return $scope.get('Comparable').$normalize(cmp) >= 0; - }); - - Opal.defn(self, '$<', function(other) { - var $a, self = this, cmp = nil; - - if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed") - }; - return $scope.get('Comparable').$normalize(cmp) < 0; - }); - - Opal.defn(self, '$<=', function(other) { - var $a, self = this, cmp = nil; - - if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed") - }; - return $scope.get('Comparable').$normalize(cmp) <= 0; - }); - - Opal.defn(self, '$between?', function(min, max) { - var self = this; - - if ($rb_lt(self, min)) { - return false}; - if ($rb_gt(self, max)) { - return false}; - return true; - }); - })($scope.base) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/regexp"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass, $gvars = Opal.gvars; - - Opal.add_stubs(['$nil?', '$[]', '$raise', '$escape', '$options', '$to_str', '$new', '$join', '$coerce_to!', '$!', '$match', '$coerce_to?', '$begin', '$coerce_to', '$call', '$=~', '$attr_reader', '$===', '$inspect', '$to_a']); - (function($base, $super) { - function $RegexpError(){}; - var self = $RegexpError = $klass($base, $super, 'RegexpError', $RegexpError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - (function($base, $super) { - function $Regexp(){}; - var self = $Regexp = $klass($base, $super, 'Regexp', $Regexp); - - var def = self.$$proto, $scope = self.$$scope, TMP_2; - - Opal.cdecl($scope, 'IGNORECASE', 1); - - Opal.cdecl($scope, 'MULTILINE', 4); - - def.$$is_regexp = true; - - (function(self) { - var $scope = self.$$scope, def = self.$$proto, TMP_1; - - Opal.defn(self, '$allocate', TMP_1 = function() {var $zuper = $slice.call(arguments, 0); - var self = this, $iter = TMP_1.$$p, $yield = $iter || nil, allocated = nil; - - TMP_1.$$p = null; - allocated = Opal.find_super_dispatcher(self, 'allocate', TMP_1, $iter).apply(self, $zuper); - allocated.uninitialized = true; - return allocated; - }); - Opal.defn(self, '$escape', function(string) { - var self = this; - - - return string.replace(/([-[\]\/{}()*+?.^$\\| ])/g, '\\$1') - .replace(/[\n]/g, '\\n') - .replace(/[\r]/g, '\\r') - .replace(/[\f]/g, '\\f') - .replace(/[\t]/g, '\\t'); - - }); - Opal.defn(self, '$last_match', function(n) { - var $a, self = this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - if (n == null) { - n = nil - } - if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return $gvars["~"] - } else { - return $gvars["~"]['$[]'](n) - }; - }); - Opal.alias(self, 'quote', 'escape'); - Opal.defn(self, '$union', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var parts = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - parts[arg_index] = arguments[arg_index + 0]; - } - - var is_first_part_array, quoted_validated, part, options, each_part_options; - if (parts.length == 0) { - return /(?!)/; - } - // cover the 2 arrays passed as arguments case - is_first_part_array = parts[0].$$is_array; - if (parts.length > 1 && is_first_part_array) { - self.$raise($scope.get('TypeError'), "no implicit conversion of Array into String") - } - // deal with splat issues (related to https://github.com/opal/opal/issues/858) - if (is_first_part_array) { - parts = parts[0]; - } - options = undefined; - quoted_validated = []; - for (var i=0; i < parts.length; i++) { - part = parts[i]; - if (part.$$is_string) { - quoted_validated.push(self.$escape(part)); - } - else if (part.$$is_regexp) { - each_part_options = (part).$options(); - if (options != undefined && options != each_part_options) { - self.$raise($scope.get('TypeError'), "All expressions must use the same options") - } - options = each_part_options; - quoted_validated.push('('+part.source+')'); - } - else { - quoted_validated.push(self.$escape((part).$to_str())); - } - } - - return self.$new((quoted_validated).$join("|"), options); - }); - return (Opal.defn(self, '$new', function(regexp, options) { - var self = this; - - - if (regexp.$$is_regexp) { - return new RegExp(regexp); - } - - regexp = $scope.get('Opal')['$coerce_to!'](regexp, $scope.get('String'), "to_str"); - - if (regexp.charAt(regexp.length - 1) === '\\') { - self.$raise($scope.get('RegexpError'), "too short escape sequence: /" + (regexp) + "/") - } - - if (options === undefined || options['$!']()) { - return new RegExp(regexp); - } - - if (options.$$is_number) { - var temp = ''; - if ($scope.get('IGNORECASE') & options) { temp += 'i'; } - if ($scope.get('MULTILINE') & options) { temp += 'm'; } - options = temp; - } - else { - options = 'i'; - } - - return new RegExp(regexp, options); - ; - }), nil) && 'new'; - })(Opal.get_singleton_class(self)); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return other.constructor == RegExp && self.toString() === other.toString(); - }); - - Opal.defn(self, '$===', function(string) { - var self = this; - - return self.$match($scope.get('Opal')['$coerce_to?'](string, $scope.get('String'), "to_str")) !== nil; - }); - - Opal.defn(self, '$=~', function(string) { - var $a, self = this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return ($a = self.$match(string), $a !== false && $a !== nil ?$gvars["~"].$begin(0) : $a); - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return self.toString(); - }); - - Opal.defn(self, '$match', TMP_2 = function(string, pos) { - var self = this, $iter = TMP_2.$$p, block = $iter || nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - TMP_2.$$p = null; - - if (self.uninitialized) { - self.$raise($scope.get('TypeError'), "uninitialized Regexp") - } - - if (pos === undefined) { - pos = 0; - } else { - pos = $scope.get('Opal').$coerce_to(pos, $scope.get('Integer'), "to_int"); - } - - if (string === nil) { - return $gvars["~"] = nil; - } - - string = $scope.get('Opal').$coerce_to(string, $scope.get('String'), "to_str"); - - if (pos < 0) { - pos += string.length; - if (pos < 0) { - return $gvars["~"] = nil; - } - } - - var source = self.source; - var flags = 'g'; - // m flag + a . in Ruby will match white space, but in JS, it only matches beginning/ending of lines, so we get the equivalent here - if (self.multiline) { - source = source.replace('.', "[\\s\\S]"); - flags += 'm'; - } - - // global RegExp maintains state, so not using self/this - var md, re = new RegExp(source, flags + (self.ignoreCase ? 'i' : '')); - - while (true) { - md = re.exec(string); - if (md === null) { - return $gvars["~"] = nil; - } - if (md.index >= pos) { - $gvars["~"] = $scope.get('MatchData').$new(re, md) - return block === nil ? $gvars["~"] : block.$call($gvars["~"]); - } - re.lastIndex = md.index + 1; - } - ; - }); - - Opal.defn(self, '$~', function() { - var self = this; - if ($gvars._ == null) $gvars._ = nil; - - return self['$=~']($gvars._); - }); - - Opal.defn(self, '$source', function() { - var self = this; - - return self.source; - }); - - Opal.defn(self, '$options', function() { - var self = this; - - - if (self.uninitialized) { - self.$raise($scope.get('TypeError'), "uninitialized Regexp") - } - var result = 0; - // should be supported in IE6 according to https://msdn.microsoft.com/en-us/library/7f5z26w4(v=vs.94).aspx - if (self.multiline) { - result |= $scope.get('MULTILINE'); - } - if (self.ignoreCase) { - result |= $scope.get('IGNORECASE'); - } - return result; - ; - }); - - Opal.defn(self, '$casefold?', function() { - var self = this; - - return self.ignoreCase; - }); - - return Opal.alias(self, 'to_s', 'source'); - })($scope.base, RegExp); - return (function($base, $super) { - function $MatchData(){}; - var self = $MatchData = $klass($base, $super, 'MatchData', $MatchData); - - var def = self.$$proto, $scope = self.$$scope; - - def.matches = nil; - self.$attr_reader("post_match", "pre_match", "regexp", "string"); - - Opal.defn(self, '$initialize', function(regexp, match_groups) { - var self = this; - - $gvars["~"] = self; - self.regexp = regexp; - self.begin = match_groups.index; - self.string = match_groups.input; - self.pre_match = match_groups.input.slice(0, match_groups.index); - self.post_match = match_groups.input.slice(match_groups.index + match_groups[0].length); - self.matches = []; - - for (var i = 0, length = match_groups.length; i < length; i++) { - var group = match_groups[i]; - - if (group == null) { - self.matches.push(nil); - } - else { - self.matches.push(group); - } - } - - }); - - Opal.defn(self, '$[]', function() { - var $a, 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 ($a = self.matches)['$[]'].apply($a, Opal.to_a(args)); - }); - - Opal.defn(self, '$offset', function(n) { - var self = this; - - - if (n !== 0) { - self.$raise($scope.get('ArgumentError'), "MatchData#offset only supports 0th element") - } - return [self.begin, self.begin + self.matches[n].length]; - ; - }); - - Opal.defn(self, '$==', function(other) { - var $a, $b, $c, $d, self = this; - - if ((($a = $scope.get('MatchData')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return false - }; - return ($a = ($b = ($c = ($d = self.string == other.string, $d !== false && $d !== nil ?self.regexp.toString() == other.regexp.toString() : $d), $c !== false && $c !== nil ?self.pre_match == other.pre_match : $c), $b !== false && $b !== nil ?self.post_match == other.post_match : $b), $a !== false && $a !== nil ?self.begin == other.begin : $a); - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.defn(self, '$begin', function(n) { - var self = this; - - - if (n !== 0) { - self.$raise($scope.get('ArgumentError'), "MatchData#begin only supports 0th element") - } - return self.begin; - ; - }); - - Opal.defn(self, '$end', function(n) { - var self = this; - - - if (n !== 0) { - self.$raise($scope.get('ArgumentError'), "MatchData#end only supports 0th element") - } - return self.begin + self.matches[n].length; - ; - }); - - Opal.defn(self, '$captures', function() { - var self = this; - - return self.matches.slice(1); - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - - var str = "#"; - ; - }); - - Opal.defn(self, '$length', function() { - var self = this; - - return self.matches.length; - }); - - Opal.alias(self, 'size', 'length'); - - Opal.defn(self, '$to_a', function() { - var self = this; - - return self.matches; - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return self.matches[0]; - }); - - return (Opal.defn(self, '$values_at', 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]; - } - - var i, a, index, values = []; - - for (i = 0; i < args.length; i++) { - - if (args[i].$$is_range) { - a = (args[i]).$to_a(); - a.unshift(i, 1); - Array.prototype.splice.apply(args, a); - } - - index = $scope.get('Opal')['$coerce_to!'](args[i], $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += self.matches.length; - if (index < 0) { - values.push(nil); - continue; - } - } - - values.push(self.matches[index]); - } - - return values; - - }), nil) && 'values_at'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/string"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - 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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars; - - Opal.add_stubs(['$require', '$include', '$coerce_to?', '$coerce_to', '$raise', '$===', '$format', '$to_s', '$respond_to?', '$to_str', '$<=>', '$==', '$=~', '$new', '$empty?', '$ljust', '$ceil', '$/', '$+', '$rjust', '$floor', '$to_a', '$each_char', '$to_proc', '$coerce_to!', '$copy_singleton_methods', '$initialize_clone', '$initialize_dup', '$enum_for', '$size', '$chomp', '$[]', '$to_i', '$class', '$each_line', '$match', '$captures', '$proc', '$shift', '$__send__', '$succ', '$escape']); - self.$require("corelib/comparable"); - self.$require("corelib/regexp"); - (function($base, $super) { - function $String(){}; - var self = $String = $klass($base, $super, 'String', $String); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_4, TMP_5, TMP_6, TMP_7, TMP_8, TMP_9, TMP_11; - - def.length = nil; - self.$include($scope.get('Comparable')); - - def.$$is_string = true; - - Opal.defn(self, '$__id__', function() { - var self = this; - - return self.toString(); - }); - - Opal.alias(self, 'object_id', '__id__'); - - Opal.defs(self, '$try_convert', function(what) { - var self = this; - - return $scope.get('Opal')['$coerce_to?'](what, $scope.get('String'), "to_str"); - }); - - Opal.defs(self, '$new', function(str) { - var self = this; - - if (str == null) { - str = "" - } - str = $scope.get('Opal').$coerce_to(str, $scope.get('String'), "to_str"); - return new String(str); - }); - - Opal.defn(self, '$initialize', function(str) { - var self = this; - - - if (str === undefined) { - return self; - } - - return self.$raise($scope.get('NotImplementedError'), "Mutable strings are not supported in Opal."); - }); - - Opal.defn(self, '$%', function(data) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](data)) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = self).$format.apply($a, [self].concat(Opal.to_a(data))) - } else { - return self.$format(self, data) - }; - }); - - Opal.defn(self, '$*', function(count) { - var self = this; - - - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - - if (count < 0) { - self.$raise($scope.get('ArgumentError'), "negative argument") - } - - if (count === 0) { - return ''; - } - - var result = '', - string = self.toString(); - - // All credit for the bit-twiddling magic code below goes to Mozilla - // polyfill implementation of String.prototype.repeat() posted here: - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat - - if (string.length * count >= 1 << 28) { - self.$raise($scope.get('RangeError'), "multiply count must not overflow maximum string size") - } - - for (;;) { - if ((count & 1) === 1) { - result += string; - } - count >>>= 1; - if (count === 0) { - break; - } - string += string; - } - - return result; - ; - }); - - Opal.defn(self, '$+', function(other) { - var self = this; - - other = $scope.get('Opal').$coerce_to(other, $scope.get('String'), "to_str"); - return self + other.$to_s(); - }); - - Opal.defn(self, '$<=>', function(other) { - var $a, self = this; - - if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_str().$to_s(); - return self > other ? 1 : (self < other ? -1 : 0); - } else { - - var cmp = other['$<=>'](self); - - if (cmp === nil) { - return nil; - } - else { - return cmp > 0 ? -1 : (cmp < 0 ? 1 : 0); - } - ; - }; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - - if (other.$$is_string) { - return self.toString() === other.toString(); - } - if ($scope.get('Opal')['$respond_to?'](other, "to_str")) { - return other['$=='](self); - } - return false; - ; - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.alias(self, '===', '=='); - - Opal.defn(self, '$=~', function(other) { - var self = this; - - - if (other.$$is_string) { - self.$raise($scope.get('TypeError'), "type mismatch: String given"); - } - - return other['$=~'](self); - ; - }); - - Opal.defn(self, '$[]', function(index, length) { - var self = this; - - - var size = self.length, exclude; - - if (index.$$is_range) { - exclude = index.exclude; - length = $scope.get('Opal').$coerce_to(index.end, $scope.get('Integer'), "to_int"); - index = $scope.get('Opal').$coerce_to(index.begin, $scope.get('Integer'), "to_int"); - - if (Math.abs(index) > size) { - return nil; - } - - if (index < 0) { - index += size; - } - - if (length < 0) { - length += size; - } - - if (!exclude) { - length += 1; - } - - length = length - index; - - if (length < 0) { - length = 0; - } - - return self.substr(index, length); - } - - - if (index.$$is_string) { - if (length != null) { - self.$raise($scope.get('TypeError')) - } - return self.indexOf(index) !== -1 ? index : nil; - } - - - if (index.$$is_regexp) { - var match = self.match(index); - - if (match === null) { - $gvars["~"] = nil - return nil; - } - - $gvars["~"] = $scope.get('MatchData').$new(index, match) - - if (length == null) { - return match[0]; - } - - length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int"); - - if (length < 0 && -length < match.length) { - return match[length += match.length]; - } - - if (length >= 0 && length < match.length) { - return match[length]; - } - - return nil; - } - - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += size; - } - - if (length == null) { - if (index >= size || index < 0) { - return nil; - } - return self.substr(index, 1); - } - - length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int"); - - if (length < 0) { - return nil; - } - - if (index > size || index < 0) { - return nil; - } - - return self.substr(index, length); - - }); - - Opal.alias(self, 'byteslice', '[]'); - - Opal.defn(self, '$capitalize', function() { - var self = this; - - return self.charAt(0).toUpperCase() + self.substr(1).toLowerCase(); - }); - - Opal.defn(self, '$casecmp', function(other) { - var self = this; - - other = $scope.get('Opal').$coerce_to(other, $scope.get('String'), "to_str").$to_s(); - - var ascii_only = /^[\x00-\x7F]*$/; - if (ascii_only.test(self) && ascii_only.test(other)) { - self = self.toLowerCase(); - other = other.toLowerCase(); - } - - return self['$<=>'](other); - }); - - Opal.defn(self, '$center', function(width, padstr) { - var $a, self = this; - - if (padstr == null) { - padstr = " " - } - width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int"); - padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s(); - if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "zero width padding")}; - if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - - var ljustified = self.$ljust($rb_divide(($rb_plus(width, self.length)), 2).$ceil(), padstr), - rjustified = self.$rjust($rb_divide(($rb_plus(width, self.length)), 2).$floor(), padstr); - - return rjustified + ljustified.slice(self.length); - ; - }); - - Opal.defn(self, '$chars', TMP_1 = function() { - var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil; - - TMP_1.$$p = null; - if (block !== false && block !== nil) { - } else { - return self.$each_char().$to_a() - }; - return ($a = ($b = self).$each_char, $a.$$p = block.$to_proc(), $a).call($b); - }); - - Opal.defn(self, '$chomp', function(separator) { - var $a, self = this; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - if ((($a = separator === nil || self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - separator = $scope.get('Opal')['$coerce_to!'](separator, $scope.get('String'), "to_str").$to_s(); - - if (separator === "\n") { - return self.replace(/\r?\n?$/, ''); - } - else if (separator === "") { - return self.replace(/(\r?\n)+$/, ''); - } - else if (self.length > separator.length) { - var tail = self.substr(self.length - separator.length, separator.length); - - if (tail === separator) { - return self.substr(0, self.length - separator.length); - } - } - - return self; - }); - - Opal.defn(self, '$chop', function() { - var self = this; - - - var length = self.length; - - if (length <= 1) { - return ""; - } - - if (self.charAt(length - 1) === "\n" && self.charAt(length - 2) === "\r") { - return self.substr(0, length - 2); - } - else { - return self.substr(0, length - 1); - } - - }); - - Opal.defn(self, '$chr', function() { - var self = this; - - return self.charAt(0); - }); - - Opal.defn(self, '$clone', function() { - var self = this, copy = nil; - - copy = self.slice(); - copy.$copy_singleton_methods(self); - copy.$initialize_clone(self); - return copy; - }); - - Opal.defn(self, '$dup', function() { - var self = this, copy = nil; - - copy = self.slice(); - copy.$initialize_dup(self); - return copy; - }); - - Opal.defn(self, '$count', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var sets = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - sets[arg_index] = arguments[arg_index + 0]; - } - - if (sets.length === 0) { - self.$raise($scope.get('ArgumentError'), "ArgumentError: wrong number of arguments (0 for 1+)") - } - var char_class = char_class_from_char_sets(sets); - if (char_class === null) { - return 0; - } - return self.length - self.replace(new RegExp(char_class, 'g'), '').length; - ; - }); - - Opal.defn(self, '$delete', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var sets = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - sets[arg_index] = arguments[arg_index + 0]; - } - - if (sets.length === 0) { - self.$raise($scope.get('ArgumentError'), "ArgumentError: wrong number of arguments (0 for 1+)") - } - var char_class = char_class_from_char_sets(sets); - if (char_class === null) { - return self; - } - return self.replace(new RegExp(char_class, 'g'), ''); - ; - }); - - Opal.defn(self, '$downcase', function() { - var self = this; - - return self.toLowerCase(); - }); - - Opal.defn(self, '$each_char', TMP_2 = function() { - var $a, $b, TMP_3, self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_3 = function(){var self = TMP_3.$$s || this; - - return self.$size()}, TMP_3.$$s = self, TMP_3), $a).call($b, "each_char") - }; - - for (var i = 0, length = self.length; i < length; i++) { - var value = Opal.yield1(block, self.charAt(i)); - - if (value === $breaker) { - return $breaker.$v; - } - } - - return self; - }); - - Opal.defn(self, '$each_line', TMP_4 = function(separator) { - var self = this, $iter = TMP_4.$$p, block = $iter || nil; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - TMP_4.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("each_line", separator) - }; - - var value; - - if (separator === nil) { - value = Opal.yield1(block, self); - - if (value === $breaker) { - return value.$v; - } - else { - return self; - } - } - - separator = $scope.get('Opal').$coerce_to(separator, $scope.get('String'), "to_str") - - var a, i, n, length, chomped, trailing, splitted; - - if (separator.length === 0) { - for (a = self.split(/(\n{2,})/), i = 0, n = a.length; i < n; i += 2) { - if (a[i] || a[i + 1]) { - value = Opal.yield1(block, (a[i] || "") + (a[i + 1] || "")); - - if (value === $breaker) { - return value.$v; - } - } - } - - return self; - } - - chomped = self.$chomp(separator); - trailing = self.length != chomped.length; - splitted = chomped.split(separator); - - for (i = 0, length = splitted.length; i < length; i++) { - if (i < length - 1 || trailing) { - value = Opal.yield1(block, splitted[i] + separator); - - if (value === $breaker) { - return value.$v; - } - } - else { - value = Opal.yield1(block, splitted[i]); - - if (value === $breaker) { - return value.$v; - } - } - } - - return self; - }); - - Opal.defn(self, '$empty?', function() { - var self = this; - - return self.length === 0; - }); - - Opal.defn(self, '$end_with?', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var suffixes = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - suffixes[arg_index] = arguments[arg_index + 0]; - } - - for (var i = 0, length = suffixes.length; i < length; i++) { - var suffix = $scope.get('Opal').$coerce_to(suffixes[i], $scope.get('String'), "to_str").$to_s(); - - if (self.length >= suffix.length && - self.substr(self.length - suffix.length, suffix.length) == suffix) { - return true; - } - } - - return false; - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.alias(self, 'equal?', '==='); - - Opal.defn(self, '$gsub', TMP_5 = function(pattern, replacement) { - var self = this, $iter = TMP_5.$$p, block = $iter || nil; - - TMP_5.$$p = null; - - if (replacement === undefined && block === nil) { - return self.$enum_for("gsub", pattern); - } - - var result = '', match_data = nil, index = 0, match, _replacement; - - if (pattern.$$is_regexp) { - pattern = new RegExp(pattern.source, 'gm' + (pattern.ignoreCase ? 'i' : '')); - } else { - pattern = $scope.get('Opal').$coerce_to(pattern, $scope.get('String'), "to_str"); - pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); - } - - while (true) { - match = pattern.exec(self); - - if (match === null) { - $gvars["~"] = nil - result += self.slice(index); - break; - } - - match_data = $scope.get('MatchData').$new(pattern, match); - - if (replacement === undefined) { - _replacement = block(match[0]); - } - else if (replacement.$$is_hash) { - _replacement = (replacement)['$[]'](match[0]).$to_s(); - } - else { - if (!replacement.$$is_string) { - replacement = $scope.get('Opal').$coerce_to(replacement, $scope.get('String'), "to_str"); - } - _replacement = replacement.replace(/([\\]+)([0-9+&`'])/g, function (original, slashes, command) { - if (slashes.length % 2 === 0) { - return original; - } - switch (command) { - case "+": - for (var i = match.length - 1; i > 0; i--) { - if (match[i] !== undefined) { - return slashes.slice(1) + match[i]; - } - } - return ''; - case "&": return slashes.slice(1) + match[0]; - case "`": return slashes.slice(1) + self.slice(0, match.index); - case "'": return slashes.slice(1) + self.slice(match.index + match[0].length); - default: return slashes.slice(1) + (match[command] || ''); - } - }).replace(/\\\\/g, '\\'); - } - - if (pattern.lastIndex === match.index) { - result += (_replacement + self.slice(index, match.index + 1)) - pattern.lastIndex += 1; - } - else { - result += (self.slice(index, match.index) + _replacement) - } - index = pattern.lastIndex; - } - - $gvars["~"] = match_data - return result; - ; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return self.toString(); - }); - - Opal.defn(self, '$hex', function() { - var self = this; - - return self.$to_i(16); - }); - - Opal.defn(self, '$include?', function(other) { - var $a, self = this; - - - if (other.$$is_string) { - return self.indexOf(other) !== -1; - } - - if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "no implicit conversion of " + (other.$class()) + " into String") - }; - return self.indexOf(other.$to_str()) !== -1; - }); - - Opal.defn(self, '$index', function(search, offset) { - var self = this; - - - var index, - match, - regex; - - if (offset === undefined) { - offset = 0; - } else { - offset = $scope.get('Opal').$coerce_to(offset, $scope.get('Integer'), "to_int"); - if (offset < 0) { - offset += self.length; - if (offset < 0) { - return nil; - } - } - } - - if (search.$$is_regexp) { - regex = new RegExp(search.source, 'gm' + (search.ignoreCase ? 'i' : '')); - while (true) { - match = regex.exec(self); - if (match === null) { - $gvars["~"] = nil; - index = -1; - break; - } - if (match.index >= offset) { - $gvars["~"] = $scope.get('MatchData').$new(regex, match) - index = match.index; - break; - } - regex.lastIndex = match.index + 1; - } - } else { - search = $scope.get('Opal').$coerce_to(search, $scope.get('String'), "to_str"); - if (search.length === 0 && offset > self.length) { - index = -1; - } else { - index = self.indexOf(search, offset); - } - } - - return index === -1 ? nil : index; - - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { - '\u0007': '\\a', - '\u001b': '\\e', - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\v': '\\v', - '"' : '\\"', - '\\': '\\\\' - }, - escaped = self.replace(escapable, function (chr) { - return meta[chr] || '\\u' + ('0000' + chr.charCodeAt(0).toString(16).toUpperCase()).slice(-4); - }); - return '"' + escaped.replace(/\#[\$\@\{]/g, '\\$&') + '"'; - - }); - - Opal.defn(self, '$intern', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$lines', TMP_6 = function(separator) { - var $a, $b, self = this, $iter = TMP_6.$$p, block = $iter || nil, e = nil; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - TMP_6.$$p = null; - e = ($a = ($b = self).$each_line, $a.$$p = block.$to_proc(), $a).call($b, separator); - if (block !== false && block !== nil) { - return self - } else { - return e.$to_a() - }; - }); - - Opal.defn(self, '$length', function() { - var self = this; - - return self.length; - }); - - Opal.defn(self, '$ljust', function(width, padstr) { - var $a, self = this; - - if (padstr == null) { - padstr = " " - } - width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int"); - padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s(); - if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "zero width padding")}; - if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - - var index = -1, - result = ""; - - width -= self.length; - - while (++index < width) { - result += padstr; - } - - return self + result.slice(0, width); - - }); - - Opal.defn(self, '$lstrip', function() { - var self = this; - - return self.replace(/^\s*/, ''); - }); - - Opal.defn(self, '$match', TMP_7 = function(pattern, pos) { - var $a, $b, self = this, $iter = TMP_7.$$p, block = $iter || nil; - - TMP_7.$$p = null; - if ((($a = ((($b = $scope.get('String')['$==='](pattern)) !== false && $b !== nil) ? $b : pattern['$respond_to?']("to_str"))) !== nil && (!$a.$$is_boolean || $a == true))) { - pattern = $scope.get('Regexp').$new(pattern.$to_str())}; - if ((($a = $scope.get('Regexp')['$==='](pattern)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "wrong argument type " + (pattern.$class()) + " (expected Regexp)") - }; - return ($a = ($b = pattern).$match, $a.$$p = block.$to_proc(), $a).call($b, self, pos); - }); - - Opal.defn(self, '$next', function() { - var self = this; - - - var i = self.length; - if (i === 0) { - return ''; - } - var result = self; - var first_alphanum_char_index = self.search(/[a-zA-Z0-9]/); - var carry = false; - var code; - while (i--) { - code = self.charCodeAt(i); - if ((code >= 48 && code <= 57) || - (code >= 65 && code <= 90) || - (code >= 97 && code <= 122)) { - switch (code) { - case 57: - carry = true; - code = 48; - break; - case 90: - carry = true; - code = 65; - break; - case 122: - carry = true; - code = 97; - break; - default: - carry = false; - code += 1; - } - } else { - if (first_alphanum_char_index === -1) { - if (code === 255) { - carry = true; - code = 0; - } else { - carry = false; - code += 1; - } - } else { - carry = true; - } - } - result = result.slice(0, i) + String.fromCharCode(code) + result.slice(i + 1); - if (carry && (i === 0 || i === first_alphanum_char_index)) { - switch (code) { - case 65: - break; - case 97: - break; - default: - code += 1; - } - if (i === 0) { - result = String.fromCharCode(code) + result; - } else { - result = result.slice(0, i) + String.fromCharCode(code) + result.slice(i); - } - carry = false; - } - if (!carry) { - break; - } - } - return result; - - }); - - Opal.defn(self, '$oct', function() { - var self = this; - - - var result, - string = self, - radix = 8; - - if (/^\s*_/.test(string)) { - return 0; - } - - string = string.replace(/^(\s*[+-]?)(0[bodx]?)(.+)$/i, function (original, head, flag, tail) { - switch (tail.charAt(0)) { - case '+': - case '-': - return original; - case '0': - if (tail.charAt(1) === 'x' && flag === '0x') { - return original; - } - } - switch (flag) { - case '0b': - radix = 2; - break; - case '0': - case '0o': - radix = 8; - break; - case '0d': - radix = 10; - break; - case '0x': - radix = 16; - break; - } - return head + tail; - }); - - result = parseInt(string.replace(/_(?!_)/g, ''), radix); - return isNaN(result) ? 0 : result; - - }); - - Opal.defn(self, '$ord', function() { - var self = this; - - return self.charCodeAt(0); - }); - - Opal.defn(self, '$partition', function(sep) { - var self = this; - - - var i, m; - - if (sep.$$is_regexp) { - m = sep.exec(self); - if (m === null) { - i = -1; - } else { - $scope.get('MatchData').$new(sep, m); - sep = m[0]; - i = m.index; - } - } else { - sep = $scope.get('Opal').$coerce_to(sep, $scope.get('String'), "to_str"); - i = self.indexOf(sep); - } - - if (i === -1) { - return [self, '', '']; - } - - return [ - self.slice(0, i), - self.slice(i, i + sep.length), - self.slice(i + sep.length) - ]; - - }); - - Opal.defn(self, '$reverse', function() { - var self = this; - - return self.split('').reverse().join(''); - }); - - Opal.defn(self, '$rindex', function(search, offset) { - var self = this; - - - var i, m, r, _m; - - if (offset === undefined) { - offset = self.length; - } else { - offset = $scope.get('Opal').$coerce_to(offset, $scope.get('Integer'), "to_int"); - if (offset < 0) { - offset += self.length; - if (offset < 0) { - return nil; - } - } - } - - if (search.$$is_regexp) { - m = null; - r = new RegExp(search.source, 'gm' + (search.ignoreCase ? 'i' : '')); - while (true) { - _m = r.exec(self); - if (_m === null || _m.index > offset) { - break; - } - m = _m; - r.lastIndex = m.index + 1; - } - if (m === null) { - $gvars["~"] = nil - i = -1; - } else { - $scope.get('MatchData').$new(r, m); - i = m.index; - } - } else { - search = $scope.get('Opal').$coerce_to(search, $scope.get('String'), "to_str"); - i = self.lastIndexOf(search, offset); - } - - return i === -1 ? nil : i; - - }); - - Opal.defn(self, '$rjust', function(width, padstr) { - var $a, self = this; - - if (padstr == null) { - padstr = " " - } - width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int"); - padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s(); - if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "zero width padding")}; - if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - - var chars = Math.floor(width - self.length), - patterns = Math.floor(chars / padstr.length), - result = Array(patterns + 1).join(padstr), - remaining = chars - result.length; - - return result + padstr.slice(0, remaining) + self; - - }); - - Opal.defn(self, '$rpartition', function(sep) { - var self = this; - - - var i, m, r, _m; - - if (sep.$$is_regexp) { - m = null; - r = new RegExp(sep.source, 'gm' + (sep.ignoreCase ? 'i' : '')); - - while (true) { - _m = r.exec(self); - if (_m === null) { - break; - } - m = _m; - r.lastIndex = m.index + 1; - } - - if (m === null) { - i = -1; - } else { - $scope.get('MatchData').$new(r, m); - sep = m[0]; - i = m.index; - } - - } else { - sep = $scope.get('Opal').$coerce_to(sep, $scope.get('String'), "to_str"); - i = self.lastIndexOf(sep); - } - - if (i === -1) { - return ['', '', self]; - } - - return [ - self.slice(0, i), - self.slice(i, i + sep.length), - self.slice(i + sep.length) - ]; - - }); - - Opal.defn(self, '$rstrip', function() { - var self = this; - - return self.replace(/[\s\u0000]*$/, ''); - }); - - Opal.defn(self, '$scan', TMP_8 = function(pattern) { - var self = this, $iter = TMP_8.$$p, block = $iter || nil; - - TMP_8.$$p = null; - - var result = [], - match_data = nil, - match; - - if (pattern.$$is_regexp) { - pattern = new RegExp(pattern.source, 'gm' + (pattern.ignoreCase ? 'i' : '')); - } else { - pattern = $scope.get('Opal').$coerce_to(pattern, $scope.get('String'), "to_str"); - pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); - } - - while ((match = pattern.exec(self)) != null) { - match_data = $scope.get('MatchData').$new(pattern, match); - if (block === nil) { - match.length == 1 ? result.push(match[0]) : result.push((match_data).$captures()); - } else { - match.length == 1 ? block(match[0]) : block.call(self, (match_data).$captures()); - } - if (pattern.lastIndex === match.index) { - pattern.lastIndex += 1; - } - } - - $gvars["~"] = match_data - - return (block !== nil ? self : result); - - }); - - Opal.alias(self, 'size', 'length'); - - Opal.alias(self, 'slice', '[]'); - - Opal.defn(self, '$split', function(pattern, limit) { - var $a, self = this; - if ($gvars[";"] == null) $gvars[";"] = nil; - - - if (self.length === 0) { - return []; - } - - if (limit === undefined) { - limit = 0; - } else { - limit = $scope.get('Opal')['$coerce_to!'](limit, $scope.get('Integer'), "to_int"); - if (limit === 1) { - return [self]; - } - } - - if (pattern === undefined || pattern === nil) { - pattern = ((($a = $gvars[";"]) !== false && $a !== nil) ? $a : " "); - } - - var result = [], - string = self.toString(), - index = 0, - match, - i; - - if (pattern.$$is_regexp) { - pattern = new RegExp(pattern.source, 'gm' + (pattern.ignoreCase ? 'i' : '')); - } else { - pattern = $scope.get('Opal').$coerce_to(pattern, $scope.get('String'), "to_str").$to_s(); - if (pattern === ' ') { - pattern = /\s+/gm; - string = string.replace(/^\s+/, ''); - } else { - pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); - } - } - - result = string.split(pattern); - - if (result.length === 1 && result[0] === string) { - return result; - } - - while ((i = result.indexOf(undefined)) !== -1) { - result.splice(i, 1); - } - - if (limit === 0) { - while (result[result.length - 1] === '') { - result.length -= 1; - } - return result; - } - - match = pattern.exec(string); - - if (limit < 0) { - if (match !== null && match[0] === '' && pattern.source.indexOf('(?=') === -1) { - for (i = 0; i < match.length; i++) { - result.push(''); - } - } - return result; - } - - if (match !== null && match[0] === '') { - result.splice(limit - 1, result.length - 1, result.slice(limit - 1).join('')); - return result; - } - - i = 0; - while (match !== null) { - i++; - index = pattern.lastIndex; - if (i + 1 === limit) { - break; - } - match = pattern.exec(string); - } - - result.splice(limit - 1, result.length - 1, string.slice(index)); - return result; - - }); - - Opal.defn(self, '$squeeze', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var sets = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - sets[arg_index] = arguments[arg_index + 0]; - } - - if (sets.length === 0) { - return self.replace(/(.)\1+/g, '$1'); - } - var char_class = char_class_from_char_sets(sets); - if (char_class === null) { - return self; - } - return self.replace(new RegExp('(' + char_class + ')\\1+', 'g'), '$1'); - - }); - - Opal.defn(self, '$start_with?', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var prefixes = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - prefixes[arg_index] = arguments[arg_index + 0]; - } - - for (var i = 0, length = prefixes.length; i < length; i++) { - var prefix = $scope.get('Opal').$coerce_to(prefixes[i], $scope.get('String'), "to_str").$to_s(); - - if (self.indexOf(prefix) === 0) { - return true; - } - } - - return false; - - }); - - Opal.defn(self, '$strip', function() { - var self = this; - - return self.replace(/^\s*/, '').replace(/[\s\u0000]*$/, ''); - }); - - Opal.defn(self, '$sub', TMP_9 = function(pattern, replacement) { - var self = this, $iter = TMP_9.$$p, block = $iter || nil; - - TMP_9.$$p = null; - - if (!pattern.$$is_regexp) { - pattern = $scope.get('Opal').$coerce_to(pattern, $scope.get('String'), "to_str"); - pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')); - } - - var result = pattern.exec(self); - - if (result === null) { - $gvars["~"] = nil - return self.toString(); - } - - $scope.get('MatchData').$new(pattern, result) - - if (replacement === undefined) { - if (block === nil) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (1 for 2)") - } - return self.slice(0, result.index) + block(result[0]) + self.slice(result.index + result[0].length); - } - - if (replacement.$$is_hash) { - return self.slice(0, result.index) + (replacement)['$[]'](result[0]).$to_s() + self.slice(result.index + result[0].length); - } - - replacement = $scope.get('Opal').$coerce_to(replacement, $scope.get('String'), "to_str"); - - replacement = replacement.replace(/([\\]+)([0-9+&`'])/g, function (original, slashes, command) { - if (slashes.length % 2 === 0) { - return original; - } - switch (command) { - case "+": - for (var i = result.length - 1; i > 0; i--) { - if (result[i] !== undefined) { - return slashes.slice(1) + result[i]; - } - } - return ''; - case "&": return slashes.slice(1) + result[0]; - case "`": return slashes.slice(1) + self.slice(0, result.index); - case "'": return slashes.slice(1) + self.slice(result.index + result[0].length); - default: return slashes.slice(1) + (result[command] || ''); - } - }).replace(/\\\\/g, '\\'); - - return self.slice(0, result.index) + replacement + self.slice(result.index + result[0].length); - ; - }); - - Opal.alias(self, 'succ', 'next'); - - Opal.defn(self, '$sum', function(n) { - var self = this; - - if (n == null) { - n = 16 - } - - n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int"); - - var result = 0, - length = self.length, - i = 0; - - for (; i < length; i++) { - result += self.charCodeAt(i); - } - - if (n <= 0) { - return result; - } - - return result & (Math.pow(2, n) - 1); - ; - }); - - Opal.defn(self, '$swapcase', function() { - var self = this; - - - var str = self.replace(/([a-z]+)|([A-Z]+)/g, function($0,$1,$2) { - return $1 ? $0.toUpperCase() : $0.toLowerCase(); - }); - - if (self.constructor === String) { - return str; - } - - return self.$class().$new(str); - - }); - - Opal.defn(self, '$to_f', function() { - var self = this; - - - if (self.charAt(0) === '_') { - return 0; - } - - var result = parseFloat(self.replace(/_/g, '')); - - if (isNaN(result) || result == Infinity || result == -Infinity) { - return 0; - } - else { - return result; - } - - }); - - Opal.defn(self, '$to_i', function(base) { - var self = this; - - if (base == null) { - base = 10 - } - - var result, - string = self.toLowerCase(), - radix = $scope.get('Opal').$coerce_to(base, $scope.get('Integer'), "to_int"); - - if (radix === 1 || radix < 0 || radix > 36) { - self.$raise($scope.get('ArgumentError'), "invalid radix " + (radix)) - } - - if (/^\s*_/.test(string)) { - return 0; - } - - string = string.replace(/^(\s*[+-]?)(0[bodx]?)(.+)$/, function (original, head, flag, tail) { - switch (tail.charAt(0)) { - case '+': - case '-': - return original; - case '0': - if (tail.charAt(1) === 'x' && flag === '0x' && (radix === 0 || radix === 16)) { - return original; - } - } - switch (flag) { - case '0b': - if (radix === 0 || radix === 2) { - radix = 2; - return head + tail; - } - break; - case '0': - case '0o': - if (radix === 0 || radix === 8) { - radix = 8; - return head + tail; - } - break; - case '0d': - if (radix === 0 || radix === 10) { - radix = 10; - return head + tail; - } - break; - case '0x': - if (radix === 0 || radix === 16) { - radix = 16; - return head + tail; - } - break; - } - return original - }); - - result = parseInt(string.replace(/_(?!_)/g, ''), radix); - return isNaN(result) ? 0 : result; - ; - }); - - Opal.defn(self, '$to_proc', function() { - var $a, $b, TMP_10, self = this, sym = nil; - - sym = self; - return ($a = ($b = self).$proc, $a.$$p = (TMP_10 = function(args){var self = TMP_10.$$s || this, block, $a, $b, obj = nil; -args = $slice.call(arguments, 0); - block = TMP_10.$$p || nil, TMP_10.$$p = null; - if ((($a = args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "no receiver given")}; - obj = args.$shift(); - return ($a = ($b = obj).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, [sym].concat(Opal.to_a(args)));}, TMP_10.$$s = self, TMP_10), $a).call($b); - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return self.toString(); - }); - - Opal.alias(self, 'to_str', 'to_s'); - - Opal.alias(self, 'to_sym', 'intern'); - - Opal.defn(self, '$tr', function(from, to) { - var self = this; - - from = $scope.get('Opal').$coerce_to(from, $scope.get('String'), "to_str").$to_s(); - to = $scope.get('Opal').$coerce_to(to, $scope.get('String'), "to_str").$to_s(); - - if (from.length == 0 || from === to) { - return self; - } - - var i, in_range, c, ch, start, end, length; - var subs = {}; - var from_chars = from.split(''); - var from_length = from_chars.length; - var to_chars = to.split(''); - var to_length = to_chars.length; - - var inverse = false; - var global_sub = null; - if (from_chars[0] === '^' && from_chars.length > 1) { - inverse = true; - from_chars.shift(); - global_sub = to_chars[to_length - 1] - from_length -= 1; - } - - var from_chars_expanded = []; - var last_from = null; - in_range = false; - for (i = 0; i < from_length; i++) { - ch = from_chars[i]; - if (last_from == null) { - last_from = ch; - from_chars_expanded.push(ch); - } - else if (ch === '-') { - if (last_from === '-') { - from_chars_expanded.push('-'); - from_chars_expanded.push('-'); - } - else if (i == from_length - 1) { - from_chars_expanded.push('-'); - } - else { - in_range = true; - } - } - else if (in_range) { - start = last_from.charCodeAt(0); - end = ch.charCodeAt(0); - if (start > end) { - self.$raise($scope.get('ArgumentError'), "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") - } - for (c = start + 1; c < end; c++) { - from_chars_expanded.push(String.fromCharCode(c)); - } - from_chars_expanded.push(ch); - in_range = null; - last_from = null; - } - else { - from_chars_expanded.push(ch); - } - } - - from_chars = from_chars_expanded; - from_length = from_chars.length; - - if (inverse) { - for (i = 0; i < from_length; i++) { - subs[from_chars[i]] = true; - } - } - else { - if (to_length > 0) { - var to_chars_expanded = []; - var last_to = null; - in_range = false; - for (i = 0; i < to_length; i++) { - ch = to_chars[i]; - if (last_from == null) { - last_from = ch; - to_chars_expanded.push(ch); - } - else if (ch === '-') { - if (last_to === '-') { - to_chars_expanded.push('-'); - to_chars_expanded.push('-'); - } - else if (i == to_length - 1) { - to_chars_expanded.push('-'); - } - else { - in_range = true; - } - } - else if (in_range) { - start = last_from.charCodeAt(0); - end = ch.charCodeAt(0); - if (start > end) { - self.$raise($scope.get('ArgumentError'), "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") - } - for (c = start + 1; c < end; c++) { - to_chars_expanded.push(String.fromCharCode(c)); - } - to_chars_expanded.push(ch); - in_range = null; - last_from = null; - } - else { - to_chars_expanded.push(ch); - } - } - - to_chars = to_chars_expanded; - to_length = to_chars.length; - } - - var length_diff = from_length - to_length; - if (length_diff > 0) { - var pad_char = (to_length > 0 ? to_chars[to_length - 1] : ''); - for (i = 0; i < length_diff; i++) { - to_chars.push(pad_char); - } - } - - for (i = 0; i < from_length; i++) { - subs[from_chars[i]] = to_chars[i]; - } - } - - var new_str = '' - for (i = 0, length = self.length; i < length; i++) { - ch = self.charAt(i); - var sub = subs[ch]; - if (inverse) { - new_str += (sub == null ? global_sub : ch); - } - else { - new_str += (sub != null ? sub : ch); - } - } - return new_str; - - }); - - Opal.defn(self, '$tr_s', function(from, to) { - var self = this; - - from = $scope.get('Opal').$coerce_to(from, $scope.get('String'), "to_str").$to_s(); - to = $scope.get('Opal').$coerce_to(to, $scope.get('String'), "to_str").$to_s(); - - if (from.length == 0) { - return self; - } - - var i, in_range, c, ch, start, end, length; - var subs = {}; - var from_chars = from.split(''); - var from_length = from_chars.length; - var to_chars = to.split(''); - var to_length = to_chars.length; - - var inverse = false; - var global_sub = null; - if (from_chars[0] === '^' && from_chars.length > 1) { - inverse = true; - from_chars.shift(); - global_sub = to_chars[to_length - 1] - from_length -= 1; - } - - var from_chars_expanded = []; - var last_from = null; - in_range = false; - for (i = 0; i < from_length; i++) { - ch = from_chars[i]; - if (last_from == null) { - last_from = ch; - from_chars_expanded.push(ch); - } - else if (ch === '-') { - if (last_from === '-') { - from_chars_expanded.push('-'); - from_chars_expanded.push('-'); - } - else if (i == from_length - 1) { - from_chars_expanded.push('-'); - } - else { - in_range = true; - } - } - else if (in_range) { - start = last_from.charCodeAt(0); - end = ch.charCodeAt(0); - if (start > end) { - self.$raise($scope.get('ArgumentError'), "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") - } - for (c = start + 1; c < end; c++) { - from_chars_expanded.push(String.fromCharCode(c)); - } - from_chars_expanded.push(ch); - in_range = null; - last_from = null; - } - else { - from_chars_expanded.push(ch); - } - } - - from_chars = from_chars_expanded; - from_length = from_chars.length; - - if (inverse) { - for (i = 0; i < from_length; i++) { - subs[from_chars[i]] = true; - } - } - else { - if (to_length > 0) { - var to_chars_expanded = []; - var last_to = null; - in_range = false; - for (i = 0; i < to_length; i++) { - ch = to_chars[i]; - if (last_from == null) { - last_from = ch; - to_chars_expanded.push(ch); - } - else if (ch === '-') { - if (last_to === '-') { - to_chars_expanded.push('-'); - to_chars_expanded.push('-'); - } - else if (i == to_length - 1) { - to_chars_expanded.push('-'); - } - else { - in_range = true; - } - } - else if (in_range) { - start = last_from.charCodeAt(0); - end = ch.charCodeAt(0); - if (start > end) { - self.$raise($scope.get('ArgumentError'), "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") - } - for (c = start + 1; c < end; c++) { - to_chars_expanded.push(String.fromCharCode(c)); - } - to_chars_expanded.push(ch); - in_range = null; - last_from = null; - } - else { - to_chars_expanded.push(ch); - } - } - - to_chars = to_chars_expanded; - to_length = to_chars.length; - } - - var length_diff = from_length - to_length; - if (length_diff > 0) { - var pad_char = (to_length > 0 ? to_chars[to_length - 1] : ''); - for (i = 0; i < length_diff; i++) { - to_chars.push(pad_char); - } - } - - for (i = 0; i < from_length; i++) { - subs[from_chars[i]] = to_chars[i]; - } - } - var new_str = '' - var last_substitute = null - for (i = 0, length = self.length; i < length; i++) { - ch = self.charAt(i); - var sub = subs[ch] - if (inverse) { - if (sub == null) { - if (last_substitute == null) { - new_str += global_sub; - last_substitute = true; - } - } - else { - new_str += ch; - last_substitute = null; - } - } - else { - if (sub != null) { - if (last_substitute == null || last_substitute !== sub) { - new_str += sub; - last_substitute = sub; - } - } - else { - new_str += ch; - last_substitute = null; - } - } - } - return new_str; - - }); - - Opal.defn(self, '$upcase', function() { - var self = this; - - return self.toUpperCase(); - }); - - Opal.defn(self, '$upto', TMP_11 = function(stop, excl) { - var self = this, $iter = TMP_11.$$p, block = $iter || nil; - - if (excl == null) { - excl = false - } - TMP_11.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("upto", stop, excl) - }; - stop = $scope.get('Opal').$coerce_to(stop, $scope.get('String'), "to_str"); - - var a, b, s = self.toString(); - - if (s.length === 1 && stop.length === 1) { - - a = s.charCodeAt(0); - b = stop.charCodeAt(0); - - while (a <= b) { - if (excl && a === b) { - break; - } - block(String.fromCharCode(a)); - a += 1; - } - - } else if (parseInt(s, 10).toString() === s && parseInt(stop, 10).toString() === stop) { - - a = parseInt(s, 10); - b = parseInt(stop, 10); - - while (a <= b) { - if (excl && a === b) { - break; - } - block(a.toString()); - a += 1; - } - - } else { - - while (s.length <= stop.length && s <= stop) { - if (excl && s === stop) { - break; - } - block(s); - s = (s).$succ(); - } - - } - return self; - - }); - - - function char_class_from_char_sets(sets) { - function explode_sequences_in_character_set(set) { - var result = '', - i, len = set.length, - curr_char, - skip_next_dash, - char_code_from, - char_code_upto, - char_code; - for (i = 0; i < len; i++) { - curr_char = set.charAt(i); - if (curr_char === '-' && i > 0 && i < (len - 1) && !skip_next_dash) { - char_code_from = set.charCodeAt(i - 1); - char_code_upto = set.charCodeAt(i + 1); - if (char_code_from > char_code_upto) { - self.$raise($scope.get('ArgumentError'), "invalid range \"" + (char_code_from) + "-" + (char_code_upto) + "\" in string transliteration") - } - for (char_code = char_code_from + 1; char_code < char_code_upto + 1; char_code++) { - result += String.fromCharCode(char_code); - } - skip_next_dash = true; - i++; - } else { - skip_next_dash = (curr_char === '\\'); - result += curr_char; - } - } - return result; - } - - function intersection(setA, setB) { - if (setA.length === 0) { - return setB; - } - var result = '', - i, len = setA.length, - chr; - for (i = 0; i < len; i++) { - chr = setA.charAt(i); - if (setB.indexOf(chr) !== -1) { - result += chr; - } - } - return result; - } - - var i, len, set, neg, chr, tmp, - pos_intersection = '', - neg_intersection = ''; - - for (i = 0, len = sets.length; i < len; i++) { - set = $scope.get('Opal').$coerce_to(sets[i], $scope.get('String'), "to_str"); - neg = (set.charAt(0) === '^' && set.length > 1); - set = explode_sequences_in_character_set(neg ? set.slice(1) : set); - if (neg) { - neg_intersection = intersection(neg_intersection, set); - } else { - pos_intersection = intersection(pos_intersection, set); - } - } - - if (pos_intersection.length > 0 && neg_intersection.length > 0) { - tmp = ''; - for (i = 0, len = pos_intersection.length; i < len; i++) { - chr = pos_intersection.charAt(i); - if (neg_intersection.indexOf(chr) === -1) { - tmp += chr; - } - } - pos_intersection = tmp; - neg_intersection = ''; - } - - if (pos_intersection.length > 0) { - return '[' + $scope.get('Regexp').$escape(pos_intersection) + ']'; - } - - if (neg_intersection.length > 0) { - return '[^' + $scope.get('Regexp').$escape(neg_intersection) + ']'; - } - - return null; - } - - })($scope.base, String); - return Opal.cdecl($scope, 'Symbol', $scope.get('String')); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/enumerable"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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); - } - function $rb_minus(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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; - - Opal.add_stubs(['$raise', '$new', '$yield', '$dup', '$enum_for', '$enumerator_size', '$flatten', '$map', '$==', '$destructure', '$respond_to?', '$coerce_to!', '$>', '$*', '$nil?', '$coerce_to', '$try_convert', '$<', '$+', '$-', '$ceil', '$/', '$size', '$===', '$<<', '$[]', '$[]=', '$inspect', '$__send__', '$compare', '$<=>', '$proc', '$call', '$to_a', '$lambda', '$sort!', '$map!', '$first', '$zip']); - return (function($base) { - var self = $module($base, 'Enumerable'); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_6, TMP_8, TMP_11, TMP_12, TMP_14, TMP_15, TMP_16, TMP_18, TMP_19, TMP_21, TMP_23, TMP_25, TMP_27, TMP_28, TMP_29, TMP_31, TMP_33, TMP_34, TMP_36, TMP_37, TMP_39, TMP_41, TMP_42, TMP_43, TMP_44, TMP_46, TMP_48, TMP_50, TMP_52, TMP_54, TMP_59, TMP_60; - - Opal.defn(self, '$all?', TMP_1 = function() { - var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil; - - TMP_1.$$p = null; - - var result = true; - - if (block !== nil) { - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - result = false; - return $breaker; - } - }; - } - else { - self.$each.$$p = function(obj) { - if (arguments.length == 1 && (($a = obj) === nil || ($a.$$is_boolean && $a == false))) { - result = false; - return $breaker; - } - }; - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$any?', TMP_2 = function() { - var $a, self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - - var result = false; - - if (block !== nil) { - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result = true; - return $breaker; - } - }; - } - else { - self.$each.$$p = function(obj) { - if (arguments.length != 1 || (($a = obj) !== nil && (!$a.$$is_boolean || $a == true))) { - result = true; - return $breaker; - } - } - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$chunk', TMP_3 = function(state) { - var $a, $b, TMP_4, self = this, $iter = TMP_3.$$p, original_block = $iter || nil; - - TMP_3.$$p = null; - if (original_block !== false && original_block !== nil) { - } else { - $scope.get('Kernel').$raise($scope.get('ArgumentError'), "no block given") - }; - return ($a = ($b = Opal.get('Enumerator')).$new, $a.$$p = (TMP_4 = function(yielder){var self = TMP_4.$$s || this, $a, $b, TMP_5; -if (yielder == null) yielder = nil; - - var block, previous = nil, accumulate = []; - - if (state == undefined || state === nil) { - block = original_block; - } else { - block = ($a = ($b = $scope.get('Proc')).$new, $a.$$p = (TMP_5 = function(val){var self = TMP_5.$$s || this; -if (val == null) val = nil; - return original_block.$yield(val, state.$dup())}, TMP_5.$$s = self, TMP_5), $a).call($b) - } - - function releaseAccumulate() { - if (accumulate.length > 0) { - yielder.$yield(previous, accumulate) - } - } - - self.$each.$$p = function(value) { - var key = Opal.yield1(block, value); - - if (key === $breaker) { - return $breaker; - } - - if (key === nil) { - releaseAccumulate(); - accumulate = []; - previous = nil; - } else { - if (previous === nil || previous === key) { - accumulate.push(value); - } else { - releaseAccumulate(); - accumulate = [value]; - } - - previous = key; - } - } - - self.$each(); - - releaseAccumulate(); - ;}, TMP_4.$$s = self, TMP_4), $a).call($b); - }); - - Opal.defn(self, '$collect', TMP_6 = function() { - var $a, $b, TMP_7, self = this, $iter = TMP_6.$$p, block = $iter || nil; - - TMP_6.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_7 = function(){var self = TMP_7.$$s || this; - - return self.$enumerator_size()}, TMP_7.$$s = self, TMP_7), $a).call($b, "collect") - }; - - var result = []; - - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - result.push(value); - }; - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$collect_concat', TMP_8 = function() { - var $a, $b, TMP_9, $c, TMP_10, self = this, $iter = TMP_8.$$p, block = $iter || nil; - - TMP_8.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_9 = function(){var self = TMP_9.$$s || this; - - return self.$enumerator_size()}, TMP_9.$$s = self, TMP_9), $a).call($b, "collect_concat") - }; - return ($a = ($c = self).$map, $a.$$p = (TMP_10 = function(item){var self = TMP_10.$$s || this, $a; -if (item == null) item = nil; - return $a = Opal.yield1(block, item), $a === $breaker ? $a : $a}, TMP_10.$$s = self, TMP_10), $a).call($c).$flatten(1); - }); - - Opal.defn(self, '$count', TMP_11 = function(object) { - var $a, self = this, $iter = TMP_11.$$p, block = $iter || nil; - - TMP_11.$$p = null; - - var result = 0; - - if (object != null) { - block = function() { - return $scope.get('Opal').$destructure(arguments)['$=='](object); - }; - } - else if (block === nil) { - block = function() { return true; }; - } - - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result++; - } - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$cycle', TMP_12 = function(n) { - var $a, $b, TMP_13, self = this, $iter = TMP_12.$$p, block = $iter || nil; - - if (n == null) { - n = nil - } - TMP_12.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_13 = function(){var self = TMP_13.$$s || this, $a; - - if (n['$=='](nil)) { - if ((($a = self['$respond_to?']("size")) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($scope.get('Float')).$$scope.get('INFINITY')) - } else { - return nil - } - } else { - n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int"); - if ($rb_gt(n, 0)) { - return $rb_times(self.$enumerator_size(), n) - } else { - return 0 - }; - }}, TMP_13.$$s = self, TMP_13), $a).call($b, "cycle", n) - }; - if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int"); - if ((($a = n <= 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - }; - - var result, - all = [], i, length, value; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - all.push(param); - } - - self.$each(); - - if (result !== undefined) { - return result; - } - - if (all.length === 0) { - return nil; - } - - if (n === nil) { - while (true) { - for (i = 0, length = all.length; i < length; i++) { - value = Opal.yield1(block, all[i]); - - if (value === $breaker) { - return $breaker.$v; - } - } - } - } - else { - while (n > 1) { - for (i = 0, length = all.length; i < length; i++) { - value = Opal.yield1(block, all[i]); - - if (value === $breaker) { - return $breaker.$v; - } - } - - n--; - } - } - - }); - - Opal.defn(self, '$detect', TMP_14 = function(ifnone) { - var $a, self = this, $iter = TMP_14.$$p, block = $iter || nil; - - TMP_14.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("detect", ifnone) - }; - - var result; - - self.$each.$$p = function() { - var params = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, params); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result = params; - return $breaker; - } - }; - - self.$each(); - - if (result === undefined && ifnone !== undefined) { - if (typeof(ifnone) === 'function') { - result = ifnone(); - } - else { - result = ifnone; - } - } - - return result === undefined ? nil : result; - - }); - - Opal.defn(self, '$drop', function(number) { - var $a, self = this; - - number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int"); - if ((($a = number < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "attempt to drop negative size")}; - - var result = [], - current = 0; - - self.$each.$$p = function() { - if (number <= current) { - result.push($scope.get('Opal').$destructure(arguments)); - } - - current++; - }; - - self.$each() - - return result; - - }); - - Opal.defn(self, '$drop_while', TMP_15 = function() { - var $a, self = this, $iter = TMP_15.$$p, block = $iter || nil; - - TMP_15.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("drop_while") - }; - - var result = [], - dropping = true; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if (dropping) { - var value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - dropping = false; - result.push(param); - } - } - else { - result.push(param); - } - }; - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$each_cons', TMP_16 = function(n) { - var $a, $b, TMP_17, self = this, $iter = TMP_16.$$p, block = $iter || nil; - - TMP_16.$$p = null; - if ((($a = arguments.length != 1) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 1)")}; - n = $scope.get('Opal').$try_convert(n, $scope.get('Integer'), "to_int"); - if ((($a = n <= 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "invalid size")}; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_17 = function(){var self = TMP_17.$$s || this, $a, $b, enum_size = nil; - - enum_size = self.$enumerator_size(); - if ((($a = enum_size['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else if ((($a = ((($b = enum_size['$=='](0)) !== false && $b !== nil) ? $b : $rb_lt(enum_size, n))) !== nil && (!$a.$$is_boolean || $a == true))) { - return 0 - } else { - return $rb_plus($rb_minus(enum_size, n), 1) - };}, TMP_17.$$s = self, TMP_17), $a).call($b, "each_cons", n) - }; - - var buffer = [], result = nil; - - self.$each.$$p = function() { - var element = $scope.get('Opal').$destructure(arguments); - buffer.push(element); - if (buffer.length > n) { - buffer.shift(); - } - if (buffer.length == n) { - var value = Opal.yield1(block, buffer.slice(0, n)); - - if (value == $breaker) { - result = $breaker.$v; - return $breaker; - } - } - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$each_entry', TMP_18 = function() { - var self = this, $iter = TMP_18.$$p, block = $iter || nil; - - TMP_18.$$p = null; - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$each_slice', TMP_19 = function(n) { - var $a, $b, TMP_20, self = this, $iter = TMP_19.$$p, block = $iter || nil; - - TMP_19.$$p = null; - n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int"); - if ((($a = n <= 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "invalid slice size")}; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_20 = function(){var self = TMP_20.$$s || this, $a; - - if ((($a = self['$respond_to?']("size")) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($rb_divide(self.$size(), n)).$ceil() - } else { - return nil - }}, TMP_20.$$s = self, TMP_20), $a).call($b, "each_slice", n) - }; - - var result, - slice = [] - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - slice.push(param); - - if (slice.length === n) { - if (Opal.yield1(block, slice) === $breaker) { - result = $breaker.$v; - return $breaker; - } - - slice = []; - } - }; - - self.$each(); - - if (result !== undefined) { - return result; - } - - // our "last" group, if smaller than n then won't have been yielded - if (slice.length > 0) { - if (Opal.yield1(block, slice) === $breaker) { - return $breaker.$v; - } - } - ; - return nil; - }); - - Opal.defn(self, '$each_with_index', TMP_21 = function() { - var $a, $b, TMP_22, self = this, $iter = TMP_21.$$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_21.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_22 = function(){var self = TMP_22.$$s || this; - - return self.$enumerator_size()}, TMP_22.$$s = self, TMP_22), $a).apply($b, ["each_with_index"].concat(Opal.to_a(args))) - }; - - var result, - index = 0; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = block(param, index); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - index++; - }; - - self.$each.apply(self, args); - - if (result !== undefined) { - return result; - } - - return self; - }); - - Opal.defn(self, '$each_with_object', TMP_23 = function(object) { - var $a, $b, TMP_24, self = this, $iter = TMP_23.$$p, block = $iter || nil; - - TMP_23.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_24 = function(){var self = TMP_24.$$s || this; - - return self.$enumerator_size()}, TMP_24.$$s = self, TMP_24), $a).call($b, "each_with_object", object) - }; - - var result; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = block(param, object); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - }; - - self.$each(); - - if (result !== undefined) { - return result; - } - - return object; - }); - - Opal.defn(self, '$entries', 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]; - } - - var result = []; - - self.$each.$$p = function() { - result.push($scope.get('Opal').$destructure(arguments)); - }; - - self.$each.apply(self, args); - - return result; - - }); - - Opal.alias(self, 'find', 'detect'); - - Opal.defn(self, '$find_all', TMP_25 = function() { - var $a, $b, TMP_26, self = this, $iter = TMP_25.$$p, block = $iter || nil; - - TMP_25.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_26 = function(){var self = TMP_26.$$s || this; - - return self.$enumerator_size()}, TMP_26.$$s = self, TMP_26), $a).call($b, "find_all") - }; - - var result = []; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result.push(param); - } - }; - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$find_index', TMP_27 = function(object) { - var $a, self = this, $iter = TMP_27.$$p, block = $iter || nil; - - TMP_27.$$p = null; - if ((($a = object === undefined && block === nil) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$enum_for("find_index")}; - - var result = nil, - index = 0; - - if (object != null) { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if ((param)['$=='](object)) { - result = index; - return $breaker; - } - - index += 1; - }; - } - else if (block !== nil) { - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result = index; - return $breaker; - } - - index += 1; - }; - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$first', function(number) { - var $a, self = this, result = nil; - - if ((($a = number === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - result = nil; - - self.$each.$$p = function() { - result = $scope.get('Opal').$destructure(arguments); - - return $breaker; - }; - - self.$each(); - ; - } else { - result = []; - number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int"); - if ((($a = number < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "attempt to take negative size")}; - if ((($a = number == 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - - var current = 0; - number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int"); - - self.$each.$$p = function() { - result.push($scope.get('Opal').$destructure(arguments)); - - if (number <= ++current) { - return $breaker; - } - }; - - self.$each(); - - }; - return result; - }); - - Opal.alias(self, 'flat_map', 'collect_concat'); - - Opal.defn(self, '$grep', TMP_28 = function(pattern) { - var $a, self = this, $iter = TMP_28.$$p, block = $iter || nil; - - TMP_28.$$p = null; - - var result = []; - - if (block !== nil) { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = pattern['$==='](param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - result.push(value); - } - }; - } - else { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = pattern['$==='](param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result.push(param); - } - }; - } - - self.$each(); - - return result; - ; - }); - - Opal.defn(self, '$group_by', TMP_29 = function() { - var $a, $b, TMP_30, $c, $d, self = this, $iter = TMP_29.$$p, block = $iter || nil, hash = nil; - - TMP_29.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_30 = function(){var self = TMP_30.$$s || this; - - return self.$enumerator_size()}, TMP_30.$$s = self, TMP_30), $a).call($b, "group_by") - }; - hash = $scope.get('Hash').$new(); - - var result; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - (($a = value, $c = hash, ((($d = $c['$[]']($a)) !== false && $d !== nil) ? $d : $c['$[]=']($a, []))))['$<<'](param); - } - - self.$each(); - - if (result !== undefined) { - return result; - } - - return hash; - }); - - Opal.defn(self, '$include?', function(obj) { - var self = this; - - - var result = false; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if ((param)['$=='](obj)) { - result = true; - return $breaker; - } - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$inject', TMP_31 = function(object, sym) { - var self = this, $iter = TMP_31.$$p, block = $iter || nil; - - TMP_31.$$p = null; - - var result = object; - - if (block !== nil && sym === undefined) { - self.$each.$$p = function() { - var value = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = value; - return; - } - - value = Opal.yieldX(block, [result, value]); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - result = value; - }; - } - else { - if (sym === undefined) { - if (!$scope.get('Symbol')['$==='](object)) { - self.$raise($scope.get('TypeError'), "" + (object.$inspect()) + " is not a Symbol"); - } - - sym = object; - result = undefined; - } - - self.$each.$$p = function() { - var value = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = value; - return; - } - - result = (result).$__send__(sym, value); - }; - } - - self.$each(); - - return result == undefined ? nil : result; - ; - }); - - Opal.defn(self, '$lazy', function() { - var $a, $b, TMP_32, self = this; - - return ($a = ($b = (($scope.get('Enumerator')).$$scope.get('Lazy'))).$new, $a.$$p = (TMP_32 = function(enum$, args){var self = TMP_32.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - return ($a = enum$).$yield.apply($a, Opal.to_a(args))}, TMP_32.$$s = self, TMP_32), $a).call($b, self, self.$enumerator_size()); - }); - - Opal.defn(self, '$enumerator_size', function() { - var $a, self = this; - - if ((($a = self['$respond_to?']("size")) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$size() - } else { - return nil - }; - }); - - Opal.alias(self, 'map', 'collect'); - - Opal.defn(self, '$max', TMP_33 = function() { - var self = this, $iter = TMP_33.$$p, block = $iter || nil; - - TMP_33.$$p = null; - - var result; - - if (block !== nil) { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = param; - return; - } - - var value = block(param, result); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if (value === nil) { - self.$raise($scope.get('ArgumentError'), "comparison failed"); - } - - if (value > 0) { - result = param; - } - }; - } - else { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = param; - return; - } - - if ($scope.get('Opal').$compare(param, result) > 0) { - result = param; - } - }; - } - - self.$each(); - - return result === undefined ? nil : result; - - }); - - Opal.defn(self, '$max_by', TMP_34 = function() { - var $a, $b, TMP_35, self = this, $iter = TMP_34.$$p, block = $iter || nil; - - TMP_34.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_35 = function(){var self = TMP_35.$$s || this; - - return self.$enumerator_size()}, TMP_35.$$s = self, TMP_35), $a).call($b, "max_by") - }; - - var result, - by; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (result === undefined) { - result = param; - by = value; - return; - } - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((value)['$<=>'](by) > 0) { - result = param - by = value; - } - }; - - self.$each(); - - return result === undefined ? nil : result; - - }); - - Opal.alias(self, 'member?', 'include?'); - - Opal.defn(self, '$min', TMP_36 = function() { - var self = this, $iter = TMP_36.$$p, block = $iter || nil; - - TMP_36.$$p = null; - - var result; - - if (block !== nil) { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = param; - return; - } - - var value = block(param, result); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if (value === nil) { - self.$raise($scope.get('ArgumentError'), "comparison failed"); - } - - if (value < 0) { - result = param; - } - }; - } - else { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments); - - if (result === undefined) { - result = param; - return; - } - - if ($scope.get('Opal').$compare(param, result) < 0) { - result = param; - } - }; - } - - self.$each(); - - return result === undefined ? nil : result; - - }); - - Opal.defn(self, '$min_by', TMP_37 = function() { - var $a, $b, TMP_38, self = this, $iter = TMP_37.$$p, block = $iter || nil; - - TMP_37.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_38 = function(){var self = TMP_38.$$s || this; - - return self.$enumerator_size()}, TMP_38.$$s = self, TMP_38), $a).call($b, "min_by") - }; - - var result, - by; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (result === undefined) { - result = param; - by = value; - return; - } - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((value)['$<=>'](by) < 0) { - result = param - by = value; - } - }; - - self.$each(); - - return result === undefined ? nil : result; - - }); - - Opal.defn(self, '$minmax', TMP_39 = function() { - var $a, $b, $c, TMP_40, self = this, $iter = TMP_39.$$p, block = $iter || nil; - - TMP_39.$$p = null; - ((($a = block) !== false && $a !== nil) ? $a : block = ($b = ($c = self).$proc, $b.$$p = (TMP_40 = function(a, b){var self = TMP_40.$$s || this; -if (a == null) a = nil;if (b == null) b = nil; - return a['$<=>'](b)}, TMP_40.$$s = self, TMP_40), $b).call($c)); - - var min = nil, max = nil, first_time = true; - - self.$each.$$p = function() { - var element = $scope.get('Opal').$destructure(arguments); - if (first_time) { - min = max = element; - first_time = false; - } else { - var min_cmp = block.$call(min, element); - - if (min_cmp === nil) { - self.$raise($scope.get('ArgumentError'), "comparison failed") - } else if (min_cmp > 0) { - min = element; - } - - var max_cmp = block.$call(max, element); - - if (max_cmp === nil) { - self.$raise($scope.get('ArgumentError'), "comparison failed") - } else if (max_cmp < 0) { - max = element; - } - } - } - - self.$each(); - - return [min, max]; - - }); - - Opal.defn(self, '$minmax_by', TMP_41 = function() { - var self = this, $iter = TMP_41.$$p, block = $iter || nil; - - TMP_41.$$p = null; - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$none?', TMP_42 = function() { - var $a, self = this, $iter = TMP_42.$$p, block = $iter || nil; - - TMP_42.$$p = null; - - var result = true; - - if (block !== nil) { - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result = false; - return $breaker; - } - } - } - else { - self.$each.$$p = function() { - var value = $scope.get('Opal').$destructure(arguments); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - result = false; - return $breaker; - } - }; - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$one?', TMP_43 = function() { - var $a, self = this, $iter = TMP_43.$$p, block = $iter || nil; - - TMP_43.$$p = null; - - var result = false; - - if (block !== nil) { - self.$each.$$p = function() { - var value = Opal.yieldX(block, arguments); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - if (result === true) { - result = false; - return $breaker; - } - - result = true; - } - } - } - else { - self.$each.$$p = function() { - var value = $scope.get('Opal').$destructure(arguments); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - if (result === true) { - result = false; - return $breaker; - } - - result = true; - } - } - } - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$partition', TMP_44 = function() { - var $a, $b, TMP_45, self = this, $iter = TMP_44.$$p, block = $iter || nil; - - TMP_44.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_45 = function(){var self = TMP_45.$$s || this; - - return self.$enumerator_size()}, TMP_45.$$s = self, TMP_45), $a).call($b, "partition") - }; - - var truthy = [], falsy = [], result; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - truthy.push(param); - } - else { - falsy.push(param); - } - }; - - self.$each(); - - return [truthy, falsy]; - - }); - - Opal.alias(self, 'reduce', 'inject'); - - Opal.defn(self, '$reject', TMP_46 = function() { - var $a, $b, TMP_47, self = this, $iter = TMP_46.$$p, block = $iter || nil; - - TMP_46.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_47 = function(){var self = TMP_47.$$s || this; - - return self.$enumerator_size()}, TMP_47.$$s = self, TMP_47), $a).call($b, "reject") - }; - - var result = []; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - result.push(param); - } - }; - - self.$each(); - - return result; - - }); - - Opal.defn(self, '$reverse_each', TMP_48 = function() { - var $a, $b, TMP_49, self = this, $iter = TMP_48.$$p, block = $iter || nil; - - TMP_48.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_49 = function(){var self = TMP_49.$$s || this; - - return self.$enumerator_size()}, TMP_49.$$s = self, TMP_49), $a).call($b, "reverse_each") - }; - - var result = []; - - self.$each.$$p = function() { - result.push(arguments); - }; - - self.$each(); - - for (var i = result.length - 1; i >= 0; i--) { - Opal.yieldX(block, result[i]); - } - - return result; - - }); - - Opal.alias(self, 'select', 'find_all'); - - Opal.defn(self, '$slice_before', TMP_50 = function(pattern) { - var $a, $b, TMP_51, self = this, $iter = TMP_50.$$p, block = $iter || nil; - - TMP_50.$$p = null; - if ((($a = pattern === undefined && block === nil || arguments.length > 1) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 1)")}; - return ($a = ($b = $scope.get('Enumerator')).$new, $a.$$p = (TMP_51 = function(e){var self = TMP_51.$$s || this, $a; -if (e == null) e = nil; - - var slice = []; - - if (block !== nil) { - if (pattern === undefined) { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) { - e['$<<'](slice); - slice = []; - } - - slice.push(param); - }; - } - else { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = block(param, pattern.$dup()); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) { - e['$<<'](slice); - slice = []; - } - - slice.push(param); - }; - } - } - else { - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = pattern['$==='](param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) { - e['$<<'](slice); - slice = []; - } - - slice.push(param); - }; - } - - self.$each(); - - if (slice.length > 0) { - e['$<<'](slice); - } - ;}, TMP_51.$$s = self, TMP_51), $a).call($b); - }); - - Opal.defn(self, '$sort', TMP_52 = function() { - var $a, $b, TMP_53, self = this, $iter = TMP_52.$$p, block = $iter || nil, ary = nil; - - TMP_52.$$p = null; - ary = self.$to_a(); - if ((block !== nil)) { - } else { - block = ($a = ($b = self).$lambda, $a.$$p = (TMP_53 = function(a, b){var self = TMP_53.$$s || this; -if (a == null) a = nil;if (b == null) b = nil; - return a['$<=>'](b)}, TMP_53.$$s = self, TMP_53), $a).call($b) - }; - return ary.sort(block); - }); - - Opal.defn(self, '$sort_by', TMP_54 = function() { - var $a, $b, TMP_55, $c, TMP_56, $d, TMP_57, $e, TMP_58, self = this, $iter = TMP_54.$$p, block = $iter || nil, dup = nil; - - TMP_54.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_55 = function(){var self = TMP_55.$$s || this; - - return self.$enumerator_size()}, TMP_55.$$s = self, TMP_55), $a).call($b, "sort_by") - }; - dup = ($a = ($c = self).$map, $a.$$p = (TMP_56 = function(){var self = TMP_56.$$s || this, arg = nil; - - arg = $scope.get('Opal').$destructure(arguments); - return [block.$call(arg), arg];}, TMP_56.$$s = self, TMP_56), $a).call($c); - ($a = ($d = dup)['$sort!'], $a.$$p = (TMP_57 = function(a, b){var self = TMP_57.$$s || this; -if (a == null) a = nil;if (b == null) b = nil; - return (a[0])['$<=>'](b[0])}, TMP_57.$$s = self, TMP_57), $a).call($d); - return ($a = ($e = dup)['$map!'], $a.$$p = (TMP_58 = function(i){var self = TMP_58.$$s || this; -if (i == null) i = nil; - return i[1];}, TMP_58.$$s = self, TMP_58), $a).call($e); - }); - - Opal.defn(self, '$take', function(num) { - var self = this; - - return self.$first(num); - }); - - Opal.defn(self, '$take_while', TMP_59 = function() { - var $a, self = this, $iter = TMP_59.$$p, block = $iter || nil; - - TMP_59.$$p = null; - if (block !== false && block !== nil) { - } else { - return self.$enum_for("take_while") - }; - - var result = []; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = Opal.yield1(block, param); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - return $breaker; - } - - result.push(param); - }; - - self.$each(); - - return result; - - }); - - Opal.alias(self, 'to_a', 'entries'); - - Opal.defn(self, '$zip', TMP_60 = function() { - var $a, self = this, $iter = TMP_60.$$p, block = $iter || nil; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var others = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - others[arg_index] = arguments[arg_index + 0]; - } - TMP_60.$$p = null; - return ($a = self.$to_a()).$zip.apply($a, Opal.to_a(others)); - }); - })($scope.base) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/enumerator"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$include', '$allocate', '$new', '$to_proc', '$coerce_to', '$nil?', '$empty?', '$+', '$class', '$__send__', '$===', '$call', '$enum_for', '$size', '$destructure', '$inspect', '$[]', '$raise', '$yield', '$each', '$enumerator_size', '$respond_to?', '$try_convert', '$<', '$for']); - self.$require("corelib/enumerable"); - return (function($base, $super) { - function $Enumerator(){}; - var self = $Enumerator = $klass($base, $super, 'Enumerator', $Enumerator); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4; - - def.size = def.args = def.object = def.method = nil; - self.$include($scope.get('Enumerable')); - - Opal.defs(self, '$for', TMP_1 = function(object, method) { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - var array_size = arguments.length - 2; - 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 + 2]; - } - if (method == null) { - method = "each" - } - TMP_1.$$p = null; - - var obj = self.$allocate(); - - obj.object = object; - obj.size = block; - obj.method = method; - obj.args = args; - - return obj; - ; - }); - - Opal.defn(self, '$initialize', TMP_2 = function() { - var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - if (block !== false && block !== nil) { - self.object = ($a = ($b = $scope.get('Generator')).$new, $a.$$p = block.$to_proc(), $a).call($b); - self.method = "each"; - self.args = []; - self.size = arguments[0] || nil; - if ((($a = self.size) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.size = $scope.get('Opal').$coerce_to(self.size, $scope.get('Integer'), "to_int") - } else { - return nil - }; - } else { - self.object = arguments[0]; - self.method = arguments[1] || "each"; - self.args = $slice.call(arguments, 2); - return self.size = nil; - }; - }); - - Opal.defn(self, '$each', TMP_3 = function() { - var $a, $b, $c, self = this, $iter = TMP_3.$$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_3.$$p = null; - if ((($a = ($b = block['$nil?'](), $b !== false && $b !== nil ?args['$empty?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - args = $rb_plus(self.args, args); - if ((($a = block['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = self.$class()).$new.apply($a, [self.object, self.method].concat(Opal.to_a(args)))}; - return ($b = ($c = self.object).$__send__, $b.$$p = block.$to_proc(), $b).apply($c, [self.method].concat(Opal.to_a(args))); - }); - - Opal.defn(self, '$size', function() { - var $a, self = this; - - if ((($a = $scope.get('Proc')['$==='](self.size)) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = self.size).$call.apply($a, Opal.to_a(self.args)) - } else { - return self.size - }; - }); - - Opal.defn(self, '$with_index', TMP_4 = function(offset) { - var $a, $b, TMP_5, self = this, $iter = TMP_4.$$p, block = $iter || nil; - - if (offset == null) { - offset = 0 - } - TMP_4.$$p = null; - if (offset !== false && offset !== nil) { - offset = $scope.get('Opal').$coerce_to(offset, $scope.get('Integer'), "to_int") - } else { - offset = 0 - }; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_5 = function(){var self = TMP_5.$$s || this; - - return self.$size()}, TMP_5.$$s = self, TMP_5), $a).call($b, "with_index", offset) - }; - - var result, index = offset; - - self.$each.$$p = function() { - var param = $scope.get('Opal').$destructure(arguments), - value = block(param, index); - - if (value === $breaker) { - result = $breaker.$v; - return $breaker; - } - - index++; - - return value; - } - - self.$each(); - - if (result !== undefined) { - return result; - } - - return self.object; - - }); - - Opal.alias(self, 'with_object', 'each_with_object'); - - Opal.defn(self, '$inspect', function() { - var $a, self = this, result = nil; - - result = "#<" + (self.$class()) + ": " + (self.object.$inspect()) + ":" + (self.method); - if ((($a = self.args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - result = $rb_plus(result, "(" + (self.args.$inspect()['$[]']($scope.get('Range').$new(1, -2))) + ")") - }; - return $rb_plus(result, ">"); - }); - - (function($base, $super) { - function $Generator(){}; - var self = $Generator = $klass($base, $super, 'Generator', $Generator); - - var def = self.$$proto, $scope = self.$$scope, TMP_6, TMP_7; - - def.block = nil; - self.$include($scope.get('Enumerable')); - - Opal.defn(self, '$initialize', TMP_6 = function() { - var self = this, $iter = TMP_6.$$p, block = $iter || nil; - - TMP_6.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('LocalJumpError'), "no block given") - }; - return self.block = block; - }); - - return (Opal.defn(self, '$each', TMP_7 = function() { - var $a, $b, self = this, $iter = TMP_7.$$p, block = $iter || nil, yielder = 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_7.$$p = null; - yielder = ($a = ($b = $scope.get('Yielder')).$new, $a.$$p = block.$to_proc(), $a).call($b); - - try { - args.unshift(yielder); - - if (Opal.yieldX(self.block, args) === $breaker) { - return $breaker.$v; - } - } - catch (e) { - if (e === $breaker) { - return $breaker.$v; - } - else { - throw e; - } - } - ; - return self; - }), nil) && 'each'; - })($scope.base, null); - - (function($base, $super) { - function $Yielder(){}; - var self = $Yielder = $klass($base, $super, 'Yielder', $Yielder); - - var def = self.$$proto, $scope = self.$$scope, TMP_8; - - def.block = nil; - Opal.defn(self, '$initialize', TMP_8 = function() { - var self = this, $iter = TMP_8.$$p, block = $iter || nil; - - TMP_8.$$p = null; - return self.block = block; - }); - - Opal.defn(self, '$yield', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var values = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - values[arg_index] = arguments[arg_index + 0]; - } - - var value = Opal.yieldX(self.block, values); - - if (value === $breaker) { - throw $breaker; - } - - return value; - ; - }); - - return (Opal.defn(self, '$<<', function() { - var $a, self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var values = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - values[arg_index] = arguments[arg_index + 0]; - } - ($a = self).$yield.apply($a, Opal.to_a(values)); - return self; - }), nil) && '<<'; - })($scope.base, null); - - return (function($base, $super) { - function $Lazy(){}; - var self = $Lazy = $klass($base, $super, 'Lazy', $Lazy); - - var def = self.$$proto, $scope = self.$$scope, TMP_9, TMP_12, TMP_14, TMP_19, TMP_21, TMP_22, TMP_24, TMP_27, TMP_30; - - def.enumerator = nil; - (function($base, $super) { - function $StopLazyError(){}; - var self = $StopLazyError = $klass($base, $super, 'StopLazyError', $StopLazyError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('Exception')); - - Opal.defn(self, '$initialize', TMP_9 = function(object, size) { - var TMP_10, self = this, $iter = TMP_9.$$p, block = $iter || nil; - - if (size == null) { - size = nil - } - TMP_9.$$p = null; - if ((block !== nil)) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy new without a block") - }; - self.enumerator = object; - return Opal.find_super_dispatcher(self, 'initialize', TMP_9, (TMP_10 = function(yielder, each_args){var self = TMP_10.$$s || this, $a, $b, TMP_11; -if (yielder == null) yielder = nil;each_args = $slice.call(arguments, 1); - try { - return ($a = ($b = object).$each, $a.$$p = (TMP_11 = function(args){var self = TMP_11.$$s || this; -args = $slice.call(arguments, 0); - - args.unshift(yielder); - - if (Opal.yieldX(block, args) === $breaker) { - return $breaker; - } - ;}, TMP_11.$$s = self, TMP_11), $a).apply($b, Opal.to_a(each_args)) - } catch ($err) {if (Opal.rescue($err, [$scope.get('Exception')])) { - try { - return nil - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }}, TMP_10.$$s = self, TMP_10)).apply(self, [size]); - }); - - Opal.alias(self, 'force', 'to_a'); - - Opal.defn(self, '$lazy', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$collect', TMP_12 = function() { - var $a, $b, TMP_13, self = this, $iter = TMP_12.$$p, block = $iter || nil; - - TMP_12.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy map without a block") - }; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_13 = function(enum$, args){var self = TMP_13.$$s || this; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - enum$.$yield(value); - }, TMP_13.$$s = self, TMP_13), $a).call($b, self, self.$enumerator_size()); - }); - - Opal.defn(self, '$collect_concat', TMP_14 = function() { - var $a, $b, TMP_15, self = this, $iter = TMP_14.$$p, block = $iter || nil; - - TMP_14.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy map without a block") - }; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_15 = function(enum$, args){var self = TMP_15.$$s || this, $a, $b, TMP_16, $c, TMP_17; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - if ((value)['$respond_to?']("force") && (value)['$respond_to?']("each")) { - ($a = ($b = (value)).$each, $a.$$p = (TMP_16 = function(v){var self = TMP_16.$$s || this; -if (v == null) v = nil; - return enum$.$yield(v)}, TMP_16.$$s = self, TMP_16), $a).call($b) - } - else { - var array = $scope.get('Opal').$try_convert(value, $scope.get('Array'), "to_ary"); - - if (array === nil) { - enum$.$yield(value); - } - else { - ($a = ($c = (value)).$each, $a.$$p = (TMP_17 = function(v){var self = TMP_17.$$s || this; -if (v == null) v = nil; - return enum$.$yield(v)}, TMP_17.$$s = self, TMP_17), $a).call($c); - } - } - ;}, TMP_15.$$s = self, TMP_15), $a).call($b, self, nil); - }); - - Opal.defn(self, '$drop', function(n) { - var $a, $b, TMP_18, self = this, current_size = nil, set_size = nil, dropped = nil; - - n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int"); - if ($rb_lt(n, 0)) { - self.$raise($scope.get('ArgumentError'), "attempt to drop negative size")}; - current_size = self.$enumerator_size(); - set_size = (function() {if ((($a = $scope.get('Integer')['$==='](current_size)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ($rb_lt(n, current_size)) { - return n - } else { - return current_size - } - } else { - return current_size - }; return nil; })(); - dropped = 0; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_18 = function(enum$, args){var self = TMP_18.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - if ($rb_lt(dropped, n)) { - return dropped = $rb_plus(dropped, 1) - } else { - return ($a = enum$).$yield.apply($a, Opal.to_a(args)) - }}, TMP_18.$$s = self, TMP_18), $a).call($b, self, set_size); - }); - - Opal.defn(self, '$drop_while', TMP_19 = function() { - var $a, $b, TMP_20, self = this, $iter = TMP_19.$$p, block = $iter || nil, succeeding = nil; - - TMP_19.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy drop_while without a block") - }; - succeeding = true; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_20 = function(enum$, args){var self = TMP_20.$$s || this, $a, $b; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - if (succeeding !== false && succeeding !== nil) { - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - succeeding = false; - - ($a = enum$).$yield.apply($a, Opal.to_a(args)); - } - - } else { - return ($b = enum$).$yield.apply($b, Opal.to_a(args)) - }}, TMP_20.$$s = self, TMP_20), $a).call($b, self, nil); - }); - - Opal.defn(self, '$enum_for', TMP_21 = function(method) { - var $a, $b, self = this, $iter = TMP_21.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - if (method == null) { - method = "each" - } - TMP_21.$$p = null; - return ($a = ($b = self.$class()).$for, $a.$$p = block.$to_proc(), $a).apply($b, [self, method].concat(Opal.to_a(args))); - }); - - Opal.defn(self, '$find_all', TMP_22 = function() { - var $a, $b, TMP_23, self = this, $iter = TMP_22.$$p, block = $iter || nil; - - TMP_22.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy select without a block") - }; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_23 = function(enum$, args){var self = TMP_23.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - ($a = enum$).$yield.apply($a, Opal.to_a(args)); - } - ;}, TMP_23.$$s = self, TMP_23), $a).call($b, self, nil); - }); - - Opal.alias(self, 'flat_map', 'collect_concat'); - - Opal.defn(self, '$grep', TMP_24 = function(pattern) { - var $a, $b, TMP_25, $c, TMP_26, self = this, $iter = TMP_24.$$p, block = $iter || nil; - - TMP_24.$$p = null; - if (block !== false && block !== nil) { - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_25 = function(enum$, args){var self = TMP_25.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var param = $scope.get('Opal').$destructure(args), - value = pattern['$==='](param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - value = Opal.yield1(block, param); - - if (value === $breaker) { - return $breaker; - } - - enum$.$yield(Opal.yield1(block, param)); - } - ;}, TMP_25.$$s = self, TMP_25), $a).call($b, self, nil) - } else { - return ($a = ($c = $scope.get('Lazy')).$new, $a.$$p = (TMP_26 = function(enum$, args){var self = TMP_26.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var param = $scope.get('Opal').$destructure(args), - value = pattern['$==='](param); - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - enum$.$yield(param); - } - ;}, TMP_26.$$s = self, TMP_26), $a).call($c, self, nil) - }; - }); - - Opal.alias(self, 'map', 'collect'); - - Opal.alias(self, 'select', 'find_all'); - - Opal.defn(self, '$reject', TMP_27 = function() { - var $a, $b, TMP_28, self = this, $iter = TMP_27.$$p, block = $iter || nil; - - TMP_27.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy reject without a block") - }; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_28 = function(enum$, args){var self = TMP_28.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) { - ($a = enum$).$yield.apply($a, Opal.to_a(args)); - } - ;}, TMP_28.$$s = self, TMP_28), $a).call($b, self, nil); - }); - - Opal.defn(self, '$take', function(n) { - var $a, $b, TMP_29, self = this, current_size = nil, set_size = nil, taken = nil; - - n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int"); - if ($rb_lt(n, 0)) { - self.$raise($scope.get('ArgumentError'), "attempt to take negative size")}; - current_size = self.$enumerator_size(); - set_size = (function() {if ((($a = $scope.get('Integer')['$==='](current_size)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ($rb_lt(n, current_size)) { - return n - } else { - return current_size - } - } else { - return current_size - }; return nil; })(); - taken = 0; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_29 = function(enum$, args){var self = TMP_29.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - if ($rb_lt(taken, n)) { - ($a = enum$).$yield.apply($a, Opal.to_a(args)); - return taken = $rb_plus(taken, 1); - } else { - return self.$raise($scope.get('StopLazyError')) - }}, TMP_29.$$s = self, TMP_29), $a).call($b, self, set_size); - }); - - Opal.defn(self, '$take_while', TMP_30 = function() { - var $a, $b, TMP_31, self = this, $iter = TMP_30.$$p, block = $iter || nil; - - TMP_30.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to call lazy take_while without a block") - }; - return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_31 = function(enum$, args){var self = TMP_31.$$s || this, $a; -if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1); - - var value = Opal.yieldX(block, args); - - if (value === $breaker) { - return $breaker; - } - - if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) { - ($a = enum$).$yield.apply($a, Opal.to_a(args)); - } - else { - self.$raise($scope.get('StopLazyError')); - } - ;}, TMP_31.$$s = self, TMP_31), $a).call($b, self, nil); - }); - - Opal.alias(self, 'to_enum', 'enum_for'); - - return (Opal.defn(self, '$inspect', function() { - var self = this; - - return "#<" + (self.$class()) + ": " + (self.enumerator.$inspect()) + ">"; - }), nil) && 'inspect'; - })($scope.base, self); - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/numeric"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - function $rb_minus(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); - } - function $rb_divide(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, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$include', '$instance_of?', '$class', '$Float', '$coerce', '$===', '$raise', '$__send__', '$equal?', '$coerce_to!', '$-@', '$**', '$-', '$*', '$div', '$<', '$ceil', '$to_f', '$denominator', '$to_r', '$==', '$floor', '$/', '$%', '$Complex', '$zero?', '$numerator', '$abs', '$arg', '$round', '$to_i', '$truncate', '$>']); - self.$require("corelib/comparable"); - return (function($base, $super) { - function $Numeric(){}; - var self = $Numeric = $klass($base, $super, 'Numeric', $Numeric); - - var def = self.$$proto, $scope = self.$$scope; - - self.$include($scope.get('Comparable')); - - Opal.defn(self, '$coerce', function(other) { - var $a, self = this; - - if ((($a = other['$instance_of?'](self.$class())) !== nil && (!$a.$$is_boolean || $a == true))) { - return [other, self]}; - return [self.$Float(other), self.$Float(self)]; - }); - - Opal.defn(self, '$__coerced__', function(method, other) { - var $a, self = this, a = nil, b = nil, $case = nil; - - try { - $a = Opal.to_ary(other.$coerce(self)), a = ($a[0] == null ? nil : $a[0]), b = ($a[1] == null ? nil : $a[1]) - } catch ($err) {if (true) { - try { - $case = method;if ("+"['$===']($case) || "-"['$===']($case) || "*"['$===']($case) || "/"['$===']($case) || "%"['$===']($case) || "&"['$===']($case) || "|"['$===']($case) || "^"['$===']($case) || "**"['$===']($case)) {self.$raise($scope.get('TypeError'), "" + (other.$class()) + " can't be coerce into Numeric")}else if (">"['$===']($case) || ">="['$===']($case) || "<"['$===']($case) || "<="['$===']($case) || "<=>"['$===']($case)) {self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")} - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - return a.$__send__(method, b); - }); - - Opal.defn(self, '$<=>', function(other) { - var $a, self = this; - - if ((($a = self['$equal?'](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return 0}; - return nil; - }); - - Opal.defn(self, '$[]', function(bit) { - var self = this, min = nil, max = nil; - - bit = $scope.get('Opal')['$coerce_to!'](bit, $scope.get('Integer'), "to_int"); - min = ((2)['$**'](30))['$-@'](); - max = $rb_minus(((2)['$**'](30)), 1); - return (bit < min || bit > max) ? 0 : (self >> bit) % 2; - }); - - Opal.defn(self, '$+@', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$-@', function() { - var self = this; - - return $rb_minus(0, self); - }); - - Opal.defn(self, '$%', function(other) { - var self = this; - - return $rb_minus(self, $rb_times(other, self.$div(other))); - }); - - Opal.defn(self, '$abs', function() { - var self = this; - - if ($rb_lt(self, 0)) { - return self['$-@']() - } else { - return self - }; - }); - - Opal.defn(self, '$abs2', function() { - var self = this; - - return $rb_times(self, self); - }); - - Opal.defn(self, '$angle', function() { - var self = this; - - if ($rb_lt(self, 0)) { - return (($scope.get('Math')).$$scope.get('PI')) - } else { - return 0 - }; - }); - - Opal.alias(self, 'arg', 'angle'); - - Opal.defn(self, '$ceil', function() { - var self = this; - - return self.$to_f().$ceil(); - }); - - Opal.defn(self, '$conj', function() { - var self = this; - - return self; - }); - - Opal.alias(self, 'conjugate', 'conj'); - - Opal.defn(self, '$denominator', function() { - var self = this; - - return self.$to_r().$denominator(); - }); - - Opal.defn(self, '$div', function(other) { - var self = this; - - if (other['$=='](0)) { - self.$raise($scope.get('ZeroDivisionError'), "divided by o")}; - return ($rb_divide(self, other)).$floor(); - }); - - Opal.defn(self, '$divmod', function(other) { - var self = this; - - return [self.$div(other), self['$%'](other)]; - }); - - Opal.defn(self, '$fdiv', function(other) { - var self = this; - - return $rb_divide(self.$to_f(), other); - }); - - Opal.defn(self, '$floor', function() { - var self = this; - - return self.$to_f().$floor(); - }); - - Opal.defn(self, '$i', function() { - var self = this; - - return self.$Complex(0, self); - }); - - Opal.defn(self, '$imag', function() { - var self = this; - - return 0; - }); - - Opal.alias(self, 'imaginary', 'imag'); - - Opal.defn(self, '$integer?', function() { - var self = this; - - return false; - }); - - Opal.alias(self, 'magnitude', 'abs'); - - Opal.alias(self, 'modulo', '%'); - - Opal.defn(self, '$nonzero?', function() { - var $a, self = this; - - if ((($a = self['$zero?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return self - }; - }); - - Opal.defn(self, '$numerator', function() { - var self = this; - - return self.$to_r().$numerator(); - }); - - Opal.alias(self, 'phase', 'arg'); - - Opal.defn(self, '$polar', function() { - var self = this; - - return [self.$abs(), self.$arg()]; - }); - - Opal.defn(self, '$quo', function(other) { - var self = this; - - return $rb_divide($scope.get('Opal')['$coerce_to!'](self, $scope.get('Rational'), "to_r"), other); - }); - - Opal.defn(self, '$real', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$real?', function() { - var self = this; - - return true; - }); - - Opal.defn(self, '$rect', function() { - var self = this; - - return [self, 0]; - }); - - Opal.alias(self, 'rectangular', 'rect'); - - Opal.defn(self, '$round', function(digits) { - var self = this; - - return self.$to_f().$round(digits); - }); - - Opal.defn(self, '$to_c', function() { - var self = this; - - return self.$Complex(self, 0); - }); - - Opal.defn(self, '$to_int', function() { - var self = this; - - return self.$to_i(); - }); - - Opal.defn(self, '$truncate', function() { - var self = this; - - return self.$to_f().$truncate(); - }); - - Opal.defn(self, '$zero?', function() { - var self = this; - - return self['$=='](0); - }); - - Opal.defn(self, '$positive?', function() { - var self = this; - - return $rb_gt(self, 0); - }); - - Opal.defn(self, '$negative?', function() { - var self = this; - - return $rb_lt(self, 0); - }); - - Opal.defn(self, '$dup', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't dup " + (self.$class())); - }); - - return (Opal.defn(self, '$clone', function() { - var self = this; - - return self.$raise($scope.get('TypeError'), "can't clone " + (self.$class())); - }), nil) && 'clone'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/array"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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, $klass = Opal.klass, $hash2 = Opal.hash2, $gvars = Opal.gvars; - - Opal.add_stubs(['$require', '$include', '$raise', '$===', '$to_a', '$respond_to?', '$to_ary', '$coerce_to', '$initialize', '$to_proc', '$coerce_to?', '$join', '$to_str', '$class', '$clone', '$hash', '$<=>', '$==', '$object_id', '$inspect', '$enum_for', '$coerce_to!', '$>', '$*', '$enumerator_size', '$empty?', '$copy_singleton_methods', '$initialize_clone', '$initialize_dup', '$replace', '$size', '$eql?', '$length', '$begin', '$end', '$exclude_end?', '$flatten', '$__id__', '$[]', '$to_s', '$new', '$!', '$delete_if', '$each', '$reverse', '$rotate', '$rand', '$at', '$keep_if', '$shuffle!', '$dup', '$<', '$sort', '$!=', '$times', '$[]=', '$<<', '$kind_of?', '$last', '$first', '$upto']); - self.$require("corelib/enumerable"); - self.$require("corelib/numeric"); - return (function($base, $super) { - function $Array(){}; - var self = $Array = $klass($base, $super, 'Array', $Array); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_6, TMP_8, TMP_10, TMP_12, TMP_13, TMP_15, TMP_17, TMP_19, TMP_20, TMP_21, TMP_22, TMP_24, TMP_26, TMP_27, TMP_29, TMP_31, TMP_33, TMP_34, TMP_36, TMP_38, TMP_39, TMP_40, TMP_43, TMP_44, TMP_47; - - def.length = nil; - self.$include($scope.get('Enumerable')); - - def.$$is_array = true; - - Opal.defs(self, '$[]', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 0]; - } - return objects; - }); - - Opal.defn(self, '$initialize', TMP_1 = function(size, obj) { - var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil; - - if (size == null) { - size = nil - } - if (obj == null) { - obj = nil - } - TMP_1.$$p = null; - if ((($a = arguments.length > 2) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 0..2)")}; - - if (arguments.length === 0) { - self.splice(0, self.length); - return self; - } - - if ((($a = arguments.length === 1) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = $scope.get('Array')['$==='](size)) !== nil && (!$a.$$is_boolean || $a == true))) { - return size.$to_a() - } else if ((($a = size['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) { - return size.$to_ary()}}; - size = $scope.get('Opal').$coerce_to(size, $scope.get('Integer'), "to_int"); - if ((($a = size < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "negative array size")}; - - self.splice(0, self.length); - var i, value; - - if (block === nil) { - for (i = 0; i < size; i++) { - self.push(obj); - } - } - else { - for (i = 0, value; i < size; i++) { - value = block(i); - - if (value === $breaker) { - return $breaker.$v; - } - - self[i] = value; - } - } - - return self; - - }); - - Opal.defs(self, '$new', TMP_2 = function() { - var $a, $b, self = this, $iter = TMP_2.$$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_2.$$p = null; - return ($a = ($b = []).$initialize, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - }); - - Opal.defs(self, '$try_convert', function(obj) { - var self = this; - - return $scope.get('Opal')['$coerce_to?'](obj, $scope.get('Array'), "to_ary"); - }); - - Opal.defn(self, '$&', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - - var result = [], hash = $hash2([], {}), i, length, item; - - for (i = 0, length = other.length; i < length; i++) { - Opal.hash_put(hash, other[i], true); - } - - for (i = 0, length = self.length; i < length; i++) { - item = self[i]; - if (Opal.hash_delete(hash, item) !== undefined) { - result.push(item); - } - } - - return result; - ; - }); - - Opal.defn(self, '$|', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - - var hash = $hash2([], {}), i, length, item; - - for (i = 0, length = self.length; i < length; i++) { - Opal.hash_put(hash, self[i], true); - } - - for (i = 0, length = other.length; i < length; i++) { - Opal.hash_put(hash, other[i], true); - } - - return hash.$keys(); - ; - }); - - Opal.defn(self, '$*', function(other) { - var $a, self = this; - - if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$join(other.$to_str())}; - if ((($a = other['$respond_to?']("to_int")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "no implicit conversion of " + (other.$class()) + " into Integer") - }; - other = $scope.get('Opal').$coerce_to(other, $scope.get('Integer'), "to_int"); - if ((($a = other < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "negative argument")}; - - var result = []; - - for (var i = 0; i < other; i++) { - result = result.concat(self); - } - - return result; - - }); - - Opal.defn(self, '$+', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - return self.concat(other); - }); - - Opal.defn(self, '$-', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - if ((($a = other.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$clone()}; - - var result = [], hash = $hash2([], {}), i, length, item; - - for (i = 0, length = other.length; i < length; i++) { - Opal.hash_put(hash, other[i], true); - } - - for (i = 0, length = self.length; i < length; i++) { - item = self[i]; - if (Opal.hash_get(hash, item) === undefined) { - result.push(item); - } - } - - return result; - ; - }); - - Opal.defn(self, '$<<', function(object) { - var self = this; - - self.push(object); - return self; - }); - - Opal.defn(self, '$<=>', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else if ((($a = other['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_ary().$to_a() - } else { - return nil - }; - - if (self.$hash() === other.$hash()) { - return 0; - } - - var count = Math.min(self.length, other.length); - - for (var i = 0; i < count; i++) { - var tmp = (self[i])['$<=>'](other[i]); - - if (tmp !== 0) { - return tmp; - } - } - - return (self.length)['$<=>'](other.length); - ; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - - var recursed = {}; - - function _eqeq(array, other) { - var i, length, a, b; - - if (!other.$$is_array) { - if ($scope.get('Opal')['$respond_to?'](other, "to_ary")) { - return (other)['$=='](array); - } else { - return false; - } - } - - other = other.$to_a(); - - if (array.length !== other.length) { - return false; - } - - recursed[(array).$object_id()] = true; - - for (i = 0, length = array.length; i < length; i++) { - a = array[i]; - b = other[i]; - if (a.$$is_array) { - if (b.$$is_array && b.length !== a.length) { - return false; - } - if (!recursed.hasOwnProperty((a).$object_id())) { - if (!_eqeq(a, b)) { - return false; - } - } - } else { - if (!(a)['$=='](b)) { - return false; - } - } - } - - return true; - } - - return _eqeq(self, other); - ; - }); - - Opal.defn(self, '$[]', function(index, length) { - var self = this; - - - var size = self.length, - exclude, from, to; - - if (index.$$is_range) { - exclude = index.exclude; - from = $scope.get('Opal').$coerce_to(index.begin, $scope.get('Integer'), "to_int"); - to = $scope.get('Opal').$coerce_to(index.end, $scope.get('Integer'), "to_int"); - - if (from < 0) { - from += size; - - if (from < 0) { - return nil; - } - } - - if (from > size) { - return nil; - } - - if (to < 0) { - to += size; - - if (to < 0) { - return []; - } - } - - if (!exclude) { - to += 1; - } - - return self.slice(from, to); - } - else { - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += size; - - if (index < 0) { - return nil; - } - } - - if (length === undefined) { - if (index >= size || index < 0) { - return nil; - } - - return self[index]; - } - else { - length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int"); - - if (length < 0 || index > size || index < 0) { - return nil; - } - - return self.slice(index, index + length); - } - } - - }); - - Opal.defn(self, '$[]=', function(index, value, extra) { - var $a, self = this, data = nil, length = nil; - - - var i, size = self.length; - - if ((($a = $scope.get('Range')['$==='](index)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = $scope.get('Array')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) { - data = value.$to_a() - } else if ((($a = value['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) { - data = value.$to_ary().$to_a() - } else { - data = [value] - }; - - var exclude = index.exclude, - from = $scope.get('Opal').$coerce_to(index.begin, $scope.get('Integer'), "to_int"), - to = $scope.get('Opal').$coerce_to(index.end, $scope.get('Integer'), "to_int"); - - if (from < 0) { - from += size; - - if (from < 0) { - self.$raise($scope.get('RangeError'), "" + (index.$inspect()) + " out of range"); - } - } - - if (to < 0) { - to += size; - } - - if (!exclude) { - to += 1; - } - - if (from > size) { - for (i = size; i < from; i++) { - self[i] = nil; - } - } - - if (to < 0) { - self.splice.apply(self, [from, 0].concat(data)); - } - else { - self.splice.apply(self, [from, to - from].concat(data)); - } - - return value; - ; - } else { - if ((($a = extra === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - length = 1 - } else { - length = value; - value = extra; - if ((($a = $scope.get('Array')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) { - data = value.$to_a() - } else if ((($a = value['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) { - data = value.$to_ary().$to_a() - } else { - data = [value] - }; - }; - - var old; - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int"); - - if (index < 0) { - old = index; - index += size; - - if (index < 0) { - self.$raise($scope.get('IndexError'), "index " + (old) + " too small for array; minimum " + (-self.length)); - } - } - - if (length < 0) { - self.$raise($scope.get('IndexError'), "negative length (" + (length) + ")") - } - - if (index > size) { - for (i = size; i < index; i++) { - self[i] = nil; - } - } - - if (extra === undefined) { - self[index] = value; - } - else { - self.splice.apply(self, [index, length].concat(data)); - } - - return value; - - }; - }); - - Opal.defn(self, '$assoc', function(object) { - var self = this; - - - for (var i = 0, length = self.length, item; i < length; i++) { - if (item = self[i], item.length && (item[0])['$=='](object)) { - return item; - } - } - - return nil; - - }); - - Opal.defn(self, '$at', function(index) { - var self = this; - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += self.length; - } - - if (index < 0 || index >= self.length) { - return nil; - } - - return self[index]; - - }); - - Opal.defn(self, '$bsearch', TMP_3 = function() { - var self = this, $iter = TMP_3.$$p, block = $iter || nil; - - TMP_3.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("bsearch") - }; - - var min = 0, - max = self.length, - mid, - val, - ret, - smaller = false, - satisfied = nil; - - while (min < max) { - mid = min + Math.floor((max - min) / 2); - val = self[mid]; - ret = block(val); - - if (ret === $breaker) { - return $breaker.$v; - } - else if (ret === true) { - satisfied = val; - smaller = true; - } - else if (ret === false || ret === nil) { - smaller = false; - } - else if (ret.$$is_number) { - if (ret === 0) { return val; } - smaller = (ret < 0); - } - else { - self.$raise($scope.get('TypeError'), "wrong argument type " + ((ret).$class()) + " (must be numeric, true, false or nil)") - } - - if (smaller) { max = mid; } else { min = mid + 1; } - } - - return satisfied; - - }); - - Opal.defn(self, '$cycle', TMP_4 = function(n) { - var $a, $b, TMP_5, $c, self = this, $iter = TMP_4.$$p, block = $iter || nil; - - if (n == null) { - n = nil - } - TMP_4.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_5 = function(){var self = TMP_5.$$s || this; - - if (n['$=='](nil)) { - return (($scope.get('Float')).$$scope.get('INFINITY')) - } else { - n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int"); - if ($rb_gt(n, 0)) { - return $rb_times(self.$enumerator_size(), n) - } else { - return 0 - }; - }}, TMP_5.$$s = self, TMP_5), $a).call($b, "cycle", n) - }; - if ((($a = ((($c = self['$empty?']()) !== false && $c !== nil) ? $c : n['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - - var i, length, value; - - if (n === nil) { - while (true) { - for (i = 0, length = self.length; i < length; i++) { - value = Opal.yield1(block, self[i]); - - if (value === $breaker) { - return $breaker.$v; - } - } - } - } - else { - n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int"); - if (n <= 0) { - return self; - } - - while (n > 0) { - for (i = 0, length = self.length; i < length; i++) { - value = Opal.yield1(block, self[i]); - - if (value === $breaker) { - return $breaker.$v; - } - } - - n--; - } - } - - return self; - }); - - Opal.defn(self, '$clear', function() { - var self = this; - - self.splice(0, self.length); - return self; - }); - - Opal.defn(self, '$clone', function() { - var self = this, copy = nil; - - copy = []; - copy.$copy_singleton_methods(self); - copy.$initialize_clone(self); - return copy; - }); - - Opal.defn(self, '$dup', function() { - var self = this, copy = nil; - - copy = []; - copy.$initialize_dup(self); - return copy; - }); - - Opal.defn(self, '$initialize_copy', function(other) { - var self = this; - - return self.$replace(other); - }); - - Opal.defn(self, '$collect', TMP_6 = function() { - var $a, $b, TMP_7, self = this, $iter = TMP_6.$$p, block = $iter || nil; - - TMP_6.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_7 = function(){var self = TMP_7.$$s || this; - - return self.$size()}, TMP_7.$$s = self, TMP_7), $a).call($b, "collect") - }; - - var result = []; - - for (var i = 0, length = self.length; i < length; i++) { - var value = Opal.yield1(block, self[i]); - - if (value === $breaker) { - return $breaker.$v; - } - - result.push(value); - } - - return result; - - }); - - Opal.defn(self, '$collect!', TMP_8 = function() { - var $a, $b, TMP_9, self = this, $iter = TMP_8.$$p, block = $iter || nil; - - TMP_8.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_9 = function(){var self = TMP_9.$$s || this; - - return self.$size()}, TMP_9.$$s = self, TMP_9), $a).call($b, "collect!") - }; - - for (var i = 0, length = self.length; i < length; i++) { - var value = Opal.yield1(block, self[i]); - - if (value === $breaker) { - return $breaker.$v; - } - - self[i] = value; - } - - return self; - }); - - - function binomial_coefficient(n, k) { - if (n === k || k === 0) { - return 1; - } - - if (k > 0 && n > k) { - return binomial_coefficient(n - 1, k - 1) + binomial_coefficient(n - 1, k); - } - - return 0; - } - - - Opal.defn(self, '$combination', TMP_10 = function(n) { - var $a, $b, TMP_11, self = this, $iter = TMP_10.$$p, $yield = $iter || nil, num = nil; - - TMP_10.$$p = null; - num = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int"); - if (($yield !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_11 = function(){var self = TMP_11.$$s || this; - - return binomial_coefficient(self.length, num);}, TMP_11.$$s = self, TMP_11), $a).call($b, "combination", num) - }; - - var i, length, stack, chosen, lev, done, next; - - if (num === 0) { - ((($a = Opal.yield1($yield, [])) === $breaker) ? $breaker.$v : $a) - } else if (num === 1) { - for (i = 0, length = self.length; i < length; i++) { - ((($a = Opal.yield1($yield, [self[i]])) === $breaker) ? $breaker.$v : $a) - } - } - else if (num === self.length) { - ((($a = Opal.yield1($yield, self.slice())) === $breaker) ? $breaker.$v : $a) - } - else if (num >= 0 && num < self.length) { - stack = []; - for (i = 0; i <= num + 1; i++) { - stack.push(0); - } - - chosen = []; - lev = 0; - done = false; - stack[0] = -1; - - while (!done) { - chosen[lev] = self[stack[lev+1]]; - while (lev < num - 1) { - lev++; - next = stack[lev+1] = stack[lev] + 1; - chosen[lev] = self[next]; - } - ((($a = Opal.yield1($yield, chosen.slice())) === $breaker) ? $breaker.$v : $a) - lev++; - do { - done = (lev === 0); - stack[lev]++; - lev--; - } while ( stack[lev+1] + num === self.length + lev + 1 ); - } - } - ; - return self; - }); - - Opal.defn(self, '$compact', function() { - var self = this; - - - var result = []; - - for (var i = 0, length = self.length, item; i < length; i++) { - if ((item = self[i]) !== nil) { - result.push(item); - } - } - - return result; - - }); - - Opal.defn(self, '$compact!', function() { - var self = this; - - - var original = self.length; - - for (var i = 0, length = self.length; i < length; i++) { - if (self[i] === nil) { - self.splice(i, 1); - - length--; - i--; - } - } - - return self.length === original ? nil : self; - - }); - - Opal.defn(self, '$concat', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - - for (var i = 0, length = other.length; i < length; i++) { - self.push(other[i]); - } - - return self; - }); - - Opal.defn(self, '$delete', TMP_12 = function(object) { - var $a, self = this, $iter = TMP_12.$$p, $yield = $iter || nil; - - TMP_12.$$p = null; - - var original = self.length; - - for (var i = 0, length = original; i < length; i++) { - if ((self[i])['$=='](object)) { - self.splice(i, 1); - - length--; - i--; - } - } - - if (self.length === original) { - if (($yield !== nil)) { - return ((($a = Opal.yieldX($yield, [])) === $breaker) ? $breaker.$v : $a); - } - return nil; - } - return object; - ; - }); - - Opal.defn(self, '$delete_at', function(index) { - var self = this; - - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += self.length; - } - - if (index < 0 || index >= self.length) { - return nil; - } - - var result = self[index]; - - self.splice(index, 1); - - return result; - ; - }); - - Opal.defn(self, '$delete_if', TMP_13 = function() { - var $a, $b, TMP_14, self = this, $iter = TMP_13.$$p, block = $iter || nil; - - TMP_13.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_14 = function(){var self = TMP_14.$$s || this; - - return self.$size()}, TMP_14.$$s = self, TMP_14), $a).call($b, "delete_if") - }; - - for (var i = 0, length = self.length, value; i < length; i++) { - if ((value = block(self[i])) === $breaker) { - return $breaker.$v; - } - - if (value !== false && value !== nil) { - self.splice(i, 1); - - length--; - i--; - } - } - - return self; - }); - - Opal.defn(self, '$drop', function(number) { - var self = this; - - - if (number < 0) { - self.$raise($scope.get('ArgumentError')) - } - - return self.slice(number); - ; - }); - - Opal.defn(self, '$each', TMP_15 = function() { - var $a, $b, TMP_16, self = this, $iter = TMP_15.$$p, block = $iter || nil; - - TMP_15.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_16 = function(){var self = TMP_16.$$s || this; - - return self.$size()}, TMP_16.$$s = self, TMP_16), $a).call($b, "each") - }; - - for (var i = 0, length = self.length; i < length; i++) { - var value = Opal.yield1(block, self[i]); - - if (value == $breaker) { - return $breaker.$v; - } - } - - return self; - }); - - Opal.defn(self, '$each_index', TMP_17 = function() { - var $a, $b, TMP_18, self = this, $iter = TMP_17.$$p, block = $iter || nil; - - TMP_17.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_18 = function(){var self = TMP_18.$$s || this; - - return self.$size()}, TMP_18.$$s = self, TMP_18), $a).call($b, "each_index") - }; - - for (var i = 0, length = self.length; i < length; i++) { - var value = Opal.yield1(block, i); - - if (value === $breaker) { - return $breaker.$v; - } - } - - return self; - }); - - Opal.defn(self, '$empty?', function() { - var self = this; - - return self.length === 0; - }); - - Opal.defn(self, '$eql?', function(other) { - var self = this; - - - var recursed = {}; - - function _eql(array, other) { - var i, length, a, b; - - if (!other.$$is_array) { - return false; - } - - other = other.$to_a(); - - if (array.length !== other.length) { - return false; - } - - recursed[(array).$object_id()] = true; - - for (i = 0, length = array.length; i < length; i++) { - a = array[i]; - b = other[i]; - if (a.$$is_array) { - if (b.$$is_array && b.length !== a.length) { - return false; - } - if (!recursed.hasOwnProperty((a).$object_id())) { - if (!_eql(a, b)) { - return false; - } - } - } else { - if (!(a)['$eql?'](b)) { - return false; - } - } - } - - return true; - } - - return _eql(self, other); - - }); - - Opal.defn(self, '$fetch', TMP_19 = function(index, defaults) { - var self = this, $iter = TMP_19.$$p, block = $iter || nil; - - TMP_19.$$p = null; - - var original = index; - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (index < 0) { - index += self.length; - } - - if (index >= 0 && index < self.length) { - return self[index]; - } - - if (block !== nil) { - return block(original); - } - - if (defaults != null) { - return defaults; - } - - if (self.length === 0) { - self.$raise($scope.get('IndexError'), "index " + (original) + " outside of array bounds: 0...0") - } - else { - self.$raise($scope.get('IndexError'), "index " + (original) + " outside of array bounds: -" + (self.length) + "..." + (self.length)); - } - ; - }); - - Opal.defn(self, '$fill', TMP_20 = function() { - var $a, self = this, $iter = TMP_20.$$p, block = $iter || nil, one = nil, two = nil, obj = nil, left = nil, right = 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_20.$$p = null; - - var i, length, value; - - if (block !== false && block !== nil) { - if ((($a = args.length > 2) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (args.$length()) + " for 0..2)")}; - $a = Opal.to_ary(args), one = ($a[0] == null ? nil : $a[0]), two = ($a[1] == null ? nil : $a[1]); - } else { - if ((($a = args.length == 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (0 for 1..3)") - } else if ((($a = args.length > 3) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (args.$length()) + " for 1..3)")}; - $a = Opal.to_ary(args), obj = ($a[0] == null ? nil : $a[0]), one = ($a[1] == null ? nil : $a[1]), two = ($a[2] == null ? nil : $a[2]); - }; - if ((($a = $scope.get('Range')['$==='](one)) !== nil && (!$a.$$is_boolean || $a == true))) { - if (two !== false && two !== nil) { - self.$raise($scope.get('TypeError'), "length invalid with range")}; - left = $scope.get('Opal').$coerce_to(one.$begin(), $scope.get('Integer'), "to_int"); - if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - left += self.length;}; - if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('RangeError'), "" + (one.$inspect()) + " out of range")}; - right = $scope.get('Opal').$coerce_to(one.$end(), $scope.get('Integer'), "to_int"); - if ((($a = right < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - right += self.length;}; - if ((($a = one['$exclude_end?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - right += 1; - }; - if ((($a = right <= left) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - } else if (one !== false && one !== nil) { - left = $scope.get('Opal').$coerce_to(one, $scope.get('Integer'), "to_int"); - if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - left += self.length;}; - if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - left = 0}; - if (two !== false && two !== nil) { - right = $scope.get('Opal').$coerce_to(two, $scope.get('Integer'), "to_int"); - if ((($a = right == 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - right += left; - } else { - right = self.length - }; - } else { - left = 0; - right = self.length; - }; - if ((($a = left > self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - - for (i = self.length; i < right; i++) { - self[i] = nil; - } - ;}; - if ((($a = right > self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - self.length = right}; - if (block !== false && block !== nil) { - - for (length = self.length; left < right; left++) { - value = block(left); - - if (value === $breaker) { - return $breaker.$v; - } - - self[left] = value; - } - ; - } else { - - for (length = self.length; left < right; left++) { - self[left] = obj; - } - ; - }; - return self; - }); - - Opal.defn(self, '$first', function(count) { - var self = this; - - - if (count == null) { - return self.length === 0 ? nil : self[0]; - } - - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - - if (count < 0) { - self.$raise($scope.get('ArgumentError'), "negative array size"); - } - - return self.slice(0, count); - - }); - - Opal.defn(self, '$flatten', function(level) { - var self = this; - - - function _flatten(array, level) { - var result = [], - i, length, - item, ary; - - array = (array).$to_a(); - - for (i = 0, length = array.length; i < length; i++) { - item = array[i]; - - if (!$scope.get('Opal')['$respond_to?'](item, "to_ary")) { - result.push(item); - continue; - } - - ary = (item).$to_ary(); - - if (ary === nil) { - result.push(item); - continue; - } - - if (!ary.$$is_array) { - self.$raise($scope.get('TypeError')); - } - - if (ary === self) { - self.$raise($scope.get('ArgumentError')); - } - - switch (level) { - case undefined: - result.push.apply(result, _flatten(ary)); - break; - case 0: - result.push(ary); - break; - default: - result.push.apply(result, _flatten(ary, level - 1)); - } - } - return result; - } - - if (level !== undefined) { - level = $scope.get('Opal').$coerce_to(level, $scope.get('Integer'), "to_int"); - } - - return _flatten(self, level); - - }); - - Opal.defn(self, '$flatten!', function(level) { - var self = this; - - - var flattened = self.$flatten(level); - - if (self.length == flattened.length) { - for (var i = 0, length = self.length; i < length; i++) { - if (self[i] !== flattened[i]) { - break; - } - } - - if (i == length) { - return nil; - } - } - - self.$replace(flattened); - ; - return self; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - - var top = (Opal.hash_ids == undefined), - result = ['A'], - hash_id = self.$object_id(), - item, i, key; - - try { - if (top) { - Opal.hash_ids = {}; - } - - if (Opal.hash_ids.hasOwnProperty(hash_id)) { - return 'self'; - } - - for (key in Opal.hash_ids) { - if (Opal.hash_ids.hasOwnProperty(key)) { - item = Opal.hash_ids[key]; - if (self['$eql?'](item)) { - return 'self'; - } - } - } - - Opal.hash_ids[hash_id] = self; - - for (i = 0; i < self.length; i++) { - item = self[i]; - result.push(item.$hash()); - } - - return result.join(','); - } finally { - if (top) { - delete Opal.hash_ids; - } - } - - }); - - Opal.defn(self, '$include?', function(member) { - var self = this; - - - for (var i = 0, length = self.length; i < length; i++) { - if ((self[i])['$=='](member)) { - return true; - } - } - - return false; - - }); - - Opal.defn(self, '$index', TMP_21 = function(object) { - var self = this, $iter = TMP_21.$$p, block = $iter || nil; - - TMP_21.$$p = null; - - var i, length, value; - - if (object != null) { - for (i = 0, length = self.length; i < length; i++) { - if ((self[i])['$=='](object)) { - return i; - } - } - } - else if (block !== nil) { - for (i = 0, length = self.length; i < length; i++) { - if ((value = block(self[i])) === $breaker) { - return $breaker.$v; - } - - if (value !== false && value !== nil) { - return i; - } - } - } - else { - return self.$enum_for("index"); - } - - return nil; - - }); - - Opal.defn(self, '$insert', function(index) { - var self = this; - - var array_size = arguments.length - 1; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 1]; - } - - index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"); - - if (objects.length > 0) { - if (index < 0) { - index += self.length + 1; - - if (index < 0) { - self.$raise($scope.get('IndexError'), "" + (index) + " is out of bounds"); - } - } - if (index > self.length) { - for (var i = self.length; i < index; i++) { - self.push(nil); - } - } - - self.splice.apply(self, [index, 0].concat(objects)); - } - ; - return self; - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - - var result = [], - id = self.$__id__(); - - for (var i = 0, length = self.length; i < length; i++) { - var item = self['$[]'](i); - - if ((item).$__id__() === id) { - result.push('[...]'); - } - else { - result.push((item).$inspect()); - } - } - - return '[' + result.join(', ') + ']'; - ; - }); - - Opal.defn(self, '$join', function(sep) { - var $a, self = this; - if ($gvars[","] == null) $gvars[","] = nil; - - if (sep == null) { - sep = nil - } - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return ""}; - if ((($a = sep === nil) !== nil && (!$a.$$is_boolean || $a == true))) { - sep = $gvars[","]}; - - var result = []; - var i, length, item, tmp; - - for (i = 0, length = self.length; i < length; i++) { - item = self[i]; - - if ($scope.get('Opal')['$respond_to?'](item, "to_str")) { - tmp = (item).$to_str(); - - if (tmp !== nil) { - result.push((tmp).$to_s()); - - continue; - } - } - - if ($scope.get('Opal')['$respond_to?'](item, "to_ary")) { - tmp = (item).$to_ary(); - - if (tmp === self) { - self.$raise($scope.get('ArgumentError')); - } - - if (tmp !== nil) { - result.push((tmp).$join(sep)); - - continue; - } - } - - if ($scope.get('Opal')['$respond_to?'](item, "to_s")) { - tmp = (item).$to_s(); - - if (tmp !== nil) { - result.push(tmp); - - continue; - } - } - - self.$raise($scope.get('NoMethodError').$new("" + ($scope.get('Opal').$inspect(item)) + " doesn't respond to #to_str, #to_ary or #to_s", "to_str")); - } - - if (sep === nil) { - return result.join(''); - } - else { - return result.join($scope.get('Opal')['$coerce_to!'](sep, $scope.get('String'), "to_str").$to_s()); - } - ; - }); - - Opal.defn(self, '$keep_if', TMP_22 = function() { - var $a, $b, TMP_23, self = this, $iter = TMP_22.$$p, block = $iter || nil; - - TMP_22.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_23 = function(){var self = TMP_23.$$s || this; - - return self.$size()}, TMP_23.$$s = self, TMP_23), $a).call($b, "keep_if") - }; - - for (var i = 0, length = self.length, value; i < length; i++) { - if ((value = block(self[i])) === $breaker) { - return $breaker.$v; - } - - if (value === false || value === nil) { - self.splice(i, 1); - - length--; - i--; - } - } - - return self; - }); - - Opal.defn(self, '$last', function(count) { - var self = this; - - - if (count == null) { - return self.length === 0 ? nil : self[self.length - 1]; - } - - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - - if (count < 0) { - self.$raise($scope.get('ArgumentError'), "negative array size"); - } - - if (count > self.length) { - count = self.length; - } - - return self.slice(self.length - count, self.length); - - }); - - Opal.defn(self, '$length', function() { - var self = this; - - return self.length; - }); - - Opal.alias(self, 'map', 'collect'); - - Opal.alias(self, 'map!', 'collect!'); - - Opal.defn(self, '$permutation', TMP_24 = function(num) { - var $a, $b, TMP_25, self = this, $iter = TMP_24.$$p, block = $iter || nil, perm = nil, used = nil; - - TMP_24.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_25 = function(){var self = TMP_25.$$s || this; - - return self.$size()}, TMP_25.$$s = self, TMP_25), $a).call($b, "permutation", num) - }; - - var permute, offensive, output; - - if (num === undefined) { - num = self.length; - } - else { - num = $scope.get('Opal').$coerce_to(num, $scope.get('Integer'), "to_int") - } - - if (num < 0 || self.length < num) { - // no permutations, yield nothing - } - else if (num === 0) { - // exactly one permutation: the zero-length array - ((($a = Opal.yield1(block, [])) === $breaker) ? $breaker.$v : $a) - } - else if (num === 1) { - // this is a special, easy case - for (var i = 0; i < self.length; i++) { - ((($a = Opal.yield1(block, [self[i]])) === $breaker) ? $breaker.$v : $a) - } - } - else { - // this is the general case - perm = $scope.get('Array').$new(num) - used = $scope.get('Array').$new(self.length, false) - - permute = function(num, perm, index, used, blk) { - self = this; - for(var i = 0; i < self.length; i++){ - if(used['$[]'](i)['$!']()) { - perm[index] = i; - if(index < num - 1) { - used[i] = true; - permute.call(self, num, perm, index + 1, used, blk); - used[i] = false; - } - else { - output = []; - for (var j = 0; j < perm.length; j++) { - output.push(self[perm[j]]); - } - Opal.yield1(blk, output); - } - } - } - } - - if ((block !== nil)) { - // offensive (both definitions) copy. - offensive = self.slice(); - permute.call(offensive, num, perm, 0, used, block); - } - else { - permute.call(self, num, perm, 0, used, block); - } - } - ; - return self; - }); - - Opal.defn(self, '$pop', function(count) { - var $a, self = this; - - if ((($a = count === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - return self.pop();}; - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - if ((($a = count < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "negative array size")}; - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - if ((($a = count > self.length) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.splice(0, self.length); - } else { - return self.splice(self.length - count, self.length); - }; - }); - - Opal.defn(self, '$product', TMP_26 = function() { - var $a, self = this, $iter = TMP_26.$$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_26.$$p = null; - - var result = (block !== nil) ? null : [], - n = args.length + 1, - counters = new Array(n), - lengths = new Array(n), - arrays = new Array(n), - i, m, subarray, len, resultlen = 1; - - arrays[0] = self; - for (i = 1; i < n; i++) { - arrays[i] = $scope.get('Opal').$coerce_to(args[i - 1], $scope.get('Array'), "to_ary"); - } - - for (i = 0; i < n; i++) { - len = arrays[i].length; - if (len === 0) { - return result || self; - } - resultlen *= len; - if (resultlen > 2147483647) { - self.$raise($scope.get('RangeError'), "too big to product") - } - lengths[i] = len; - counters[i] = 0; - } - - outer_loop: for (;;) { - subarray = []; - for (i = 0; i < n; i++) { - subarray.push(arrays[i][counters[i]]); - } - if (result) { - result.push(subarray); - } else { - ((($a = Opal.yield1(block, subarray)) === $breaker) ? $breaker.$v : $a) - } - m = n - 1; - counters[m]++; - while (counters[m] === lengths[m]) { - counters[m] = 0; - if (--m < 0) break outer_loop; - counters[m]++; - } - } - - return result || self; - ; - }); - - Opal.defn(self, '$push', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 0]; - } - - for (var i = 0, length = objects.length; i < length; i++) { - self.push(objects[i]); - } - - return self; - }); - - Opal.defn(self, '$rassoc', function(object) { - var self = this; - - - for (var i = 0, length = self.length, item; i < length; i++) { - item = self[i]; - - if (item.length && item[1] !== undefined) { - if ((item[1])['$=='](object)) { - return item; - } - } - } - - return nil; - - }); - - Opal.defn(self, '$reject', TMP_27 = function() { - var $a, $b, TMP_28, self = this, $iter = TMP_27.$$p, block = $iter || nil; - - TMP_27.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_28 = function(){var self = TMP_28.$$s || this; - - return self.$size()}, TMP_28.$$s = self, TMP_28), $a).call($b, "reject") - }; - - var result = []; - - for (var i = 0, length = self.length, value; i < length; i++) { - if ((value = block(self[i])) === $breaker) { - return $breaker.$v; - } - - if (value === false || value === nil) { - result.push(self[i]); - } - } - return result; - - }); - - Opal.defn(self, '$reject!', TMP_29 = function() { - var $a, $b, TMP_30, $c, self = this, $iter = TMP_29.$$p, block = $iter || nil, original = nil; - - TMP_29.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_30 = function(){var self = TMP_30.$$s || this; - - return self.$size()}, TMP_30.$$s = self, TMP_30), $a).call($b, "reject!") - }; - original = self.$length(); - ($a = ($c = self).$delete_if, $a.$$p = block.$to_proc(), $a).call($c); - if (self.$length()['$=='](original)) { - return nil - } else { - return self - }; - }); - - Opal.defn(self, '$replace', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - other = other.$to_a() - } else { - other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a() - }; - - self.splice(0, self.length); - self.push.apply(self, other); - - return self; - }); - - Opal.defn(self, '$reverse', function() { - var self = this; - - return self.slice(0).reverse(); - }); - - Opal.defn(self, '$reverse!', function() { - var self = this; - - return self.reverse(); - }); - - Opal.defn(self, '$reverse_each', TMP_31 = function() { - var $a, $b, TMP_32, $c, self = this, $iter = TMP_31.$$p, block = $iter || nil; - - TMP_31.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_32 = function(){var self = TMP_32.$$s || this; - - return self.$size()}, TMP_32.$$s = self, TMP_32), $a).call($b, "reverse_each") - }; - ($a = ($c = self.$reverse()).$each, $a.$$p = block.$to_proc(), $a).call($c); - return self; - }); - - Opal.defn(self, '$rindex', TMP_33 = function(object) { - var self = this, $iter = TMP_33.$$p, block = $iter || nil; - - TMP_33.$$p = null; - - var i, value; - - if (object != null) { - for (i = self.length - 1; i >= 0; i--) { - if (i >= self.length) { - break; - } - if ((self[i])['$=='](object)) { - return i; - } - } - } - else if (block !== nil) { - for (i = self.length - 1; i >= 0; i--) { - if (i >= self.length) { - break; - } - if ((value = block(self[i])) === $breaker) { - return $breaker.$v; - } - if (value !== false && value !== nil) { - return i; - } - } - } - else if (object == null) { - return self.$enum_for("rindex"); - } - - return nil; - - }); - - Opal.defn(self, '$rotate', function(n) { - var self = this; - - if (n == null) { - n = 1 - } - n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int"); - - var ary, idx, firstPart, lastPart; - - if (self.length === 1) { - return self.slice(); - } - if (self.length === 0) { - return []; - } - - ary = self.slice(); - idx = n % ary.length; - - firstPart = ary.slice(idx); - lastPart = ary.slice(0, idx); - return firstPart.concat(lastPart); - - }); - - Opal.defn(self, '$rotate!', function(cnt) { - var self = this, ary = nil; - - if (cnt == null) { - cnt = 1 - } - - if (self.length === 0 || self.length === 1) { - return self; - } - - cnt = $scope.get('Opal').$coerce_to(cnt, $scope.get('Integer'), "to_int"); - ary = self.$rotate(cnt); - return self.$replace(ary); - }); - - (function($base, $super) { - function $SampleRandom(){}; - var self = $SampleRandom = $klass($base, $super, 'SampleRandom', $SampleRandom); - - var def = self.$$proto, $scope = self.$$scope; - - def.rng = nil; - Opal.defn(self, '$initialize', function(rng) { - var self = this; - - return self.rng = rng; - }); - - return (Opal.defn(self, '$rand', function(size) { - var $a, self = this, random = nil; - - random = $scope.get('Opal').$coerce_to(self.rng.$rand(size), $scope.get('Integer'), "to_int"); - if ((($a = random < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('RangeError'), "random value must be >= 0")}; - if ((($a = random < size) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('RangeError'), "random value must be less than Array size") - }; - return random; - }), nil) && 'rand'; - })($scope.base, null); - - Opal.defn(self, '$sample', function(count, options) { - var $a, $b, self = this, o = nil, rng = nil; - - if ((($a = count === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$at($scope.get('Kernel').$rand(self.length))}; - if ((($a = options === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = (o = $scope.get('Opal')['$coerce_to?'](count, $scope.get('Hash'), "to_hash"))) !== nil && (!$a.$$is_boolean || $a == true))) { - options = o; - count = nil; - } else { - options = nil; - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - } - } else { - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - options = $scope.get('Opal').$coerce_to(options, $scope.get('Hash'), "to_hash"); - }; - if ((($a = (($b = count !== false && count !== nil) ? count < 0 : count)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "count must be greater than 0")}; - if (options !== false && options !== nil) { - rng = options['$[]']("random")}; - if ((($a = (($b = rng !== false && rng !== nil) ? rng['$respond_to?']("rand") : rng)) !== nil && (!$a.$$is_boolean || $a == true))) { - rng = $scope.get('SampleRandom').$new(rng) - } else { - rng = $scope.get('Kernel') - }; - if (count !== false && count !== nil) { - } else { - return self[rng.$rand(self.length)] - }; - - - var abandon, spin, result, i, j, k, targetIndex, oldValue; - - if (count > self.length) { - count = self.length; - } - - switch (count) { - case 0: - return []; - break; - case 1: - return [self[rng.$rand(self.length)]]; - break; - case 2: - i = rng.$rand(self.length); - j = rng.$rand(self.length); - if (i === j) { - j = i === 0 ? i + 1 : i - 1; - } - return [self[i], self[j]]; - break; - default: - if (self.length / count > 3) { - abandon = false; - spin = 0; - - result = $scope.get('Array').$new(count); - i = 1; - - result[0] = rng.$rand(self.length); - while (i < count) { - k = rng.$rand(self.length); - j = 0; - - while (j < i) { - while (k === result[j]) { - spin++; - if (spin > 100) { - abandon = true; - break; - } - k = rng.$rand(self.length); - } - if (abandon) { break; } - - j++; - } - - if (abandon) { break; } - - result[i] = k; - - i++; - } - - if (!abandon) { - i = 0; - while (i < count) { - result[i] = self[result[i]]; - i++; - } - - return result; - } - } - - result = self.slice(); - - for (var c = 0; c < count; c++) { - targetIndex = rng.$rand(self.length); - oldValue = result[c]; - result[c] = result[targetIndex]; - result[targetIndex] = oldValue; - } - - return count === self.length ? result : (result)['$[]'](0, count); - } - - }); - - Opal.defn(self, '$select', TMP_34 = function() { - var $a, $b, TMP_35, self = this, $iter = TMP_34.$$p, block = $iter || nil; - - TMP_34.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_35 = function(){var self = TMP_35.$$s || this; - - return self.$size()}, TMP_35.$$s = self, TMP_35), $a).call($b, "select") - }; - - var result = []; - - for (var i = 0, length = self.length, item, value; i < length; i++) { - item = self[i]; - - if ((value = Opal.yield1(block, item)) === $breaker) { - return $breaker.$v; - } - - if (value !== false && value !== nil) { - result.push(item); - } - } - - return result; - - }); - - Opal.defn(self, '$select!', TMP_36 = function() { - var $a, $b, TMP_37, $c, self = this, $iter = TMP_36.$$p, block = $iter || nil; - - TMP_36.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_37 = function(){var self = TMP_37.$$s || this; - - return self.$size()}, TMP_37.$$s = self, TMP_37), $a).call($b, "select!") - }; - - var original = self.length; - ($a = ($c = self).$keep_if, $a.$$p = block.$to_proc(), $a).call($c); - return self.length === original ? nil : self; - - }); - - Opal.defn(self, '$shift', function(count) { - var $a, self = this; - - if ((($a = count === undefined) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - return self.shift();}; - count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int"); - if ((($a = count < 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "negative array size")}; - if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - return self.splice(0, count); - }); - - Opal.alias(self, 'size', 'length'); - - Opal.defn(self, '$shuffle', function(rng) { - var self = this; - - return self.$dup()['$shuffle!'](rng); - }); - - Opal.defn(self, '$shuffle!', function(rng) { - var self = this; - - - var randgen, i = self.length, j, tmp; - - if (rng !== undefined) { - rng = $scope.get('Opal')['$coerce_to?'](rng, $scope.get('Hash'), "to_hash"); - - if (rng !== nil) { - rng = rng['$[]']("random"); - - if (rng !== nil && rng['$respond_to?']("rand")) { - randgen = rng; - } - } - } - - while (i) { - if (randgen) { - j = randgen.$rand(i).$to_int(); - - if (j < 0) { - self.$raise($scope.get('RangeError'), "random number too small " + (j)) - } - - if (j >= i) { - self.$raise($scope.get('RangeError'), "random number too big " + (j)) - } - } - else { - j = Math.floor(Math.random() * i); - } - - tmp = self[--i]; - self[i] = self[j]; - self[j] = tmp; - } - - return self; - ; - }); - - Opal.alias(self, 'slice', '[]'); - - Opal.defn(self, '$slice!', function(index, length) { - var self = this; - - - if (index < 0) { - index += self.length; - } - - if (length != null) { - return self.splice(index, length); - } - - if (index < 0 || index >= self.length) { - return nil; - } - - return self.splice(index, 1)[0]; - - }); - - Opal.defn(self, '$sort', TMP_38 = function() { - var $a, self = this, $iter = TMP_38.$$p, block = $iter || nil; - - TMP_38.$$p = null; - if ((($a = self.length > 1) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return self - }; - - if (block === nil) { - block = function(a, b) { - return (a)['$<=>'](b); - }; - } - - try { - return self.slice().sort(function(x, y) { - var ret = block(x, y); - - if (ret === $breaker) { - throw $breaker; - } - else if (ret === nil) { - self.$raise($scope.get('ArgumentError'), "comparison of " + ((x).$inspect()) + " with " + ((y).$inspect()) + " failed"); - } - - return $rb_gt(ret, 0) ? 1 : ($rb_lt(ret, 0) ? -1 : 0); - }); - } - catch (e) { - if (e === $breaker) { - return $breaker.$v; - } - else { - throw e; - } - } - ; - }); - - Opal.defn(self, '$sort!', TMP_39 = function() { - var $a, $b, self = this, $iter = TMP_39.$$p, block = $iter || nil; - - TMP_39.$$p = null; - - var result; - - if ((block !== nil)) { - result = ($a = ($b = (self.slice())).$sort, $a.$$p = block.$to_proc(), $a).call($b); - } - else { - result = (self.slice()).$sort(); - } - - self.length = 0; - for(var i = 0, length = result.length; i < length; i++) { - self.push(result[i]); - } - - return self; - ; - }); - - Opal.defn(self, '$take', function(count) { - var self = this; - - - if (count < 0) { - self.$raise($scope.get('ArgumentError')); - } - - return self.slice(0, count); - ; - }); - - Opal.defn(self, '$take_while', TMP_40 = function() { - var self = this, $iter = TMP_40.$$p, block = $iter || nil; - - TMP_40.$$p = null; - - var result = []; - - for (var i = 0, length = self.length, item, value; i < length; i++) { - item = self[i]; - - if ((value = block(item)) === $breaker) { - return $breaker.$v; - } - - if (value === false || value === nil) { - return result; - } - - result.push(item); - } - - return result; - - }); - - Opal.defn(self, '$to_a', function() { - var self = this; - - return self; - }); - - Opal.alias(self, 'to_ary', 'to_a'); - - Opal.defn(self, '$to_h', function() { - var self = this; - - - var i, len = self.length, ary, key, val, hash = $hash2([], {}); - - for (i = 0; i < len; i++) { - ary = $scope.get('Opal')['$coerce_to?'](self[i], $scope.get('Array'), "to_ary"); - if (!ary.$$is_array) { - self.$raise($scope.get('TypeError'), "wrong element type " + ((ary).$class()) + " at " + (i) + " (expected array)") - } - if (ary.length !== 2) { - self.$raise($scope.get('ArgumentError'), "wrong array length at " + (i) + " (expected 2, was " + ((ary).$length()) + ")") - } - key = ary[0]; - val = ary[1]; - Opal.hash_put(hash, key, val); - } - - return hash; - ; - }); - - Opal.alias(self, 'to_s', 'inspect'); - - Opal.defn(self, '$transpose', function() { - var $a, $b, TMP_41, self = this, result = nil, max = nil; - - if ((($a = self['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - result = []; - max = nil; - ($a = ($b = self).$each, $a.$$p = (TMP_41 = function(row){var self = TMP_41.$$s || this, $a, $b, TMP_42; -if (row == null) row = nil; - if ((($a = $scope.get('Array')['$==='](row)) !== nil && (!$a.$$is_boolean || $a == true))) { - row = row.$to_a() - } else { - row = $scope.get('Opal').$coerce_to(row, $scope.get('Array'), "to_ary").$to_a() - }; - ((($a = max) !== false && $a !== nil) ? $a : max = row.length); - if ((($a = (row.length)['$!='](max)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('IndexError'), "element size differs (" + (row.length) + " should be " + (max))}; - return ($a = ($b = (row.length)).$times, $a.$$p = (TMP_42 = function(i){var self = TMP_42.$$s || this, $a, $b, $c, entry = nil; -if (i == null) i = nil; - entry = (($a = i, $b = result, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, [])))); - return entry['$<<'](row.$at(i));}, TMP_42.$$s = self, TMP_42), $a).call($b);}, TMP_41.$$s = self, TMP_41), $a).call($b); - return result; - }); - - Opal.defn(self, '$uniq', TMP_43 = function() { - var self = this, $iter = TMP_43.$$p, block = $iter || nil; - - TMP_43.$$p = null; - - var hash = $hash2([], {}), i, length, item, key; - - if (block === nil) { - for (i = 0, length = self.length; i < length; i++) { - item = self[i]; - if (Opal.hash_get(hash, item) === undefined) { - Opal.hash_put(hash, item, item); - } - } - } - else { - for (i = 0, length = self.length; i < length; i++) { - item = self[i]; - key = Opal.yield1(block, item); - if (Opal.hash_get(hash, key) === undefined) { - Opal.hash_put(hash, key, item); - } - } - } - - return hash.$values(); - ; - }); - - Opal.defn(self, '$uniq!', TMP_44 = function() { - var self = this, $iter = TMP_44.$$p, block = $iter || nil; - - TMP_44.$$p = null; - - var original_length = self.length, hash = $hash2([], {}), i, length, item, key; - - for (i = 0, length = original_length; i < length; i++) { - item = self[i]; - key = (block === nil ? item : Opal.yield1(block, item)); - - if (Opal.hash_get(hash, key) === undefined) { - Opal.hash_put(hash, key, item); - continue; - } - - self.splice(i, 1); - length--; - i--; - } - - return self.length === original_length ? nil : self; - ; - }); - - Opal.defn(self, '$unshift', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 0]; - } - - for (var i = objects.length - 1; i >= 0; i--) { - self.unshift(objects[i]); - } - - return self; - }); - - Opal.defn(self, '$values_at', function() { - var $a, $b, TMP_45, self = this, out = 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]; - } - out = []; - ($a = ($b = args).$each, $a.$$p = (TMP_45 = function(elem){var self = TMP_45.$$s || this, $a, $b, TMP_46, finish = nil, start = nil, i = nil; -if (elem == null) elem = nil; - if ((($a = elem['$kind_of?']($scope.get('Range'))) !== nil && (!$a.$$is_boolean || $a == true))) { - finish = $scope.get('Opal').$coerce_to(elem.$last(), $scope.get('Integer'), "to_int"); - start = $scope.get('Opal').$coerce_to(elem.$first(), $scope.get('Integer'), "to_int"); - - if (start < 0) { - start = start + self.length; - return nil;; - } - - - if (finish < 0) { - finish = finish + self.length; - } - if (elem['$exclude_end?']()) { - finish--; - } - if (finish < start) { - return nil;; - } - - return ($a = ($b = start).$upto, $a.$$p = (TMP_46 = function(i){var self = TMP_46.$$s || this; -if (i == null) i = nil; - return out['$<<'](self.$at(i))}, TMP_46.$$s = self, TMP_46), $a).call($b, finish); - } else { - i = $scope.get('Opal').$coerce_to(elem, $scope.get('Integer'), "to_int"); - return out['$<<'](self.$at(i)); - }}, TMP_45.$$s = self, TMP_45), $a).call($b); - return out; - }); - - return (Opal.defn(self, '$zip', TMP_47 = function() { - var $a, self = this, $iter = TMP_47.$$p, block = $iter || nil; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var others = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - others[arg_index] = arguments[arg_index + 0]; - } - TMP_47.$$p = null; - - var result = [], size = self.length, part, o, i, j, jj; - - for (j = 0, jj = others.length; j < jj; j++) { - o = others[j]; - if (!o.$$is_array) { - others[j] = (((($a = $scope.get('Opal')['$coerce_to?'](o, $scope.get('Array'), "to_ary")) !== false && $a !== nil) ? $a : $scope.get('Opal')['$coerce_to!'](o, $scope.get('Enumerator'), "each"))).$to_a(); - } - } - - for (i = 0; i < size; i++) { - part = [self[i]]; - - for (j = 0, jj = others.length; j < jj; j++) { - o = others[j][i]; - - if (o == null) { - o = nil; - } - - part[j + 1] = o; - } - - result[i] = part; - } - - if (block !== nil) { - for (i = 0; i < size; i++) { - block(result[i]); - } - - return nil; - } - - return result; - - }), nil) && 'zip'; - })($scope.base, Array); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/hash"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$include', '$coerce_to?', '$[]', '$merge!', '$allocate', '$raise', '$==', '$coerce_to!', '$lambda?', '$abs', '$arity', '$call', '$enum_for', '$size', '$inspect', '$flatten', '$eql?', '$default', '$to_proc', '$dup', '$===', '$default_proc', '$default_proc=', '$default=', '$alias_method']); - self.$require("corelib/enumerable"); - return (function($base, $super) { - function $Hash(){}; - var self = $Hash = $klass($base, $super, 'Hash', $Hash); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_5, TMP_7, TMP_9, TMP_11, TMP_12, TMP_14, TMP_15, TMP_16, TMP_18, TMP_20, TMP_22; - - def.proc = def.none = nil; - self.$include($scope.get('Enumerable')); - - def.$$is_hash = true; - - Opal.defs(self, '$[]', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var argv = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - argv[arg_index] = arguments[arg_index + 0]; - } - - var hash, argc = argv.length, i; - - if (argc === 1) { - hash = $scope.get('Opal')['$coerce_to?'](argv['$[]'](0), $scope.get('Hash'), "to_hash"); - if (hash !== nil) { - return self.$allocate()['$merge!'](hash); - } - - argv = $scope.get('Opal')['$coerce_to?'](argv['$[]'](0), $scope.get('Array'), "to_ary"); - if (argv === nil) { - self.$raise($scope.get('ArgumentError'), "odd number of arguments for Hash") - } - - argc = argv.length; - hash = self.$allocate(); - - for (i = 0; i < argc; i++) { - if (!argv[i].$$is_array) continue; - switch(argv[i].length) { - case 1: - hash.$store(argv[i][0], nil); - break; - case 2: - hash.$store(argv[i][0], argv[i][1]); - break; - default: - self.$raise($scope.get('ArgumentError'), "invalid number of elements (" + (argv[i].length) + " for 1..2)") - } - } - - return hash; - } - - if (argc % 2 !== 0) { - self.$raise($scope.get('ArgumentError'), "odd number of arguments for Hash") - } - - hash = self.$allocate(); - - for (i = 0; i < argc; i += 2) { - hash.$store(argv[i], argv[i + 1]); - } - - return hash; - ; - }); - - Opal.defs(self, '$allocate', function() { - var self = this; - - - var hash = new self.$$alloc(); - - Opal.hash_init(hash); - - hash.none = nil; - hash.proc = nil; - - return hash; - - }); - - Opal.defs(self, '$try_convert', function(obj) { - var self = this; - - return $scope.get('Opal')['$coerce_to?'](obj, $scope.get('Hash'), "to_hash"); - }); - - Opal.defn(self, '$initialize', TMP_1 = function(defaults) { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - TMP_1.$$p = null; - - if (defaults !== undefined && block !== nil) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (1 for 0)") - } - self.none = (defaults === undefined ? nil : defaults); - self.proc = block; - ; - return self; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - - if (self === other) { - return true; - } - - if (!other.$$is_hash) { - return false; - } - - if (self.keys.length !== other.keys.length) { - return false; - } - - for (var i = 0, keys = self.keys, length = keys.length, key, value, other_value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - other_value = other.smap[key]; - } else { - value = key.value; - other_value = Opal.hash_get(other, key.key); - } - - if (other_value === undefined || !value['$eql?'](other_value)) { - return false; - } - } - - return true; - - }); - - Opal.defn(self, '$[]', function(key) { - var self = this; - - - var value = Opal.hash_get(self, key); - - if (value !== undefined) { - return value; - } - - return self.$default(key); - - }); - - Opal.defn(self, '$[]=', function(key, value) { - var self = this; - - - Opal.hash_put(self, key, value); - return value; - - }); - - Opal.defn(self, '$assoc', function(object) { - var self = this; - - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - if ((key)['$=='](object)) { - return [key, self.smap[key]]; - } - } else { - if ((key.key)['$=='](object)) { - return [key.key, key.value]; - } - } - } - - return nil; - - }); - - Opal.defn(self, '$clear', function() { - var self = this; - - - Opal.hash_init(self); - return self; - - }); - - Opal.defn(self, '$clone', function() { - var self = this; - - - var hash = new self.$$class.$$alloc(); - - Opal.hash_init(hash); - Opal.hash_clone(self, hash); - - return hash; - - }); - - Opal.defn(self, '$default', function(key) { - var self = this; - - - if (key !== undefined && self.proc !== nil) { - return self.proc.$call(self, key); - } - return self.none; - ; - }); - - Opal.defn(self, '$default=', function(object) { - var self = this; - - - self.proc = nil; - self.none = object; - - return object; - - }); - - Opal.defn(self, '$default_proc', function() { - var self = this; - - return self.proc; - }); - - Opal.defn(self, '$default_proc=', function(proc) { - var self = this; - - - if (proc !== nil) { - proc = $scope.get('Opal')['$coerce_to!'](proc, $scope.get('Proc'), "to_proc"); - - if (proc['$lambda?']() && proc.$arity().$abs() !== 2) { - self.$raise($scope.get('TypeError'), "default_proc takes two arguments"); - } - } - - self.none = nil; - self.proc = proc; - - return proc; - ; - }); - - Opal.defn(self, '$delete', TMP_2 = function(key) { - var self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - - var value = Opal.hash_delete(self, key); - - if (value !== undefined) { - return value; - } - - if (block !== nil) { - return block.$call(key); - } - - return nil; - - }); - - Opal.defn(self, '$delete_if', TMP_3 = function() { - var $a, $b, TMP_4, self = this, $iter = TMP_3.$$p, block = $iter || nil; - - TMP_3.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_4 = function(){var self = TMP_4.$$s || this; - - return self.$size()}, TMP_4.$$s = self, TMP_4), $a).call($b, "delete_if") - }; - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj !== false && obj !== nil) { - if (Opal.hash_delete(self, key) !== undefined) { - length--; - i--; - } - } - } - - return self; - - }); - - Opal.alias(self, 'dup', 'clone'); - - Opal.defn(self, '$each', TMP_5 = function() { - var $a, $b, TMP_6, self = this, $iter = TMP_5.$$p, block = $iter || nil; - - TMP_5.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_6 = function(){var self = TMP_6.$$s || this; - - return self.$size()}, TMP_6.$$s = self, TMP_6), $a).call($b, "each") - }; - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = Opal.yield1(block, [key, value]); - - if (obj === $breaker) { - return $breaker.$v; - } - } - - return self; - - }); - - Opal.defn(self, '$each_key', TMP_7 = function() { - var $a, $b, TMP_8, self = this, $iter = TMP_7.$$p, block = $iter || nil; - - TMP_7.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_8 = function(){var self = TMP_8.$$s || this; - - return self.$size()}, TMP_8.$$s = self, TMP_8), $a).call($b, "each_key") - }; - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (block(key.$$is_string ? key : key.key) === $breaker) { - return $breaker.$v; - } - } - - return self; - - }); - - Opal.alias(self, 'each_pair', 'each'); - - Opal.defn(self, '$each_value', TMP_9 = function() { - var $a, $b, TMP_10, self = this, $iter = TMP_9.$$p, block = $iter || nil; - - TMP_9.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_10 = function(){var self = TMP_10.$$s || this; - - return self.$size()}, TMP_10.$$s = self, TMP_10), $a).call($b, "each_value") - }; - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (block(key.$$is_string ? self.smap[key] : key.value) === $breaker) { - return $breaker.$v; - } - } - - return self; - - }); - - Opal.defn(self, '$empty?', function() { - var self = this; - - return self.keys.length === 0; - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.defn(self, '$fetch', TMP_11 = function(key, defaults) { - var self = this, $iter = TMP_11.$$p, block = $iter || nil; - - TMP_11.$$p = null; - - var value = Opal.hash_get(self, key); - - if (value !== undefined) { - return value; - } - - if (block !== nil) { - value = block(key); - - if (value === $breaker) { - return $breaker.$v; - } - - return value; - } - - if (defaults !== undefined) { - return defaults; - } - - return self.$raise($scope.get('KeyError'), "key not found: " + (key.$inspect())); - }); - - Opal.defn(self, '$flatten', function(level) { - var self = this; - - if (level == null) { - level = 1 - } - level = $scope.get('Opal')['$coerce_to!'](level, $scope.get('Integer'), "to_int"); - - var result = []; - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - result.push(key); - - if (value.$$is_array) { - if (level === 1) { - result.push(value); - continue; - } - - result = result.concat((value).$flatten(level - 2)); - continue; - } - - result.push(value); - } - - return result; - - }); - - Opal.defn(self, '$has_key?', function(key) { - var self = this; - - return Opal.hash_get(self, key) !== undefined; - }); - - Opal.defn(self, '$has_value?', function(value) { - var self = this; - - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (((key.$$is_string ? self.smap[key] : key.value))['$=='](value)) { - return true; - } - } - - return false; - - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - - var top = (Opal.hash_ids === undefined), - hash_id = self.$object_id(), - result = ['Hash'], - key, item; - - try { - if (top) { - Opal.hash_ids = {}; - } - - if (Opal.hash_ids.hasOwnProperty(hash_id)) { - return 'self'; - } - - for (key in Opal.hash_ids) { - if (Opal.hash_ids.hasOwnProperty(key)) { - item = Opal.hash_ids[key]; - if (self['$eql?'](item)) { - return 'self'; - } - } - } - - Opal.hash_ids[hash_id] = self; - - for (var i = 0, keys = self.keys, length = keys.length; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - result.push([key, self.smap[key].$hash()]); - } else { - result.push([key.key_hash, key.value.$hash()]); - } - } - - return result.sort().join(); - - } finally { - if (top) { - delete Opal.hash_ids; - } - } - - }); - - Opal.alias(self, 'include?', 'has_key?'); - - Opal.defn(self, '$index', function(object) { - var self = this; - - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - if ((value)['$=='](object)) { - return key; - } - } - - return nil; - - }); - - Opal.defn(self, '$indexes', 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]; - } - - var result = []; - - for (var i = 0, length = args.length, key, value; i < length; i++) { - key = args[i]; - value = Opal.hash_get(self, key); - - if (value === undefined) { - result.push(self.$default()); - continue; - } - - result.push(value); - } - - return result; - - }); - - Opal.alias(self, 'indices', 'indexes'); - - var inspect_ids; - - Opal.defn(self, '$inspect', function() { - var self = this; - - - var top = (inspect_ids === undefined), - hash_id = self.$object_id(), - result = []; - - try { - if (top) { - inspect_ids = {}; - } - - if (inspect_ids.hasOwnProperty(hash_id)) { - return '{...}'; - } - - inspect_ids[hash_id] = true; - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - result.push(key.$inspect() + '=>' + value.$inspect()); - } - - return '{' + result.join(', ') + '}'; - - } finally { - if (top) { - inspect_ids = undefined; - } - } - - }); - - Opal.defn(self, '$invert', function() { - var self = this; - - - var hash = Opal.hash(); - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - Opal.hash_put(hash, value, key); - } - - return hash; - - }); - - Opal.defn(self, '$keep_if', TMP_12 = function() { - var $a, $b, TMP_13, self = this, $iter = TMP_12.$$p, block = $iter || nil; - - TMP_12.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_13 = function(){var self = TMP_13.$$s || this; - - return self.$size()}, TMP_13.$$s = self, TMP_13), $a).call($b, "keep_if") - }; - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj === false || obj === nil) { - if (Opal.hash_delete(self, key) !== undefined) { - length--; - i--; - } - } - } - - return self; - - }); - - Opal.alias(self, 'key', 'index'); - - Opal.alias(self, 'key?', 'has_key?'); - - Opal.defn(self, '$keys', function() { - var self = this; - - - var result = []; - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - result.push(key); - } else { - result.push(key.key); - } - } - - return result; - - }); - - Opal.defn(self, '$length', function() { - var self = this; - - return self.keys.length; - }); - - Opal.alias(self, 'member?', 'has_key?'); - - Opal.defn(self, '$merge', TMP_14 = function(other) { - var $a, $b, self = this, $iter = TMP_14.$$p, block = $iter || nil; - - TMP_14.$$p = null; - return ($a = ($b = self.$dup())['$merge!'], $a.$$p = block.$to_proc(), $a).call($b, other); - }); - - Opal.defn(self, '$merge!', TMP_15 = function(other) { - var self = this, $iter = TMP_15.$$p, block = $iter || nil; - - TMP_15.$$p = null; - - if (!$scope.get('Hash')['$==='](other)) { - other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Hash'), "to_hash"); - } - - var i, other_keys = other.keys, length = other_keys.length, key, value, other_value; - - if (block === nil) { - for (i = 0; i < length; i++) { - key = other_keys[i]; - - if (key.$$is_string) { - other_value = other.smap[key]; - } else { - other_value = key.value; - key = key.key; - } - - Opal.hash_put(self, key, other_value); - } - - return self; - } - - for (i = 0; i < length; i++) { - key = other_keys[i]; - - if (key.$$is_string) { - other_value = other.smap[key]; - } else { - other_value = key.value; - key = key.key; - } - - value = Opal.hash_get(self, key); - - if (value === undefined) { - Opal.hash_put(self, key, other_value); - continue; - } - - Opal.hash_put(self, key, block(key, value, other_value)); - } - - return self; - ; - }); - - Opal.defn(self, '$rassoc', function(object) { - var self = this; - - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - if ((value)['$=='](object)) { - return [key, value]; - } - } - - return nil; - - }); - - Opal.defn(self, '$rehash', function() { - var self = this; - - - Opal.hash_rehash(self); - return self; - - }); - - Opal.defn(self, '$reject', TMP_16 = function() { - var $a, $b, TMP_17, self = this, $iter = TMP_16.$$p, block = $iter || nil; - - TMP_16.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_17 = function(){var self = TMP_17.$$s || this; - - return self.$size()}, TMP_17.$$s = self, TMP_17), $a).call($b, "reject") - }; - - var hash = Opal.hash(); - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj === false || obj === nil) { - Opal.hash_put(hash, key, value); - } - } - - return hash; - - }); - - Opal.defn(self, '$reject!', TMP_18 = function() { - var $a, $b, TMP_19, self = this, $iter = TMP_18.$$p, block = $iter || nil; - - TMP_18.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_19 = function(){var self = TMP_19.$$s || this; - - return self.$size()}, TMP_19.$$s = self, TMP_19), $a).call($b, "reject!") - }; - - var changes_were_made = false; - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj !== false && obj !== nil) { - if (Opal.hash_delete(self, key) !== undefined) { - changes_were_made = true; - length--; - i--; - } - } - } - - return changes_were_made ? self : nil; - - }); - - Opal.defn(self, '$replace', function(other) { - var $a, $b, self = this; - - other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Hash'), "to_hash"); - - Opal.hash_init(self); - - for (var i = 0, other_keys = other.keys, length = other_keys.length, key, value, other_value; i < length; i++) { - key = other_keys[i]; - - if (key.$$is_string) { - other_value = other.smap[key]; - } else { - other_value = key.value; - key = key.key; - } - - Opal.hash_put(self, key, other_value); - } - - if ((($a = other.$default_proc()) !== nil && (!$a.$$is_boolean || $a == true))) { - (($a = [other.$default_proc()]), $b = self, $b['$default_proc='].apply($b, $a), $a[$a.length-1]) - } else { - (($a = [other.$default()]), $b = self, $b['$default='].apply($b, $a), $a[$a.length-1]) - }; - return self; - }); - - Opal.defn(self, '$select', TMP_20 = function() { - var $a, $b, TMP_21, self = this, $iter = TMP_20.$$p, block = $iter || nil; - - TMP_20.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_21 = function(){var self = TMP_21.$$s || this; - - return self.$size()}, TMP_21.$$s = self, TMP_21), $a).call($b, "select") - }; - - var hash = Opal.hash(); - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj !== false && obj !== nil) { - Opal.hash_put(hash, key, value); - } - } - - return hash; - - }); - - Opal.defn(self, '$select!', TMP_22 = function() { - var $a, $b, TMP_23, self = this, $iter = TMP_22.$$p, block = $iter || nil; - - TMP_22.$$p = null; - if (block !== false && block !== nil) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_23 = function(){var self = TMP_23.$$s || this; - - return self.$size()}, TMP_23.$$s = self, TMP_23), $a).call($b, "select!") - }; - - var result = nil; - - for (var i = 0, keys = self.keys, length = keys.length, key, value, obj; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - obj = block(key, value); - - if (obj === $breaker) { - return $breaker.$v; - } - - if (obj === false || obj === nil) { - if (Opal.hash_delete(self, key) !== undefined) { - length--; - i--; - } - result = self; - } - } - - return result; - - }); - - Opal.defn(self, '$shift', function() { - var self = this; - - - var keys = self.keys, - key; - - if (keys.length > 0) { - key = keys[0]; - - key = key.$$is_string ? key : key.key; - - return [key, Opal.hash_delete(self, key)]; - } - - return self.$default(nil); - - }); - - Opal.alias(self, 'size', 'length'); - - self.$alias_method("store", "[]="); - - Opal.defn(self, '$to_a', function() { - var self = this; - - - var result = []; - - for (var i = 0, keys = self.keys, length = keys.length, key, value; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - value = self.smap[key]; - } else { - value = key.value; - key = key.key; - } - - result.push([key, value]); - } - - return result; - - }); - - Opal.defn(self, '$to_h', function() { - var self = this; - - - if (self.$$class === Opal.Hash) { - return self; - } - - var hash = new Opal.Hash.$$alloc(); - - Opal.hash_init(hash); - Opal.hash_clone(self, hash); - - return hash; - - }); - - Opal.defn(self, '$to_hash', function() { - var self = this; - - return self; - }); - - Opal.alias(self, 'to_s', 'inspect'); - - Opal.alias(self, 'update', 'merge!'); - - Opal.alias(self, 'value?', 'has_value?'); - - Opal.alias(self, 'values_at', 'indexes'); - - return (Opal.defn(self, '$values', function() { - var self = this; - - - var result = []; - - for (var i = 0, keys = self.keys, length = keys.length, key; i < length; i++) { - key = keys[i]; - - if (key.$$is_string) { - result.push(self.smap[key]); - } else { - result.push(key.value); - } - } - - return result; - - }), nil) && 'values'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/number"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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); - } - function $rb_minus(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_times(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_ge(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, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$bridge', '$raise', '$class', '$Float', '$respond_to?', '$coerce_to!', '$__coerced__', '$===', '$!', '$>', '$**', '$new', '$<', '$to_f', '$==', '$nan?', '$infinite?', '$enum_for', '$+', '$-', '$gcd', '$lcm', '$/', '$frexp', '$to_i', '$ldexp', '$rationalize', '$*', '$<<', '$to_r', '$-@', '$size', '$<=', '$>=']); - self.$require("corelib/numeric"); - (function($base, $super) { - function $Number(){}; - var self = $Number = $klass($base, $super, 'Number', $Number); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_4, TMP_5, TMP_6, TMP_7, TMP_8, TMP_9, TMP_10, TMP_11; - - $scope.get('Opal').$bridge(self, Number); - - Number.prototype.$$is_number = true; - - Opal.defn(self, '$coerce', function(other) { - var self = this; - - - if (other === nil) { - self.$raise($scope.get('TypeError'), "can't convert " + (other.$class()) + " into Float"); - } - else if (other.$$is_string) { - return [self.$Float(other), self]; - } - else if (other['$respond_to?']("to_f")) { - return [$scope.get('Opal')['$coerce_to!'](other, $scope.get('Float'), "to_f"), self]; - } - else if (other.$$is_number) { - return [other, self]; - } - else { - self.$raise($scope.get('TypeError'), "can't convert " + (other.$class()) + " into Float"); - } - ; - }); - - Opal.defn(self, '$__id__', function() { - var self = this; - - return (self * 2) + 1; - }); - - Opal.alias(self, 'object_id', '__id__'); - - Opal.defn(self, '$+', function(other) { - var self = this; - - - if (other.$$is_number) { - return self + other; - } - else { - return self.$__coerced__("+", other); - } - - }); - - Opal.defn(self, '$-', function(other) { - var self = this; - - - if (other.$$is_number) { - return self - other; - } - else { - return self.$__coerced__("-", other); - } - - }); - - Opal.defn(self, '$*', function(other) { - var self = this; - - - if (other.$$is_number) { - return self * other; - } - else { - return self.$__coerced__("*", other); - } - - }); - - Opal.defn(self, '$/', function(other) { - var self = this; - - - if (other.$$is_number) { - return self / other; - } - else { - return self.$__coerced__("/", other); - } - - }); - - Opal.alias(self, 'fdiv', '/'); - - Opal.defn(self, '$%', function(other) { - var self = this; - - - if (other.$$is_number) { - if (other == -Infinity) { - return other; - } - else if (other == 0) { - self.$raise($scope.get('ZeroDivisionError'), "divided by 0"); - } - else if (other < 0 || self < 0) { - return (self % other + other) % other; - } - else { - return self % other; - } - } - else { - return self.$__coerced__("%", other); - } - - }); - - Opal.defn(self, '$&', function(other) { - var self = this; - - - if (other.$$is_number) { - return self & other; - } - else { - return self.$__coerced__("&", other); - } - - }); - - Opal.defn(self, '$|', function(other) { - var self = this; - - - if (other.$$is_number) { - return self | other; - } - else { - return self.$__coerced__("|", other); - } - - }); - - Opal.defn(self, '$^', function(other) { - var self = this; - - - if (other.$$is_number) { - return self ^ other; - } - else { - return self.$__coerced__("^", other); - } - - }); - - Opal.defn(self, '$<', function(other) { - var self = this; - - - if (other.$$is_number) { - return self < other; - } - else { - return self.$__coerced__("<", other); - } - - }); - - Opal.defn(self, '$<=', function(other) { - var self = this; - - - if (other.$$is_number) { - return self <= other; - } - else { - return self.$__coerced__("<=", other); - } - - }); - - Opal.defn(self, '$>', function(other) { - var self = this; - - - if (other.$$is_number) { - return self > other; - } - else { - return self.$__coerced__(">", other); - } - - }); - - Opal.defn(self, '$>=', function(other) { - var self = this; - - - if (other.$$is_number) { - return self >= other; - } - else { - return self.$__coerced__(">=", other); - } - - }); - - Opal.defn(self, '$<=>', function(other) { - var self = this; - - try { - - if (other.$$is_number) { - if (isNaN(self) || isNaN(other)) { - return nil; - } - - return self > other ? 1 : (self < other ? -1 : 0); - } - else { - return self.$__coerced__("<=>", other); - } - - } catch ($err) {if (Opal.rescue($err, [$scope.get('ArgumentError')])) { - try { - return nil - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - Opal.defn(self, '$<<', function(count) { - var self = this; - - count = $scope.get('Opal')['$coerce_to!'](count, $scope.get('Integer'), "to_int"); - return count > 0 ? self << count : self >> -count; - }); - - Opal.defn(self, '$>>', function(count) { - var self = this; - - count = $scope.get('Opal')['$coerce_to!'](count, $scope.get('Integer'), "to_int"); - return count > 0 ? self >> count : self << -count; - }); - - Opal.defn(self, '$[]', function(bit) { - var self = this; - - bit = $scope.get('Opal')['$coerce_to!'](bit, $scope.get('Integer'), "to_int"); - - if (bit < (($scope.get('Integer')).$$scope.get('MIN')) || bit > (($scope.get('Integer')).$$scope.get('MAX'))) { - return 0; - } - - if (self < 0) { - return (((~self) + 1) >> bit) % 2; - } - else { - return (self >> bit) % 2; - } - ; - }); - - Opal.defn(self, '$+@', function() { - var self = this; - - return +self; - }); - - Opal.defn(self, '$-@', function() { - var self = this; - - return -self; - }); - - Opal.defn(self, '$~', function() { - var self = this; - - return ~self; - }); - - Opal.defn(self, '$**', function(other) { - var $a, $b, $c, self = this; - - if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = ((($b = ($scope.get('Integer')['$==='](self))['$!']()) !== false && $b !== nil) ? $b : $rb_gt(other, 0))) !== nil && (!$a.$$is_boolean || $a == true))) { - return Math.pow(self, other); - } else { - return $scope.get('Rational').$new(self, 1)['$**'](other) - } - } else if ((($a = (($b = $rb_lt(self, 0)) ? (((($c = $scope.get('Float')['$==='](other)) !== false && $c !== nil) ? $c : $scope.get('Rational')['$==='](other))) : $rb_lt(self, 0))) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Complex').$new(self, 0)['$**'](other.$to_f()) - } else if ((($a = other.$$is_number != null) !== nil && (!$a.$$is_boolean || $a == true))) { - return Math.pow(self, other); - } else { - return self.$__coerced__("**", other) - }; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - - if (other.$$is_number) { - return self == Number(other); - } - else if (other['$respond_to?']("==")) { - return other['$=='](self); - } - else { - return false; - } - ; - }); - - Opal.defn(self, '$abs', function() { - var self = this; - - return Math.abs(self); - }); - - Opal.defn(self, '$abs2', function() { - var self = this; - - return Math.abs(self * self); - }); - - Opal.defn(self, '$angle', function() { - var $a, self = this; - - if ((($a = self['$nan?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - - if (self == 0) { - if (1 / self > 0) { - return 0; - } - else { - return Math.PI; - } - } - else if (self < 0) { - return Math.PI; - } - else { - return 0; - } - - }); - - Opal.alias(self, 'arg', 'angle'); - - Opal.alias(self, 'phase', 'angle'); - - Opal.defn(self, '$bit_length', function() { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](self)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NoMethodError').$new("undefined method `bit_length` for " + (self) + ":Float", "bit_length")) - }; - - if (self === 0 || self === -1) { - return 0; - } - - var result = 0, - value = self < 0 ? ~self : self; - - while (value != 0) { - result += 1; - value >>>= 1; - } - - return result; - - }); - - Opal.defn(self, '$ceil', function() { - var self = this; - - return Math.ceil(self); - }); - - Opal.defn(self, '$chr', function(encoding) { - var self = this; - - return String.fromCharCode(self); - }); - - Opal.defn(self, '$denominator', TMP_1 = function() {var $zuper = $slice.call(arguments, 0); - var $a, $b, self = this, $iter = TMP_1.$$p, $yield = $iter || nil; - - TMP_1.$$p = null; - if ((($a = ((($b = self['$nan?']()) !== false && $b !== nil) ? $b : self['$infinite?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - return 1 - } else { - return Opal.find_super_dispatcher(self, 'denominator', TMP_1, $iter).apply(self, $zuper) - }; - }); - - Opal.defn(self, '$downto', TMP_2 = function(stop) { - var $a, $b, TMP_3, self = this, $iter = TMP_2.$$p, block = $iter || nil; - - TMP_2.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_3 = function(){var self = TMP_3.$$s || this, $a; - - if ((($a = $scope.get('Numeric')['$==='](stop)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") - }; - if ($rb_gt(stop, self)) { - return 0 - } else { - return $rb_plus($rb_minus(self, stop), 1) - };}, TMP_3.$$s = self, TMP_3), $a).call($b, "downto", stop) - }; - - if (!stop.$$is_number) { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") - } - for (var i = self; i >= stop; i--) { - if (block(i) === $breaker) { - return $breaker.$v; - } - } - ; - return self; - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.defn(self, '$equal?', function(other) { - var $a, self = this; - - return ((($a = self['$=='](other)) !== false && $a !== nil) ? $a : isNaN(self) && isNaN(other)); - }); - - Opal.defn(self, '$even?', function() { - var self = this; - - return self % 2 === 0; - }); - - Opal.defn(self, '$floor', function() { - var self = this; - - return Math.floor(self); - }); - - Opal.defn(self, '$gcd', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "not an integer") - }; - - var min = Math.abs(self), - max = Math.abs(other); - - while (min > 0) { - var tmp = min; - - min = max % min; - max = tmp; - } - - return max; - - }); - - Opal.defn(self, '$gcdlcm', function(other) { - var self = this; - - return [self.$gcd(), self.$lcm()]; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return 'Numeric:'+self.toString(); - }); - - Opal.defn(self, '$integer?', function() { - var self = this; - - return self % 1 === 0; - }); - - Opal.defn(self, '$is_a?', TMP_4 = function(klass) {var $zuper = $slice.call(arguments, 0); - var $a, $b, self = this, $iter = TMP_4.$$p, $yield = $iter || nil; - - TMP_4.$$p = null; - if ((($a = (($b = klass['$==']($scope.get('Fixnum'))) ? $scope.get('Integer')['$==='](self) : klass['$==']($scope.get('Fixnum')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - if ((($a = (($b = klass['$==']($scope.get('Integer'))) ? $scope.get('Integer')['$==='](self) : klass['$==']($scope.get('Integer')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - if ((($a = (($b = klass['$==']($scope.get('Float'))) ? $scope.get('Float')['$==='](self) : klass['$==']($scope.get('Float')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - return Opal.find_super_dispatcher(self, 'is_a?', TMP_4, $iter).apply(self, $zuper); - }); - - Opal.alias(self, 'kind_of?', 'is_a?'); - - Opal.defn(self, '$instance_of?', TMP_5 = function(klass) {var $zuper = $slice.call(arguments, 0); - var $a, $b, self = this, $iter = TMP_5.$$p, $yield = $iter || nil; - - TMP_5.$$p = null; - if ((($a = (($b = klass['$==']($scope.get('Fixnum'))) ? $scope.get('Integer')['$==='](self) : klass['$==']($scope.get('Fixnum')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - if ((($a = (($b = klass['$==']($scope.get('Integer'))) ? $scope.get('Integer')['$==='](self) : klass['$==']($scope.get('Integer')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - if ((($a = (($b = klass['$==']($scope.get('Float'))) ? $scope.get('Float')['$==='](self) : klass['$==']($scope.get('Float')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return true}; - return Opal.find_super_dispatcher(self, 'instance_of?', TMP_5, $iter).apply(self, $zuper); - }); - - Opal.defn(self, '$lcm', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "not an integer") - }; - - if (self == 0 || other == 0) { - return 0; - } - else { - return Math.abs(self * other / self.$gcd(other)); - } - - }); - - Opal.alias(self, 'magnitude', 'abs'); - - Opal.alias(self, 'modulo', '%'); - - Opal.defn(self, '$next', function() { - var self = this; - - return self + 1; - }); - - Opal.defn(self, '$nonzero?', function() { - var self = this; - - return self == 0 ? nil : self; - }); - - Opal.defn(self, '$numerator', TMP_6 = function() {var $zuper = $slice.call(arguments, 0); - var $a, $b, self = this, $iter = TMP_6.$$p, $yield = $iter || nil; - - TMP_6.$$p = null; - if ((($a = ((($b = self['$nan?']()) !== false && $b !== nil) ? $b : self['$infinite?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - return self - } else { - return Opal.find_super_dispatcher(self, 'numerator', TMP_6, $iter).apply(self, $zuper) - }; - }); - - Opal.defn(self, '$odd?', function() { - var self = this; - - return self % 2 !== 0; - }); - - Opal.defn(self, '$ord', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$pred', function() { - var self = this; - - return self - 1; - }); - - Opal.defn(self, '$quo', TMP_7 = function(other) {var $zuper = $slice.call(arguments, 0); - var $a, self = this, $iter = TMP_7.$$p, $yield = $iter || nil; - - TMP_7.$$p = null; - if ((($a = $scope.get('Integer')['$==='](self)) !== nil && (!$a.$$is_boolean || $a == true))) { - return Opal.find_super_dispatcher(self, 'quo', TMP_7, $iter).apply(self, $zuper) - } else { - return $rb_divide(self, other) - }; - }); - - Opal.defn(self, '$rationalize', function(eps) { - var $a, self = this, f = nil, n = nil; - - - if (arguments.length > 1) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 0..1)"); - } - ; - if ((($a = $scope.get('Integer')['$==='](self)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Rational').$new(self, 1) - } else if ((($a = self['$infinite?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('FloatDomainError'), "Infinity") - } else if ((($a = self['$nan?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('FloatDomainError'), "NaN") - } else if ((($a = eps == null) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary($scope.get('Math').$frexp(self)), f = ($a[0] == null ? nil : $a[0]), n = ($a[1] == null ? nil : $a[1]); - f = $scope.get('Math').$ldexp(f, (($scope.get('Float')).$$scope.get('MANT_DIG'))).$to_i(); - n = $rb_minus(n, (($scope.get('Float')).$$scope.get('MANT_DIG'))); - return $scope.get('Rational').$new($rb_times(2, f), (1)['$<<'](($rb_minus(1, n)))).$rationalize($scope.get('Rational').$new(1, (1)['$<<'](($rb_minus(1, n))))); - } else { - return self.$to_r().$rationalize(eps) - }; - }); - - Opal.defn(self, '$round', function(ndigits) { - var $a, $b, self = this, _ = nil, exp = nil; - - if ((($a = $scope.get('Integer')['$==='](self)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = ndigits == null) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - if ((($a = ($b = $scope.get('Float')['$==='](ndigits), $b !== false && $b !== nil ?ndigits['$infinite?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('RangeError'), "Infinity")}; - ndigits = $scope.get('Opal')['$coerce_to!'](ndigits, $scope.get('Integer'), "to_int"); - if ($rb_lt(ndigits, (($scope.get('Integer')).$$scope.get('MIN')))) { - self.$raise($scope.get('RangeError'), "out of bounds")}; - if ((($a = ndigits >= 0) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - ndigits = ndigits['$-@'](); - - if (0.415241 * ndigits - 0.125 > self.$size()) { - return 0; - } - - var f = Math.pow(10, ndigits), - x = Math.floor((Math.abs(x) + f / 2) / f) * f; - - return self < 0 ? -x : x; - ; - } else { - if ((($a = ($b = self['$nan?'](), $b !== false && $b !== nil ?ndigits == null : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('FloatDomainError'), "NaN")}; - ndigits = $scope.get('Opal')['$coerce_to!'](ndigits || 0, $scope.get('Integer'), "to_int"); - if ($rb_le(ndigits, 0)) { - if ((($a = self['$nan?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('RangeError'), "NaN") - } else if ((($a = self['$infinite?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('FloatDomainError'), "Infinity")} - } else if (ndigits['$=='](0)) { - return Math.round(self) - } else if ((($a = ((($b = self['$nan?']()) !== false && $b !== nil) ? $b : self['$infinite?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - return self}; - $a = Opal.to_ary($scope.get('Math').$frexp(self)), _ = ($a[0] == null ? nil : $a[0]), exp = ($a[1] == null ? nil : $a[1]); - if ($rb_ge(ndigits, $rb_minus(($rb_plus((($scope.get('Float')).$$scope.get('DIG')), 2)), ((function() {if ($rb_gt(exp, 0)) { - return $rb_divide(exp, 4) - } else { - return $rb_minus($rb_divide(exp, 3), 1) - }; return nil; })())))) { - return self}; - if ($rb_lt(ndigits, ((function() {if ($rb_gt(exp, 0)) { - return $rb_plus($rb_divide(exp, 3), 1) - } else { - return $rb_divide(exp, 4) - }; return nil; })())['$-@']())) { - return 0}; - return Math.round(self * Math.pow(10, ndigits)) / Math.pow(10, ndigits); - }; - }); - - Opal.defn(self, '$step', TMP_8 = function(limit, step) { - var $a, self = this, $iter = TMP_8.$$p, block = $iter || nil; - - if (step == null) { - step = 1 - } - TMP_8.$$p = null; - if (block !== false && block !== nil) { - } else { - return self.$enum_for("step", limit, step) - }; - if ((($a = step == 0) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "step cannot be 0")}; - - var value = self; - - if (limit === Infinity || limit === -Infinity) { - block(value); - return self; - } - - if (step > 0) { - while (value <= limit) { - block(value); - value += step; - } - } - else { - while (value >= limit) { - block(value); - value += step; - } - } - - return self; - }); - - Opal.alias(self, 'succ', 'next'); - - Opal.defn(self, '$times', TMP_9 = function() { - var self = this, $iter = TMP_9.$$p, block = $iter || nil; - - TMP_9.$$p = null; - if (block !== false && block !== nil) { - } else { - return self.$enum_for("times") - }; - - for (var i = 0; i < self; i++) { - if (block(i) === $breaker) { - return $breaker.$v; - } - } - - return self; - }); - - Opal.defn(self, '$to_f', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$to_i', function() { - var self = this; - - return parseInt(self, 10); - }); - - Opal.alias(self, 'to_int', 'to_i'); - - Opal.defn(self, '$to_r', function() { - var $a, self = this, f = nil, e = nil; - - if ((($a = $scope.get('Integer')['$==='](self)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Rational').$new(self, 1) - } else { - $a = Opal.to_ary($scope.get('Math').$frexp(self)), f = ($a[0] == null ? nil : $a[0]), e = ($a[1] == null ? nil : $a[1]); - f = $scope.get('Math').$ldexp(f, (($scope.get('Float')).$$scope.get('MANT_DIG'))).$to_i(); - e = $rb_minus(e, (($scope.get('Float')).$$scope.get('MANT_DIG'))); - return ($rb_times(f, ((($scope.get('Float')).$$scope.get('RADIX'))['$**'](e)))).$to_r(); - }; - }); - - Opal.defn(self, '$to_s', function(base) { - var $a, $b, self = this; - - if (base == null) { - base = 10 - } - if ((($a = ((($b = $rb_lt(base, 2)) !== false && $b !== nil) ? $b : $rb_gt(base, 36))) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "base must be between 2 and 36")}; - return self.toString(base); - }); - - Opal.alias(self, 'truncate', 'to_i'); - - Opal.alias(self, 'inspect', 'to_s'); - - Opal.defn(self, '$divmod', TMP_10 = function(other) {var $zuper = $slice.call(arguments, 0); - var $a, $b, self = this, $iter = TMP_10.$$p, $yield = $iter || nil; - - TMP_10.$$p = null; - if ((($a = ((($b = self['$nan?']()) !== false && $b !== nil) ? $b : other['$nan?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('FloatDomainError'), "NaN") - } else if ((($a = self['$infinite?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('FloatDomainError'), "Infinity") - } else { - return Opal.find_super_dispatcher(self, 'divmod', TMP_10, $iter).apply(self, $zuper) - }; - }); - - Opal.defn(self, '$upto', TMP_11 = function(stop) { - var $a, $b, TMP_12, self = this, $iter = TMP_11.$$p, block = $iter || nil; - - TMP_11.$$p = null; - if ((block !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_12 = function(){var self = TMP_12.$$s || this, $a; - - if ((($a = $scope.get('Numeric')['$==='](stop)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") - }; - if ($rb_lt(stop, self)) { - return 0 - } else { - return $rb_plus($rb_minus(stop, self), 1) - };}, TMP_12.$$s = self, TMP_12), $a).call($b, "upto", stop) - }; - - if (!stop.$$is_number) { - self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") - } - for (var i = self; i <= stop; i++) { - if (block(i) === $breaker) { - return $breaker.$v; - } - } - ; - return self; - }); - - Opal.defn(self, '$zero?', function() { - var self = this; - - return self == 0; - }); - - Opal.defn(self, '$size', function() { - var self = this; - - return 4; - }); - - Opal.defn(self, '$nan?', function() { - var self = this; - - return isNaN(self); - }); - - Opal.defn(self, '$finite?', function() { - var self = this; - - return self != Infinity && self != -Infinity && !isNaN(self); - }); - - Opal.defn(self, '$infinite?', function() { - var self = this; - - - if (self == Infinity) { - return +1; - } - else if (self == -Infinity) { - return -1; - } - else { - return nil; - } - - }); - - Opal.defn(self, '$positive?', function() { - var self = this; - - return self == Infinity || 1 / self > 0; - }); - - return (Opal.defn(self, '$negative?', function() { - var self = this; - - return self == -Infinity || 1 / self < 0; - }), nil) && 'negative?'; - })($scope.base, $scope.get('Numeric')); - Opal.cdecl($scope, 'Fixnum', $scope.get('Number')); - (function($base, $super) { - function $Integer(){}; - var self = $Integer = $klass($base, $super, 'Integer', $Integer); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defs(self, '$===', function(other) { - var self = this; - - - if (!other.$$is_number) { - return false; - } - - return (other % 1) === 0; - - }); - - Opal.cdecl($scope, 'MAX', Math.pow(2, 30) - 1); - - return Opal.cdecl($scope, 'MIN', -Math.pow(2, 30)); - })($scope.base, $scope.get('Numeric')); - return (function($base, $super) { - function $Float(){}; - var self = $Float = $klass($base, $super, 'Float', $Float); - - var def = self.$$proto, $scope = self.$$scope, $a; - - Opal.defs(self, '$===', function(other) { - var self = this; - - return !!other.$$is_number; - }); - - Opal.cdecl($scope, 'INFINITY', Infinity); - - Opal.cdecl($scope, 'MAX', Number.MAX_VALUE); - - Opal.cdecl($scope, 'MIN', Number.MIN_VALUE); - - Opal.cdecl($scope, 'NAN', NaN); - - Opal.cdecl($scope, 'DIG', 15); - - Opal.cdecl($scope, 'MANT_DIG', 53); - - Opal.cdecl($scope, 'RADIX', 2); - - if ((($a = (typeof(Number.EPSILON) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - return Opal.cdecl($scope, 'EPSILON', Number.EPSILON) - } else { - return Opal.cdecl($scope, 'EPSILON', 2.2204460492503130808472633361816E-16) - }; - })($scope.base, $scope.get('Numeric')); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/range"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - 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_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, $klass = Opal.klass; - - Opal.add_stubs(['$require', '$include', '$attr_reader', '$<=>', '$raise', '$include?', '$<=', '$<', '$enum_for', '$succ', '$!', '$==', '$===', '$exclude_end?', '$eql?', '$begin', '$end', '$-', '$abs', '$to_i', '$inspect']); - self.$require("corelib/enumerable"); - return (function($base, $super) { - function $Range(){}; - var self = $Range = $klass($base, $super, 'Range', $Range); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3; - - def.begin = def.exclude = def.end = nil; - self.$include($scope.get('Enumerable')); - - def.$$is_range = true; - - self.$attr_reader("begin", "end"); - - Opal.defn(self, '$initialize', function(first, last, exclude) { - var $a, self = this; - - if (exclude == null) { - exclude = false - } - if ((($a = first['$<=>'](last)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError')) - }; - self.begin = first; - self.end = last; - return self.exclude = exclude; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - - if (!other.$$is_range) { - return false; - } - - return self.exclude === other.exclude && - self.begin == other.begin && - self.end == other.end; - - }); - - Opal.defn(self, '$===', function(value) { - var self = this; - - return self['$include?'](value); - }); - - Opal.defn(self, '$cover?', function(value) { - var $a, $b, self = this; - - return (($a = $rb_le(self.begin, value)) ? ((function() {if ((($b = self.exclude) !== nil && (!$b.$$is_boolean || $b == true))) { - return $rb_lt(value, self.end) - } else { - return $rb_le(value, self.end) - }; return nil; })()) : $rb_le(self.begin, value)); - }); - - Opal.defn(self, '$each', TMP_1 = function() { - var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil, current = nil, last = nil; - - TMP_1.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("each") - }; - current = self.begin; - last = self.end; - while ($rb_lt(current, last)) { - if (Opal.yield1(block, current) === $breaker) return $breaker.$v; - current = current.$succ();}; - if ((($a = ($b = self.exclude['$!'](), $b !== false && $b !== nil ?current['$=='](last) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - if (Opal.yield1(block, current) === $breaker) return $breaker.$v}; - return self; - }); - - Opal.defn(self, '$eql?', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Range')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return false - }; - return ($a = ($b = self.exclude['$==='](other['$exclude_end?']()), $b !== false && $b !== nil ?self.begin['$eql?'](other.$begin()) : $b), $a !== false && $a !== nil ?self.end['$eql?'](other.$end()) : $a); - }); - - Opal.defn(self, '$exclude_end?', function() { - var self = this; - - return self.exclude; - }); - - Opal.alias(self, 'first', 'begin'); - - Opal.alias(self, 'include?', 'cover?'); - - Opal.alias(self, 'last', 'end'); - - Opal.defn(self, '$max', TMP_2 = function() {var $zuper = $slice.call(arguments, 0); - var self = this, $iter = TMP_2.$$p, $yield = $iter || nil; - - TMP_2.$$p = null; - if (($yield !== nil)) { - return Opal.find_super_dispatcher(self, 'max', TMP_2, $iter).apply(self, $zuper) - } else { - return self.exclude ? self.end - 1 : self.end; - }; - }); - - Opal.alias(self, 'member?', 'cover?'); - - Opal.defn(self, '$min', TMP_3 = function() {var $zuper = $slice.call(arguments, 0); - var self = this, $iter = TMP_3.$$p, $yield = $iter || nil; - - TMP_3.$$p = null; - if (($yield !== nil)) { - return Opal.find_super_dispatcher(self, 'min', TMP_3, $iter).apply(self, $zuper) - } else { - return self.begin - }; - }); - - Opal.alias(self, 'member?', 'include?'); - - Opal.defn(self, '$size', function() { - var $a, $b, self = this, _begin = nil, _end = nil, infinity = nil; - - _begin = self.begin; - _end = self.end; - if ((($a = self.exclude) !== nil && (!$a.$$is_boolean || $a == true))) { - _end = $rb_minus(_end, 1)}; - if ((($a = ($b = $scope.get('Numeric')['$==='](_begin), $b !== false && $b !== nil ?$scope.get('Numeric')['$==='](_end) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return nil - }; - if ($rb_lt(_end, _begin)) { - return 0}; - infinity = (($scope.get('Float')).$$scope.get('INFINITY')); - if ((($a = ((($b = infinity['$=='](_begin.$abs())) !== false && $b !== nil) ? $b : _end.$abs()['$=='](infinity))) !== nil && (!$a.$$is_boolean || $a == true))) { - return infinity}; - return ((Math.abs(_end - _begin) + 1)).$to_i(); - }); - - Opal.defn(self, '$step', function(n) { - var self = this; - - if (n == null) { - n = 1 - } - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return self.begin.$inspect() + (self.exclude ? '...' : '..') + self.end.$inspect(); - }); - - return Opal.alias(self, 'inspect', 'to_s'); - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/proc"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$raise', '$coerce_to!']); - return (function($base, $super) { - function $Proc(){}; - var self = $Proc = $klass($base, $super, 'Proc', $Proc); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2; - - def.$$is_proc = true; - - def.$$is_lambda = false; - - Opal.defs(self, '$new', TMP_1 = function() { - var self = this, $iter = TMP_1.$$p, block = $iter || nil; - - TMP_1.$$p = null; - if (block !== false && block !== nil) { - } else { - self.$raise($scope.get('ArgumentError'), "tried to create a Proc object without a block") - }; - return block; - }); - - Opal.defn(self, '$call', TMP_2 = function() { - var self = this, $iter = TMP_2.$$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_2.$$p = null; - - if (block !== nil) { - self.$$p = block; - } - - var result; - - if (self.$$is_lambda) { - result = self.apply(null, args); - } - else { - result = Opal.yieldX(self, args); - } - - if (result === $breaker) { - return $breaker.$v; - } - - return result; - - }); - - Opal.alias(self, '[]', 'call'); - - Opal.alias(self, '===', 'call'); - - Opal.alias(self, 'yield', 'call'); - - Opal.defn(self, '$to_proc', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$lambda?', function() { - var self = this; - - return !!self.$$is_lambda; - }); - - Opal.defn(self, '$arity', function() { - var self = this; - - if (self.$$is_curried) { return -1; } - if (self.$$arity) { return self.$$arity }; - return self.length; - }); - - Opal.defn(self, '$source_location', function() { - var self = this; - - if (self.$$is_curried) { return nil; } - return nil; - }); - - Opal.defn(self, '$binding', function() { - var self = this; - - if (self.$$is_curried) { self.$raise($scope.get('ArgumentError'), "Can't create Binding") }; - return nil; - }); - - Opal.defn(self, '$parameters', function() { - var self = this; - - if (self.$$is_curried) { return [["rest"]]; }; - return nil; - }); - - Opal.defn(self, '$curry', function(arity) { - var self = this; - - - if (arity === undefined) { - arity = self.length; - } - else { - arity = $scope.get('Opal')['$coerce_to!'](arity, $scope.get('Integer'), "to_int"); - if (self.$$is_lambda && arity !== self.length) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arity) + " for " + (self.length) + ")") - } - } - - function curried () { - var args = $slice.call(arguments), - length = args.length, - result; - - if (length > arity && self.$$is_lambda && !self.$$is_curried) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (length) + " for " + (arity) + ")") - } - - if (length >= arity) { - return self.$call.apply(self, args); - } - - result = function () { - return curried.apply(null, - args.concat($slice.call(arguments))); - } - result.$$is_lambda = self.$$is_lambda; - result.$$is_curried = true; - - return result; - }; - - curried.$$is_lambda = self.$$is_lambda; - curried.$$is_curried = true; - return curried; - - }); - - Opal.defn(self, '$dup', function() { - var self = this; - - - var original_proc = self.$$original_proc || self, - proc = function () { - return original_proc.apply(this, arguments); - }; - - for (var prop in self) { - if (self.hasOwnProperty(prop)) { - proc[prop] = self[prop]; - } - } - - return proc; - - }); - - return Opal.alias(self, 'clone', 'dup'); - })($scope.base, Function) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/method"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$attr_reader', '$class', '$arity', '$new', '$name']); - (function($base, $super) { - function $Method(){}; - var self = $Method = $klass($base, $super, 'Method', $Method); - - var def = self.$$proto, $scope = self.$$scope, TMP_1; - - def.method = def.receiver = def.owner = def.name = nil; - self.$attr_reader("owner", "receiver", "name"); - - Opal.defn(self, '$initialize', function(receiver, method, name) { - var self = this; - - self.receiver = receiver; - self.owner = receiver.$class(); - self.name = name; - return self.method = method; - }); - - Opal.defn(self, '$arity', function() { - var self = this; - - return self.method.$arity(); - }); - - Opal.defn(self, '$call', TMP_1 = function() { - var self = this, $iter = TMP_1.$$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_1.$$p = null; - - self.method.$$p = block; - - return self.method.apply(self.receiver, args); - ; - }); - - Opal.alias(self, '[]', 'call'); - - Opal.defn(self, '$unbind', function() { - var self = this; - - return $scope.get('UnboundMethod').$new(self.owner, self.method, self.name); - }); - - Opal.defn(self, '$to_proc', function() { - var self = this; - - - var proc = function () { return self.$call.apply(self, $slice.call(arguments)); }; - proc.$$unbound = self.method; - proc.$$is_lambda = true; - return proc; - - }); - - return (Opal.defn(self, '$inspect', function() { - var self = this; - - return "#"; - }), nil) && 'inspect'; - })($scope.base, null); - return (function($base, $super) { - function $UnboundMethod(){}; - var self = $UnboundMethod = $klass($base, $super, 'UnboundMethod', $UnboundMethod); - - var def = self.$$proto, $scope = self.$$scope; - - def.method = def.name = def.owner = nil; - self.$attr_reader("owner", "name"); - - Opal.defn(self, '$initialize', function(owner, method, name) { - var self = this; - - self.owner = owner; - self.method = method; - return self.name = name; - }); - - Opal.defn(self, '$arity', function() { - var self = this; - - return self.method.$arity(); - }); - - Opal.defn(self, '$bind', function(object) { - var self = this; - - return $scope.get('Method').$new(object, self.method, self.name); - }); - - return (Opal.defn(self, '$inspect', function() { - var self = this; - - return "#"; - }), nil) && 'inspect'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/variables"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $gvars = Opal.gvars, $hash2 = Opal.hash2; - - Opal.add_stubs(['$new']); - $gvars["&"] = $gvars["~"] = $gvars["`"] = $gvars["'"] = nil; - $gvars.LOADED_FEATURES = $gvars["\""] = Opal.loaded_features; - $gvars.LOAD_PATH = $gvars[":"] = []; - $gvars["/"] = "\n"; - $gvars[","] = nil; - Opal.cdecl($scope, 'ARGV', []); - Opal.cdecl($scope, 'ARGF', $scope.get('Object').$new()); - Opal.cdecl($scope, 'ENV', $hash2([], {})); - $gvars.VERBOSE = false; - $gvars.DEBUG = false; - return $gvars.SAFE = 0; -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["opal/mini"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.add_stubs(['$require']); - self.$require("opal/base"); - self.$require("corelib/nil"); - self.$require("corelib/boolean"); - self.$require("corelib/string"); - self.$require("corelib/comparable"); - self.$require("corelib/enumerable"); - self.$require("corelib/enumerator"); - self.$require("corelib/array"); - self.$require("corelib/hash"); - self.$require("corelib/number"); - self.$require("corelib/range"); - self.$require("corelib/proc"); - self.$require("corelib/method"); - self.$require("corelib/regexp"); - return self.$require("corelib/variables"); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/array/inheritance"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_minus(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, $klass = Opal.klass; - - Opal.add_stubs(['$new', '$allocate', '$initialize', '$to_proc', '$__send__', '$clone', '$respond_to?', '$==', '$eql?', '$inspect', '$hash', '$*', '$class', '$slice', '$uniq', '$flatten', '$-', '$+']); - (function($base, $super) { - function $Array(){}; - var self = $Array = $klass($base, $super, 'Array', $Array); - - var def = self.$$proto, $scope = self.$$scope; - - return (Opal.defs(self, '$inherited', function(klass) { - var self = this, replace = nil; - - replace = $scope.get('Class').$new((($scope.get('Array')).$$scope.get('Wrapper'))); - - klass.$$proto = replace.$$proto; - klass.$$proto.$$class = klass; - klass.$$alloc = replace.$$alloc; - klass.$$parent = (($scope.get('Array')).$$scope.get('Wrapper')); - - klass.$allocate = replace.$allocate; - klass.$new = replace.$new; - klass["$[]"] = replace["$[]"]; - - }), nil) && 'inherited' - })($scope.base, null); - return (function($base, $super) { - function $Wrapper(){}; - var self = $Wrapper = $klass($base, $super, 'Wrapper', $Wrapper); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5; - - def.literal = nil; - def.$$is_array = true; - - Opal.defs(self, '$allocate', TMP_1 = function(array) { - var self = this, $iter = TMP_1.$$p, $yield = $iter || nil, obj = nil; - - if (array == null) { - array = [] - } - TMP_1.$$p = null; - obj = Opal.find_super_dispatcher(self, 'allocate', TMP_1, null, $Wrapper).apply(self, []); - obj.literal = array; - return obj; - }); - - Opal.defs(self, '$new', TMP_2 = function() { - var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil, obj = 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_2.$$p = null; - obj = self.$allocate(); - ($a = ($b = obj).$initialize, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - return obj; - }); - - Opal.defs(self, '$[]', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 0]; - } - return self.$allocate(objects); - }); - - Opal.defn(self, '$initialize', TMP_3 = function() { - var $a, $b, self = this, $iter = TMP_3.$$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_3.$$p = null; - return self.literal = ($a = ($b = $scope.get('Array')).$new, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - }); - - Opal.defn(self, '$method_missing', TMP_4 = function() { - var $a, $b, self = this, $iter = TMP_4.$$p, block = $iter || nil, result = 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_4.$$p = null; - result = ($a = ($b = self.literal).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - if ((($a = result === self.literal) !== nil && (!$a.$$is_boolean || $a == true))) { - return self - } else { - return result - }; - }); - - Opal.defn(self, '$initialize_copy', function(other) { - var self = this; - - return self.literal = (other.literal).$clone(); - }); - - Opal.defn(self, '$respond_to?', TMP_5 = function(name) {var $zuper = $slice.call(arguments, 0); - var $a, self = this, $iter = TMP_5.$$p, $yield = $iter || nil; - - TMP_5.$$p = null; - return ((($a = Opal.find_super_dispatcher(self, 'respond_to?', TMP_5, $iter).apply(self, $zuper)) !== false && $a !== nil) ? $a : self.literal['$respond_to?'](name)); - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return self.literal['$=='](other); - }); - - Opal.defn(self, '$eql?', function(other) { - var self = this; - - return self.literal['$eql?'](other); - }); - - Opal.defn(self, '$to_a', function() { - var self = this; - - return self.literal; - }); - - Opal.defn(self, '$to_ary', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return self.literal.$inspect(); - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return self.literal.$hash(); - }); - - Opal.defn(self, '$*', function(other) { - var self = this; - - - var result = $rb_times(self.literal, other); - - if (result.$$is_array) { - return self.$class().$allocate(result) - } - else { - return result; - } - ; - }); - - Opal.defn(self, '$[]', function(index, length) { - var self = this; - - - var result = self.literal.$slice(index, length); - - if (result.$$is_array && (index.$$is_range || length !== undefined)) { - return self.$class().$allocate(result) - } - else { - return result; - } - ; - }); - - Opal.alias(self, 'slice', '[]'); - - Opal.defn(self, '$uniq', function() { - var self = this; - - return self.$class().$allocate(self.literal.$uniq()); - }); - - Opal.defn(self, '$flatten', function(level) { - var self = this; - - return self.$class().$allocate(self.literal.$flatten(level)); - }); - - Opal.defn(self, '$-', function(other) { - var self = this; - - return $rb_minus(self.literal, other); - }); - - return (Opal.defn(self, '$+', function(other) { - var self = this; - - return $rb_plus(self.literal, other); - }), nil) && '+'; - })($scope.get('Array'), null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/string/inheritance"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass, $gvars = Opal.gvars; - - Opal.add_stubs(['$require', '$new', '$allocate', '$initialize', '$to_proc', '$__send__', '$class', '$clone', '$respond_to?', '$==', '$inspect', '$+', '$*', '$map', '$split', '$enum_for', '$each_line', '$to_a', '$%']); - self.$require("corelib/string"); - (function($base, $super) { - function $String(){}; - var self = $String = $klass($base, $super, 'String', $String); - - var def = self.$$proto, $scope = self.$$scope; - - return (Opal.defs(self, '$inherited', function(klass) { - var self = this, replace = nil; - - replace = $scope.get('Class').$new((($scope.get('String')).$$scope.get('Wrapper'))); - - klass.$$proto = replace.$$proto; - klass.$$proto.$$class = klass; - klass.$$alloc = replace.$$alloc; - klass.$$parent = (($scope.get('String')).$$scope.get('Wrapper')); - - klass.$allocate = replace.$allocate; - klass.$new = replace.$new; - - }), nil) && 'inherited' - })($scope.base, null); - return (function($base, $super) { - function $Wrapper(){}; - var self = $Wrapper = $klass($base, $super, 'Wrapper', $Wrapper); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_6, TMP_8; - - def.literal = nil; - def.$$is_string = true; - - Opal.defs(self, '$allocate', TMP_1 = function(string) { - var self = this, $iter = TMP_1.$$p, $yield = $iter || nil, obj = nil; - - if (string == null) { - string = "" - } - TMP_1.$$p = null; - obj = Opal.find_super_dispatcher(self, 'allocate', TMP_1, null, $Wrapper).apply(self, []); - obj.literal = string; - return obj; - }); - - Opal.defs(self, '$new', TMP_2 = function() { - var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil, obj = 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_2.$$p = null; - obj = self.$allocate(); - ($a = ($b = obj).$initialize, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - return obj; - }); - - Opal.defs(self, '$[]', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var objects = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - objects[arg_index] = arguments[arg_index + 0]; - } - return self.$allocate(objects); - }); - - Opal.defn(self, '$initialize', function(string) { - var self = this; - - if (string == null) { - string = "" - } - return self.literal = string; - }); - - Opal.defn(self, '$method_missing', TMP_3 = function() { - var $a, $b, self = this, $iter = TMP_3.$$p, block = $iter || nil, result = 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; - result = ($a = ($b = self.literal).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, Opal.to_a(args)); - if ((($a = result.$$is_string != null) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = result == self.literal) !== nil && (!$a.$$is_boolean || $a == true))) { - return self - } else { - return self.$class().$allocate(result) - } - } else { - return result - }; - }); - - Opal.defn(self, '$initialize_copy', function(other) { - var self = this; - - return self.literal = (other.literal).$clone(); - }); - - Opal.defn(self, '$respond_to?', TMP_4 = function(name) {var $zuper = $slice.call(arguments, 0); - var $a, self = this, $iter = TMP_4.$$p, $yield = $iter || nil; - - TMP_4.$$p = null; - return ((($a = Opal.find_super_dispatcher(self, 'respond_to?', TMP_4, $iter).apply(self, $zuper)) !== false && $a !== nil) ? $a : self.literal['$respond_to?'](name)); - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return self.literal['$=='](other); - }); - - Opal.alias(self, 'eql?', '=='); - - Opal.alias(self, '===', '=='); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return self.literal; - }); - - Opal.alias(self, 'to_str', 'to_s'); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return self.literal.$inspect(); - }); - - Opal.defn(self, '$+', function(other) { - var self = this; - - return $rb_plus(self.literal, other); - }); - - Opal.defn(self, '$*', function(other) { - var self = this; - - - var result = $rb_times(self.literal, other); - - if (result.$$is_string) { - return self.$class().$allocate(result) - } - else { - return result; - } - ; - }); - - Opal.defn(self, '$split', function(pattern, limit) { - var $a, $b, TMP_5, self = this; - - return ($a = ($b = self.literal.$split(pattern, limit)).$map, $a.$$p = (TMP_5 = function(str){var self = TMP_5.$$s || this; -if (str == null) str = nil; - return self.$class().$allocate(str)}, TMP_5.$$s = self, TMP_5), $a).call($b); - }); - - Opal.defn(self, '$replace', function(string) { - var self = this; - - return self.literal = string; - }); - - Opal.defn(self, '$each_line', TMP_6 = function(separator) { - var $a, $b, TMP_7, self = this, $iter = TMP_6.$$p, $yield = $iter || nil; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - TMP_6.$$p = null; - if (($yield !== nil)) { - } else { - return self.$enum_for("each_line", separator) - }; - return ($a = ($b = self.literal).$each_line, $a.$$p = (TMP_7 = function(str){var self = TMP_7.$$s || this, $a; -if (str == null) str = nil; - return $a = Opal.yield1($yield, self.$class().$allocate(str)), $a === $breaker ? $a : $a}, TMP_7.$$s = self, TMP_7), $a).call($b, separator); - }); - - Opal.defn(self, '$lines', TMP_8 = function(separator) { - var $a, $b, self = this, $iter = TMP_8.$$p, block = $iter || nil, e = nil; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - TMP_8.$$p = null; - e = ($a = ($b = self).$each_line, $a.$$p = block.$to_proc(), $a).call($b, separator); - if (block !== false && block !== nil) { - return self - } else { - return e.$to_a() - }; - }); - - return (Opal.defn(self, '$%', function(data) { - var self = this; - - return self.literal['$%'](data); - }), nil) && '%'; - })($scope.get('String'), null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/string/encoding"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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); - } - var $a, $b, TMP_4, $c, TMP_6, $d, TMP_8, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2; - - Opal.add_stubs(['$require', '$+', '$[]', '$new', '$to_proc', '$each', '$const_set', '$sub', '$upcase', '$const_get', '$===', '$==', '$name', '$include?', '$names', '$constants', '$raise', '$attr_accessor', '$attr_reader', '$register', '$length', '$bytes', '$to_a', '$each_byte', '$bytesize', '$enum_for', '$force_encoding', '$dup', '$coerce_to!', '$find', '$nil?', '$getbyte']); - self.$require("corelib/string"); - (function($base, $super) { - function $Encoding(){}; - var self = $Encoding = $klass($base, $super, 'Encoding', $Encoding); - - var def = self.$$proto, $scope = self.$$scope, TMP_1; - - def.ascii = def.dummy = def.name = nil; - Opal.defs(self, '$register', TMP_1 = function(name, options) { - var $a, $b, $c, TMP_2, self = this, $iter = TMP_1.$$p, block = $iter || nil, names = nil, encoding = nil; - - if (options == null) { - options = $hash2([], {}) - } - TMP_1.$$p = null; - names = $rb_plus([name], (((($a = options['$[]']("aliases")) !== false && $a !== nil) ? $a : []))); - encoding = ($a = ($b = $scope.get('Class')).$new, $a.$$p = block.$to_proc(), $a).call($b, self).$new(name, names, ((($a = options['$[]']("ascii")) !== false && $a !== nil) ? $a : false), ((($a = options['$[]']("dummy")) !== false && $a !== nil) ? $a : false)); - return ($a = ($c = names).$each, $a.$$p = (TMP_2 = function(name){var self = TMP_2.$$s || this; -if (name == null) name = nil; - return self.$const_set(name.$sub("-", "_"), encoding)}, TMP_2.$$s = self, TMP_2), $a).call($c); - }); - - Opal.defs(self, '$find', function(name) {try { - - var $a, $b, TMP_3, self = this, upcase = nil; - - upcase = name.$upcase(); - ($a = ($b = self.$constants()).$each, $a.$$p = (TMP_3 = function(const$){var self = TMP_3.$$s || this, $a, $b, encoding = nil; -if (const$ == null) const$ = nil; - encoding = self.$const_get(const$); - if ((($a = $scope.get('Encoding')['$==='](encoding)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return nil; - }; - if ((($a = ((($b = encoding.$name()['$=='](upcase)) !== false && $b !== nil) ? $b : encoding.$names()['$include?'](upcase))) !== nil && (!$a.$$is_boolean || $a == true))) { - Opal.ret(encoding) - } else { - return nil - };}, TMP_3.$$s = self, TMP_3), $a).call($b); - return self.$raise($scope.get('ArgumentError'), "unknown encoding name - " + (name)); - } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } - }); - - (function(self) { - var $scope = self.$$scope, def = self.$$proto; - - return self.$attr_accessor("default_external") - })(Opal.get_singleton_class(self)); - - self.$attr_reader("name", "names"); - - Opal.defn(self, '$initialize', function(name, names, ascii, dummy) { - var self = this; - - self.name = name; - self.names = names; - self.ascii = ascii; - return self.dummy = dummy; - }); - - Opal.defn(self, '$ascii_compatible?', function() { - var self = this; - - return self.ascii; - }); - - Opal.defn(self, '$dummy?', function() { - var self = this; - - return self.dummy; - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return self.name; - }); - - Opal.defn(self, '$inspect', function() { - var $a, self = this; - - return "#"; - }); - - Opal.defn(self, '$each_byte', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$getbyte', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$bytesize', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError')); - }); - - (function($base, $super) { - function $EncodingError(){}; - var self = $EncodingError = $klass($base, $super, 'EncodingError', $EncodingError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('StandardError')); - - return (function($base, $super) { - function $CompatibilityError(){}; - var self = $CompatibilityError = $klass($base, $super, 'CompatibilityError', $CompatibilityError); - - var def = self.$$proto, $scope = self.$$scope; - - return nil; - })($scope.base, $scope.get('EncodingError')); - })($scope.base, null); - ($a = ($b = $scope.get('Encoding')).$register, $a.$$p = (TMP_4 = function(){var self = TMP_4.$$s || this, TMP_5; - - Opal.def(self, '$each_byte', TMP_5 = function(string) { - var $a, self = this, $iter = TMP_5.$$p, block = $iter || nil; - - TMP_5.$$p = null; - - for (var i = 0, length = string.length; i < length; i++) { - var code = string.charCodeAt(i); - - if (code <= 0x7f) { - ((($a = Opal.yield1(block, code)) === $breaker) ? $breaker.$v : $a); - } - else { - var encoded = encodeURIComponent(string.charAt(i)).substr(1).split('%'); - - for (var j = 0, encoded_length = encoded.length; j < encoded_length; j++) { - ((($a = Opal.yield1(block, parseInt(encoded[j], 16))) === $breaker) ? $breaker.$v : $a); - } - } - } - - }); - return (Opal.def(self, '$bytesize', function() { - var self = this; - - return self.$bytes().$length(); - }), nil) && 'bytesize';}, TMP_4.$$s = self, TMP_4), $a).call($b, "UTF-8", $hash2(["aliases", "ascii"], {"aliases": ["CP65001"], "ascii": true})); - ($a = ($c = $scope.get('Encoding')).$register, $a.$$p = (TMP_6 = function(){var self = TMP_6.$$s || this, TMP_7; - - Opal.def(self, '$each_byte', TMP_7 = function(string) { - var $a, self = this, $iter = TMP_7.$$p, block = $iter || nil; - - TMP_7.$$p = null; - - for (var i = 0, length = string.length; i < length; i++) { - var code = string.charCodeAt(i); - - ((($a = Opal.yield1(block, code & 0xff)) === $breaker) ? $breaker.$v : $a); - ((($a = Opal.yield1(block, code >> 8)) === $breaker) ? $breaker.$v : $a); - } - - }); - return (Opal.def(self, '$bytesize', function() { - var self = this; - - return self.$bytes().$length(); - }), nil) && 'bytesize';}, TMP_6.$$s = self, TMP_6), $a).call($c, "UTF-16LE"); - ($a = ($d = $scope.get('Encoding')).$register, $a.$$p = (TMP_8 = function(){var self = TMP_8.$$s || this, TMP_9; - - Opal.def(self, '$each_byte', TMP_9 = function(string) { - var $a, self = this, $iter = TMP_9.$$p, block = $iter || nil; - - TMP_9.$$p = null; - - for (var i = 0, length = string.length; i < length; i++) { - ((($a = Opal.yield1(block, string.charCodeAt(i) & 0xff)) === $breaker) ? $breaker.$v : $a); - } - - }); - return (Opal.def(self, '$bytesize', function() { - var self = this; - - return self.$bytes().$length(); - }), nil) && 'bytesize';}, TMP_8.$$s = self, TMP_8), $a).call($d, "ASCII-8BIT", $hash2(["aliases", "ascii"], {"aliases": ["BINARY"], "ascii": true})); - return (function($base, $super) { - function $String(){}; - var self = $String = $klass($base, $super, 'String', $String); - - var def = self.$$proto, $scope = self.$$scope, TMP_10; - - def.encoding = nil; - String.prototype.encoding = (($scope.get('Encoding')).$$scope.get('UTF_16LE')); - - Opal.defn(self, '$bytes', function() { - var self = this; - - return self.$each_byte().$to_a(); - }); - - Opal.defn(self, '$bytesize', function() { - var self = this; - - return self.encoding.$bytesize(self); - }); - - Opal.defn(self, '$each_byte', TMP_10 = function() { - var $a, $b, self = this, $iter = TMP_10.$$p, block = $iter || nil; - - TMP_10.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("each_byte") - }; - ($a = ($b = self.encoding).$each_byte, $a.$$p = block.$to_proc(), $a).call($b, self); - return self; - }); - - Opal.defn(self, '$encode', function(encoding) { - var self = this; - - return self.$dup().$force_encoding(encoding); - }); - - Opal.defn(self, '$encoding', function() { - var self = this; - - return self.encoding; - }); - - Opal.defn(self, '$force_encoding', function(encoding) { - var $a, self = this; - - encoding = $scope.get('Opal')['$coerce_to!'](encoding, $scope.get('String'), "to_str"); - encoding = $scope.get('Encoding').$find(encoding); - if (encoding['$=='](self.encoding)) { - return self}; - if ((($a = encoding['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('ArgumentError'), "unknown encoding name - " + (encoding))}; - - var result = new String(self); - result.encoding = encoding; - - return result; - - }); - - return (Opal.defn(self, '$getbyte', function(idx) { - var self = this; - - return self.encoding.$getbyte(self, idx); - }), nil) && 'getbyte'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/math"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - function $rb_minus(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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; - - Opal.add_stubs(['$new', '$raise', '$Float', '$type_error', '$Integer', '$module_function', '$checked', '$float!', '$===', '$gamma', '$-', '$integer!', '$/', '$infinite?']); - return (function($base) { - var self = $module($base, 'Math'); - - var def = self.$$proto, $scope = self.$$scope, $a; - - Opal.cdecl($scope, 'E', Math.E); - - Opal.cdecl($scope, 'PI', Math.PI); - - Opal.cdecl($scope, 'DomainError', $scope.get('Class').$new($scope.get('StandardError'))); - - Opal.defs(self, '$checked', function(method) { - var self = this; - - var array_size = arguments.length - 1; - 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 + 1]; - } - - if (isNaN(args[0]) || (args.length == 2 && isNaN(args[1]))) { - return NaN; - } - - var result = Math[method].apply(null, args); - - if (isNaN(result)) { - self.$raise($scope.get('DomainError'), "Numerical argument is out of domain - \"" + (method) + "\""); - } - - return result; - - }); - - Opal.defs(self, '$float!', function(value) { - var self = this; - - try { - return self.$Float(value) - } catch ($err) {if (Opal.rescue($err, [$scope.get('ArgumentError')])) { - try { - return self.$raise($scope.get('Opal').$type_error(value, $scope.get('Float'))) - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - Opal.defs(self, '$integer!', function(value) { - var self = this; - - try { - return self.$Integer(value) - } catch ($err) {if (Opal.rescue($err, [$scope.get('ArgumentError')])) { - try { - return self.$raise($scope.get('Opal').$type_error(value, $scope.get('Integer'))) - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - self.$module_function(); - - Opal.defn(self, '$acos', function(x) { - var self = this; - - return $scope.get('Math').$checked("acos", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.acosh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.acosh = function(x) { - return Math.log(x + Math.sqrt(x * x - 1)); - } - - }; - - Opal.defn(self, '$acosh', function(x) { - var self = this; - - return $scope.get('Math').$checked("acosh", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$asin', function(x) { - var self = this; - - return $scope.get('Math').$checked("asin", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.asinh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.asinh = function(x) { - return Math.log(x + Math.sqrt(x * x + 1)) - } - ; - }; - - Opal.defn(self, '$asinh', function(x) { - var self = this; - - return $scope.get('Math').$checked("asinh", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$atan', function(x) { - var self = this; - - return $scope.get('Math').$checked("atan", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$atan2', function(y, x) { - var self = this; - - return $scope.get('Math').$checked("atan2", $scope.get('Math')['$float!'](y), $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.atanh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.atanh = function(x) { - return 0.5 * Math.log((1 + x) / (1 - x)); - } - - }; - - Opal.defn(self, '$atanh', function(x) { - var self = this; - - return $scope.get('Math').$checked("atanh", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.cbrt) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.cbrt = function(x) { - if (x == 0) { - return 0; - } - - if (x < 0) { - return -Math.cbrt(-x); - } - - var r = x, - ex = 0; - - while (r < 0.125) { - r *= 8; - ex--; - } - - while (r > 1.0) { - r *= 0.125; - ex++; - } - - r = (-0.46946116 * r + 1.072302) * r + 0.3812513; - - while (ex < 0) { - r *= 0.5; - ex++; - } - - while (ex > 0) { - r *= 2; - ex--; - } - - r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); - r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); - r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); - r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); - - return r; - } - - }; - - Opal.defn(self, '$cbrt', function(x) { - var self = this; - - return $scope.get('Math').$checked("cbrt", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$cos', function(x) { - var self = this; - - return $scope.get('Math').$checked("cos", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.cosh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.cosh = function(x) { - return (Math.exp(x) + Math.exp(-x)) / 2; - } - - }; - - Opal.defn(self, '$cosh', function(x) { - var self = this; - - return $scope.get('Math').$checked("cosh", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.erf) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.erf = function(x) { - var A1 = 0.254829592, - A2 = -0.284496736, - A3 = 1.421413741, - A4 = -1.453152027, - A5 = 1.061405429, - P = 0.3275911; - - var sign = 1; - - if (x < 0) { - sign = -1; - } - - x = Math.abs(x); - - var t = 1.0 / (1.0 + P * x); - var y = 1.0 - (((((A5 * t + A4) * t) + A3) * t + A2) * t + A1) * t * Math.exp(-x * x); - - return sign * y; - } - - }; - - Opal.defn(self, '$erf', function(x) { - var self = this; - - return $scope.get('Math').$checked("erf", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.erfc) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.erfc = function(x) { - var z = Math.abs(x), - t = 1.0 / (0.5 * z + 1.0); - - var A1 = t * 0.17087277 + -0.82215223, - A2 = t * A1 + 1.48851587, - A3 = t * A2 + -1.13520398, - A4 = t * A3 + 0.27886807, - A5 = t * A4 + -0.18628806, - A6 = t * A5 + 0.09678418, - A7 = t * A6 + 0.37409196, - A8 = t * A7 + 1.00002368, - A9 = t * A8, - A10 = -z * z - 1.26551223 + A9; - - var a = t * Math.exp(A10); - - if (x < 0.0) { - return 2.0 - a; - } - else { - return a; - } - } - - }; - - Opal.defn(self, '$erfc', function(x) { - var self = this; - - return $scope.get('Math').$checked("erfc", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$exp', function(x) { - var self = this; - - return $scope.get('Math').$checked("exp", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$frexp', function(x) { - var self = this; - - x = $scope.get('Math')['$float!'](x); - - if (isNaN(x)) { - return [NaN, 0]; - } - - var ex = Math.floor(Math.log(Math.abs(x)) / Math.log(2)) + 1, - frac = x / Math.pow(2, ex); - - return [frac, ex]; - - }); - - Opal.defn(self, '$gamma', function(n) { - var self = this; - - n = $scope.get('Math')['$float!'](n); - - var i, t, x, value, result, twoN, threeN, fourN, fiveN; - - var G = 4.7421875; - - var P = [ - 0.99999999999999709182, - 57.156235665862923517, - -59.597960355475491248, - 14.136097974741747174, - -0.49191381609762019978, - 0.33994649984811888699e-4, - 0.46523628927048575665e-4, - -0.98374475304879564677e-4, - 0.15808870322491248884e-3, - -0.21026444172410488319e-3, - 0.21743961811521264320e-3, - -0.16431810653676389022e-3, - 0.84418223983852743293e-4, - -0.26190838401581408670e-4, - 0.36899182659531622704e-5 - ]; - - - if (isNaN(n)) { - return NaN; - } - - if (n === 0 && 1 / n < 0) { - return -Infinity; - } - - if (n === -1 || n === -Infinity) { - self.$raise($scope.get('DomainError'), "Numerical argument is out of domain - \"gamma\""); - } - - if ($scope.get('Integer')['$==='](n)) { - if (n <= 0) { - return isFinite(n) ? Infinity : NaN; - } - - if (n > 171) { - return Infinity; - } - - value = n - 2; - result = n - 1; - - while (value > 1) { - result *= value; - value--; - } - - if (result == 0) { - result = 1; - } - - return result; - } - - if (n < 0.5) { - return Math.PI / (Math.sin(Math.PI * n) * $scope.get('Math').$gamma($rb_minus(1, n))); - } - - if (n >= 171.35) { - return Infinity; - } - - if (n > 85.0) { - twoN = n * n; - threeN = twoN * n; - fourN = threeN * n; - fiveN = fourN * n; - - return Math.sqrt(2 * Math.PI / n) * Math.pow((n / Math.E), n) * - (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + - 5246819 / (75246796800 * fiveN * n)); - } - - n -= 1; - x = P[0]; - - for (i = 1; i < P.length; ++i) { - x += P[i] / (n + i); - } - - t = n + G + 0.5; - - return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x; - - }); - - if ((($a = (typeof(Math.hypot) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.hypot = function(x, y) { - return Math.sqrt(x * x + y * y) - } - ; - }; - - Opal.defn(self, '$hypot', function(x, y) { - var self = this; - - return $scope.get('Math').$checked("hypot", $scope.get('Math')['$float!'](x), $scope.get('Math')['$float!'](y)); - }); - - Opal.defn(self, '$ldexp', function(mantissa, exponent) { - var self = this; - - mantissa = $scope.get('Math')['$float!'](mantissa); - exponent = $scope.get('Math')['$integer!'](exponent); - - if (isNaN(exponent)) { - self.$raise($scope.get('RangeError'), "float NaN out of range of integer"); - } - - return mantissa * Math.pow(2, exponent); - ; - }); - - Opal.defn(self, '$lgamma', function(n) { - var self = this; - - - if (n == -1) { - return [Infinity, 1]; - } - else { - return [Math.log(Math.abs($scope.get('Math').$gamma(n))), $scope.get('Math').$gamma(n) < 0 ? -1 : 1]; - } - ; - }); - - Opal.defn(self, '$log', function(x, base) { - var $a, self = this; - - if ((($a = $scope.get('String')['$==='](x)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('Opal').$type_error(x, $scope.get('Float')))}; - if ((($a = base == null) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Math').$checked("log", $scope.get('Math')['$float!'](x)) - } else { - if ((($a = $scope.get('String')['$==='](base)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('Opal').$type_error(base, $scope.get('Float')))}; - return $rb_divide($scope.get('Math').$checked("log", $scope.get('Math')['$float!'](x)), $scope.get('Math').$checked("log", $scope.get('Math')['$float!'](base))); - }; - }); - - if ((($a = (typeof(Math.log10) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.log10 = function(x) { - return Math.log(x) / Math.LN10; - } - - }; - - Opal.defn(self, '$log10', function(x) { - var $a, self = this; - - if ((($a = $scope.get('String')['$==='](x)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('Opal').$type_error(x, $scope.get('Float')))}; - return $scope.get('Math').$checked("log10", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.log2) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.log2 = function(x) { - return Math.log(x) / Math.LN2; - } - - }; - - Opal.defn(self, '$log2', function(x) { - var $a, self = this; - - if ((($a = $scope.get('String')['$==='](x)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('Opal').$type_error(x, $scope.get('Float')))}; - return $scope.get('Math').$checked("log2", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$sin', function(x) { - var self = this; - - return $scope.get('Math').$checked("sin", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.sinh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.sinh = function(x) { - return (Math.exp(x) - Math.exp(-x)) / 2; - } - - }; - - Opal.defn(self, '$sinh', function(x) { - var self = this; - - return $scope.get('Math').$checked("sinh", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$sqrt', function(x) { - var self = this; - - return $scope.get('Math').$checked("sqrt", $scope.get('Math')['$float!'](x)); - }); - - Opal.defn(self, '$tan', function(x) { - var $a, self = this; - - x = $scope.get('Math')['$float!'](x); - if ((($a = x['$infinite?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($scope.get('Float')).$$scope.get('NAN'))}; - return $scope.get('Math').$checked("tan", $scope.get('Math')['$float!'](x)); - }); - - if ((($a = (typeof(Math.tanh) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - - Math.tanh = function(x) { - if (x == Infinity) { - return 1; - } - else if (x == -Infinity) { - return -1; - } - else { - return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x)); - } - } - - }; - - Opal.defn(self, '$tanh', function(x) { - var self = this; - - return $scope.get('Math').$checked("tanh", $scope.get('Math')['$float!'](x)); - }); - })($scope.base) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/complex"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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); - } - function $rb_divide(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, $klass = Opal.klass, $module = Opal.module; - - Opal.add_stubs(['$require', '$===', '$real?', '$raise', '$new', '$*', '$cos', '$sin', '$attr_reader', '$class', '$==', '$real', '$imag', '$Complex', '$-@', '$+', '$__coerced__', '$-', '$nan?', '$/', '$conj', '$abs2', '$quo', '$polar', '$exp', '$log', '$>', '$!=', '$divmod', '$**', '$hypot', '$atan2', '$lcm', '$denominator', '$to_s', '$numerator', '$abs', '$arg', '$rationalize', '$to_f', '$to_i', '$to_r', '$inspect', '$positive?', '$infinite?']); - self.$require("corelib/numeric"); - (function($base, $super) { - function $Complex(){}; - var self = $Complex = $klass($base, $super, 'Complex', $Complex); - - var def = self.$$proto, $scope = self.$$scope; - - def.real = def.imag = nil; - Opal.defs(self, '$rect', function(real, imag) { - var $a, $b, $c, $d, self = this; - - if (imag == null) { - imag = 0 - } - if ((($a = ($b = ($c = ($d = $scope.get('Numeric')['$==='](real), $d !== false && $d !== nil ?real['$real?']() : $d), $c !== false && $c !== nil ?$scope.get('Numeric')['$==='](imag) : $c), $b !== false && $b !== nil ?imag['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "not a real") - }; - return self.$new(real, imag); - }); - - (function(self) { - var $scope = self.$$scope, def = self.$$proto; - - return Opal.alias(self, 'rectangular', 'rect') - })(Opal.get_singleton_class(self)); - - Opal.defs(self, '$polar', function(r, theta) { - var $a, $b, $c, $d, self = this; - - if (theta == null) { - theta = 0 - } - if ((($a = ($b = ($c = ($d = $scope.get('Numeric')['$==='](r), $d !== false && $d !== nil ?r['$real?']() : $d), $c !== false && $c !== nil ?$scope.get('Numeric')['$==='](theta) : $c), $b !== false && $b !== nil ?theta['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "not a real") - }; - return self.$new($rb_times(r, $scope.get('Math').$cos(theta)), $rb_times(r, $scope.get('Math').$sin(theta))); - }); - - self.$attr_reader("real", "imag"); - - Opal.defn(self, '$initialize', function(real, imag) { - var self = this; - - if (imag == null) { - imag = 0 - } - self.real = real; - return self.imag = imag; - }); - - Opal.defn(self, '$coerce', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return [other, self] - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return [$scope.get('Complex').$new(other, 0), self] - } else { - return self.$raise($scope.get('TypeError'), "" + (other.$class()) + " can't be coerced into Complex") - }; - }); - - Opal.defn(self, '$==', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($a = self.real['$=='](other.$real())) ? self.imag['$=='](other.$imag()) : self.real['$=='](other.$real())) - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($a = self.real['$=='](other)) ? self.imag['$=='](0) : self.real['$=='](other)) - } else { - return other['$=='](self) - }; - }); - - Opal.defn(self, '$-@', function() { - var self = this; - - return self.$Complex(self.real['$-@'](), self.imag['$-@']()); - }); - - Opal.defn(self, '$+', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_plus(self.real, other.$real()), $rb_plus(self.imag, other.$imag())) - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_plus(self.real, other), self.imag) - } else { - return self.$__coerced__("+", other) - }; - }); - - Opal.defn(self, '$-', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_minus(self.real, other.$real()), $rb_minus(self.imag, other.$imag())) - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_minus(self.real, other), self.imag) - } else { - return self.$__coerced__("-", other) - }; - }); - - Opal.defn(self, '$*', function(other) { - var $a, $b, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_minus($rb_times(self.real, other.$real()), $rb_times(self.imag, other.$imag())), $rb_plus($rb_times(self.real, other.$imag()), $rb_times(self.imag, other.$real()))) - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex($rb_times(self.real, other), $rb_times(self.imag, other)) - } else { - return self.$__coerced__("*", other) - }; - }); - - Opal.defn(self, '$/', function(other) { - var $a, $b, $c, $d, $e, self = this; - - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = ((($b = ((($c = ((($d = (($e = $scope.get('Number')['$==='](self.real), $e !== false && $e !== nil ?self.real['$nan?']() : $e))) !== false && $d !== nil) ? $d : (($e = $scope.get('Number')['$==='](self.imag), $e !== false && $e !== nil ?self.imag['$nan?']() : $e)))) !== false && $c !== nil) ? $c : (($d = $scope.get('Number')['$==='](other.$real()), $d !== false && $d !== nil ?other.$real()['$nan?']() : $d)))) !== false && $b !== nil) ? $b : (($c = $scope.get('Number')['$==='](other.$imag()), $c !== false && $c !== nil ?other.$imag()['$nan?']() : $c)))) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Complex').$new((($scope.get('Float')).$$scope.get('NAN')), (($scope.get('Float')).$$scope.get('NAN'))) - } else { - return $rb_divide($rb_times(self, other.$conj()), other.$abs2()) - } - } else if ((($a = ($b = $scope.get('Numeric')['$==='](other), $b !== false && $b !== nil ?other['$real?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$Complex(self.real.$quo(other), self.imag.$quo(other)) - } else { - return self.$__coerced__("/", other) - }; - }); - - Opal.defn(self, '$**', function(other) { - var $a, $b, $c, $d, self = this, r = nil, theta = nil, ore = nil, oim = nil, nr = nil, ntheta = nil, x = nil, z = nil, n = nil, div = nil, mod = nil; - - if (other['$=='](0)) { - return $scope.get('Complex').$new(1, 0)}; - if ((($a = $scope.get('Complex')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary(self.$polar()), r = ($a[0] == null ? nil : $a[0]), theta = ($a[1] == null ? nil : $a[1]); - ore = other.$real(); - oim = other.$imag(); - nr = $scope.get('Math').$exp($rb_minus($rb_times(ore, $scope.get('Math').$log(r)), $rb_times(oim, theta))); - ntheta = $rb_plus($rb_times(theta, ore), $rb_times(oim, $scope.get('Math').$log(r))); - return $scope.get('Complex').$polar(nr, ntheta); - } else if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ($rb_gt(other, 0)) { - x = self; - z = x; - n = $rb_minus(other, 1); - while ((($b = n['$!='](0)) !== nil && (!$b.$$is_boolean || $b == true))) { - while ((($c = ($d = Opal.to_ary(n.$divmod(2)), div = ($d[0] == null ? nil : $d[0]), mod = ($d[1] == null ? nil : $d[1]), mod['$=='](0))) !== nil && (!$c.$$is_boolean || $c == true))) { - x = self.$Complex($rb_minus($rb_times(x.$real(), x.$real()), $rb_times(x.$imag(), x.$imag())), $rb_times($rb_times(2, x.$real()), x.$imag())); - n = div;}; - z = $rb_times(z, x); - n = $rb_minus(n, 1);}; - return z; - } else { - return ($rb_divide($scope.get('Rational').$new(1, 1), self))['$**'](other['$-@']()) - } - } else if ((($a = ((($b = $scope.get('Float')['$==='](other)) !== false && $b !== nil) ? $b : $scope.get('Rational')['$==='](other))) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary(self.$polar()), r = ($a[0] == null ? nil : $a[0]), theta = ($a[1] == null ? nil : $a[1]); - return $scope.get('Complex').$polar(r['$**'](other), $rb_times(theta, other)); - } else { - return self.$__coerced__("**", other) - }; - }); - - Opal.defn(self, '$abs', function() { - var self = this; - - return $scope.get('Math').$hypot(self.real, self.imag); - }); - - Opal.defn(self, '$abs2', function() { - var self = this; - - return $rb_plus($rb_times(self.real, self.real), $rb_times(self.imag, self.imag)); - }); - - Opal.defn(self, '$angle', function() { - var self = this; - - return $scope.get('Math').$atan2(self.imag, self.real); - }); - - Opal.alias(self, 'arg', 'angle'); - - Opal.defn(self, '$conj', function() { - var self = this; - - return self.$Complex(self.real, self.imag['$-@']()); - }); - - Opal.alias(self, 'conjugate', 'conj'); - - Opal.defn(self, '$denominator', function() { - var self = this; - - return self.real.$denominator().$lcm(self.imag.$denominator()); - }); - - Opal.alias(self, 'divide', '/'); - - Opal.defn(self, '$eql?', function(other) { - var $a, $b, self = this; - - return ($a = ($b = $scope.get('Complex')['$==='](other), $b !== false && $b !== nil ?self.real.$class()['$=='](self.imag.$class()) : $b), $a !== false && $a !== nil ?self['$=='](other) : $a); - }); - - Opal.defn(self, '$fdiv', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Numeric')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "" + (other.$class()) + " can't be coerced into Complex") - }; - return $rb_divide(self, other); - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return "Complex:" + (self.real) + ":" + (self.imag); - }); - - Opal.alias(self, 'imaginary', 'imag'); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return "(" + (self.$to_s()) + ")"; - }); - - Opal.alias(self, 'magnitude', 'abs'); - - Opal.defn(self, '$numerator', function() { - var self = this, d = nil; - - d = self.$denominator(); - return self.$Complex($rb_times(self.real.$numerator(), ($rb_divide(d, self.real.$denominator()))), $rb_times(self.imag.$numerator(), ($rb_divide(d, self.imag.$denominator())))); - }); - - Opal.alias(self, 'phase', 'arg'); - - Opal.defn(self, '$polar', function() { - var self = this; - - return [self.$abs(), self.$arg()]; - }); - - Opal.alias(self, 'quo', '/'); - - Opal.defn(self, '$rationalize', function(eps) { - var $a, self = this; - - - if (arguments.length > 1) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 0..1)"); - } - ; - if ((($a = self.imag['$!='](0)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('RangeError'), "can't' convert " + (self) + " into Rational")}; - return self.$real().$rationalize(eps); - }); - - Opal.defn(self, '$real?', function() { - var self = this; - - return false; - }); - - Opal.defn(self, '$rect', function() { - var self = this; - - return [self.real, self.imag]; - }); - - Opal.alias(self, 'rectangular', 'rect'); - - Opal.defn(self, '$to_f', function() { - var self = this; - - if (self.imag['$=='](0)) { - } else { - self.$raise($scope.get('RangeError'), "can't convert " + (self) + " into Float") - }; - return self.real.$to_f(); - }); - - Opal.defn(self, '$to_i', function() { - var self = this; - - if (self.imag['$=='](0)) { - } else { - self.$raise($scope.get('RangeError'), "can't convert " + (self) + " into Integer") - }; - return self.real.$to_i(); - }); - - Opal.defn(self, '$to_r', function() { - var self = this; - - if (self.imag['$=='](0)) { - } else { - self.$raise($scope.get('RangeError'), "can't convert " + (self) + " into Rational") - }; - return self.real.$to_r(); - }); - - Opal.defn(self, '$to_s', function() { - var $a, $b, $c, self = this, result = nil; - - result = self.real.$inspect(); - if ((($a = ((($b = (($c = $scope.get('Number')['$==='](self.imag), $c !== false && $c !== nil ?self.imag['$nan?']() : $c))) !== false && $b !== nil) ? $b : self.imag['$positive?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - result = $rb_plus(result, "+") - } else { - result = $rb_plus(result, "-") - }; - result = $rb_plus(result, self.imag.$abs().$inspect()); - if ((($a = ($b = $scope.get('Number')['$==='](self.imag), $b !== false && $b !== nil ?(((($c = self.imag['$nan?']()) !== false && $c !== nil) ? $c : self.imag['$infinite?']())) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = $rb_plus(result, "*")}; - return $rb_plus(result, "i"); - }); - - return Opal.cdecl($scope, 'I', self.$new(0, 1)); - })($scope.base, $scope.get('Numeric')); - return (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$Complex', function(real, imag) { - var self = this; - - if (imag == null) { - imag = nil - } - if (imag !== false && imag !== nil) { - return $scope.get('Complex').$new(real, imag) - } else { - return $scope.get('Complex').$new(real, 0) - }; - }) - })($scope.base); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/rational"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - function $rb_lt(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_minus(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_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_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, $klass = Opal.klass, $module = Opal.module; - - Opal.add_stubs(['$require', '$to_i', '$==', '$raise', '$<', '$-@', '$new', '$gcd', '$/', '$nil?', '$===', '$reduce', '$to_r', '$equal?', '$!', '$coerce_to!', '$attr_reader', '$to_f', '$numerator', '$denominator', '$<=>', '$-', '$*', '$__coerced__', '$+', '$Rational', '$>', '$**', '$abs', '$ceil', '$with_precision', '$floor', '$to_s', '$<=', '$truncate', '$send', '$convert']); - self.$require("corelib/numeric"); - (function($base, $super) { - function $Rational(){}; - var self = $Rational = $klass($base, $super, 'Rational', $Rational); - - var def = self.$$proto, $scope = self.$$scope; - - def.num = def.den = nil; - Opal.defs(self, '$reduce', function(num, den) { - var self = this, gcd = nil; - - num = num.$to_i(); - den = den.$to_i(); - if (den['$=='](0)) { - self.$raise($scope.get('ZeroDivisionError'), "divided by 0") - } else if ($rb_lt(den, 0)) { - num = num['$-@'](); - den = den['$-@'](); - } else if (den['$=='](1)) { - return self.$new(num, den)}; - gcd = num.$gcd(den); - return self.$new($rb_divide(num, gcd), $rb_divide(den, gcd)); - }); - - Opal.defs(self, '$convert', function(num, den) { - var $a, $b, $c, self = this; - - if ((($a = ((($b = num['$nil?']()) !== false && $b !== nil) ? $b : den['$nil?']())) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('TypeError'), "cannot convert nil into Rational")}; - if ((($a = ($b = $scope.get('Integer')['$==='](num), $b !== false && $b !== nil ?$scope.get('Integer')['$==='](den) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$reduce(num, den)}; - if ((($a = ((($b = ((($c = $scope.get('Float')['$==='](num)) !== false && $c !== nil) ? $c : $scope.get('String')['$==='](num))) !== false && $b !== nil) ? $b : $scope.get('Complex')['$==='](num))) !== nil && (!$a.$$is_boolean || $a == true))) { - num = num.$to_r()}; - if ((($a = ((($b = ((($c = $scope.get('Float')['$==='](den)) !== false && $c !== nil) ? $c : $scope.get('String')['$==='](den))) !== false && $b !== nil) ? $b : $scope.get('Complex')['$==='](den))) !== nil && (!$a.$$is_boolean || $a == true))) { - den = den.$to_r()}; - if ((($a = ($b = den['$equal?'](1), $b !== false && $b !== nil ?($scope.get('Integer')['$==='](num))['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('Opal')['$coerce_to!'](num, $scope.get('Rational'), "to_r") - } else if ((($a = ($b = $scope.get('Numeric')['$==='](num), $b !== false && $b !== nil ?$scope.get('Numeric')['$==='](den) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $rb_divide(num, den) - } else { - return self.$reduce(num, den) - }; - }); - - self.$attr_reader("numerator", "denominator"); - - Opal.defn(self, '$initialize', function(num, den) { - var self = this; - - self.num = num; - return self.den = den; - }); - - Opal.defn(self, '$numerator', function() { - var self = this; - - return self.num; - }); - - Opal.defn(self, '$denominator', function() { - var self = this; - - return self.den; - }); - - Opal.defn(self, '$coerce', function(other) { - var self = this, $case = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {return [other, self]}else if ($scope.get('Integer')['$===']($case)) {return [other.$to_r(), self]}else if ($scope.get('Float')['$===']($case)) {return [other, self.$to_f()]}else { return nil }})(); - }); - - Opal.defn(self, '$==', function(other) { - var $a, self = this, $case = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {return (($a = self.num['$=='](other.$numerator())) ? self.den['$=='](other.$denominator()) : self.num['$=='](other.$numerator()))}else if ($scope.get('Integer')['$===']($case)) {return (($a = self.num['$=='](other)) ? self.den['$=='](1) : self.num['$=='](other))}else if ($scope.get('Float')['$===']($case)) {return self.$to_f()['$=='](other)}else {return other['$=='](self)}})(); - }); - - Opal.defn(self, '$<=>', function(other) { - var self = this, $case = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {return $rb_minus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator()))['$<=>'](0)}else if ($scope.get('Integer')['$===']($case)) {return $rb_minus(self.num, $rb_times(self.den, other))['$<=>'](0)}else if ($scope.get('Float')['$===']($case)) {return self.$to_f()['$<=>'](other)}else {return self.$__coerced__("<=>", other)}})(); - }); - - Opal.defn(self, '$+', function(other) { - var self = this, $case = nil, num = nil, den = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {num = $rb_plus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator())); - den = $rb_times(self.den, other.$denominator()); - return self.$Rational(num, den);}else if ($scope.get('Integer')['$===']($case)) {return self.$Rational($rb_plus(self.num, $rb_times(other, self.den)), self.den)}else if ($scope.get('Float')['$===']($case)) {return $rb_plus(self.$to_f(), other)}else {return self.$__coerced__("+", other)}})(); - }); - - Opal.defn(self, '$-', function(other) { - var self = this, $case = nil, num = nil, den = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {num = $rb_minus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator())); - den = $rb_times(self.den, other.$denominator()); - return self.$Rational(num, den);}else if ($scope.get('Integer')['$===']($case)) {return self.$Rational($rb_minus(self.num, $rb_times(other, self.den)), self.den)}else if ($scope.get('Float')['$===']($case)) {return $rb_minus(self.$to_f(), other)}else {return self.$__coerced__("-", other)}})(); - }); - - Opal.defn(self, '$*', function(other) { - var self = this, $case = nil, num = nil, den = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {num = $rb_times(self.num, other.$numerator()); - den = $rb_times(self.den, other.$denominator()); - return self.$Rational(num, den);}else if ($scope.get('Integer')['$===']($case)) {return self.$Rational($rb_times(self.num, other), self.den)}else if ($scope.get('Float')['$===']($case)) {return $rb_times(self.$to_f(), other)}else {return self.$__coerced__("*", other)}})(); - }); - - Opal.defn(self, '$/', function(other) { - var self = this, $case = nil, num = nil, den = nil; - - return (function() {$case = other;if ($scope.get('Rational')['$===']($case)) {num = $rb_times(self.num, other.$denominator()); - den = $rb_times(self.den, other.$numerator()); - return self.$Rational(num, den);}else if ($scope.get('Integer')['$===']($case)) {if (other['$=='](0)) { - return $rb_divide(self.$to_f(), 0.0) - } else { - return self.$Rational(self.num, $rb_times(self.den, other)) - }}else if ($scope.get('Float')['$===']($case)) {return $rb_divide(self.$to_f(), other)}else {return self.$__coerced__("/", other)}})(); - }); - - Opal.defn(self, '$**', function(other) { - var $a, $b, self = this, $case = nil; - - return (function() {$case = other;if ($scope.get('Integer')['$===']($case)) {if ((($a = (($b = self['$=='](0)) ? $rb_lt(other, 0) : self['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($scope.get('Float')).$$scope.get('INFINITY')) - } else if ($rb_gt(other, 0)) { - return self.$Rational(self.num['$**'](other), self.den['$**'](other)) - } else if ($rb_lt(other, 0)) { - return self.$Rational(self.den['$**'](other['$-@']()), self.num['$**'](other['$-@']())) - } else { - return self.$Rational(1, 1) - }}else if ($scope.get('Float')['$===']($case)) {return self.$to_f()['$**'](other)}else if ($scope.get('Rational')['$===']($case)) {if (other['$=='](0)) { - return self.$Rational(1, 1) - } else if (other.$denominator()['$=='](1)) { - if ($rb_lt(other, 0)) { - return self.$Rational(self.den['$**'](other.$numerator().$abs()), self.num['$**'](other.$numerator().$abs())) - } else { - return self.$Rational(self.num['$**'](other.$numerator()), self.den['$**'](other.$numerator())) - } - } else if ((($a = (($b = self['$=='](0)) ? $rb_lt(other, 0) : self['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$raise($scope.get('ZeroDivisionError'), "divided by 0") - } else { - return self.$to_f()['$**'](other) - }}else {return self.$__coerced__("**", other)}})(); - }); - - Opal.defn(self, '$abs', function() { - var self = this; - - return self.$Rational(self.num.$abs(), self.den.$abs()); - }); - - Opal.defn(self, '$ceil', function(precision) { - var self = this; - - if (precision == null) { - precision = 0 - } - if (precision['$=='](0)) { - return (($rb_divide(self.num['$-@'](), self.den))['$-@']()).$ceil() - } else { - return self.$with_precision("ceil", precision) - }; - }); - - Opal.alias(self, 'divide', '/'); - - Opal.defn(self, '$floor', function(precision) { - var self = this; - - if (precision == null) { - precision = 0 - } - if (precision['$=='](0)) { - return (($rb_divide(self.num['$-@'](), self.den))['$-@']()).$floor() - } else { - return self.$with_precision("floor", precision) - }; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return "Rational:" + (self.num) + ":" + (self.den); - }); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return "(" + (self.$to_s()) + ")"; - }); - - Opal.alias(self, 'quo', '/'); - - Opal.defn(self, '$rationalize', function(eps) { - var self = this; - - - if (arguments.length > 1) { - self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 0..1)"); - } - - if (eps == null) { - return self; - } - - var e = eps.$abs(), - a = $rb_minus(self, e), - b = $rb_plus(self, e); - - var p0 = 0, - p1 = 1, - q0 = 1, - q1 = 0, - p2, q2; - - var c, k, t; - - while (true) { - c = (a).$ceil(); - - if ($rb_le(c, b)) { - break; - } - - k = c - 1; - p2 = k * p1 + p0; - q2 = k * q1 + q0; - t = $rb_divide(1, ($rb_minus(b, k))); - b = $rb_divide(1, ($rb_minus(a, k))); - a = t; - - p0 = p1; - q0 = q1; - p1 = p2; - q1 = q2; - } - - return self.$Rational(c * p1 + p0, c * q1 + q0); - ; - }); - - Opal.defn(self, '$round', function(precision) { - var self = this, num = nil, den = nil, approx = nil; - - if (precision == null) { - precision = 0 - } - if (precision['$=='](0)) { - } else { - return self.$with_precision("round", precision) - }; - if (self.num['$=='](0)) { - return 0}; - if (self.den['$=='](1)) { - return self.num}; - num = $rb_plus($rb_times(self.num.$abs(), 2), self.den); - den = $rb_times(self.den, 2); - approx = ($rb_divide(num, den)).$truncate(); - if ($rb_lt(self.num, 0)) { - return approx['$-@']() - } else { - return approx - }; - }); - - Opal.defn(self, '$to_f', function() { - var self = this; - - return $rb_divide(self.num, self.den); - }); - - Opal.defn(self, '$to_i', function() { - var self = this; - - return self.$truncate(); - }); - - Opal.defn(self, '$to_r', function() { - var self = this; - - return self; - }); - - Opal.defn(self, '$to_s', function() { - var self = this; - - return "" + (self.num) + "/" + (self.den); - }); - - Opal.defn(self, '$truncate', function(precision) { - var self = this; - - if (precision == null) { - precision = 0 - } - if (precision['$=='](0)) { - if ($rb_lt(self.num, 0)) { - return self.$ceil() - } else { - return self.$floor() - } - } else { - return self.$with_precision("truncate", precision) - }; - }); - - return (Opal.defn(self, '$with_precision', function(method, precision) { - var $a, self = this, p = nil, s = nil; - - if ((($a = $scope.get('Integer')['$==='](precision)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('TypeError'), "not an Integer") - }; - p = (10)['$**'](precision); - s = $rb_times(self, p); - if ($rb_lt(precision, 1)) { - return ($rb_divide(s.$send(method), p)).$to_i() - } else { - return self.$Rational(s.$send(method), p) - }; - }), nil) && 'with_precision'; - })($scope.base, $scope.get('Numeric')); - return (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$Rational', function(numerator, denominator) { - var self = this; - - if (denominator == null) { - denominator = 1 - } - return $scope.get('Rational').$convert(numerator, denominator); - }) - })($scope.base); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/time"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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_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); - } - function $rb_divide(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); - } - var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $range = Opal.range; - - Opal.add_stubs(['$require', '$include', '$===', '$raise', '$coerce_to!', '$respond_to?', '$to_str', '$to_i', '$new', '$<=>', '$to_f', '$nil?', '$>', '$<', '$strftime', '$year', '$month', '$day', '$+', '$round', '$/', '$-', '$copy_instance_variables', '$initialize_dup', '$is_a?', '$zero?', '$wday', '$utc?', '$mon', '$yday', '$hour', '$min', '$sec', '$rjust', '$ljust', '$zone', '$to_s', '$[]', '$cweek_cyear', '$isdst', '$<=', '$!=', '$==', '$ceil']); - self.$require("corelib/comparable"); - return (function($base, $super) { - function $Time(){}; - var self = $Time = $klass($base, $super, 'Time', $Time); - - var def = self.$$proto, $scope = self.$$scope; - - self.$include($scope.get('Comparable')); - - - var days_of_week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], - short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], - short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - long_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; - ; - - Opal.defs(self, '$at', function(seconds, frac) { - var self = this; - - - var result; - - if ($scope.get('Time')['$==='](seconds)) { - if (frac !== undefined) { - self.$raise($scope.get('TypeError'), "can't convert Time into an exact number") - } - result = new Date(seconds.getTime()); - result.is_utc = seconds.is_utc; - return result; - } - - if (!seconds.$$is_number) { - seconds = $scope.get('Opal')['$coerce_to!'](seconds, $scope.get('Integer'), "to_int"); - } - - if (frac === undefined) { - return new Date(seconds * 1000); - } - - if (!frac.$$is_number) { - frac = $scope.get('Opal')['$coerce_to!'](frac, $scope.get('Integer'), "to_int"); - } - - return new Date(seconds * 1000 + (frac / 1000)); - ; - }); - - - function time_params(year, month, day, hour, min, sec) { - if (year.$$is_string) { - year = parseInt(year, 10); - } else { - year = $scope.get('Opal')['$coerce_to!'](year, $scope.get('Integer'), "to_int"); - } - - if (month === nil) { - month = 1; - } else if (!month.$$is_number) { - if ((month)['$respond_to?']("to_str")) { - month = (month).$to_str(); - switch (month.toLowerCase()) { - case 'jan': month = 1; break; - case 'feb': month = 2; break; - case 'mar': month = 3; break; - case 'apr': month = 4; break; - case 'may': month = 5; break; - case 'jun': month = 6; break; - case 'jul': month = 7; break; - case 'aug': month = 8; break; - case 'sep': month = 9; break; - case 'oct': month = 10; break; - case 'nov': month = 11; break; - case 'dec': month = 12; break; - default: month = (month).$to_i(); - } - } else { - month = $scope.get('Opal')['$coerce_to!'](month, $scope.get('Integer'), "to_int"); - } - } - - if (month < 1 || month > 12) { - self.$raise($scope.get('ArgumentError'), "month out of range: " + (month)) - } - month = month - 1; - - if (day === nil) { - day = 1; - } else if (day.$$is_string) { - day = parseInt(day, 10); - } else { - day = $scope.get('Opal')['$coerce_to!'](day, $scope.get('Integer'), "to_int"); - } - - if (day < 1 || day > 31) { - self.$raise($scope.get('ArgumentError'), "day out of range: " + (day)) - } - - if (hour === nil) { - hour = 0; - } else if (hour.$$is_string) { - hour = parseInt(hour, 10); - } else { - hour = $scope.get('Opal')['$coerce_to!'](hour, $scope.get('Integer'), "to_int"); - } - - if (hour < 0 || hour > 24) { - self.$raise($scope.get('ArgumentError'), "hour out of range: " + (hour)) - } - - if (min === nil) { - min = 0; - } else if (min.$$is_string) { - min = parseInt(min, 10); - } else { - min = $scope.get('Opal')['$coerce_to!'](min, $scope.get('Integer'), "to_int"); - } - - if (min < 0 || min > 59) { - self.$raise($scope.get('ArgumentError'), "min out of range: " + (min)) - } - - if (sec === nil) { - sec = 0; - } else if (!sec.$$is_number) { - if (sec.$$is_string) { - sec = parseInt(sec, 10); - } else { - sec = $scope.get('Opal')['$coerce_to!'](sec, $scope.get('Integer'), "to_int"); - } - } - - if (sec < 0 || sec > 60) { - self.$raise($scope.get('ArgumentError'), "sec out of range: " + (sec)) - } - - return [year, month, day, hour, min, sec]; - } - ; - - Opal.defs(self, '$new', function(year, month, day, hour, min, sec, utc_offset) { - var self = this; - - if (month == null) { - month = nil - } - if (day == null) { - day = nil - } - if (hour == null) { - hour = nil - } - if (min == null) { - min = nil - } - if (sec == null) { - sec = nil - } - if (utc_offset == null) { - utc_offset = nil - } - - var args, result; - - if (year === undefined) { - return new Date(); - } - - if (utc_offset !== nil) { - self.$raise($scope.get('ArgumentError'), "Opal does not support explicitly specifying UTC offset for Time") - } - - args = time_params(year, month, day, hour, min, sec); - year = args[0]; - month = args[1]; - day = args[2]; - hour = args[3]; - min = args[4]; - sec = args[5]; - - result = new Date(year, month, day, hour, min, 0, sec * 1000); - if (year < 100) { - result.setFullYear(year); - } - return result; - - }); - - Opal.defs(self, '$local', function(year, month, day, hour, min, sec, millisecond, _dummy1, _dummy2, _dummy3) { - var self = this; - - if (month == null) { - month = nil - } - if (day == null) { - day = nil - } - if (hour == null) { - hour = nil - } - if (min == null) { - min = nil - } - if (sec == null) { - sec = nil - } - if (millisecond == null) { - millisecond = nil - } - if (_dummy1 == null) { - _dummy1 = nil - } - if (_dummy2 == null) { - _dummy2 = nil - } - if (_dummy3 == null) { - _dummy3 = nil - } - - var args, result; - - if (arguments.length === 10) { - args = $slice.call(arguments); - year = args[5]; - month = args[4]; - day = args[3]; - hour = args[2]; - min = args[1]; - sec = args[0]; - } - - args = time_params(year, month, day, hour, min, sec); - year = args[0]; - month = args[1]; - day = args[2]; - hour = args[3]; - min = args[4]; - sec = args[5]; - - result = new Date(year, month, day, hour, min, 0, sec * 1000); - if (year < 100) { - result.setFullYear(year); - } - return result; - - }); - - Opal.defs(self, '$gm', function(year, month, day, hour, min, sec, millisecond, _dummy1, _dummy2, _dummy3) { - var self = this; - - if (month == null) { - month = nil - } - if (day == null) { - day = nil - } - if (hour == null) { - hour = nil - } - if (min == null) { - min = nil - } - if (sec == null) { - sec = nil - } - if (millisecond == null) { - millisecond = nil - } - if (_dummy1 == null) { - _dummy1 = nil - } - if (_dummy2 == null) { - _dummy2 = nil - } - if (_dummy3 == null) { - _dummy3 = nil - } - - var args, result; - - if (arguments.length === 10) { - args = $slice.call(arguments); - year = args[5]; - month = args[4]; - day = args[3]; - hour = args[2]; - min = args[1]; - sec = args[0]; - } - - args = time_params(year, month, day, hour, min, sec); - year = args[0]; - month = args[1]; - day = args[2]; - hour = args[3]; - min = args[4]; - sec = args[5]; - - result = new Date(Date.UTC(year, month, day, hour, min, 0, sec * 1000)); - if (year < 100) { - result.setUTCFullYear(year); - } - result.is_utc = true; - return result; - - }); - - (function(self) { - var $scope = self.$$scope, def = self.$$proto; - - Opal.alias(self, 'mktime', 'local'); - return Opal.alias(self, 'utc', 'gm'); - })(Opal.get_singleton_class(self)); - - Opal.defs(self, '$now', function() { - var self = this; - - return self.$new(); - }); - - Opal.defn(self, '$+', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Time')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$raise($scope.get('TypeError'), "time + time?")}; - - if (!other.$$is_number) { - other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Integer'), "to_int"); - } - var result = new Date(self.getTime() + (other * 1000)); - result.is_utc = self.is_utc; - return result; - ; - }); - - Opal.defn(self, '$-', function(other) { - var $a, self = this; - - if ((($a = $scope.get('Time')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return (self.getTime() - other.getTime()) / 1000}; - - if (!other.$$is_number) { - other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Integer'), "to_int"); - } - var result = new Date(self.getTime() - (other * 1000)); - result.is_utc = self.is_utc; - return result; - ; - }); - - Opal.defn(self, '$<=>', function(other) { - var $a, self = this, r = nil; - - if ((($a = $scope.get('Time')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$to_f()['$<=>'](other.$to_f()) - } else { - r = other['$<=>'](self); - if ((($a = r['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else if ($rb_gt(r, 0)) { - return -1 - } else if ($rb_lt(r, 0)) { - return 1 - } else { - return 0 - }; - }; - }); - - Opal.defn(self, '$==', function(other) { - var self = this; - - return self.$to_f() === other.$to_f(); - }); - - Opal.defn(self, '$asctime', function() { - var self = this; - - return self.$strftime("%a %b %e %H:%M:%S %Y"); - }); - - Opal.alias(self, 'ctime', 'asctime'); - - Opal.defn(self, '$day', function() { - var self = this; - - return self.is_utc ? self.getUTCDate() : self.getDate(); - }); - - Opal.defn(self, '$yday', function() { - var self = this, start_of_year = nil, start_of_day = nil, one_day = nil; - - start_of_year = $scope.get('Time').$new(self.$year()).$to_i(); - start_of_day = $scope.get('Time').$new(self.$year(), self.$month(), self.$day()).$to_i(); - one_day = 86400; - return $rb_plus(($rb_divide(($rb_minus(start_of_day, start_of_year)), one_day)).$round(), 1); - }); - - Opal.defn(self, '$isdst', function() { - var self = this; - - - var jan = new Date(self.getFullYear(), 0, 1), - jul = new Date(self.getFullYear(), 6, 1); - return self.getTimezoneOffset() < Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); - - }); - - Opal.alias(self, 'dst?', 'isdst'); - - Opal.defn(self, '$dup', function() { - var self = this, copy = nil; - - copy = new Date(self.getTime()); - copy.$copy_instance_variables(self); - copy.$initialize_dup(self); - return copy; - }); - - Opal.defn(self, '$eql?', function(other) { - var $a, self = this; - - return ($a = other['$is_a?']($scope.get('Time')), $a !== false && $a !== nil ?(self['$<=>'](other))['$zero?']() : $a); - }); - - Opal.defn(self, '$friday?', function() { - var self = this; - - return self.$wday() == 5; - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return 'Time:' + self.getTime(); - }); - - Opal.defn(self, '$hour', function() { - var self = this; - - return self.is_utc ? self.getUTCHours() : self.getHours(); - }); - - Opal.defn(self, '$inspect', function() { - var $a, self = this; - - if ((($a = self['$utc?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$strftime("%Y-%m-%d %H:%M:%S UTC") - } else { - return self.$strftime("%Y-%m-%d %H:%M:%S %z") - }; - }); - - Opal.alias(self, 'mday', 'day'); - - Opal.defn(self, '$min', function() { - var self = this; - - return self.is_utc ? self.getUTCMinutes() : self.getMinutes(); - }); - - Opal.defn(self, '$mon', function() { - var self = this; - - return (self.is_utc ? self.getUTCMonth() : self.getMonth()) + 1; - }); - - Opal.defn(self, '$monday?', function() { - var self = this; - - return self.$wday() == 1; - }); - - Opal.alias(self, 'month', 'mon'); - - Opal.defn(self, '$saturday?', function() { - var self = this; - - return self.$wday() == 6; - }); - - Opal.defn(self, '$sec', function() { - var self = this; - - return self.is_utc ? self.getUTCSeconds() : self.getSeconds(); - }); - - Opal.defn(self, '$succ', function() { - var self = this; - - - var result = new Date(self.getTime() + 1000); - result.is_utc = self.is_utc; - return result; - - }); - - Opal.defn(self, '$usec', function() { - var self = this; - - return self.getMilliseconds() * 1000; - }); - - Opal.defn(self, '$zone', function() { - var self = this; - - - var string = self.toString(), - result; - - if (string.indexOf('(') == -1) { - result = string.match(/[A-Z]{3,4}/)[0]; - } - else { - result = string.match(/\([^)]+\)/)[0].match(/[A-Z]/g).join(''); - } - - if (result == "GMT" && /(GMT\W*\d{4})/.test(string)) { - return RegExp.$1; - } - else { - return result; - } - - }); - - Opal.defn(self, '$getgm', function() { - var self = this; - - - var result = new Date(self.getTime()); - result.is_utc = true; - return result; - - }); - - Opal.alias(self, 'getutc', 'getgm'); - - Opal.defn(self, '$gmtime', function() { - var self = this; - - - self.is_utc = true; - return self; - - }); - - Opal.alias(self, 'utc', 'gmtime'); - - Opal.defn(self, '$gmt?', function() { - var self = this; - - return self.is_utc === true; - }); - - Opal.defn(self, '$gmt_offset', function() { - var self = this; - - return -self.getTimezoneOffset() * 60; - }); - - Opal.defn(self, '$strftime', function(format) { - var self = this; - - - return format.replace(/%([\-_#^0]*:{0,2})(\d+)?([EO]*)(.)/g, function(full, flags, width, _, conv) { - var result = "", - zero = flags.indexOf('0') !== -1, - pad = flags.indexOf('-') === -1, - blank = flags.indexOf('_') !== -1, - upcase = flags.indexOf('^') !== -1, - invert = flags.indexOf('#') !== -1, - colons = (flags.match(':') || []).length; - - width = parseInt(width, 10); - - if (zero && blank) { - if (flags.indexOf('0') < flags.indexOf('_')) { - zero = false; - } - else { - blank = false; - } - } - - switch (conv) { - case 'Y': - result += self.$year(); - break; - - case 'C': - zero = !blank; - result += Math.round(self.$year() / 100); - break; - - case 'y': - zero = !blank; - result += (self.$year() % 100); - break; - - case 'm': - zero = !blank; - result += self.$mon(); - break; - - case 'B': - result += long_months[self.$mon() - 1]; - break; - - case 'b': - case 'h': - blank = !zero; - result += short_months[self.$mon() - 1]; - break; - - case 'd': - zero = !blank - result += self.$day(); - break; - - case 'e': - blank = !zero - result += self.$day(); - break; - - case 'j': - result += self.$yday(); - break; - - case 'H': - zero = !blank; - result += self.$hour(); - break; - - case 'k': - blank = !zero; - result += self.$hour(); - break; - - case 'I': - zero = !blank; - result += (self.$hour() % 12 || 12); - break; - - case 'l': - blank = !zero; - result += (self.$hour() % 12 || 12); - break; - - case 'P': - result += (self.$hour() >= 12 ? "pm" : "am"); - break; - - case 'p': - result += (self.$hour() >= 12 ? "PM" : "AM"); - break; - - case 'M': - zero = !blank; - result += self.$min(); - break; - - case 'S': - zero = !blank; - result += self.$sec() - break; - - case 'L': - zero = !blank; - width = isNaN(width) ? 3 : width; - result += self.getMilliseconds(); - break; - - case 'N': - width = isNaN(width) ? 9 : width; - result += (self.getMilliseconds().toString()).$rjust(3, "0"); - result = (result).$ljust(width, "0"); - break; - - case 'z': - var offset = self.getTimezoneOffset(), - hours = Math.floor(Math.abs(offset) / 60), - minutes = Math.abs(offset) % 60; - - result += offset < 0 ? "+" : "-"; - result += hours < 10 ? "0" : ""; - result += hours; - - if (colons > 0) { - result += ":"; - } - - result += minutes < 10 ? "0" : ""; - result += minutes; - - if (colons > 1) { - result += ":00"; - } - - break; - - case 'Z': - result += self.$zone(); - break; - - case 'A': - result += days_of_week[self.$wday()]; - break; - - case 'a': - result += short_days[self.$wday()]; - break; - - case 'u': - result += (self.$wday() + 1); - break; - - case 'w': - result += self.$wday(); - break; - - case 'V': - result += self.$cweek_cyear()['$[]'](0).$to_s().$rjust(2, "0"); - break; - - case 'G': - result += self.$cweek_cyear()['$[]'](1); - break; - - case 'g': - result += self.$cweek_cyear()['$[]'](1)['$[]']($range(-2, -1, false)); - break; - - case 's': - result += self.$to_i(); - break; - - case 'n': - result += "\n"; - break; - - case 't': - result += "\t"; - break; - - case '%': - result += "%"; - break; - - case 'c': - result += self.$strftime("%a %b %e %T %Y"); - break; - - case 'D': - case 'x': - result += self.$strftime("%m/%d/%y"); - break; - - case 'F': - result += self.$strftime("%Y-%m-%d"); - break; - - case 'v': - result += self.$strftime("%e-%^b-%4Y"); - break; - - case 'r': - result += self.$strftime("%I:%M:%S %p"); - break; - - case 'R': - result += self.$strftime("%H:%M"); - break; - - case 'T': - case 'X': - result += self.$strftime("%H:%M:%S"); - break; - - default: - return full; - } - - if (upcase) { - result = result.toUpperCase(); - } - - if (invert) { - result = result.replace(/[A-Z]/, function(c) { c.toLowerCase() }). - replace(/[a-z]/, function(c) { c.toUpperCase() }); - } - - if (pad && (zero || blank)) { - result = (result).$rjust(isNaN(width) ? 2 : width, blank ? " " : "0"); - } - - return result; - }); - - }); - - Opal.defn(self, '$sunday?', function() { - var self = this; - - return self.$wday() == 0; - }); - - Opal.defn(self, '$thursday?', function() { - var self = this; - - return self.$wday() == 4; - }); - - Opal.defn(self, '$to_a', function() { - var self = this; - - return [self.$sec(), self.$min(), self.$hour(), self.$day(), self.$month(), self.$year(), self.$wday(), self.$yday(), self.$isdst(), self.$zone()]; - }); - - Opal.defn(self, '$to_f', function() { - var self = this; - - return self.getTime() / 1000; - }); - - Opal.defn(self, '$to_i', function() { - var self = this; - - return parseInt(self.getTime() / 1000, 10); - }); - - Opal.alias(self, 'to_s', 'inspect'); - - Opal.defn(self, '$tuesday?', function() { - var self = this; - - return self.$wday() == 2; - }); - - Opal.alias(self, 'tv_sec', 'sec'); - - Opal.alias(self, 'tv_usec', 'usec'); - - Opal.alias(self, 'utc?', 'gmt?'); - - Opal.alias(self, 'gmtoff', 'gmt_offset'); - - Opal.alias(self, 'utc_offset', 'gmt_offset'); - - Opal.defn(self, '$wday', function() { - var self = this; - - return self.is_utc ? self.getUTCDay() : self.getDay(); - }); - - Opal.defn(self, '$wednesday?', function() { - var self = this; - - return self.$wday() == 3; - }); - - Opal.defn(self, '$year', function() { - var self = this; - - return self.is_utc ? self.getUTCFullYear() : self.getFullYear(); - }); - - return (Opal.defn(self, '$cweek_cyear', function() { - var $a, $b, self = this, jan01 = nil, jan01_wday = nil, first_monday = nil, year = nil, offset = nil, week = nil, dec31 = nil, dec31_wday = nil; - - jan01 = $scope.get('Time').$new(self.$year(), 1, 1); - jan01_wday = jan01.$wday(); - first_monday = 0; - year = self.$year(); - if ((($a = (($b = $rb_le(jan01_wday, 4)) ? jan01_wday['$!='](0) : $rb_le(jan01_wday, 4))) !== nil && (!$a.$$is_boolean || $a == true))) { - offset = $rb_minus(jan01_wday, 1) - } else { - offset = $rb_minus($rb_minus(jan01_wday, 7), 1); - if (offset['$=='](-8)) { - offset = -1}; - }; - week = ($rb_divide(($rb_plus(self.$yday(), offset)), 7.0)).$ceil(); - if ($rb_le(week, 0)) { - return $scope.get('Time').$new($rb_minus(self.$year(), 1), 12, 31).$cweek_cyear() - } else if (week['$=='](53)) { - dec31 = $scope.get('Time').$new(self.$year(), 12, 31); - dec31_wday = dec31.$wday(); - if ((($a = (($b = $rb_le(dec31_wday, 3)) ? dec31_wday['$!='](0) : $rb_le(dec31_wday, 3))) !== nil && (!$a.$$is_boolean || $a == true))) { - week = 1; - year = $rb_plus(year, 1);};}; - return [week, year]; - }), nil) && 'cweek_cyear'; - })($scope.base, Date); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/struct"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - 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_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, $klass = Opal.klass, $hash2 = Opal.hash2; - - Opal.add_stubs(['$require', '$include', '$==', '$[]', '$upcase', '$const_set', '$new', '$unshift', '$each', '$define_struct_attribute', '$class_eval', '$to_proc', '$allocate', '$initialize', '$raise', '$<<', '$members', '$define_method', '$[]=', '$instance_eval', '$each_with_index', '$class', '$hash', '$===', '$<', '$-@', '$size', '$>=', '$include?', '$to_sym', '$coerce_to!', '$instance_of?', '$__id__', '$eql?', '$enum_for', '$length', '$map', '$+', '$join', '$inspect', '$each_pair', '$inject', '$flatten', '$to_a']); - self.$require("corelib/enumerable"); - return (function($base, $super) { - function $Struct(){}; - var self = $Struct = $klass($base, $super, 'Struct', $Struct); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_8, TMP_11; - - self.$include($scope.get('Enumerable')); - - Opal.defs(self, '$new', TMP_1 = function(name) {var $zuper = $slice.call(arguments, 0); - var $a, $b, $c, TMP_2, self = this, $iter = TMP_1.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - TMP_1.$$p = null; - if (self['$==']($scope.get('Struct'))) { - } else { - return Opal.find_super_dispatcher(self, 'new', TMP_1, $iter, $Struct).apply(self, $zuper) - }; - if (name['$[]'](0)['$=='](name['$[]'](0).$upcase())) { - return $scope.get('Struct').$const_set(name, ($a = self).$new.apply($a, Opal.to_a(args))) - } else { - args.$unshift(name); - return ($b = ($c = $scope.get('Class')).$new, $b.$$p = (TMP_2 = function(){var self = TMP_2.$$s || this, $a, $b, TMP_3, $c; - - ($a = ($b = args).$each, $a.$$p = (TMP_3 = function(arg){var self = TMP_3.$$s || this; -if (arg == null) arg = nil; - return self.$define_struct_attribute(arg)}, TMP_3.$$s = self, TMP_3), $a).call($b); - if (block !== false && block !== nil) { - ($a = ($c = self).$class_eval, $a.$$p = block.$to_proc(), $a).call($c)}; - return (function(self) { - var $scope = self.$$scope, def = self.$$proto; - - Opal.defn(self, '$new', function() { - var $a, self = this, instance = 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]; - } - instance = self.$allocate(); - instance.$$data = {};; - ($a = instance).$initialize.apply($a, Opal.to_a(args)); - return instance; - }); - return Opal.alias(self, '[]', 'new'); - })(Opal.get_singleton_class(self));}, TMP_2.$$s = self, TMP_2), $b).call($c, self); - }; - }); - - Opal.defs(self, '$define_struct_attribute', function(name) { - var $a, $b, TMP_4, $c, TMP_5, self = this; - - if (self['$==']($scope.get('Struct'))) { - self.$raise($scope.get('ArgumentError'), "you cannot define attributes to the Struct class")}; - self.$members()['$<<'](name); - ($a = ($b = self).$define_method, $a.$$p = (TMP_4 = function(){var self = TMP_4.$$s || this; - - return self['$[]'](name)}, TMP_4.$$s = self, TMP_4), $a).call($b, name); - return ($a = ($c = self).$define_method, $a.$$p = (TMP_5 = function(value){var self = TMP_5.$$s || this; -if (value == null) value = nil; - return self['$[]='](name, value)}, TMP_5.$$s = self, TMP_5), $a).call($c, "" + (name) + "="); - }); - - Opal.defs(self, '$members', function() { - var $a, self = this; - if (self.members == null) self.members = nil; - - if (self['$==']($scope.get('Struct'))) { - self.$raise($scope.get('ArgumentError'), "the Struct class has no members")}; - return ((($a = self.members) !== false && $a !== nil) ? $a : self.members = []); - }); - - Opal.defs(self, '$inherited', function(klass) { - var $a, $b, TMP_6, self = this, members = nil; - if (self.members == null) self.members = nil; - - members = self.members; - return ($a = ($b = klass).$instance_eval, $a.$$p = (TMP_6 = function(){var self = TMP_6.$$s || this; - - return self.members = members}, TMP_6.$$s = self, TMP_6), $a).call($b); - }); - - Opal.defn(self, '$initialize', function() { - var $a, $b, TMP_7, 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 ($a = ($b = self.$members()).$each_with_index, $a.$$p = (TMP_7 = function(name, index){var self = TMP_7.$$s || this; -if (name == null) name = nil;if (index == null) index = nil; - return self['$[]='](name, args['$[]'](index))}, TMP_7.$$s = self, TMP_7), $a).call($b); - }); - - Opal.defn(self, '$members', function() { - var self = this; - - return self.$class().$members(); - }); - - Opal.defn(self, '$hash', function() { - var self = this; - - return $scope.get('Hash').$new(self.$$data).$hash(); - }); - - Opal.defn(self, '$[]', function(name) { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ($rb_lt(name, self.$members().$size()['$-@']())) { - self.$raise($scope.get('IndexError'), "offset " + (name) + " too small for struct(size:" + (self.$members().$size()) + ")")}; - if ($rb_ge(name, self.$members().$size())) { - self.$raise($scope.get('IndexError'), "offset " + (name) + " too large for struct(size:" + (self.$members().$size()) + ")")}; - name = self.$members()['$[]'](name); - } else if ((($a = $scope.get('String')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self.$members()['$include?'](name.$to_sym())) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("no member '" + (name) + "' in struct", name)) - } - } else { - self.$raise($scope.get('TypeError'), "no implicit conversion of " + (name.$class()) + " into Integer") - }; - name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str"); - return self.$$data[name]; - }); - - Opal.defn(self, '$[]=', function(name, value) { - var $a, self = this; - - if ((($a = $scope.get('Integer')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ($rb_lt(name, self.$members().$size()['$-@']())) { - self.$raise($scope.get('IndexError'), "offset " + (name) + " too small for struct(size:" + (self.$members().$size()) + ")")}; - if ($rb_ge(name, self.$members().$size())) { - self.$raise($scope.get('IndexError'), "offset " + (name) + " too large for struct(size:" + (self.$members().$size()) + ")")}; - name = self.$members()['$[]'](name); - } else if ((($a = $scope.get('String')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self.$members()['$include?'](name.$to_sym())) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('NameError').$new("no member '" + (name) + "' in struct", name)) - } - } else { - self.$raise($scope.get('TypeError'), "no implicit conversion of " + (name.$class()) + " into Integer") - }; - name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str"); - return self.$$data[name] = value; - }); - - Opal.defn(self, '$==', function(other) { - var $a, self = this; - - if ((($a = other['$instance_of?'](self.$class())) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return false - }; - - var recursed1 = {}, recursed2 = {}; - - function _eqeq(struct, other) { - var key, a, b; - - recursed1[(struct).$__id__()] = true; - recursed2[(other).$__id__()] = true; - - for (key in struct.$$data) { - a = struct.$$data[key]; - b = other.$$data[key]; - - if ($scope.get('Struct')['$==='](a)) { - if (!recursed1.hasOwnProperty((a).$__id__()) || !recursed2.hasOwnProperty((b).$__id__())) { - if (!_eqeq(a, b)) { - return false; - } - } - } else { - if (!(a)['$=='](b)) { - return false; - } - } - } - - return true; - } - - return _eqeq(self, other); - ; - }); - - Opal.defn(self, '$eql?', function(other) { - var $a, self = this; - - if ((($a = other['$instance_of?'](self.$class())) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - return false - }; - - var recursed1 = {}, recursed2 = {}; - - function _eqeq(struct, other) { - var key, a, b; - - recursed1[(struct).$__id__()] = true; - recursed2[(other).$__id__()] = true; - - for (key in struct.$$data) { - a = struct.$$data[key]; - b = other.$$data[key]; - - if ($scope.get('Struct')['$==='](a)) { - if (!recursed1.hasOwnProperty((a).$__id__()) || !recursed2.hasOwnProperty((b).$__id__())) { - if (!_eqeq(a, b)) { - return false; - } - } - } else { - if (!(a)['$eql?'](b)) { - return false; - } - } - } - - return true; - } - - return _eqeq(self, other); - ; - }); - - Opal.defn(self, '$each', TMP_8 = function() { - var $a, $b, TMP_9, $c, TMP_10, self = this, $iter = TMP_8.$$p, $yield = $iter || nil; - - TMP_8.$$p = null; - if (($yield !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_9 = function(){var self = TMP_9.$$s || this; - - return self.$size()}, TMP_9.$$s = self, TMP_9), $a).call($b, "each") - }; - ($a = ($c = self.$members()).$each, $a.$$p = (TMP_10 = function(name){var self = TMP_10.$$s || this, $a; -if (name == null) name = nil; - return $a = Opal.yield1($yield, self['$[]'](name)), $a === $breaker ? $a : $a}, TMP_10.$$s = self, TMP_10), $a).call($c); - return self; - }); - - Opal.defn(self, '$each_pair', TMP_11 = function() { - var $a, $b, TMP_12, $c, TMP_13, self = this, $iter = TMP_11.$$p, $yield = $iter || nil; - - TMP_11.$$p = null; - if (($yield !== nil)) { - } else { - return ($a = ($b = self).$enum_for, $a.$$p = (TMP_12 = function(){var self = TMP_12.$$s || this; - - return self.$size()}, TMP_12.$$s = self, TMP_12), $a).call($b, "each_pair") - }; - ($a = ($c = self.$members()).$each, $a.$$p = (TMP_13 = function(name){var self = TMP_13.$$s || this, $a; -if (name == null) name = nil; - return $a = Opal.yield1($yield, [name, self['$[]'](name)]), $a === $breaker ? $a : $a}, TMP_13.$$s = self, TMP_13), $a).call($c); - return self; - }); - - Opal.defn(self, '$length', function() { - var self = this; - - return self.$members().$length(); - }); - - Opal.alias(self, 'size', 'length'); - - Opal.defn(self, '$to_a', function() { - var $a, $b, TMP_14, self = this; - - return ($a = ($b = self.$members()).$map, $a.$$p = (TMP_14 = function(name){var self = TMP_14.$$s || this; -if (name == null) name = nil; - return self['$[]'](name)}, TMP_14.$$s = self, TMP_14), $a).call($b); - }); - - Opal.alias(self, 'values', 'to_a'); - - Opal.defn(self, '$inspect', function() { - var $a, $b, TMP_15, self = this, result = nil; - - result = "#"); - return result; - }); - - Opal.alias(self, 'to_s', 'inspect'); - - Opal.defn(self, '$to_h', function() { - var $a, $b, TMP_16, self = this; - - return ($a = ($b = self.$members()).$inject, $a.$$p = (TMP_16 = function(h, name){var self = TMP_16.$$s || this; -if (h == null) h = nil;if (name == null) name = nil; - h['$[]='](name, self['$[]'](name)); - return h;}, TMP_16.$$s = self, TMP_16), $a).call($b, $hash2([], {})); - }); - - return (Opal.defn(self, '$values_at', function() { - var $a, $b, TMP_17, 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]; - } - args = ($a = ($b = args).$map, $a.$$p = (TMP_17 = function(arg){var self = TMP_17.$$s || this; -if (arg == null) arg = nil; - return arg.$$is_range ? arg.$to_a() : arg;}, TMP_17.$$s = self, TMP_17), $a).call($b).$flatten(); - - var result = []; - for (var i = 0, len = args.length; i < len; i++) { - if (!args[i].$$is_number) { - self.$raise($scope.get('TypeError'), "no implicit conversion of " + ((args[i]).$class()) + " into Integer") - } - result.push(self['$[]'](args[i])); - } - return result; - ; - }), nil) && 'values_at'; - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/io"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - var $a, $b, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module, $gvars = Opal.gvars; - if ($gvars.stdout == null) $gvars.stdout = nil; - if ($gvars.stderr == null) $gvars.stderr = nil; - - Opal.add_stubs(['$attr_accessor', '$size', '$write', '$join', '$map', '$String', '$empty?', '$concat', '$chomp', '$getbyte', '$getc', '$raise', '$new', '$write_proc=', '$extend']); - (function($base, $super) { - function $IO(){}; - var self = $IO = $klass($base, $super, 'IO', $IO); - - var def = self.$$proto, $scope = self.$$scope; - - def.tty = def.closed = nil; - Opal.cdecl($scope, 'SEEK_SET', 0); - - Opal.cdecl($scope, 'SEEK_CUR', 1); - - Opal.cdecl($scope, 'SEEK_END', 2); - - Opal.defn(self, '$tty?', function() { - var self = this; - - return self.tty; - }); - - Opal.defn(self, '$closed?', function() { - var self = this; - - return self.closed; - }); - - self.$attr_accessor("write_proc"); - - Opal.defn(self, '$write', function(string) { - var self = this; - - self.write_proc(string); - return string.$size(); - }); - - self.$attr_accessor("sync"); - - (function($base) { - var self = $module($base, 'Writable'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$<<', function(string) { - var self = this; - - self.$write(string); - return self; - }); - - Opal.defn(self, '$print', function() { - var $a, $b, TMP_1, self = this; - if ($gvars[","] == null) $gvars[","] = 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]; - } - self.$write(($a = ($b = args).$map, $a.$$p = (TMP_1 = function(arg){var self = TMP_1.$$s || this; -if (arg == null) arg = nil; - return self.$String(arg)}, TMP_1.$$s = self, TMP_1), $a).call($b).$join($gvars[","])); - return nil; - }); - - Opal.defn(self, '$puts', function() { - var $a, $b, TMP_2, self = this, newline = nil; - if ($gvars["/"] == null) $gvars["/"] = 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]; - } - newline = $gvars["/"]; - if ((($a = args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$write($gvars["/"]) - } else { - self.$write(($a = ($b = args).$map, $a.$$p = (TMP_2 = function(arg){var self = TMP_2.$$s || this; -if (arg == null) arg = nil; - return self.$String(arg).$chomp()}, TMP_2.$$s = self, TMP_2), $a).call($b).$concat([nil]).$join(newline)) - }; - return nil; - }); - })($scope.base); - - return (function($base) { - var self = $module($base, 'Readable'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$readbyte', function() { - var self = this; - - return self.$getbyte(); - }); - - Opal.defn(self, '$readchar', function() { - var self = this; - - return self.$getc(); - }); - - Opal.defn(self, '$readline', function(sep) { - var self = this; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (sep == null) { - sep = $gvars["/"] - } - return self.$raise($scope.get('NotImplementedError')); - }); - - Opal.defn(self, '$readpartial', function(integer, outbuf) { - var self = this; - - if (outbuf == null) { - outbuf = nil - } - return self.$raise($scope.get('NotImplementedError')); - }); - })($scope.base); - })($scope.base, null); - Opal.cdecl($scope, 'STDERR', $gvars.stderr = $scope.get('IO').$new()); - Opal.cdecl($scope, 'STDIN', $gvars.stdin = $scope.get('IO').$new()); - Opal.cdecl($scope, 'STDOUT', $gvars.stdout = $scope.get('IO').$new()); - (($a = [typeof(process) === 'object' ? function(s){process.stdout.write(s)} : function(s){console.log(s)}]), $b = $gvars.stdout, $b['$write_proc='].apply($b, $a), $a[$a.length-1]); - (($a = [typeof(process) === 'object' ? function(s){process.stderr.write(s)} : function(s){console.warn(s)}]), $b = $gvars.stderr, $b['$write_proc='].apply($b, $a), $a[$a.length-1]); - $gvars.stdout.$extend((($scope.get('IO')).$$scope.get('Writable'))); - return $gvars.stderr.$extend((($scope.get('IO')).$$scope.get('Writable'))); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/main"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.add_stubs(['$include']); - Opal.defs(self, '$to_s', function() { - var self = this; - - return "main"; - }); - return (Opal.defs(self, '$include', function(mod) { - var self = this; - - return $scope.get('Object').$include(mod); - }), nil) && 'include'; -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/dir"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$[]']); - return (function($base, $super) { - function $Dir(){}; - var self = $Dir = $klass($base, $super, 'Dir', $Dir); - - var def = self.$$proto, $scope = self.$$scope; - - return (function(self) { - var $scope = self.$$scope, def = self.$$proto, TMP_1; - - Opal.defn(self, '$chdir', TMP_1 = function(dir) { - var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, prev_cwd = nil; - - TMP_1.$$p = null; - try { - prev_cwd = Opal.current_dir; - Opal.current_dir = dir; - return $a = Opal.yieldX($yield, []), $a === $breaker ? $a : $a; - } finally { - Opal.current_dir = prev_cwd; - }; - }); - Opal.defn(self, '$pwd', function() { - var self = this; - - return Opal.current_dir || '.'; - }); - Opal.alias(self, 'getwd', 'pwd'); - return (Opal.defn(self, '$home', function() { - var $a, self = this; - - return ((($a = $scope.get('ENV')['$[]']("HOME")) !== false && $a !== nil) ? $a : "."); - }), nil) && 'home'; - })(Opal.get_singleton_class(self)) - })($scope.base, null) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/file"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass, $range = Opal.range; - - Opal.add_stubs(['$join', '$compact', '$split', '$==', '$first', '$[]=', '$home', '$each', '$pop', '$<<', '$[]', '$gsub', '$find', '$=~']); - return (function($base, $super) { - function $File(){}; - var self = $File = $klass($base, $super, 'File', $File); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.cdecl($scope, 'Separator', Opal.cdecl($scope, 'SEPARATOR', "/")); - - Opal.cdecl($scope, 'ALT_SEPARATOR', nil); - - Opal.cdecl($scope, 'PATH_SEPARATOR', ":"); - - return (function(self) { - var $scope = self.$$scope, def = self.$$proto; - - Opal.defn(self, '$expand_path', function(path, basedir) { - var $a, $b, TMP_1, self = this, parts = nil, new_parts = nil; - - if (basedir == null) { - basedir = nil - } - path = [basedir, path].$compact().$join($scope.get('SEPARATOR')); - parts = path.$split($scope.get('SEPARATOR')); - new_parts = []; - if (parts.$first()['$==']("~")) { - parts['$[]='](0, $scope.get('Dir').$home())}; - ($a = ($b = parts).$each, $a.$$p = (TMP_1 = function(part){var self = TMP_1.$$s || this; -if (part == null) part = nil; - if (part['$==']("..")) { - return new_parts.$pop() - } else { - return new_parts['$<<'](part) - }}, TMP_1.$$s = self, TMP_1), $a).call($b); - return new_parts.$join($scope.get('SEPARATOR')); - }); - Opal.alias(self, 'realpath', 'expand_path'); - Opal.defn(self, '$dirname', function(path) { - var self = this; - - return self.$split(path)['$[]']($range(0, -2, false)); - }); - Opal.defn(self, '$basename', function(path) { - var self = this; - - return self.$split(path)['$[]'](-1); - }); - Opal.defn(self, '$exist?', function(path) { - var self = this; - - return Opal.modules[path] != null; - }); - Opal.alias(self, 'exists?', 'exist?'); - Opal.defn(self, '$directory?', function(path) { - var $a, $b, TMP_2, self = this, files = nil, file = nil; - - files = []; - - for (var key in Opal.modules) { - files.push(key) - } - ; - path = path.$gsub((new RegExp("(^." + $scope.get('SEPARATOR') + "+|" + $scope.get('SEPARATOR') + "+$)"))); - file = ($a = ($b = files).$find, $a.$$p = (TMP_2 = function(file){var self = TMP_2.$$s || this; -if (file == null) file = nil; - return file['$=~']((new RegExp("^" + path)))}, TMP_2.$$s = self, TMP_2), $a).call($b); - return file; - }); - Opal.defn(self, '$join', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var paths = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - paths[arg_index] = arguments[arg_index + 0]; - } - return paths.$join($scope.get('SEPARATOR')).$gsub((new RegExp("" + $scope.get('SEPARATOR') + "+")), $scope.get('SEPARATOR')); - }); - return (Opal.defn(self, '$split', function(path) { - var self = this; - - return path.$split($scope.get('SEPARATOR')); - }), nil) && 'split'; - })(Opal.get_singleton_class(self)); - })($scope.base, $scope.get('IO')) -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/process"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass; - - Opal.add_stubs(['$to_f', '$now', '$new']); - (function($base, $super) { - function $Process(){}; - var self = $Process = $klass($base, $super, 'Process', $Process); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.cdecl($scope, 'CLOCK_REALTIME', 0); - - Opal.cdecl($scope, 'CLOCK_MONOTONIC', 1); - - Opal.defs(self, '$pid', function() { - var self = this; - - return 0; - }); - - Opal.defs(self, '$times', function() { - var self = this, t = nil; - - t = $scope.get('Time').$now().$to_f(); - return (($scope.get('Benchmark')).$$scope.get('Tms')).$new(t, t, t, t, t); - }); - - return (Opal.defs(self, '$clock_gettime', function(clock_id, unit) { - var self = this; - - if (unit == null) { - unit = nil - } - return $scope.get('Time').$now().$to_f(); - }), nil) && 'clock_gettime'; - })($scope.base, null); - (function($base, $super) { - function $Signal(){}; - var self = $Signal = $klass($base, $super, 'Signal', $Signal); - - var def = self.$$proto, $scope = self.$$scope; - - return (Opal.defs(self, '$trap', function() { - var self = this; - - return nil; - }), nil) && 'trap' - })($scope.base, null); - return (function($base, $super) { - function $GC(){}; - var self = $GC = $klass($base, $super, 'GC', $GC); - - var def = self.$$proto, $scope = self.$$scope; - - return (Opal.defs(self, '$start', function() { - var self = this; - - return nil; - }), nil) && 'start' - })($scope.base, null); -}; -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["corelib/unsupported"] = function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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, $klass = Opal.klass, $module = Opal.module; - - Opal.add_stubs(['$warn', '$raise', '$%', '$module_function']); - - var warnings = {}; - - function warn(string) { - if (warnings[string]) { - return; - } - - warnings[string] = true; - self.$warn(string); - } - - (function($base, $super) { - function $String(){}; - var self = $String = $klass($base, $super, 'String', $String); - - var def = self.$$proto, $scope = self.$$scope; - - var ERROR = "String#%s not supported. Mutable String methods are not supported in Opal."; - - Opal.defn(self, '$<<', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("<<")); - }); - - Opal.defn(self, '$capitalize!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("capitalize!")); - }); - - Opal.defn(self, '$chomp!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("chomp!")); - }); - - Opal.defn(self, '$chop!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("chop!")); - }); - - Opal.defn(self, '$downcase!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("downcase!")); - }); - - Opal.defn(self, '$gsub!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("gsub!")); - }); - - Opal.defn(self, '$lstrip!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("lstrip!")); - }); - - Opal.defn(self, '$next!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("next!")); - }); - - Opal.defn(self, '$reverse!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("reverse!")); - }); - - Opal.defn(self, '$slice!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("slice!")); - }); - - Opal.defn(self, '$squeeze!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("squeeze!")); - }); - - Opal.defn(self, '$strip!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("strip!")); - }); - - Opal.defn(self, '$sub!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("sub!")); - }); - - Opal.defn(self, '$succ!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("succ!")); - }); - - Opal.defn(self, '$swapcase!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("swapcase!")); - }); - - Opal.defn(self, '$tr!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("tr!")); - }); - - Opal.defn(self, '$tr_s!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("tr_s!")); - }); - - return (Opal.defn(self, '$upcase!', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), (ERROR)['$%']("upcase!")); - }), nil) && 'upcase!'; - })($scope.base, null); - (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - var ERROR = "Object freezing is not supported by Opal"; - - Opal.defn(self, '$freeze', function() { - var $a, self = this; - - if ((($a = OPAL_CONFIG.freezing) !== nil && (!$a.$$is_boolean || $a == true))) { - warn(ERROR); - } else { - self.$raise($scope.get('NotImplementedError'), ERROR) - }; - return self; - }); - - Opal.defn(self, '$frozen?', function() { - var $a, self = this; - - if ((($a = OPAL_CONFIG.freezing) !== nil && (!$a.$$is_boolean || $a == true))) { - warn(ERROR); - } else { - self.$raise($scope.get('NotImplementedError'), ERROR) - }; - return false; - }); - })($scope.base); - (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - var ERROR = "Object tainting is not supported by Opal"; - - Opal.defn(self, '$taint', function() { - var $a, self = this; - - if ((($a = OPAL_CONFIG.tainting) !== nil && (!$a.$$is_boolean || $a == true))) { - warn(ERROR); - } else { - self.$raise($scope.get('NotImplementedError'), ERROR) - }; - return self; - }); - - Opal.defn(self, '$untaint', function() { - var $a, self = this; - - if ((($a = OPAL_CONFIG.tainting) !== nil && (!$a.$$is_boolean || $a == true))) { - warn(ERROR); - } else { - self.$raise($scope.get('NotImplementedError'), ERROR) - }; - return self; - }); - - Opal.defn(self, '$tainted?', function() { - var $a, self = this; - - if ((($a = OPAL_CONFIG.tainting) !== nil && (!$a.$$is_boolean || $a == true))) { - warn(ERROR); - } else { - self.$raise($scope.get('NotImplementedError'), ERROR) - }; - return false; - }); - })($scope.base); - (function($base) { - var self = $module($base, 'Marshal'); - - var def = self.$$proto, $scope = self.$$scope; - - var ERROR = "Marshalling is not supported by Opal"; - - self.$module_function(); - - Opal.defn(self, '$dump', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), ERROR); - }); - - Opal.defn(self, '$load', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), ERROR); - }); - - Opal.defn(self, '$restore', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), ERROR); - }); - })($scope.base); - (function($base, $super) { - function $Module(){}; - var self = $Module = $klass($base, $super, 'Module', $Module); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$public', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var methods = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - methods[arg_index] = arguments[arg_index + 0]; - } - - if (methods.length === 0) { - self.$$module_function = false; - } - - return nil; - - }); - - Opal.alias(self, 'private', 'public'); - - Opal.alias(self, 'protected', 'public'); - - Opal.alias(self, 'nesting', 'public'); - - Opal.defn(self, '$private_class_method', function() { - var self = this; - - return self; - }); - - Opal.alias(self, 'public_class_method', 'private_class_method'); - - Opal.defn(self, '$private_method_defined?', function(obj) { - var self = this; - - return false; - }); - - Opal.defn(self, '$private_constant', function() { - var self = this; - - return nil; - }); - - Opal.alias(self, 'protected_method_defined?', 'private_method_defined?'); - - Opal.alias(self, 'public_instance_methods', 'instance_methods'); - - return Opal.alias(self, 'public_method_defined?', 'method_defined?'); - })($scope.base, null); - (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$private_methods', function() { - var self = this; - - return []; - }); - - Opal.alias(self, 'private_instance_methods', 'private_methods'); - })($scope.base); - return (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$eval', function() { - var self = this; - - return self.$raise($scope.get('NotImplementedError'), "To use Kernel#eval, you must first require 'opal-parser'. " + ("See https://github.com/opal/opal/blob/" + ($scope.get('RUBY_ENGINE_VERSION')) + "/docs/opal_parser.md for details.")); - }) - })($scope.base); -}; -/* Generated by Opal 0.9.0.beta2 */ -(function(Opal) { - Opal.dynamic_require_severity = "warning"; - 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; - - Opal.add_stubs(['$require']); - self.$require("opal/base"); - self.$require("opal/mini"); - self.$require("corelib/array/inheritance"); - self.$require("corelib/string/inheritance"); - self.$require("corelib/string/encoding"); - self.$require("corelib/math"); - self.$require("corelib/complex"); - self.$require("corelib/rational"); - self.$require("corelib/time"); - self.$require("corelib/struct"); - self.$require("corelib/io"); - self.$require("corelib/main"); - self.$require("corelib/dir"); - self.$require("corelib/file"); - self.$require("corelib/process"); - return self.$require("corelib/unsupported"); -})(Opal); - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["set"] = function(Opal) { - Opal.dynamic_require_severity = "ignore"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - function $rb_lt(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, $klass = Opal.klass, $module = Opal.module; - - Opal.add_stubs(['$include', '$new', '$nil?', '$===', '$raise', '$each', '$add', '$call', '$merge', '$class', '$respond_to?', '$subtract', '$dup', '$join', '$to_a', '$equal?', '$instance_of?', '$==', '$instance_variable_get', '$is_a?', '$size', '$all?', '$include?', '$[]=', '$enum_for', '$[]', '$<<', '$replace', '$delete', '$select', '$each_key', '$to_proc', '$empty?', '$eql?', '$instance_eval', '$clear', '$<', '$<=', '$keys']); - (function($base, $super) { - function $Set(){}; - var self = $Set = $klass($base, $super, 'Set', $Set); - - var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_4, TMP_7, TMP_9, TMP_12; - - def.hash = nil; - self.$include($scope.get('Enumerable')); - - Opal.defs(self, '$[]', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var ary = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - ary[arg_index] = arguments[arg_index + 0]; - } - return self.$new(ary); - }); - - Opal.defn(self, '$initialize', TMP_1 = function(enum$) { - var $a, $b, TMP_2, self = this, $iter = TMP_1.$$p, block = $iter || nil; - - if (enum$ == null) { - enum$ = nil - } - TMP_1.$$p = null; - self.hash = $scope.get('Hash').$new(); - if ((($a = enum$['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil}; - if ((($a = $scope.get('Enumerable')['$==='](enum$)) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "value must be enumerable") - }; - if (block !== false && block !== nil) { - return ($a = ($b = enum$).$each, $a.$$p = (TMP_2 = function(item){var self = TMP_2.$$s || this; -if (item == null) item = nil; - return self.$add(block.$call(item))}, TMP_2.$$s = self, TMP_2), $a).call($b) - } else { - return self.$merge(enum$) - }; - }); - - Opal.defn(self, '$dup', function() { - var self = this, result = nil; - - result = self.$class().$new(); - return result.$merge(self); - }); - - Opal.defn(self, '$-', function(enum$) { - var $a, self = this; - - if ((($a = enum$['$respond_to?']("each")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "value must be enumerable") - }; - return self.$dup().$subtract(enum$); - }); - - Opal.alias(self, 'difference', '-'); - - Opal.defn(self, '$inspect', function() { - var self = this; - - return "#"; - }); - - Opal.defn(self, '$==', function(other) { - var $a, $b, TMP_3, self = this; - - if ((($a = self['$equal?'](other)) !== nil && (!$a.$$is_boolean || $a == true))) { - return true - } else if ((($a = other['$instance_of?'](self.$class())) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.hash['$=='](other.$instance_variable_get("@hash")) - } else if ((($a = ($b = other['$is_a?']($scope.get('Set')), $b !== false && $b !== nil ?self.$size()['$=='](other.$size()) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = ($b = other)['$all?'], $a.$$p = (TMP_3 = function(o){var self = TMP_3.$$s || this; - if (self.hash == null) self.hash = nil; -if (o == null) o = nil; - return self.hash['$include?'](o)}, TMP_3.$$s = self, TMP_3), $a).call($b) - } else { - return false - }; - }); - - Opal.defn(self, '$add', function(o) { - var self = this; - - self.hash['$[]='](o, true); - return self; - }); - - Opal.alias(self, '<<', 'add'); - - Opal.defn(self, '$classify', TMP_4 = function() { - var $a, $b, TMP_5, $c, TMP_6, self = this, $iter = TMP_4.$$p, block = $iter || nil, result = nil; - - TMP_4.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("classify") - }; - result = ($a = ($b = $scope.get('Hash')).$new, $a.$$p = (TMP_5 = function(h, k){var self = TMP_5.$$s || this; -if (h == null) h = nil;if (k == null) k = nil; - return h['$[]='](k, self.$class().$new())}, TMP_5.$$s = self, TMP_5), $a).call($b); - ($a = ($c = self).$each, $a.$$p = (TMP_6 = function(item){var self = TMP_6.$$s || this, $a; -if (item == null) item = nil; - return result['$[]'](((($a = Opal.yield1(block, item)) === $breaker) ? $breaker.$v : $a)).$add(item)}, TMP_6.$$s = self, TMP_6), $a).call($c); - return result; - }); - - Opal.defn(self, '$collect!', TMP_7 = function() { - var $a, $b, TMP_8, self = this, $iter = TMP_7.$$p, block = $iter || nil, result = nil; - - TMP_7.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("collect!") - }; - result = self.$class().$new(); - ($a = ($b = self).$each, $a.$$p = (TMP_8 = function(item){var self = TMP_8.$$s || this, $a; -if (item == null) item = nil; - return result['$<<'](((($a = Opal.yield1(block, item)) === $breaker) ? $breaker.$v : $a))}, TMP_8.$$s = self, TMP_8), $a).call($b); - return self.$replace(result); - }); - - Opal.alias(self, 'map!', 'collect!'); - - Opal.defn(self, '$delete', function(o) { - var self = this; - - self.hash.$delete(o); - return self; - }); - - Opal.defn(self, '$delete?', function(o) { - var $a, self = this; - - if ((($a = self['$include?'](o)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$delete(o); - return self; - } else { - return nil - }; - }); - - Opal.defn(self, '$delete_if', TMP_9 = function() {try { - - var $a, $b, TMP_10, $c, $d, TMP_11, self = this, $iter = TMP_9.$$p, $yield = $iter || nil; - - TMP_9.$$p = null; - ((($a = ($yield !== nil)) !== false && $a !== nil) ? $a : Opal.ret(self.$enum_for("delete_if"))); - ($a = ($b = ($c = ($d = self).$select, $c.$$p = (TMP_11 = function(o){var self = TMP_11.$$s || this, $a; -if (o == null) o = nil; - return $a = Opal.yield1($yield, o), $a === $breaker ? $a : $a}, TMP_11.$$s = self, TMP_11), $c).call($d)).$each, $a.$$p = (TMP_10 = function(o){var self = TMP_10.$$s || this; - if (self.hash == null) self.hash = nil; -if (o == null) o = nil; - return self.hash.$delete(o)}, TMP_10.$$s = self, TMP_10), $a).call($b); - return self; - } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } - }); - - Opal.defn(self, '$add?', function(o) { - var $a, self = this; - - if ((($a = self['$include?'](o)) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return self.$add(o) - }; - }); - - Opal.defn(self, '$each', TMP_12 = function() { - var $a, $b, self = this, $iter = TMP_12.$$p, block = $iter || nil; - - TMP_12.$$p = null; - if ((block !== nil)) { - } else { - return self.$enum_for("each") - }; - ($a = ($b = self.hash).$each_key, $a.$$p = block.$to_proc(), $a).call($b); - return self; - }); - - Opal.defn(self, '$empty?', function() { - var self = this; - - return self.hash['$empty?'](); - }); - - Opal.defn(self, '$eql?', function(other) { - var $a, $b, TMP_13, self = this; - - return self.hash['$eql?'](($a = ($b = other).$instance_eval, $a.$$p = (TMP_13 = function(){var self = TMP_13.$$s || this; - if (self.hash == null) self.hash = nil; - - return self.hash}, TMP_13.$$s = self, TMP_13), $a).call($b)); - }); - - Opal.defn(self, '$clear', function() { - var self = this; - - self.hash.$clear(); - return self; - }); - - Opal.defn(self, '$include?', function(o) { - var self = this; - - return self.hash['$include?'](o); - }); - - Opal.alias(self, 'member?', 'include?'); - - Opal.defn(self, '$merge', function(enum$) { - var $a, $b, TMP_14, self = this; - - ($a = ($b = enum$).$each, $a.$$p = (TMP_14 = function(item){var self = TMP_14.$$s || this; -if (item == null) item = nil; - return self.$add(item)}, TMP_14.$$s = self, TMP_14), $a).call($b); - return self; - }); - - Opal.defn(self, '$replace', function(enum$) { - var self = this; - - self.$clear(); - self.$merge(enum$); - return self; - }); - - Opal.defn(self, '$size', function() { - var self = this; - - return self.hash.$size(); - }); - - Opal.alias(self, 'length', 'size'); - - Opal.defn(self, '$subtract', function(enum$) { - var $a, $b, TMP_15, self = this; - - ($a = ($b = enum$).$each, $a.$$p = (TMP_15 = function(item){var self = TMP_15.$$s || this; -if (item == null) item = nil; - return self.$delete(item)}, TMP_15.$$s = self, TMP_15), $a).call($b); - return self; - }); - - Opal.defn(self, '$|', function(enum$) { - var $a, self = this; - - if ((($a = enum$['$respond_to?']("each")) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - self.$raise($scope.get('ArgumentError'), "value must be enumerable") - }; - return self.$dup().$merge(enum$); - }); - - Opal.defn(self, '$superset?', function(set) { - var $a, $b, TMP_16, self = this; - - ((($a = set['$is_a?']($scope.get('Set'))) !== false && $a !== nil) ? $a : self.$raise($scope.get('ArgumentError'), "value must be a set")); - if ($rb_lt(self.$size(), set.$size())) { - return false}; - return ($a = ($b = set)['$all?'], $a.$$p = (TMP_16 = function(o){var self = TMP_16.$$s || this; -if (o == null) o = nil; - return self['$include?'](o)}, TMP_16.$$s = self, TMP_16), $a).call($b); - }); - - Opal.alias(self, '>=', 'superset?'); - - Opal.defn(self, '$proper_superset?', function(set) { - var $a, $b, TMP_17, self = this; - - ((($a = set['$is_a?']($scope.get('Set'))) !== false && $a !== nil) ? $a : self.$raise($scope.get('ArgumentError'), "value must be a set")); - if ($rb_le(self.$size(), set.$size())) { - return false}; - return ($a = ($b = set)['$all?'], $a.$$p = (TMP_17 = function(o){var self = TMP_17.$$s || this; -if (o == null) o = nil; - return self['$include?'](o)}, TMP_17.$$s = self, TMP_17), $a).call($b); - }); - - Opal.alias(self, '>', 'proper_superset?'); - - Opal.defn(self, '$subset?', function(set) { - var $a, $b, TMP_18, self = this; - - ((($a = set['$is_a?']($scope.get('Set'))) !== false && $a !== nil) ? $a : self.$raise($scope.get('ArgumentError'), "value must be a set")); - if ($rb_lt(set.$size(), self.$size())) { - return false}; - return ($a = ($b = self)['$all?'], $a.$$p = (TMP_18 = function(o){var self = TMP_18.$$s || this; -if (o == null) o = nil; - return set['$include?'](o)}, TMP_18.$$s = self, TMP_18), $a).call($b); - }); - - Opal.alias(self, '<=', 'subset?'); - - Opal.defn(self, '$proper_subset?', function(set) { - var $a, $b, TMP_19, self = this; - - ((($a = set['$is_a?']($scope.get('Set'))) !== false && $a !== nil) ? $a : self.$raise($scope.get('ArgumentError'), "value must be a set")); - if ($rb_le(set.$size(), self.$size())) { - return false}; - return ($a = ($b = self)['$all?'], $a.$$p = (TMP_19 = function(o){var self = TMP_19.$$s || this; -if (o == null) o = nil; - return set['$include?'](o)}, TMP_19.$$s = self, TMP_19), $a).call($b); - }); - - Opal.alias(self, '<', 'proper_subset?'); - - Opal.alias(self, '+', '|'); - - Opal.alias(self, 'union', '|'); - - return (Opal.defn(self, '$to_a', function() { - var self = this; - - return self.hash.$keys(); - }), nil) && 'to_a'; - })($scope.base, null); - return (function($base) { - var self = $module($base, 'Enumerable'); - - var def = self.$$proto, $scope = self.$$scope, TMP_20; - - Opal.defn(self, '$to_set', TMP_20 = function(klass) { - var $a, $b, self = this, $iter = TMP_20.$$p, block = $iter || nil; - - var array_size = arguments.length - 1; - 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 + 1]; - } - if (klass == null) { - klass = $scope.get('Set') - } - TMP_20.$$p = null; - return ($a = ($b = klass).$new, $a.$$p = block.$to_proc(), $a).apply($b, [self].concat(Opal.to_a(args))); - }) - })($scope.base); -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["strscan"] = 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, $klass = Opal.klass; - - Opal.add_stubs(['$attr_reader', '$anchor', '$scan_until', '$length', '$size', '$rest', '$pos=', '$private']); - return (function($base, $super) { - function $StringScanner(){}; - var self = $StringScanner = $klass($base, $super, 'StringScanner', $StringScanner); - - var def = self.$$proto, $scope = self.$$scope; - - def.pos = def.string = def.working = def.matched = def.prev_pos = def.match = nil; - self.$attr_reader("pos"); - - self.$attr_reader("matched"); - - Opal.defn(self, '$initialize', function(string) { - var self = this; - - self.string = string; - self.pos = 0; - self.matched = nil; - self.working = string; - return self.match = []; - }); - - self.$attr_reader("string"); - - Opal.defn(self, '$beginning_of_line?', function() { - var self = this; - - return self.pos === 0 || self.string.charAt(self.pos - 1) === "\n"; - }); - - Opal.alias(self, 'bol?', 'beginning_of_line?'); - - Opal.defn(self, '$scan', function(pattern) { - var self = this; - - pattern = self.$anchor(pattern); - - var result = pattern.exec(self.working); - - if (result == null) { - return self.matched = nil; - } - else if (typeof(result) === 'object') { - self.prev_pos = self.pos; - self.pos += result[0].length; - self.working = self.working.substring(result[0].length); - self.matched = result[0]; - self.match = result; - - return result[0]; - } - else if (typeof(result) === 'string') { - self.pos += result.length; - self.working = self.working.substring(result.length); - - return result; - } - else { - return nil; - } - ; - }); - - Opal.defn(self, '$scan_until', function(pattern) { - var self = this; - - pattern = self.$anchor(pattern); - - var pos = self.pos, - working = self.working, - result; - - while (true) { - result = pattern.exec(working); - pos += 1; - working = working.substr(1); - - if (result == null) { - if (working.length === 0) { - return self.matched = nil; - } - - continue; - } - - self.matched = self.string.substr(self.pos, pos - self.pos - 1 + result[0].length); - self.prev_pos = pos - 1; - self.pos = pos; - self.working = working.substr(result[0].length); - - return self.matched; - } - ; - }); - - Opal.defn(self, '$[]', function(idx) { - var self = this; - - - var match = self.match; - - if (idx < 0) { - idx += match.length; - } - - if (idx < 0 || idx >= match.length) { - return nil; - } - - if (match[idx] == null) { - return nil; - } - - return match[idx]; - ; - }); - - Opal.defn(self, '$check', function(pattern) { - var self = this; - - pattern = self.$anchor(pattern); - - var result = pattern.exec(self.working); - - if (result == null) { - return self.matched = nil; - } - - return self.matched = result[0]; - ; - }); - - Opal.defn(self, '$check_until', function(pattern) { - var self = this; - - - var prev_pos = self.prev_pos, - pos = self.pos; - - var result = self.$scan_until(pattern); - - if (result !== nil) { - self.matched = result.substr(-1); - self.working = self.string.substr(pos); - } - - self.prev_pos = prev_pos; - self.pos = pos; - - return result; - ; - }); - - Opal.defn(self, '$peek', function(length) { - var self = this; - - return self.working.substring(0, length); - }); - - Opal.defn(self, '$eos?', function() { - var self = this; - - return self.working.length === 0; - }); - - Opal.defn(self, '$exist?', function(pattern) { - var self = this; - - - var result = pattern.exec(self.working); - - if (result == null) { - return nil; - } - else if (result.index == 0) { - return 0; - } - else { - return result.index + 1; - } - ; - }); - - Opal.defn(self, '$skip', function(pattern) { - var self = this; - - pattern = self.$anchor(pattern); - - var result = pattern.exec(self.working); - - if (result == null) { - return self.matched = nil; - } - else { - var match_str = result[0]; - var match_len = match_str.length; - - self.matched = match_str; - self.prev_pos = self.pos; - self.pos += match_len; - self.working = self.working.substring(match_len); - - return match_len; - } - ; - }); - - Opal.defn(self, '$skip_until', function(pattern) { - var self = this; - - - var result = self.$scan_until(pattern); - - if (result === nil) { - return nil; - } - else { - self.matched = result.substr(-1); - - return result.length; - } - ; - }); - - Opal.defn(self, '$get_byte', function() { - var self = this; - - - var result = nil; - - if (self.pos < self.string.length) { - self.prev_pos = self.pos; - self.pos += 1; - result = self.matched = self.working.substring(0, 1); - self.working = self.working.substring(1); - } - else { - self.matched = nil; - } - - return result; - ; - }); - - Opal.alias(self, 'getch', 'get_byte'); - - Opal.defn(self, '$match?', function(pattern) { - var self = this; - - pattern = self.$anchor(pattern); - - var result = pattern.exec(self.working); - - if (result == null) { - return nil; - } - else { - self.prev_pos = self.pos; - - return result[0].length; - } - ; - }); - - Opal.defn(self, '$pos=', function(pos) { - var self = this; - - - if (pos < 0) { - pos += self.string.$length(); - } - ; - self.pos = pos; - return self.working = self.string.slice(pos); - }); - - Opal.defn(self, '$post_match', function() { - var self = this; - - - if (self.matched === nil) { - return nil; - } - - return self.string.substr(self.pos); - ; - }); - - Opal.defn(self, '$pre_match', function() { - var self = this; - - - if (self.matched === nil) { - return nil; - } - - return self.string.substr(0, self.prev_pos); - ; - }); - - Opal.defn(self, '$reset', function() { - var self = this; - - self.working = self.string; - self.matched = nil; - return self.pos = 0; - }); - - Opal.defn(self, '$rest', function() { - var self = this; - - return self.working; - }); - - Opal.defn(self, '$rest?', function() { - var self = this; - - return self.working.length !== 0; - }); - - Opal.defn(self, '$rest_size', function() { - var self = this; - - return self.$rest().$size(); - }); - - Opal.defn(self, '$terminate', function() { - var $a, $b, self = this; - - self.match = nil; - return (($a = [self.string.$length()]), $b = self, $b['$pos='].apply($b, $a), $a[$a.length-1]); - }); - - Opal.defn(self, '$unscan', function() { - var self = this; - - self.pos = self.prev_pos; - self.prev_pos = nil; - self.match = nil; - return self; - }); - - self.$private(); - - return (Opal.defn(self, '$anchor', function(pattern) { - var self = this; - - return new RegExp('^' + pattern.toString().substr(1, pattern.toString().length - 2)); - }), nil) && 'anchor'; - })($scope.base, null) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext/dir"] = 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, $klass = Opal.klass; - - Opal.add_stubs(['$[]']); - return (function($base, $super) { - function $Dir(){}; - var self = $Dir = $klass($base, $super, 'Dir', $Dir); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defs(self, '$pwd', function() { - var $a, self = this; - - return ((($a = $scope.get('ENV')['$[]']("PWD")) !== false && $a !== nil) ? $a : "."); - }); - - Opal.defs(self, '$getwd', function() { - var $a, self = this; - - return ((($a = $scope.get('ENV')['$[]']("PWD")) !== false && $a !== nil) ? $a : "."); - }); - - return (Opal.defs(self, '$home', function() { - var self = this; - - return $scope.get('ENV')['$[]']("HOME"); - }), nil) && 'home'; - })($scope.base, null) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext/file"] = 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_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, $gvars = Opal.gvars, $range = Opal.range; - - Opal.add_stubs(['$new', '$attr_reader', '$read', '$size', '$to_enum', '$chomp', '$each_line', '$*', '$rindex', '$[]', '$+', '$-', '$nil_or_empty?', '$nil?', '$===']); - (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope, TMP_1; - - Opal.defn(self, '$open', TMP_1 = function(path) { - var $a, $b, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, file = nil; - - var array_size = arguments.length - 1; - if(array_size < 0) array_size = 0; - var rest = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - rest[arg_index] = arguments[arg_index + 1]; - } - TMP_1.$$p = null; - file = ($a = $scope.get('File')).$new.apply($a, [path].concat(Opal.to_a(rest))); - if (($yield !== nil)) { - return $b = Opal.yield1($yield, file), $b === $breaker ? $b : $b - } else { - return file - }; - }) - })($scope.base); - (function($base, $super) { - function $File(){}; - var self = $File = $klass($base, $super, 'File', $File); - - var def = self.$$proto, $scope = self.$$scope, TMP_2; - - def.eof = def.path = nil; - Opal.cdecl($scope, 'SEPARATOR', "/"); - - Opal.cdecl($scope, 'ALT_SEPARATOR', nil); - - self.$attr_reader("eof"); - - self.$attr_reader("lineno"); - - self.$attr_reader("path"); - - Opal.defn(self, '$initialize', function(path, mode) { - var self = this; - - if (mode == null) { - mode = "r" - } - self.path = path; - self.contents = nil; - self.eof = false; - return self.lineno = 0; - }); - - Opal.defn(self, '$read', function() { - var $a, self = this, res = nil; - - if ((($a = self.eof) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" - } else { - res = $scope.get('File').$read(self.path); - self.eof = true; - self.lineno = res.$size(); - return res; - }; - }); - - Opal.defn(self, '$each_line', TMP_2 = function(separator) { - var $a, self = this, $iter = TMP_2.$$p, block = $iter || nil, lines = nil; - if ($gvars["/"] == null) $gvars["/"] = nil; - - if (separator == null) { - separator = $gvars["/"] - } - TMP_2.$$p = null; - if ((($a = self.eof) !== nil && (!$a.$$is_boolean || $a == true))) { - return (function() {if ((block !== nil)) { - return self - } else { - return [].$to_enum() - }; return nil; })()}; - if ((block !== nil)) { - lines = $scope.get('File').$read(self.path); - - self.eof = false; - self.lineno = 0; - var chomped = lines.$chomp(), - trailing = lines.length != chomped.length, - splitted = chomped.split(separator); - - for (var i = 0, length = splitted.length; i < length; i++) { - self.lineno += 1; - if (i < length - 1 || trailing) { - ((($a = Opal.yield1(block, splitted[i] + separator)) === $breaker) ? $breaker.$v : $a); - } - else { - ((($a = Opal.yield1(block, splitted[i])) === $breaker) ? $breaker.$v : $a); - } - } - self.eof = true; - - return self; - } else { - return self.$read().$each_line() - }; - }); - - Opal.defs(self, '$expand_path', function(path) { - var self = this; - - return path; - }); - - Opal.defs(self, '$join', function() { - var self = this; - - var array_size = arguments.length - 0; - if(array_size < 0) array_size = 0; - var paths = new Array(array_size); - for(var arg_index = 0; arg_index < array_size; arg_index++) { - paths[arg_index] = arguments[arg_index + 0]; - } - return $rb_times(paths, $scope.get('SEPARATOR')); - }); - - Opal.defs(self, '$basename', function(path) { - var $a, self = this, offset = nil; - - if ((($a = (offset = path.$rindex($scope.get('SEPARATOR')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return path['$[]']($range(($rb_plus(offset, 1)), -1, false)) - } else { - return path - }; - }); - - Opal.defs(self, '$dirname', function(path) { - var $a, self = this, offset = nil; - - if ((($a = (offset = path.$rindex($scope.get('SEPARATOR')))) !== nil && (!$a.$$is_boolean || $a == true))) { - return path['$[]']($range(0, ($rb_minus(offset, 1)), false)) - } else { - return "." - }; - }); - - Opal.defs(self, '$extname', function(path) { - var $a, self = this, last_dot_idx = nil; - - if ((($a = path['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return ""}; - last_dot_idx = path['$[]']($range(1, -1, false)).$rindex("."); - if ((($a = last_dot_idx['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" - } else { - return path['$[]']($range(($rb_plus(last_dot_idx, 1)), -1, false)) - }; - }); - - Opal.defs(self, '$file?', function(path) { - var self = this; - - return true; - }); - - Opal.defs(self, '$readable?', function(path) { - var self = this; - - return true; - }); - - return (Opal.defs(self, '$read', function(path) { - var self = this, $case = nil; - - return (function() {$case = $scope.get('JAVASCRIPT_PLATFORM');if ("node"['$===']($case)) {return require('fs').readFileSync(path, 'utf8');}else if ("java-nashorn"['$===']($case)) { - var Paths = Java.type('java.nio.file.Paths'); - var Files = Java.type('java.nio.file.Files'); - var lines = Files.readAllLines(Paths.get(path), Java.type('java.nio.charset.StandardCharsets').UTF_8); - var data = []; - lines.forEach(function(line) { data.push(line); }); - return data.join("\n"); - }else if ("browser"['$===']($case)) { - var data = ''; - var status = -1; - try { - var xhr = new XMLHttpRequest(); - xhr.open('GET', path, false); - xhr.addEventListener('load', function() { - status = this.status; - // status is 0 for local file mode (i.e., file://) - if (status == 0 || status == 200) { - data = this.responseText; - } - }); - xhr.overrideMimeType('text/plain'); - xhr.send(); - } - catch (e) { - status = 0; - } - // assume that no data in local file mode means it doesn't exist - if (status == 404 || (status == 0 && data == '')) { - throw $scope.get('IOError').$new('No such file or directory: ' + path); - } - return data; - }else if ("standalone"['$===']($case)) {return read(path);}else {return ""}})(); - }), nil) && 'read'; - })($scope.base, null); - return (function($base, $super) { - function $IO(){}; - var self = $IO = $klass($base, $super, 'IO', $IO); - - var def = self.$$proto, $scope = self.$$scope; - - return (Opal.defs(self, '$read', function(path) { - var self = this; - - return $scope.get('File').$read(path); - }), nil) && 'read' - })($scope.base, null); -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext/match_data"] = 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, $klass = Opal.klass; - - Opal.add_stubs(['$[]=']); - return (function($base, $super) { - function $MatchData(){}; - var self = $MatchData = $klass($base, $super, 'MatchData', $MatchData); - - var def = self.$$proto, $scope = self.$$scope; - - def.matches = nil; - return (Opal.defn(self, '$[]=', function(idx, val) { - var self = this; - - return self.matches['$[]='](idx, val); - }), nil) && '[]=' - })($scope.base, null) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext/kernel"] = 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; - - return (function($base) { - var self = $module($base, 'Kernel'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defn(self, '$freeze', function() { - var self = this; - - return nil; - }) - })($scope.base) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext/nashorn/io"] = function(Opal) { - Opal.dynamic_require_severity = "ignore"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - var $a, $b, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $gvars = Opal.gvars; - if ($gvars.stdout == null) $gvars.stdout = nil; - if ($gvars.stderr == null) $gvars.stderr = nil; - - Opal.add_stubs(['$write_proc=']); - (($a = [function(s){print(s)}]), $b = $gvars.stdout, $b['$write_proc='].apply($b, $a), $a[$a.length-1]); - return (($a = [function(s){print(s)}]), $b = $gvars.stderr, $b['$write_proc='].apply($b, $a), $a[$a.length-1]); -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/opal_ext"] = 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, $case = nil; - - Opal.add_stubs(['$require', '$===']); - - var value; - if (typeof module !== 'undefined' && module.exports) { - value = 'node'; - } - else if (typeof XMLHttpRequest !== 'undefined') { - // or we can check for document - //else if (typeof document !== 'undefined' && document.nodeType) { - value = 'browser'; - } - else if (typeof Java !== 'undefined' && Java.type) { - value = 'java-nashorn'; - } - else if (typeof java !== 'undefined') { - value = 'java-rhino'; - } - else { - // standalone is likely SpiderMonkey - value = 'standalone'; - } - - Opal.cdecl($scope, 'JAVASCRIPT_PLATFORM', value); - self.$require("strscan"); - self.$require("asciidoctor/opal_ext/dir"); - self.$require("asciidoctor/opal_ext/file"); - self.$require("asciidoctor/opal_ext/match_data"); - self.$require("asciidoctor/opal_ext/kernel"); - return (function() {$case = $scope.get('JAVASCRIPT_PLATFORM');if ("java-nashorn"['$===']($case)) {return self.$require("asciidoctor/opal_ext/nashorn/io")}else { return nil }})(); -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/version"] = 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; - - return (function($base) { - var self = $module($base, 'Asciidoctor'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.cdecl($scope, 'VERSION', "1.5.4") - })($scope.base) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/timings"] = function(Opal) { - Opal.dynamic_require_severity = "ignore"; - var OPAL_CONFIG = { method_missing: true, arity_check: false, freezing: true, tainting: true }; - function $rb_minus(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, $gvars = Opal.gvars; - - Opal.add_stubs(['$[]=', '$now', '$-', '$delete', '$>', '$+', '$[]', '$puts', '$%', '$to_f', '$read_parse', '$convert', '$read_parse_convert']); - return (function($base) { - var self = $module($base, 'Asciidoctor'); - - var def = self.$$proto, $scope = self.$$scope; - - (function($base, $super) { - function $Timings(){}; - var self = $Timings = $klass($base, $super, 'Timings', $Timings); - - var def = self.$$proto, $scope = self.$$scope; - - def.timers = def.log = nil; - Opal.defn(self, '$initialize', function() { - var self = this; - - self.log = $hash2([], {}); - return self.timers = $hash2([], {}); - }); - - Opal.defn(self, '$start', function(key) { - var self = this; - - return self.timers['$[]='](key, Opal.get('Time').$now()); - }); - - Opal.defn(self, '$record', function(key) { - var self = this; - - return self.log['$[]='](key, ($rb_minus(Opal.get('Time').$now(), (self.timers.$delete(key))))); - }); - - Opal.defn(self, '$read_parse', function() { - var $a, self = this, time = nil; - - if ($rb_gt((time = $rb_plus((((($a = self.log['$[]']("read")) !== false && $a !== nil) ? $a : 0)), (((($a = self.log['$[]']("parse")) !== false && $a !== nil) ? $a : 0)))), 0)) { - return time - } else { - return nil - }; - }); - - Opal.defn(self, '$convert', function() { - var $a, self = this; - - return ((($a = self.log['$[]']("convert")) !== false && $a !== nil) ? $a : 0); - }); - - Opal.defn(self, '$read_parse_convert', function() { - var $a, self = this, time = nil; - - if ($rb_gt((time = $rb_plus($rb_plus((((($a = self.log['$[]']("read")) !== false && $a !== nil) ? $a : 0)), (((($a = self.log['$[]']("parse")) !== false && $a !== nil) ? $a : 0))), (((($a = self.log['$[]']("convert")) !== false && $a !== nil) ? $a : 0)))), 0)) { - return time - } else { - return nil - }; - }); - - Opal.defn(self, '$total', function() { - var $a, self = this, time = nil; - - if ($rb_gt((time = $rb_plus($rb_plus($rb_plus((((($a = self.log['$[]']("read")) !== false && $a !== nil) ? $a : 0)), (((($a = self.log['$[]']("parse")) !== false && $a !== nil) ? $a : 0))), (((($a = self.log['$[]']("convert")) !== false && $a !== nil) ? $a : 0))), (((($a = self.log['$[]']("write")) !== false && $a !== nil) ? $a : 0)))), 0)) { - return time - } else { - return nil - }; - }); - - return (Opal.defn(self, '$print_report', function(to, subject) { - var self = this; - if ($gvars.stdout == null) $gvars.stdout = nil; - - if (to == null) { - to = $gvars.stdout - } - if (subject == null) { - subject = nil - } - if (subject !== false && subject !== nil) { - to.$puts("Input file: " + (subject))}; - to.$puts(" Time to read and parse source: " + ("%05.5f"['$%'](self.$read_parse().$to_f()))); - to.$puts(" Time to convert document: " + ("%05.5f"['$%'](self.$convert().$to_f()))); - return to.$puts(" Total time (read, parse and convert): " + ("%05.5f"['$%'](self.$read_parse_convert().$to_f()))); - }), nil) && 'print_report'; - })($scope.base, null) - })($scope.base) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/core_ext/object/nil_or_empty"] = 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, $klass = Opal.klass; - - Opal.add_stubs(['$respond_to?']); - (function($base, $super) { - function $NilClass(){}; - var self = $NilClass = $klass($base, $super, 'NilClass', $NilClass); - - var def = self.$$proto, $scope = self.$$scope, $a; - - if ((($a = self['$respond_to?']("nil_or_empty?")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return Opal.alias(self, 'nil_or_empty?', 'nil?') - } - })($scope.base, null); - (function($base, $super) { - function $String(){}; - var self = $String = $klass($base, $super, 'String', $String); - - var def = self.$$proto, $scope = self.$$scope, $a; - - if ((($a = self['$respond_to?']("nil_or_empty?")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return Opal.alias(self, 'nil_or_empty?', 'empty?') - } - })($scope.base, null); - (function($base, $super) { - function $Array(){}; - var self = $Array = $klass($base, $super, 'Array', $Array); - - var def = self.$$proto, $scope = self.$$scope, $a; - - if ((($a = self['$respond_to?']("nil_or_empty?")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return Opal.alias(self, 'nil_or_empty?', 'empty?') - } - })($scope.base, null); - (function($base, $super) { - function $Hash(){}; - var self = $Hash = $klass($base, $super, 'Hash', $Hash); - - var def = self.$$proto, $scope = self.$$scope, $a; - - if ((($a = self['$respond_to?']("nil_or_empty?")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return Opal.alias(self, 'nil_or_empty?', 'empty?') - } - })($scope.base, null); - return (function($base, $super) { - function $Numeric(){}; - var self = $Numeric = $klass($base, $super, 'Numeric', $Numeric); - - var def = self.$$proto, $scope = self.$$scope, $a; - - if ((($a = self['$respond_to?']("nil_or_empty?")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return Opal.alias(self, 'nil_or_empty?', 'nil?') - } - })($scope.base, null); -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/core_ext"] = 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; - - Opal.add_stubs(['$require', '$==']); - self.$require("asciidoctor/core_ext/object/nil_or_empty"); - if ($scope.get('RUBY_ENGINE')['$==']("opal")) { - return nil}; -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/helpers"] = 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, $gvars = Opal.gvars; - - Opal.add_stubs(['$require', '$==', '$===', '$fail', '$warn', '$chomp', '$message', '$class', '$normalize_lines_from_string', '$normalize_lines_array', '$empty?', '$to_a', '$bytes', '$[]', '$map', '$rstrip', '$lines', '$encode', '$force_encoding', '$join', '$[]=', '$encoding', '$nil_or_empty?', '$each_line', '$include?', '$=~', '$gsub', '$sprintf', '$each_byte', '$extname', '$-@', '$length', '$basename', '$directory?', '$dirname', '$!', '$!=', '$mkdir_p', '$mkdir']); - return (function($base) { - var self = $module($base, 'Asciidoctor'); - - var def = self.$$proto, $scope = self.$$scope; - - (function($base) { - var self = $module($base, 'Helpers'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.defs(self, '$require_library', function(name, gem_name, on_failure) { - var self = this, e = nil, $case = nil; - - if (gem_name == null) { - gem_name = true - } - if (on_failure == null) { - on_failure = "abort" - } - try { - return self.$require(name) - } catch ($err) {if (Opal.rescue($err, [Opal.get('LoadError')])) {e = $err; - try { - if (gem_name !== false && gem_name !== nil) { - if (gem_name['$=='](true)) { - gem_name = name}; - return (function() {$case = on_failure;if ("abort"['$===']($case)) {return self.$fail("asciidoctor: FAILED: required gem '" + (gem_name) + "' is not installed. Processing aborted.")}else if ("warn"['$===']($case)) {return self.$warn("asciidoctor: WARNING: optional gem '" + (gem_name) + "' is not installed. Functionality disabled.")}else { return nil }})(); - } else { - return (function() {$case = on_failure;if ("abort"['$===']($case)) {return self.$fail("asciidoctor: FAILED: " + (e.$message().$chomp(".")) + ". Processing aborted.")}else if ("warn"['$===']($case)) {return self.$warn("asciidoctor: WARNING: " + (e.$message().$chomp(".")) + ". Functionality disabled.")}else { return nil }})() - } - } finally { - Opal.gvars["!"] = Opal.exceptions.pop() || Opal.nil; - } - }else { throw $err; } - }; - }); - - Opal.defs(self, '$normalize_lines', function(data) { - var self = this; - - if (data.$class()['$=='](Opal.get('String'))) { - return (self.$normalize_lines_from_string(data)) - } else { - return (self.$normalize_lines_array(data)) - }; - }); - - Opal.defs(self, '$normalize_lines_array', function(data) { - var $a, $b, TMP_1, $c, TMP_2, $d, TMP_3, $e, TMP_4, self = this, leading_bytes = nil, first_line = nil, utf8 = nil, leading_2_bytes = nil; - - if ((($a = data['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - leading_bytes = ((first_line = data['$[]'](0)))['$[]']($range(0, 2, false)).$bytes().$to_a(); - if ((($a = $scope.get('COERCE_ENCODING')) !== nil && (!$a.$$is_boolean || $a == true))) { - utf8 = ((Opal.get('Encoding')).$$scope.get('UTF_8')); - if (((leading_2_bytes = leading_bytes['$[]']($range(0, 1, false))))['$==']($scope.get('BOM_BYTES_UTF_16LE'))) { - return ($a = ($b = ((data.$join().$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_16LE'))))['$[]']($range(1, -1, false)).$encode(utf8)).$lines()).$map, $a.$$p = (TMP_1 = function(line){var self = TMP_1.$$s || this; -if (line == null) line = nil; - return line.$rstrip()}, TMP_1.$$s = self, TMP_1), $a).call($b) - } else if (leading_2_bytes['$==']($scope.get('BOM_BYTES_UTF_16BE'))) { - data['$[]='](0, (first_line.$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_16BE'))))['$[]']($range(1, -1, false))); - return ($a = ($c = data).$map, $a.$$p = (TMP_2 = function(line){var self = TMP_2.$$s || this; -if (line == null) line = nil; - return "" + (((line.$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_16BE')))).$encode(utf8)).$rstrip())}, TMP_2.$$s = self, TMP_2), $a).call($c); - } else if (leading_bytes['$[]']($range(0, 2, false))['$==']($scope.get('BOM_BYTES_UTF_8'))) { - data['$[]='](0, (first_line.$force_encoding(utf8))['$[]']($range(1, -1, false)))}; - return ($a = ($d = data).$map, $a.$$p = (TMP_3 = function(line){var self = TMP_3.$$s || this; -if (line == null) line = nil; - if (line.$encoding()['$=='](utf8)) { - return line.$rstrip() - } else { - return (line.$force_encoding(utf8)).$rstrip() - }}, TMP_3.$$s = self, TMP_3), $a).call($d); - } else { - if (leading_bytes['$==']($scope.get('BOM_BYTES_UTF_8'))) { - data['$[]='](0, first_line['$[]']($range(3, -1, false)))}; - return ($a = ($e = data).$map, $a.$$p = (TMP_4 = function(line){var self = TMP_4.$$s || this; -if (line == null) line = nil; - return line.$rstrip()}, TMP_4.$$s = self, TMP_4), $a).call($e); - }; - }); - - Opal.defs(self, '$normalize_lines_from_string', function(data) { - var $a, $b, TMP_5, self = this, utf8 = nil, leading_bytes = nil, leading_2_bytes = nil; - - if ((($a = data['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - if ((($a = $scope.get('COERCE_ENCODING')) !== nil && (!$a.$$is_boolean || $a == true))) { - utf8 = ((Opal.get('Encoding')).$$scope.get('UTF_8')); - leading_bytes = data['$[]']($range(0, 2, false)).$bytes().$to_a(); - if (((leading_2_bytes = leading_bytes['$[]']($range(0, 1, false))))['$==']($scope.get('BOM_BYTES_UTF_16LE'))) { - data = (data.$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_16LE'))))['$[]']($range(1, -1, false)).$encode(utf8) - } else if (leading_2_bytes['$==']($scope.get('BOM_BYTES_UTF_16BE'))) { - data = (data.$force_encoding(((Opal.get('Encoding')).$$scope.get('UTF_16BE'))))['$[]']($range(1, -1, false)).$encode(utf8) - } else if (leading_bytes['$[]']($range(0, 2, false))['$==']($scope.get('BOM_BYTES_UTF_8'))) { - data = (function() {if (data.$encoding()['$=='](utf8)) { - return data['$[]']($range(1, -1, false)) - } else { - return (data.$force_encoding(utf8))['$[]']($range(1, -1, false)) - }; return nil; })() - } else if (data.$encoding()['$=='](utf8)) { - } else { - data = data.$force_encoding(utf8) - }; - } else if (data['$[]']($range(0, 2, false)).$bytes().$to_a()['$==']($scope.get('BOM_BYTES_UTF_8'))) { - data = data['$[]']($range(3, -1, false))}; - return ($a = ($b = data.$each_line()).$map, $a.$$p = (TMP_5 = function(line){var self = TMP_5.$$s || this; -if (line == null) line = nil; - return line.$rstrip()}, TMP_5.$$s = self, TMP_5), $a).call($b); - }); - - Opal.defs(self, '$uriish?', function(str) { - var $a, self = this; - - return ($a = (str['$include?'](":")), $a !== false && $a !== nil ?str['$=~']($scope.get('UriSniffRx')) : $a); - }); - - Opal.defs(self, '$uri_prefix', function(str) { - var $a, $b, self = this; - - if ((($a = ($b = (str['$include?'](":")), $b !== false && $b !== nil ?str['$=~']($scope.get('UriSniffRx')) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - return (($a = $gvars['~']) === nil ? nil : $a['$[]'](0)) - } else { - return nil - }; - }); - - Opal.cdecl($scope, 'REGEXP_ENCODE_URI_CHARS', /[^\w\-.!~*';:@=+$,()\[\]]/); - - Opal.defs(self, '$encode_uri', function(str) { - var $a, $b, TMP_6, self = this; - - return ($a = ($b = str).$gsub, $a.$$p = (TMP_6 = function(){var self = TMP_6.$$s || this, $a, $b, TMP_7, $c; - - return ($a = ($b = (($c = $gvars['~']) === nil ? nil : $c['$[]'](0)).$each_byte()).$map, $a.$$p = (TMP_7 = function(c){var self = TMP_7.$$s || this; -if (c == null) c = nil; - return self.$sprintf("%%%02X", c)}, TMP_7.$$s = self, TMP_7), $a).call($b).$join()}, TMP_6.$$s = self, TMP_6), $a).call($b, $scope.get('REGEXP_ENCODE_URI_CHARS')); - }); - - Opal.defs(self, '$rootname', function(file_name) { - var $a, self = this, ext = nil; - - if ((($a = ((ext = Opal.get('File').$extname(file_name)))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return file_name - } else { - return file_name['$[]']($range(0, ext.$length()['$-@'](), true)) - }; - }); - - Opal.defs(self, '$basename', function(file_name, drop_extname) { - var $a, self = this; - - if (drop_extname == null) { - drop_extname = false - } - if (drop_extname !== false && drop_extname !== nil) { - return Opal.get('File').$basename(file_name, (((($a = (Opal.get('File').$extname(file_name))) !== false && $a !== nil) ? $a : ""))) - } else { - return Opal.get('File').$basename(file_name) - }; - }); - - Opal.defs(self, '$mkdir_p', function(dir) { - var $a, $b, self = this, parent_dir = nil; - - if ((($a = Opal.get('File')['$directory?'](dir)) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - parent_dir = Opal.get('File').$dirname(dir); - if ((($a = ($b = Opal.get('File')['$directory?'](parent_dir = Opal.get('File').$dirname(dir))['$!'](), $b !== false && $b !== nil ?parent_dir['$!='](".") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - self.$mkdir_p(parent_dir)}; - return Opal.get('Dir').$mkdir(dir); - }; - }); - })($scope.base) - })($scope.base) -}; - -/* Generated by Opal 0.9.0.beta2 */ -Opal.modules["asciidoctor/substitutors"] = 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); - } - 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, $hash2 = Opal.hash2, $gvars = Opal.gvars, $range = Opal.range; - - Opal.add_stubs(['$join', '$keys', '$[]', '$+', '$attr_reader', '$!', '$==', '$===', '$each', '$has_key?', '$<<', '$empty?', '$*', '$include?', '$extract_passthroughs', '$sub_specialchars', '$sub_quotes', '$sub_attributes', '$split', '$sub_replacements', '$sub_macros', '$highlight_source', '$sub_callouts', '$sub_post_replacements', '$warn', '$restore_passthroughs', '$apply_subs', '$compat_mode', '$gsub', '$nil_or_empty?', '$[]=', '$size', '$unescape_brackets', '$resolve_pass_subs', '$>', '$-', '$end_with?', '$parse_attributes', '$start_with?', '$to_sym', '$attributes', '$document', '$basebackend?', '$to_i', '$convert', '$new', '$clear', '$convert_quoted_text', '$gsub!', '$do_replacement', '$tr', '$length', '$store_attribute', '$fetch', '$attribute_undefined', '$counter', '$key?', '$downcase', '$attribute_missing', '$unescape_bracketed_text', '$inject', '$strip', '$map', '$pop', '$rstrip', '$extensions', '$inline_macros?', '$config', '$process_method', '$regexp', '$instance', '$inline_macros', '$register', '$basename', '$split_simple_csv', '$normalize_string', '$!=', '$!~', '$delete', '$chop', '$attr?', '$sub', '$chomp', '$encode_uri', '$sub_inline_xrefs', '$sub_inline_anchors', '$find', '$id', '$references', '$index', '$text', '$rootname', '$key', '$escape', '$attr', '$read_next_id', '$callouts', '$push', '$parse_quoted_text_attributes', '$shorthand_property_syntax', '$shift', '$concat', '$parse_into', '$parse', '$each_char', '$=~', '$chr', '$dup', '$&', '$resolve_subs', '$nil?', '$require_library', '$set_attr', '$sub_source', '$resolve_lines_to_highlight', '$highlight', '$to_a', '$uniq', '$sort', '$option?', '$resolve_block_subs']); - return (function($base) { - var self = $module($base, 'Asciidoctor'); - - var def = self.$$proto, $scope = self.$$scope; - - (function($base) { - var self = $module($base, 'Substitutors'); - - var def = self.$$proto, $scope = self.$$scope; - - Opal.cdecl($scope, 'SPECIAL_CHARS', $hash2(["&", "<", ">"], {"&": "&", "<": "<", ">": ">"})); - - Opal.cdecl($scope, 'SPECIAL_CHARS_PATTERN', (new RegExp("[" + $scope.get('SPECIAL_CHARS').$keys().$join() + "]"))); - - Opal.cdecl($scope, 'SUBS', $hash2(["basic", "normal", "verbatim", "title", "header", "pass"], {"basic": ["specialcharacters"], "normal": ["specialcharacters", "quotes", "attributes", "replacements", "macros", "post_replacements"], "verbatim": ["specialcharacters", "callouts"], "title": ["specialcharacters", "quotes", "replacements", "macros", "attributes", "post_replacements"], "header": ["specialcharacters", "attributes"], "pass": []})); - - Opal.cdecl($scope, 'COMPOSITE_SUBS', $hash2(["none", "normal", "verbatim", "specialchars"], {"none": [], "normal": $scope.get('SUBS')['$[]']("normal"), "verbatim": $scope.get('SUBS')['$[]']("verbatim"), "specialchars": ["specialcharacters"]})); - - Opal.cdecl($scope, 'SUB_SYMBOLS', $hash2(["a", "m", "n", "p", "q", "r", "c", "v"], {"a": "attributes", "m": "macros", "n": "normal", "p": "post_replacements", "q": "quotes", "r": "replacements", "c": "specialcharacters", "v": "verbatim"})); - - Opal.cdecl($scope, 'SUB_OPTIONS', $hash2(["block", "inline"], {"block": $rb_plus($rb_plus($scope.get('COMPOSITE_SUBS').$keys(), $scope.get('SUBS')['$[]']("normal")), ["callouts"]), "inline": $rb_plus($scope.get('COMPOSITE_SUBS').$keys(), $scope.get('SUBS')['$[]']("normal"))})); - - Opal.cdecl($scope, 'SUB_HIGHLIGHT', ["coderay", "pygments"]); - - Opal.cdecl($scope, 'PASS_START', "\u0096"); - - Opal.cdecl($scope, 'PASS_END', "\u0097"); - - Opal.cdecl($scope, 'PASS_MATCH', /\u0096(\d+)\u0097/); - - Opal.cdecl($scope, 'PASS_MATCH_HI', /]*>\u0096<\/span>[^\d]*(\d+)[^\d]*]*>\u0097<\/span>/); - - self.$attr_reader("passthroughs"); - - Opal.defn(self, '$apply_subs', function(source, subs, expand) { - var $a, $b, TMP_1, $c, TMP_2, self = this, effective_subs = nil, text = nil, multiline = nil, has_passthroughs = nil; - if (self.passthroughs == null) self.passthroughs = nil; - - if (subs == null) { - subs = "normal" - } - if (expand == null) { - expand = false - } - if ((($a = subs['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return source - } else if (subs['$==']("normal")) { - subs = $scope.get('SUBS')['$[]']("normal") - } else if (expand !== false && expand !== nil) { - if ((($a = Opal.get('Symbol')['$==='](subs)) !== nil && (!$a.$$is_boolean || $a == true))) { - subs = ((($a = $scope.get('COMPOSITE_SUBS')['$[]'](subs)) !== false && $a !== nil) ? $a : [subs]) - } else { - effective_subs = []; - ($a = ($b = subs).$each, $a.$$p = (TMP_1 = function(key){var self = TMP_1.$$s || this, $a; -if (key == null) key = nil; - if ((($a = $scope.get('COMPOSITE_SUBS')['$has_key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) { - return effective_subs = $rb_plus(effective_subs, $scope.get('COMPOSITE_SUBS')['$[]'](key)) - } else { - return effective_subs['$<<'](key) - }}, TMP_1.$$s = self, TMP_1), $a).call($b); - subs = effective_subs; - }}; - if ((($a = subs['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return source}; - text = (function() {if ((($a = (multiline = Opal.get('Array')['$==='](source))) !== nil && (!$a.$$is_boolean || $a == true))) { - return $rb_times(source, $scope.get('EOL')) - } else { - return source - }; return nil; })(); - if ((($a = (has_passthroughs = subs['$include?']("macros"))) !== nil && (!$a.$$is_boolean || $a == true))) { - text = self.$extract_passthroughs(text); - if ((($a = self.passthroughs['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - has_passthroughs = false};}; - ($a = ($c = subs).$each, $a.$$p = (TMP_2 = function(type){var self = TMP_2.$$s || this, $a, $case = nil; -if (type == null) type = nil; - return (function() {$case = type;if ("specialcharacters"['$===']($case)) {return text = self.$sub_specialchars(text)}else if ("quotes"['$===']($case)) {return text = self.$sub_quotes(text)}else if ("attributes"['$===']($case)) {return text = $rb_times(self.$sub_attributes(text.$split($scope.get('EOL'))), $scope.get('EOL'))}else if ("replacements"['$===']($case)) {return text = self.$sub_replacements(text)}else if ("macros"['$===']($case)) {return text = self.$sub_macros(text)}else if ("highlight"['$===']($case)) {return text = self.$highlight_source(text, (subs['$include?']("callouts")))}else if ("callouts"['$===']($case)) {if ((($a = subs['$include?']("highlight")) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return text = self.$sub_callouts(text) - }}else if ("post_replacements"['$===']($case)) {return text = self.$sub_post_replacements(text)}else {return self.$warn("asciidoctor: WARNING: unknown substitution type " + (type))}})()}, TMP_2.$$s = self, TMP_2), $a).call($c); - if (has_passthroughs !== false && has_passthroughs !== nil) { - text = self.$restore_passthroughs(text)}; - if (multiline !== false && multiline !== nil) { - return (text.$split($scope.get('EOL'))) - } else { - return text - }; - }); - - Opal.defn(self, '$apply_normal_subs', function(lines) { - var $a, self = this; - - return self.$apply_subs((function() {if ((($a = Opal.get('Array')['$==='](lines)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $rb_times(lines, $scope.get('EOL')) - } else { - return lines - }; return nil; })()); - }); - - Opal.defn(self, '$apply_title_subs', function(title) { - var self = this; - - return self.$apply_subs(title, $scope.get('SUBS')['$[]']("title")); - }); - - Opal.defn(self, '$apply_header_subs', function(text) { - var self = this; - - return self.$apply_subs(text, $scope.get('SUBS')['$[]']("header")); - }); - - Opal.defn(self, '$extract_passthroughs', function(text) { - var $a, $b, $c, TMP_3, $d, TMP_4, $e, TMP_5, self = this, compat_mode = nil, pass_inline_char1 = nil, pass_inline_char2 = nil, pass_inline_rx = nil; - if (self.document == null) self.document = nil; - - compat_mode = self.document.$compat_mode(); - if ((($a = ((($b = ((($c = (text['$include?']("++"))) !== false && $c !== nil) ? $c : (text['$include?']("$$")))) !== false && $b !== nil) ? $b : (text['$include?']("ss:")))) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($b = text).$gsub, $a.$$p = (TMP_3 = function(){var self = TMP_3.$$s || this, $a, $b, m = nil, preceding = nil, boundary = nil, pass_key = nil, attributes = nil, escape_count = nil, content = nil, old_behavior = nil, subs = nil; - if (self.passthroughs == null) self.passthroughs = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - preceding = nil; - if ((($a = ((boundary = m['$[]'](4)))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - if (m['$[]'](6)['$==']("\\")) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - self.passthroughs['$[]='](pass_key = self.passthroughs.$size(), $hash2(["text", "subs"], {"text": (self.$unescape_brackets(m['$[]'](8))), "subs": ((function() {if ((($a = m['$[]'](7)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return [] - } else { - return (self.$resolve_pass_subs(m['$[]'](7))) - }; return nil; })())})); - } else { - if ((($a = (($b = compat_mode !== false && compat_mode !== nil) ? boundary['$==']("++") : compat_mode)) !== nil && (!$a.$$is_boolean || $a == true))) { - return (function() {if ((($a = m['$[]'](2)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" + (m['$[]'](1)) + (m['$[]'](3)) + "++" + (self.$extract_passthroughs(m['$[]'](5))) + "++" - } else { - return "" + (m['$[]'](1)) + "[" + (m['$[]'](2)) + "]" + (m['$[]'](3)) + "++" + (self.$extract_passthroughs(m['$[]'](5))) + "++" - }; return nil; })();}; - attributes = m['$[]'](2); - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (attributes['$==']("")) { - attributes = nil}}; - escape_count = m['$[]'](3).$size(); - content = m['$[]'](5); - old_behavior = false; - if (attributes !== false && attributes !== nil) { - if ($rb_gt(escape_count, 0)) { - return "" + (m['$[]'](1)) + "[" + (attributes) + "]" + ($rb_times("\\", ($rb_minus(escape_count, 1)))) + (boundary) + (m['$[]'](5)) + (boundary) + ")"; - } else if (m['$[]'](1)['$==']("\\")) { - preceding = "[" + (attributes) + "]"; - attributes = nil; - } else { - if ((($a = (($b = boundary['$==']("++")) ? (attributes['$end_with?']("x-")) : boundary['$==']("++"))) !== nil && (!$a.$$is_boolean || $a == true))) { - old_behavior = true; - attributes = attributes['$[]']($range(0, -2, true));}; - attributes = self.$parse_attributes(attributes); - } - } else if ($rb_gt(escape_count, 0)) { - return "" + (m['$[]'](1)) + "[" + (attributes) + "]" + ($rb_times("\\", ($rb_minus(escape_count, 1)))) + (boundary) + (m['$[]'](5)) + (boundary);}; - subs = ((function() {if (boundary['$==']("+++")) { - return [] - } else { - return ["specialcharacters"] - }; return nil; })()); - pass_key = self.passthroughs.$size(); - if (attributes !== false && attributes !== nil) { - if (old_behavior !== false && old_behavior !== nil) { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs", "type", "attributes"], {"text": content, "subs": $scope.get('SUBS')['$[]']("normal"), "type": "monospaced", "attributes": attributes})) - } else { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs", "type", "attributes"], {"text": content, "subs": subs, "type": "unquoted", "attributes": attributes})) - } - } else { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs"], {"text": content, "subs": subs})) - }; - }; - return "" + (preceding) + ($scope.get('PASS_START')) + (pass_key) + ($scope.get('PASS_END'));}, TMP_3.$$s = self, TMP_3), $a).call($b, $scope.get('PassInlineMacroRx'))}; - $a = Opal.to_ary($scope.get('PassInlineRx')['$[]'](compat_mode)), pass_inline_char1 = ($a[0] == null ? nil : $a[0]), pass_inline_char2 = ($a[1] == null ? nil : $a[1]), pass_inline_rx = ($a[2] == null ? nil : $a[2]); - if ((($a = ((($c = (text['$include?'](pass_inline_char1))) !== false && $c !== nil) ? $c : ((($d = pass_inline_char2 !== false && pass_inline_char2 !== nil) ? (text['$include?'](pass_inline_char2)) : pass_inline_char2)))) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($c = text).$gsub, $a.$$p = (TMP_4 = function(){var self = TMP_4.$$s || this, $a, $b, m = nil, preceding = nil, attributes = nil, escape_mark = nil, format_mark = nil, content = nil, old_behavior = nil, pass_key = nil, subs = nil; - if (self.passthroughs == null) self.passthroughs = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - preceding = m['$[]'](1); - attributes = m['$[]'](2); - escape_mark = (function() {if ((($a = (m['$[]'](3)['$start_with?']("\\"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "\\" - } else { - return nil - }; return nil; })(); - format_mark = m['$[]'](4); - content = m['$[]'](5); - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (attributes['$==']("")) { - attributes = nil}}; - if (compat_mode !== false && compat_mode !== nil) { - old_behavior = true - } else if ((($a = (old_behavior = ((($b = attributes !== false && attributes !== nil) ? (attributes['$end_with?']("x-")) : attributes)))) !== nil && (!$a.$$is_boolean || $a == true))) { - attributes = attributes['$[]']($range(0, -2, true))}; - if (attributes !== false && attributes !== nil) { - if ((($a = (($b = format_mark['$==']("`")) ? old_behavior['$!']() : format_mark['$==']("`"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" + (preceding) + "[" + (attributes) + "]" + (escape_mark) + "`" + (self.$extract_passthroughs(content)) + "`";}; - if (escape_mark !== false && escape_mark !== nil) { - return "" + (preceding) + "[" + (attributes) + "]" + (m['$[]'](3)['$[]']($range(1, -1, false))); - } else if (preceding['$==']("\\")) { - preceding = "[" + (attributes) + "]"; - attributes = nil; - } else { - attributes = self.$parse_attributes(attributes) - }; - } else if ((($a = (($b = format_mark['$==']("`")) ? old_behavior['$!']() : format_mark['$==']("`"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" + (preceding) + (escape_mark) + "`" + (self.$extract_passthroughs(content)) + "`"; - } else if (escape_mark !== false && escape_mark !== nil) { - return "" + (preceding) + (m['$[]'](3)['$[]']($range(1, -1, false)));}; - pass_key = self.passthroughs.$size(); - if (compat_mode !== false && compat_mode !== nil) { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": ["specialcharacters"], "attributes": attributes, "type": "monospaced"})) - } else if (attributes !== false && attributes !== nil) { - if (old_behavior !== false && old_behavior !== nil) { - subs = ((function() {if (format_mark['$==']("`")) { - return ["specialcharacters"] - } else { - return $scope.get('SUBS')['$[]']("normal") - }; return nil; })()); - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": subs, "attributes": attributes, "type": "monospaced"})); - } else { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs", "attributes", "type"], {"text": content, "subs": ["specialcharacters"], "attributes": attributes, "type": "unquoted"})) - } - } else { - self.passthroughs['$[]='](pass_key, $hash2(["text", "subs"], {"text": content, "subs": ["specialcharacters"]})) - }; - return "" + (preceding) + ($scope.get('PASS_START')) + (pass_key) + ($scope.get('PASS_END'));}, TMP_4.$$s = self, TMP_4), $a).call($c, pass_inline_rx)}; - if ((($a = ($d = (text['$include?'](":")), $d !== false && $d !== nil ?(((($e = (text['$include?']("stem:"))) !== false && $e !== nil) ? $e : (text['$include?']("math:")))) : $d)) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($d = text).$gsub, $a.$$p = (TMP_5 = function(){var self = TMP_5.$$s || this, $a, m = nil, type = nil, default_stem_type = nil, content = nil, subs = nil, pass_key = nil; - if (self.document == null) self.document = nil; - if (self.passthroughs == null) self.passthroughs = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - if (((type = m['$[]'](1).$to_sym()))['$==']("stem")) { - type = ((function() {if ((($a = ((default_stem_type = self.$document().$attributes()['$[]']("stem")))['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return "asciimath" - } else { - return default_stem_type - }; return nil; })()).$to_sym()}; - content = self.$unescape_brackets(m['$[]'](3)); - if ((($a = m['$[]'](2)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - subs = (function() {if ((($a = (self.document['$basebackend?']("html"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return ["specialcharacters"] - } else { - return [] - }; return nil; })() - } else { - subs = self.$resolve_pass_subs(m['$[]'](2)) - }; - self.passthroughs['$[]='](pass_key = self.passthroughs.$size(), $hash2(["text", "subs", "type"], {"text": content, "subs": subs, "type": type})); - return "" + ($scope.get('PASS_START')) + (pass_key) + ($scope.get('PASS_END'));}, TMP_5.$$s = self, TMP_5), $a).call($d, $scope.get('StemInlineMacroRx'))}; - return text; - }); - - Opal.defn(self, '$restore_passthroughs', function(text, outer) { - var $a, $b, $c, TMP_6, self = this; - if (self.passthroughs == null) self.passthroughs = nil; - - if (outer == null) { - outer = true - } - try { - if ((($a = (($b = outer !== false && outer !== nil) ? (((($c = self.passthroughs['$empty?']()) !== false && $c !== nil) ? $c : text['$include?']($scope.get('PASS_START'))['$!']())) : outer)) !== nil && (!$a.$$is_boolean || $a == true))) { - return text}; - return ($a = ($b = text).$gsub, $a.$$p = (TMP_6 = function(){var self = TMP_6.$$s || this, $a, pass = nil, subbed_text = nil, subs = nil, type = nil; - if (self.passthroughs == null) self.passthroughs = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - pass = self.passthroughs['$[]']($gvars["~"]['$[]'](1).$to_i()); - subbed_text = (function() {if ((($a = (subs = pass['$[]']("subs"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$apply_subs(pass['$[]']("text"), subs) - } else { - return pass['$[]']("text") - }; return nil; })(); - if ((($a = (type = pass['$[]']("type"))) !== nil && (!$a.$$is_boolean || $a == true))) { - subbed_text = $scope.get('Inline').$new(self, "quoted", subbed_text, $hash2(["type", "attributes"], {"type": type, "attributes": pass['$[]']("attributes")})).$convert()}; - if ((($a = subbed_text['$include?']($scope.get('PASS_START'))) !== nil && (!$a.$$is_boolean || $a == true))) { - return self.$restore_passthroughs(subbed_text, false) - } else { - return subbed_text - };}, TMP_6.$$s = self, TMP_6), $a).call($b, $scope.get('PASS_MATCH')); - } finally { - if (outer !== false && outer !== nil) { - self.passthroughs.$clear()} - }; - }); - - Opal.defn(self, '$sub_specialchars', function(text) { - var $a, $b, TMP_7, self = this; - - if ((($a = $scope.get('SUPPORTS_GSUB_RESULT_HASH')) !== nil && (!$a.$$is_boolean || $a == true))) { - return text.$gsub($scope.get('SPECIAL_CHARS_PATTERN'), $scope.get('SPECIAL_CHARS')) - } else { - return ($a = ($b = text).$gsub, $a.$$p = (TMP_7 = function(){var self = TMP_7.$$s || this, $a; - - return $scope.get('SPECIAL_CHARS')['$[]']((($a = $gvars['~']) === nil ? nil : $a['$[]'](0)))}, TMP_7.$$s = self, TMP_7), $a).call($b, $scope.get('SPECIAL_CHARS_PATTERN')) - }; - }); - - Opal.alias(self, 'sub_specialcharacters', 'sub_specialchars'); - - Opal.defn(self, '$sub_quotes', function(text) { - var $a, $b, TMP_8, $c, TMP_10, self = this, result = nil; - if (self.document == null) self.document = nil; - - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - result = text; - ($a = ($b = $scope.get('QUOTE_SUBS')['$[]'](self.document.$compat_mode())).$each, $a.$$p = (TMP_8 = function(type, scope, pattern){var self = TMP_8.$$s || this, $a, $b, TMP_9; -if (type == null) type = nil;if (scope == null) scope = nil;if (pattern == null) pattern = nil; - return result = ($a = ($b = result).$gsub, $a.$$p = (TMP_9 = function(){var self = TMP_9.$$s || this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return self.$convert_quoted_text($gvars["~"], type, scope)}, TMP_9.$$s = self, TMP_9), $a).call($b, pattern)}, TMP_8.$$s = self, TMP_8), $a).call($b); - } else { - result = "" + (text); - ($a = ($c = $scope.get('QUOTE_SUBS')['$[]'](self.document.$compat_mode())).$each, $a.$$p = (TMP_10 = function(type, scope, pattern){var self = TMP_10.$$s || this, $a, $b, TMP_11; -if (type == null) type = nil;if (scope == null) scope = nil;if (pattern == null) pattern = nil; - return ($a = ($b = result)['$gsub!'], $a.$$p = (TMP_11 = function(){var self = TMP_11.$$s || this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return self.$convert_quoted_text($gvars["~"], type, scope)}, TMP_11.$$s = self, TMP_11), $a).call($b, pattern)}, TMP_10.$$s = self, TMP_10), $a).call($c); - }; - return result; - }); - - Opal.defn(self, '$sub_replacements', function(text) { - var $a, $b, TMP_12, $c, TMP_14, self = this, result = nil; - - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - result = text; - ($a = ($b = $scope.get('REPLACEMENTS')).$each, $a.$$p = (TMP_12 = function(pattern, replacement, restore){var self = TMP_12.$$s || this, $a, $b, TMP_13; -if (pattern == null) pattern = nil;if (replacement == null) replacement = nil;if (restore == null) restore = nil; - return result = ($a = ($b = result).$gsub, $a.$$p = (TMP_13 = function(){var self = TMP_13.$$s || this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return self.$do_replacement($gvars["~"], replacement, restore)}, TMP_13.$$s = self, TMP_13), $a).call($b, pattern)}, TMP_12.$$s = self, TMP_12), $a).call($b); - } else { - result = "" + (text); - ($a = ($c = $scope.get('REPLACEMENTS')).$each, $a.$$p = (TMP_14 = function(pattern, replacement, restore){var self = TMP_14.$$s || this, $a, $b, TMP_15; -if (pattern == null) pattern = nil;if (replacement == null) replacement = nil;if (restore == null) restore = nil; - return ($a = ($b = result)['$gsub!'], $a.$$p = (TMP_15 = function(){var self = TMP_15.$$s || this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return self.$do_replacement($gvars["~"], replacement, restore)}, TMP_15.$$s = self, TMP_15), $a).call($b, pattern)}, TMP_14.$$s = self, TMP_14), $a).call($c); - }; - return result; - }); - - Opal.defn(self, '$do_replacement', function(m, replacement, restore) { - var $a, self = this, matched = nil, $case = nil; - - if ((($a = ((matched = m['$[]'](0)))['$include?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return matched.$tr("\\", "") - } else { - return (function() {$case = restore;if ("none"['$===']($case)) {return replacement}else if ("leading"['$===']($case)) {return "" + (m['$[]'](1)) + (replacement)}else if ("bounding"['$===']($case)) {return "" + (m['$[]'](1)) + (replacement) + (m['$[]'](2))}else { return nil }})() - }; - }); - - Opal.defn(self, '$sub_attributes', function(data, opts) { - var $a, $b, TMP_16, self = this, string_data = nil, doc_attrs = nil, attribute_missing = nil, result = nil; - if (self.document == null) self.document = nil; - - if (opts == null) { - opts = $hash2([], {}) - } - if ((($a = data['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return data}; - if ((($a = (string_data = Opal.get('String')['$==='](data))) !== nil && (!$a.$$is_boolean || $a == true))) { - data = [data]}; - doc_attrs = self.document.$attributes(); - attribute_missing = nil; - result = []; - ($a = ($b = data).$each, $a.$$p = (TMP_16 = function(line){var self = TMP_16.$$s || this, $a, $b, TMP_17, $c, $d, reject = nil, reject_if_empty = nil; -if (line == null) line = nil; - reject = false; - reject_if_empty = false; - if ((($a = line['$include?']("{")) !== nil && (!$a.$$is_boolean || $a == true))) { - line = ($a = ($b = line).$gsub, $a.$$p = (TMP_17 = function(){var self = TMP_17.$$s || this, $a, $b, m = nil, offset = nil, directive = nil, expr = nil, $case = nil, args = nil, _ = nil, value = nil, val = nil, key = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = ((($b = m['$[]'](1)['$==']("\\")) !== false && $b !== nil) ? $b : m['$[]'](4)['$==']("\\"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "{" + (m['$[]'](2)) + "}" - } else if ((($a = m['$[]'](3)['$nil_or_empty?']()['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { - offset = $rb_plus(((directive = m['$[]'](3))).$length(), 1); - expr = m['$[]'](2)['$[]']($range(offset, -1, false)); - return (function() {$case = directive;if ("set"['$===']($case)) {args = expr.$split(":"); - $a = Opal.to_ary($scope.get('Parser').$store_attribute(args['$[]'](0), ((($b = args['$[]'](1)) !== false && $b !== nil) ? $b : ""), self.document)), _ = ($a[0] == null ? nil : $a[0]), value = ($a[1] == null ? nil : $a[1]); - if (value !== false && value !== nil) { - } else if (doc_attrs.$fetch("attribute-undefined", $scope.get('Compliance').$attribute_undefined())['$==']("drop-line")) { - reject = true; - return ($breaker.$v = "", $breaker);}; - reject_if_empty = true; - return "";}else if ("counter"['$===']($case) || "counter2"['$===']($case)) {args = expr.$split(":"); - val = self.document.$counter(args['$[]'](0), args['$[]'](1)); - if (directive['$==']("counter2")) { - reject_if_empty = true; - return ""; - } else { - return val - };}else {self.$warn("asciidoctor: WARNING: illegal attribute directive: " + (m['$[]'](3))); - return m['$[]'](0);}})(); - } else if ((($a = doc_attrs['$key?'](key = m['$[]'](2).$downcase())) !== nil && (!$a.$$is_boolean || $a == true))) { - return doc_attrs['$[]'](key) - } else if ((($a = $scope.get('INTRINSIC_ATTRIBUTES')['$key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('INTRINSIC_ATTRIBUTES')['$[]'](key) - } else { - return (function() {$case = (((($a = attribute_missing) !== false && $a !== nil) ? $a : attribute_missing = (((($b = opts['$[]']("attribute_missing")) !== false && $b !== nil) ? $b : doc_attrs.$fetch("attribute-missing", $scope.get('Compliance').$attribute_missing())))));if ("skip"['$===']($case)) {return m['$[]'](0)}else if ("drop-line"['$===']($case)) {self.$warn("asciidoctor: WARNING: dropping line containing reference to missing attribute: " + (key)); - reject = true; - return ($breaker.$v = "", $breaker);}else if ("warn"['$===']($case)) {self.$warn("asciidoctor: WARNING: skipping reference to missing attribute: " + (key)); - return m['$[]'](0);}else {reject_if_empty = true; - return "";}})() - };}, TMP_17.$$s = self, TMP_17), $a).call($b, $scope.get('AttributeReferenceRx'))}; - if ((($a = ((($c = reject) !== false && $c !== nil) ? $c : ((($d = reject_if_empty !== false && reject_if_empty !== nil) ? line['$empty?']() : reject_if_empty)))) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return result['$<<'](line) - };}, TMP_16.$$s = self, TMP_16), $a).call($b); - if (string_data !== false && string_data !== nil) { - return $rb_times(result, $scope.get('EOL')) - } else { - return result - }; - }); - - Opal.defn(self, '$sub_macros', function(source) { - var $a, $b, $c, TMP_18, TMP_20, $d, TMP_22, $e, TMP_24, $f, $g, TMP_26, TMP_27, $h, TMP_28, $i, $j, TMP_29, TMP_30, $k, TMP_31, self = this, found = nil, found_colon = nil, use_link_attrs = nil, experimental = nil, result = nil, extensions = nil; - if (self.document == null) self.document = nil; - - if ((($a = source['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return source}; - found = $hash2([], {}); - found['$[]=']("square_bracket", source['$include?']("[")); - found['$[]=']("round_bracket", source['$include?']("(")); - found['$[]=']("colon", found_colon = source['$include?'](":")); - found['$[]=']("macroish", (($a = found['$[]']("square_bracket"), $a !== false && $a !== nil ?found_colon : $a))); - found['$[]=']("macroish_short_form", (($a = ($b = found['$[]']("square_bracket"), $b !== false && $b !== nil ?found_colon : $b), $a !== false && $a !== nil ?source['$include?'](":[") : $a))); - use_link_attrs = self.document.$attributes()['$has_key?']("linkattrs"); - experimental = self.document.$attributes()['$has_key?']("experimental"); - result = "" + (source); - if (experimental !== false && experimental !== nil) { - if ((($a = ($b = found['$[]']("macroish_short_form"), $b !== false && $b !== nil ?(((($c = result['$include?']("kbd:")) !== false && $c !== nil) ? $c : result['$include?']("btn:"))) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($b = result).$gsub, $a.$$p = (TMP_18 = function(){var self = TMP_18.$$s || this, $a, $b, TMP_19, m = nil, captured = nil, keys = nil, label = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = ((captured = m['$[]'](0)))['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return captured['$[]']($range(1, -1, false));}; - if ((($a = captured['$start_with?']("kbd")) !== nil && (!$a.$$is_boolean || $a == true))) { - keys = self.$unescape_bracketed_text(m['$[]'](1)); - if (keys['$==']("+")) { - keys = ["+"] - } else { - keys = ($a = ($b = keys.$split($scope.get('KbdDelimiterRx'))).$inject, $a.$$p = (TMP_19 = function(c, key){var self = TMP_19.$$s || this, $a; -if (c == null) c = nil;if (key == null) key = nil; - if ((($a = key['$end_with?']("++")) !== nil && (!$a.$$is_boolean || $a == true))) { - c['$<<'](key['$[]']($range(0, -3, false)).$strip()); - c['$<<']("+"); - } else { - c['$<<'](key.$strip()) - }; - return c;}, TMP_19.$$s = self, TMP_19), $a).call($b, []) - }; - return $scope.get('Inline').$new(self, "kbd", nil, $hash2(["attributes"], {"attributes": $hash2(["keys"], {"keys": keys})})).$convert(); - } else if ((($a = captured['$start_with?']("btn")) !== nil && (!$a.$$is_boolean || $a == true))) { - label = self.$unescape_bracketed_text(m['$[]'](1)); - return $scope.get('Inline').$new(self, "button", label).$convert(); - } else { - return nil - };}, TMP_18.$$s = self, TMP_18), $a).call($b, $scope.get('KbdBtnInlineMacroRx'))}; - if ((($a = ($c = found['$[]']("macroish"), $c !== false && $c !== nil ?result['$include?']("menu:") : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($c = result).$gsub, $a.$$p = (TMP_20 = function(){var self = TMP_20.$$s || this, $a, $b, TMP_21, m = nil, captured = nil, menu = nil, items = nil, submenus = nil, menuitem = nil, delim = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = ((captured = m['$[]'](0)))['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return captured['$[]']($range(1, -1, false));}; - menu = m['$[]'](1); - items = m['$[]'](2); - if ((($a = items['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { - submenus = []; - menuitem = nil; - } else if ((($a = (delim = (function() {if ((($b = items['$include?'](">")) !== nil && (!$b.$$is_boolean || $b == true))) { - return ">" - } else { - return ((function() {if ((($b = items['$include?'](",")) !== nil && (!$b.$$is_boolean || $b == true))) { - return "," - } else { - return nil - }; return nil; })()) - }; return nil; })())) !== nil && (!$a.$$is_boolean || $a == true))) { - submenus = ($a = ($b = items.$split(delim)).$map, $a.$$p = (TMP_21 = function(it){var self = TMP_21.$$s || this; -if (it == null) it = nil; - return it.$strip()}, TMP_21.$$s = self, TMP_21), $a).call($b); - menuitem = submenus.$pop(); - } else { - submenus = []; - menuitem = items.$rstrip(); - }; - return $scope.get('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, TMP_20.$$s = self, TMP_20), $a).call($c, $scope.get('MenuInlineMacroRx'))}; - if ((($a = ($d = result['$include?']("\""), $d !== false && $d !== nil ?result['$include?'](">") : $d)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($d = result).$gsub, $a.$$p = (TMP_22 = function(){var self = TMP_22.$$s || this, $a, $b, $c, TMP_23, m = nil, captured = nil, input = nil, menu = nil, submenus = nil, menuitem = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = ((captured = m['$[]'](0)))['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return captured['$[]']($range(1, -1, false));}; - input = m['$[]'](1); - $a = Opal.to_ary(($b = ($c = input.$split(">")).$map, $b.$$p = (TMP_23 = function(it){var self = TMP_23.$$s || this; -if (it == null) it = nil; - return it.$strip()}, TMP_23.$$s = self, TMP_23), $b).call($c)), menu = ($a[0] == null ? nil : $a[0]), submenus = $slice.call($a, 1); - menuitem = submenus.$pop(); - return $scope.get('Inline').$new(self, "menu", nil, $hash2(["attributes"], {"attributes": $hash2(["menu", "submenus", "menuitem"], {"menu": menu, "submenus": submenus, "menuitem": menuitem})})).$convert();}, TMP_22.$$s = self, TMP_22), $a).call($d, $scope.get('MenuInlineRx'))};}; - if ((($a = ($e = (extensions = self.document.$extensions()), $e !== false && $e !== nil ?extensions['$inline_macros?']() : $e)) !== nil && (!$a.$$is_boolean || $a == true))) { - ($a = ($e = extensions.$inline_macros()).$each, $a.$$p = (TMP_24 = function(extension){var self = TMP_24.$$s || this, $a, $b, TMP_25; -if (extension == null) extension = nil; - return result = ($a = ($b = result).$gsub, $a.$$p = (TMP_25 = function(){var self = TMP_25.$$s || this, $a, m = nil, target = nil, attributes = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - target = m['$[]'](1); - attributes = (function() {if (extension.$config()['$[]']("format")['$==']("short")) { - return $hash2([], {}) - } else if (extension.$config()['$[]']("content_model")['$==']("attributes")) { - return self.$parse_attributes(m['$[]'](2), (((($a = extension.$config()['$[]']("pos_attrs")) !== false && $a !== nil) ? $a : [])), $hash2(["sub_input", "unescape_input"], {"sub_input": true, "unescape_input": true})) - } else { - return $hash2(["text"], {"text": (self.$unescape_bracketed_text(m['$[]'](2)))}) - }; return nil; })(); - return extension.$process_method()['$[]'](self, target, attributes);}, TMP_25.$$s = self, TMP_25), $a).call($b, extension.$instance().$regexp())}, TMP_24.$$s = self, TMP_24), $a).call($e)}; - if ((($a = ($f = found['$[]']("macroish"), $f !== false && $f !== nil ?(((($g = result['$include?']("image:")) !== false && $g !== nil) ? $g : result['$include?']("icon:"))) : $f)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($f = result).$gsub, $a.$$p = (TMP_26 = function(){var self = TMP_26.$$s || this, $a, $b, $c, m = nil, raw_attrs = nil, type = nil, posattrs = nil, target = nil, attrs = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - raw_attrs = self.$unescape_bracketed_text(m['$[]'](2)); - if ((($a = m['$[]'](0)['$start_with?']("icon:")) !== nil && (!$a.$$is_boolean || $a == true))) { - type = "icon"; - posattrs = ["size"]; - } else { - type = "image"; - posattrs = ["alt", "width", "height"]; - }; - target = self.$sub_attributes(m['$[]'](1)); - if (type['$==']("icon")) { - } else { - self.document.$register("images", target) - }; - attrs = self.$parse_attributes(raw_attrs, posattrs); - ($a = "alt", $b = attrs, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, $scope.get('Helpers').$basename(target, true).$tr("_-", " ")))); - return $scope.get('Inline').$new(self, "image", nil, $hash2(["type", "target", "attributes"], {"type": type, "target": target, "attributes": attrs})).$convert();}, TMP_26.$$s = self, TMP_26), $a).call($f, $scope.get('ImageInlineMacroRx'))}; - if ((($a = ((($g = found['$[]']("macroish_short_form")) !== false && $g !== nil) ? $g : found['$[]']("round_bracket"))) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($g = result).$gsub, $a.$$p = (TMP_27 = function(){var self = TMP_27.$$s || this, $a, $b, m = nil, num_brackets = nil, text_in_brackets = nil, macro_name = nil, terms = nil, text = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (m['$[]'](1)['$==']("")) { - m['$[]='](1, nil)}}; - num_brackets = 0; - text_in_brackets = nil; - if ((($a = (macro_name = m['$[]'](1))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - text_in_brackets = m['$[]'](3); - if ((($a = ($b = (text_in_brackets['$start_with?']("(")), $b !== false && $b !== nil ?(text_in_brackets['$end_with?'](")")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - text_in_brackets = text_in_brackets['$[]']($range(1, -1, true)); - num_brackets = 3; - } else { - num_brackets = 2 - }; - }; - if ((($a = ((($b = macro_name['$==']("indexterm")) !== false && $b !== nil) ? $b : num_brackets['$=='](3))) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = macro_name['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { - terms = self.$split_simple_csv(self.$normalize_string(text_in_brackets)) - } else { - terms = self.$split_simple_csv(self.$normalize_string(m['$[]'](2), true)) - }; - self.document.$register("indexterms", [].concat(Opal.to_a(terms))); - return $scope.get('Inline').$new(self, "indexterm", nil, $hash2(["attributes"], {"attributes": $hash2(["terms"], {"terms": terms})})).$convert(); - } else { - if ((($a = macro_name['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) { - text = self.$normalize_string(text_in_brackets) - } else { - text = self.$normalize_string(m['$[]'](2), true) - }; - self.document.$register("indexterms", [text]); - return $scope.get('Inline').$new(self, "indexterm", text, $hash2(["type"], {"type": "visible"})).$convert(); - };}, TMP_27.$$s = self, TMP_27), $a).call($g, $scope.get('IndextermInlineMacroRx'))}; - if ((($a = (($h = found_colon !== false && found_colon !== nil) ? (result['$include?']("://")) : found_colon)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($h = result).$gsub, $a.$$p = (TMP_28 = function(){var self = TMP_28.$$s || this, $a, $b, $c, $d, m = nil, prefix = nil, target = nil, suffix = nil, $case = nil, link_opts = nil, attrs = nil, text = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](2)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" + (m['$[]'](1)) + (m['$[]'](2)['$[]']($range(1, -1, false))) + (m['$[]'](3));}; - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (m['$[]'](3)['$==']("")) { - m['$[]='](3, nil)}}; - if ((($a = (($b = m['$[]'](1)['$==']("link:")) ? m['$[]'](3)['$!']() : m['$[]'](1)['$==']("link:"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0);}; - prefix = ((function() {if ((($a = m['$[]'](1)['$!=']("link:")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](1) - } else { - return "" - }; return nil; })()); - target = m['$[]'](2); - suffix = ""; - if ((($a = ((($b = m['$[]'](3)) !== false && $b !== nil) ? $b : target['$!~']($scope.get('UriTerminator')))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - $case = $gvars["~"]['$[]'](0);if (")"['$===']($case)) {target = target['$[]']($range(0, -2, false)); - suffix = ")";}else if (";"['$===']($case)) {if ((($a = ($b = prefix['$start_with?']("<"), $b !== false && $b !== nil ?target['$end_with?'](">") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - prefix = prefix['$[]']($range(4, -1, false)); - target = target['$[]']($range(0, -5, false)); - } else if ((($a = target['$end_with?'](");")) !== nil && (!$a.$$is_boolean || $a == true))) { - target = target['$[]']($range(0, -3, false)); - suffix = ");"; - } else { - target = target['$[]']($range(0, -2, false)); - suffix = ";"; - }}else if (":"['$===']($case)) {if ((($a = target['$end_with?']("):")) !== nil && (!$a.$$is_boolean || $a == true))) { - target = target['$[]']($range(0, -3, false)); - suffix = "):"; - } else { - target = target['$[]']($range(0, -2, false)); - suffix = ":"; - }} - }; - self.document.$register("links", target); - link_opts = $hash2(["type", "target"], {"type": "link", "target": target}); - attrs = nil; - if ((($a = m['$[]'](3)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - text = "" - } else { - if ((($a = (($b = use_link_attrs !== false && use_link_attrs !== nil) ? (((($c = m['$[]'](3)['$start_with?']("\"")) !== false && $c !== nil) ? $c : (($d = m['$[]'](3)['$include?'](","), $d !== false && $d !== nil ?m['$[]'](3)['$include?']("=") : $d)))) : use_link_attrs)) !== nil && (!$a.$$is_boolean || $a == true))) { - attrs = self.$parse_attributes(self.$sub_attributes(m['$[]'](3).$gsub("\\]", "]")), []); - if ((($a = attrs['$has_key?']("id")) !== nil && (!$a.$$is_boolean || $a == true))) { - link_opts['$[]=']("id", (attrs.$delete("id")))}; - text = ((($a = attrs['$[]'](1)) !== false && $a !== nil) ? $a : ""); - } else { - text = self.$sub_attributes(m['$[]'](3).$gsub("\\]", "]")) - }; - if ((($a = text['$end_with?']("^")) !== nil && (!$a.$$is_boolean || $a == true))) { - text = text.$chop(); - if (attrs !== false && attrs !== nil) { - ($a = "window", $b = attrs, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "_blank"))) - } else { - attrs = $hash2(["window"], {"window": "_blank"}) - };}; - }; - if ((($a = text['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self.document['$attr?']("hide-uri-scheme")) !== nil && (!$a.$$is_boolean || $a == true))) { - text = target.$sub($scope.get('UriSniffRx'), "") - } else { - text = target - }; - if (attrs !== false && attrs !== nil) { - attrs['$[]=']("role", (("bare ") + (attrs['$[]']("role"))).$chomp(" ")) - } else { - attrs = $hash2(["role"], {"role": "bare"}) - };}; - if (attrs !== false && attrs !== nil) { - link_opts['$[]=']("attributes", attrs)}; - return "" + (prefix) + ($scope.get('Inline').$new(self, "anchor", text, link_opts).$convert()) + (suffix);}, TMP_28.$$s = self, TMP_28), $a).call($h, $scope.get('LinkInlineRx'))}; - if ((($a = ((($i = ($j = found['$[]']("macroish"), $j !== false && $j !== nil ?(result['$include?']("link:")) : $j)) !== false && $i !== nil) ? $i : (result['$include?']("mailto:")))) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($i = result).$gsub, $a.$$p = (TMP_29 = function(){var self = TMP_29.$$s || this, $a, $b, $c, m = nil, raw_target = nil, mailto = nil, target = nil, link_opts = nil, attrs = nil, text = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - raw_target = m['$[]'](1); - mailto = m['$[]'](0)['$start_with?']("mailto:"); - target = (function() {if (mailto !== false && mailto !== nil) { - return "mailto:" + (raw_target) - } else { - return raw_target - }; return nil; })(); - link_opts = $hash2(["type", "target"], {"type": "link", "target": target}); - attrs = nil; - text = (function() {if ((($a = (($b = use_link_attrs !== false && use_link_attrs !== nil) ? (((($c = m['$[]'](2)['$start_with?']("\"")) !== false && $c !== nil) ? $c : m['$[]'](2)['$include?'](","))) : use_link_attrs)) !== nil && (!$a.$$is_boolean || $a == true))) { - attrs = self.$parse_attributes(self.$sub_attributes(m['$[]'](2).$gsub("\\]", "]")), []); - if ((($a = attrs['$key?']("id")) !== nil && (!$a.$$is_boolean || $a == true))) { - link_opts['$[]=']("id", (attrs.$delete("id")))}; - if (mailto !== false && mailto !== nil) { - if ((($a = attrs['$key?'](2)) !== nil && (!$a.$$is_boolean || $a == true))) { - target = link_opts['$[]=']("target", "" + (target) + "?subject=" + ($scope.get('Helpers').$encode_uri(attrs['$[]'](2)))); - if ((($a = attrs['$key?'](3)) !== nil && (!$a.$$is_boolean || $a == true))) { - target = link_opts['$[]=']("target", "" + (target) + "&body=" + ($scope.get('Helpers').$encode_uri(attrs['$[]'](3))))};}}; - return attrs['$[]'](1); - } else { - return self.$sub_attributes(m['$[]'](2).$gsub("\\]", "]")) - }; return nil; })(); - self.document.$register("links", target); - if ((($a = text['$end_with?']("^")) !== nil && (!$a.$$is_boolean || $a == true))) { - text = text.$chop(); - if (attrs !== false && attrs !== nil) { - ($a = "window", $b = attrs, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, "_blank"))) - } else { - attrs = $hash2(["window"], {"window": "_blank"}) - };}; - if ((($a = text['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - if (mailto !== false && mailto !== nil) { - text = raw_target - } else { - if ((($a = self.document['$attr?']("hide-uri-scheme")) !== nil && (!$a.$$is_boolean || $a == true))) { - text = raw_target.$sub($scope.get('UriSniffRx'), "") - } else { - text = raw_target - }; - if (attrs !== false && attrs !== nil) { - attrs['$[]=']("role", (("bare ") + (attrs['$[]']("role"))).$chomp(" ")) - } else { - attrs = $hash2(["role"], {"role": "bare"}) - }; - }}; - if (attrs !== false && attrs !== nil) { - link_opts['$[]=']("attributes", attrs)}; - return $scope.get('Inline').$new(self, "anchor", text, link_opts).$convert();}, TMP_29.$$s = self, TMP_29), $a).call($i, $scope.get('LinkInlineMacroRx'))}; - if ((($a = result['$include?']("@")) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($j = result).$gsub, $a.$$p = (TMP_30 = function(){var self = TMP_30.$$s || this, $a, m = nil, address = nil, lead = nil, $case = nil, target = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - address = m['$[]'](0); - if ((($a = (lead = m['$[]'](1))) !== nil && (!$a.$$is_boolean || $a == true))) { - $case = lead;if ("\\"['$===']($case)) {return address['$[]']($range(1, -1, false));}else {return address;}}; - target = "mailto:" + (address); - self.document.$register("links", target); - return $scope.get('Inline').$new(self, "anchor", address, $hash2(["type", "target"], {"type": "link", "target": target})).$convert();}, TMP_30.$$s = self, TMP_30), $a).call($j, $scope.get('EmailInlineMacroRx'))}; - if ((($a = ($k = found['$[]']("macroish_short_form"), $k !== false && $k !== nil ?result['$include?']("footnote") : $k)) !== nil && (!$a.$$is_boolean || $a == true))) { - result = ($a = ($k = result).$gsub, $a.$$p = (TMP_31 = function(){var self = TMP_31.$$s || this, $a, $b, $c, TMP_32, m = nil, id = nil, text = nil, index = nil, type = nil, target = nil, footnote = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - if (m['$[]'](1)['$==']("footnote")) { - id = nil; - text = self.$restore_passthroughs(self.$sub_inline_xrefs(self.$sub_inline_anchors(self.$normalize_string(m['$[]'](2), true))), false); - index = self.document.$counter("footnote-number"); - self.document.$register("footnotes", (($scope.get('Document')).$$scope.get('Footnote')).$new(index, id, text)); - type = nil; - target = nil; - } else { - $a = Opal.to_ary(m['$[]'](2).$split(",", 2)), id = ($a[0] == null ? nil : $a[0]), text = ($a[1] == null ? nil : $a[1]); - id = id.$strip(); - if ((($a = text['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = (footnote = ($b = ($c = self.document.$references()['$[]']("footnotes")).$find, $b.$$p = (TMP_32 = function(fn){var self = TMP_32.$$s || this; -if (fn == null) fn = nil; - return fn.$id()['$=='](id)}, TMP_32.$$s = self, TMP_32), $b).call($c))) !== nil && (!$a.$$is_boolean || $a == true))) { - index = footnote.$index(); - text = footnote.$text(); - } else { - index = nil; - text = id; - }; - target = id; - id = nil; - type = "xref"; - } else { - text = self.$restore_passthroughs(self.$sub_inline_xrefs(self.$sub_inline_anchors(self.$normalize_string(text, true))), false); - index = self.document.$counter("footnote-number"); - self.document.$register("footnotes", (($scope.get('Document')).$$scope.get('Footnote')).$new(index, id, text)); - type = "ref"; - target = nil; - }; - }; - return $scope.get('Inline').$new(self, "footnote", text, $hash2(["attributes", "id", "target", "type"], {"attributes": $hash2(["index"], {"index": index}), "id": id, "target": target, "type": type})).$convert();}, TMP_31.$$s = self, TMP_31), $a).call($k, $scope.get('FootnoteInlineMacroRx'))}; - return self.$sub_inline_xrefs(self.$sub_inline_anchors(result, found), found); - }); - - Opal.defn(self, '$sub_inline_anchors', function(text, found) { - var $a, $b, $c, TMP_33, $d, $e, TMP_34, self = this; - - if (found == null) { - found = nil - } - if ((($a = ($b = (((($c = found['$!']()) !== false && $c !== nil) ? $c : found['$[]']("square_bracket"))), $b !== false && $b !== nil ?text['$include?']("[[[") : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($b = text).$gsub, $a.$$p = (TMP_33 = function(){var self = TMP_33.$$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 m['$[]'](0)['$[]']($range(1, -1, false));}; - id = reftext = m['$[]'](1); - return $scope.get('Inline').$new(self, "anchor", reftext, $hash2(["type", "target"], {"type": "bibref", "target": id})).$convert();}, TMP_33.$$s = self, TMP_33), $a).call($b, $scope.get('InlineBiblioAnchorRx'))}; - if ((($a = ((($c = (($d = (((($e = found['$!']()) !== false && $e !== nil) ? $e : found['$[]']("square_bracket"))), $d !== false && $d !== nil ?text['$include?']("[[") : $d))) !== false && $c !== nil) ? $c : (($d = (((($e = found['$!']()) !== false && $e !== nil) ? $e : found['$[]']("macroish"))), $d !== false && $d !== nil ?text['$include?']("anchor:") : $d)))) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($c = text).$gsub, $a.$$p = (TMP_34 = function(){var self = TMP_34.$$s || this, $a, $b, 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 m['$[]'](0)['$[]']($range(1, -1, false));}; - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (m['$[]'](1)['$==']("")) { - m['$[]='](1, nil)}; - if (m['$[]'](2)['$==']("")) { - m['$[]='](2, nil)}; - if (m['$[]'](4)['$==']("")) { - m['$[]='](4, nil)};}; - id = ((($a = m['$[]'](1)) !== false && $a !== nil) ? $a : m['$[]'](3)); - reftext = ((($a = ((($b = m['$[]'](2)) !== false && $b !== nil) ? $b : m['$[]'](4))) !== false && $a !== nil) ? $a : "[" + (id) + "]"); - return $scope.get('Inline').$new(self, "anchor", reftext, $hash2(["type", "target"], {"type": "ref", "target": id})).$convert();}, TMP_34.$$s = self, TMP_34), $a).call($c, $scope.get('InlineAnchorRx'))}; - return text; - }); - - Opal.defn(self, '$sub_inline_xrefs', function(text, found) { - var $a, $b, $c, TMP_35, self = this; - - if (found == null) { - found = nil - } - if ((($a = ((($b = (((($c = found['$!']()) !== false && $c !== nil) ? $c : found['$[]']("macroish")))) !== false && $b !== nil) ? $b : text['$include?']("<<"))) !== nil && (!$a.$$is_boolean || $a == true))) { - text = ($a = ($b = text).$gsub, $a.$$p = (TMP_35 = function(){var self = TMP_35.$$s || this, $a, $b, $c, TMP_36, $d, $e, m = nil, id = nil, reftext = nil, path = nil, fragment = nil, refid = nil, target = nil, resolved_id = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if ((($a = m['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - return m['$[]'](0)['$[]']($range(1, -1, false));}; - if ((($a = Opal.get('RUBY_ENGINE_OPAL')) !== nil && (!$a.$$is_boolean || $a == true))) { - if (m['$[]'](1)['$==']("")) { - m['$[]='](1, nil)}}; - if ((($a = m['$[]'](1)) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary(($b = ($c = m['$[]'](1).$split(",", 2)).$map, $b.$$p = (TMP_36 = function(it){var self = TMP_36.$$s || this; -if (it == null) it = nil; - return it.$strip()}, TMP_36.$$s = self, TMP_36), $b).call($c)), id = ($a[0] == null ? nil : $a[0]), reftext = ($a[1] == null ? nil : $a[1]); - id = id.$sub($scope.get('DoubleQuotedRx'), "\\2"); - reftext = (function() {if ((($a = reftext['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return nil - } else { - return reftext.$sub($scope.get('DoubleQuotedMultiRx'), "\\2") - }; return nil; })(); - } else { - id = m['$[]'](2); - if ((($a = m['$[]'](3)['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - reftext = m['$[]'](3) - }; - }; - if ((($a = id['$include?']("#")) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary(id.$split("#")), path = ($a[0] == null ? nil : $a[0]), fragment = ($a[1] == null ? nil : $a[1]) - } else { - path = nil; - fragment = id; - }; - if (path !== false && path !== nil) { - path = $scope.get('Helpers').$rootname(path); - if ((($a = ((($b = self.document.$attributes()['$[]']("docname")['$=='](path)) !== false && $b !== nil) ? $b : self.document.$references()['$[]']("includes")['$include?'](path))) !== nil && (!$a.$$is_boolean || $a == true))) { - refid = fragment; - path = nil; - target = "#" + (fragment); - } else { - refid = (function() {if (fragment !== false && fragment !== nil) { - return "" + (path) + "#" + (fragment) - } else { - return path - }; return nil; })(); - path = "" + (self.document.$attributes()['$[]']("relfileprefix")) + (path) + (self.document.$attributes().$fetch("outfilesuffix", ".html")); - target = (function() {if (fragment !== false && fragment !== nil) { - return "" + (path) + "#" + (fragment) - } else { - return path - }; return nil; })(); - }; - } else { - if ((($a = ($b = ($d = (self.document.$references()['$[]']("ids")['$has_key?'](fragment))['$!'](), $d !== false && $d !== nil ?(((($e = (fragment['$include?'](" "))) !== false && $e !== nil) ? $e : fragment.$downcase()['$!='](fragment))) : $d), $b !== false && $b !== nil ?(resolved_id = (function() {if ((($d = $scope.get('RUBY_MIN_VERSION_1_9')) !== nil && (!$d.$$is_boolean || $d == true))) { - return (self.document.$references()['$[]']("ids").$key(fragment)) - } else { - return (self.document.$references()['$[]']("ids").$index(fragment)) - }; return nil; })()) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - fragment = resolved_id}; - refid = fragment; - target = "#" + (fragment); - }; - return $scope.get('Inline').$new(self, "anchor", reftext, $hash2(["type", "target", "attributes"], {"type": "xref", "target": target, "attributes": $hash2(["path", "fragment", "refid"], {"path": path, "fragment": fragment, "refid": refid})})).$convert();}, TMP_35.$$s = self, TMP_35), $a).call($b, $scope.get('XrefInlineMacroRx'))}; - return text; - }); - - Opal.defn(self, '$sub_callouts', function(text) { - var $a, $b, TMP_37, self = this, callout_rx = nil; - - callout_rx = (function() {if ((($a = (self['$attr?']("line-comment"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return (new RegExp("(?:" + Opal.get('Regexp').$escape(self.$attr("line-comment")) + " )?" + $scope.get('CalloutSourceRxt'))) - } else { - return $scope.get('CalloutSourceRx') - }; return nil; })(); - return ($a = ($b = text).$gsub, $a.$$p = (TMP_37 = function(){var self = TMP_37.$$s || this, m = nil; - if (self.document == null) self.document = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if (m['$[]'](1)['$==']("\\")) { - return m['$[]'](0).$sub("\\", "");}; - return $scope.get('Inline').$new(self, "callout", m['$[]'](3), $hash2(["id"], {"id": self.document.$callouts().$read_next_id()})).$convert();}, TMP_37.$$s = self, TMP_37), $a).call($b, callout_rx); - }); - - Opal.defn(self, '$sub_post_replacements', function(text) { - var $a, $b, TMP_38, $c, TMP_39, self = this, lines = nil, last = nil; - if (self.document == null) self.document = nil; - if (self.attributes == null) self.attributes = nil; - - if ((($a = ((($b = (self.document.$attributes()['$has_key?']("hardbreaks"))) !== false && $b !== nil) ? $b : (self.attributes['$has_key?']("hardbreaks-option")))) !== nil && (!$a.$$is_boolean || $a == true))) { - lines = (text.$split($scope.get('EOL'))); - if (lines.$size()['$=='](1)) { - return text}; - last = lines.$pop(); - return $rb_times(($a = ($b = lines).$map, $a.$$p = (TMP_38 = function(line){var self = TMP_38.$$s || this; -if (line == null) line = nil; - return $scope.get('Inline').$new(self, "break", line.$rstrip().$chomp($scope.get('LINE_BREAK')), $hash2(["type"], {"type": "line"})).$convert()}, TMP_38.$$s = self, TMP_38), $a).call($b).$push(last), $scope.get('EOL')); - } else if ((($a = text['$include?']("+")) !== nil && (!$a.$$is_boolean || $a == true))) { - return ($a = ($c = text).$gsub, $a.$$p = (TMP_39 = function(){var self = TMP_39.$$s || this; - if ($gvars["~"] == null) $gvars["~"] = nil; - - return $scope.get('Inline').$new(self, "break", $gvars["~"]['$[]'](1), $hash2(["type"], {"type": "line"})).$convert()}, TMP_39.$$s = self, TMP_39), $a).call($c, $scope.get('LineBreakRx')) - } else { - return text - }; - }); - - Opal.defn(self, '$convert_quoted_text', function(match, type, scope) { - var $a, $b, self = this, unescaped_attrs = nil, attrs = nil, attributes = nil, id = nil; - - unescaped_attrs = nil; - if ((($a = match['$[]'](0)['$start_with?']("\\")) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = (($b = scope['$==']("constrained")) ? ((attrs = match['$[]'](2)))['$nil_or_empty?']()['$!']() : scope['$==']("constrained"))) !== nil && (!$a.$$is_boolean || $a == true))) { - unescaped_attrs = "[" + (attrs) + "]" - } else { - return match['$[]'](0)['$[]']($range(1, -1, false)) - }}; - if (scope['$==']("constrained")) { - if (unescaped_attrs !== false && unescaped_attrs !== nil) { - return "" + (unescaped_attrs) + ($scope.get('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type"], {"type": type})).$convert()) - } else { - if ((($a = (attributes = self.$parse_quoted_text_attributes(match['$[]'](2)))) !== nil && (!$a.$$is_boolean || $a == true))) { - id = attributes.$delete("id"); - if (type['$==']("mark")) { - type = "unquoted"}; - } else { - id = nil - }; - return "" + (match['$[]'](1)) + ($scope.get('Inline').$new(self, "quoted", match['$[]'](3), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert()); - } - } else { - if ((($a = (attributes = self.$parse_quoted_text_attributes(match['$[]'](1)))) !== nil && (!$a.$$is_boolean || $a == true))) { - id = attributes.$delete("id"); - if (type['$==']("mark")) { - type = "unquoted"}; - } else { - id = nil - }; - return $scope.get('Inline').$new(self, "quoted", match['$[]'](2), $hash2(["type", "id", "attributes"], {"type": type, "id": id, "attributes": attributes})).$convert(); - }; - }); - - Opal.defn(self, '$parse_quoted_text_attributes', function(str) { - var $a, $b, $c, self = this, _ = nil, segments = nil, id = nil, more_roles = nil, roles = nil, attrs = nil; - - if (str !== false && str !== nil) { - } else { - return nil - }; - if ((($a = str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return $hash2([], {})}; - if ((($a = str['$include?']("{")) !== nil && (!$a.$$is_boolean || $a == true))) { - str = self.$sub_attributes(str)}; - str = str.$strip(); - if ((($a = str['$include?'](",")) !== nil && (!$a.$$is_boolean || $a == true))) { - $a = Opal.to_ary(str.$split(",", 2)), str = ($a[0] == null ? nil : $a[0]), _ = ($a[1] == null ? nil : $a[1])}; - if ((($a = str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return $hash2([], {}) - } else if ((($a = ($b = (((($c = str['$start_with?'](".")) !== false && $c !== nil) ? $c : str['$start_with?']("#"))), $b !== false && $b !== nil ?$scope.get('Compliance').$shorthand_property_syntax() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - segments = str.$split("#", 2); - if ($rb_gt(segments.$length(), 1)) { - $a = Opal.to_ary(segments['$[]'](1).$split(".")), id = ($a[0] == null ? nil : $a[0]), more_roles = $slice.call($a, 1) - } else { - id = nil; - more_roles = []; - }; - roles = (function() {if ((($a = segments['$[]'](0)['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return [] - } else { - return segments['$[]'](0).$split(".") - }; return nil; })(); - if ($rb_gt(roles.$length(), 1)) { - roles.$shift()}; - if ($rb_gt(more_roles.$length(), 0)) { - roles.$concat(more_roles)}; - attrs = $hash2([], {}); - if (id !== false && id !== nil) { - attrs['$[]=']("id", id)}; - if ((($a = roles['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - attrs['$[]=']("role", $rb_times(roles, " ")) - }; - return attrs; - } else { - return $hash2(["role"], {"role": str}) - }; - }); - - Opal.defn(self, '$parse_attributes', function(attrline, posattrs, opts) { - var $a, self = this, block = nil, into = nil; - if (self.document == null) self.document = nil; - - if (posattrs == null) { - posattrs = ["role"] - } - if (opts == null) { - opts = $hash2([], {}) - } - if (attrline !== false && attrline !== nil) { - } else { - return nil - }; - if ((($a = attrline['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return $hash2([], {})}; - if ((($a = opts['$[]']("sub_input")) !== nil && (!$a.$$is_boolean || $a == true))) { - attrline = self.document.$sub_attributes(attrline)}; - if ((($a = opts['$[]']("unescape_input")) !== nil && (!$a.$$is_boolean || $a == true))) { - attrline = self.$unescape_bracketed_text(attrline)}; - block = nil; - if ((($a = opts.$fetch("sub_result", true)) !== nil && (!$a.$$is_boolean || $a == true))) { - block = self}; - if ((($a = (into = opts['$[]']("into"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return $scope.get('AttributeList').$new(attrline, block).$parse_into(into, posattrs) - } else { - return $scope.get('AttributeList').$new(attrline, block).$parse(posattrs) - }; - }); - - Opal.defn(self, '$unescape_bracketed_text', function(text) { - var $a, self = this; - - if ((($a = text['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return ""}; - return text.$strip().$tr($scope.get('EOL'), " ").$gsub("\\]", "]"); - }); - - Opal.defn(self, '$normalize_string', function(str, unescape_brackets) { - var $a, self = this; - - if (unescape_brackets == null) { - unescape_brackets = false - } - if ((($a = str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" - } else if (unescape_brackets !== false && unescape_brackets !== nil) { - return self.$unescape_brackets(str.$strip().$tr($scope.get('EOL'), " ")) - } else { - return str.$strip().$tr($scope.get('EOL'), " ") - }; - }); - - Opal.defn(self, '$unescape_brackets', function(str) { - var $a, self = this; - - if ((($a = str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" - } else { - return str.$gsub("\\]", "]") - }; - }); - - Opal.defn(self, '$split_simple_csv', function(str) { - var $a, $b, TMP_40, $c, TMP_41, self = this, values = nil, current = nil, quote_open = nil; - - if ((($a = str['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - values = [] - } else if ((($a = str['$include?']("\"")) !== nil && (!$a.$$is_boolean || $a == true))) { - values = []; - current = []; - quote_open = false; - ($a = ($b = str).$each_char, $a.$$p = (TMP_40 = function(c){var self = TMP_40.$$s || this, $case = nil; -if (c == null) c = nil; - return (function() {$case = c;if (","['$===']($case)) {if (quote_open !== false && quote_open !== nil) { - return current.$push(c) - } else { - values['$<<'](current.$join().$strip()); - return current = []; - }}else if ("\""['$===']($case)) {return quote_open = quote_open['$!']()}else {return current.$push(c)}})()}, TMP_40.$$s = self, TMP_40), $a).call($b); - values['$<<'](current.$join().$strip()); - } else { - values = ($a = ($c = str.$split(",")).$map, $a.$$p = (TMP_41 = function(it){var self = TMP_41.$$s || this; -if (it == null) it = nil; - return it.$strip()}, TMP_41.$$s = self, TMP_41), $a).call($c) - }; - return values; - }); - - Opal.defn(self, '$resolve_subs', function(subs, type, defaults, subject) { - var $a, $b, TMP_42, self = this, candidates = nil, modifiers_present = nil, resolved = nil, invalid = nil; - - if (type == null) { - type = "block" - } - if (defaults == null) { - defaults = nil - } - if (subject == null) { - subject = nil - } - if ((($a = subs['$nil_or_empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - return []}; - candidates = nil; - modifiers_present = $scope.get('SubModifierSniffRx')['$=~'](subs); - ($a = ($b = subs.$tr(" ", "").$split(",")).$each, $a.$$p = (TMP_42 = function(key){var self = TMP_42.$$s || this, $a, $b, $c, modifier_operation = nil, first = nil, resolved_keys = nil, resolved_key = nil, candidate = nil, $case = nil; -if (key == null) key = nil; - modifier_operation = nil; - if (modifiers_present !== false && modifiers_present !== nil) { - if (((first = key.$chr()))['$==']("+")) { - modifier_operation = "append"; - key = key['$[]']($range(1, -1, false)); - } else if (first['$==']("-")) { - modifier_operation = "remove"; - key = key['$[]']($range(1, -1, false)); - } else if ((($a = key['$end_with?']("+")) !== nil && (!$a.$$is_boolean || $a == true))) { - modifier_operation = "prepend"; - key = key.$chop();}}; - key = key.$to_sym(); - if ((($a = (($b = type['$==']("inline")) ? (((($c = key['$==']("verbatim")) !== false && $c !== nil) ? $c : key['$==']("v"))) : type['$==']("inline"))) !== nil && (!$a.$$is_boolean || $a == true))) { - resolved_keys = ["specialcharacters"] - } else if ((($a = $scope.get('COMPOSITE_SUBS')['$key?'](key)) !== nil && (!$a.$$is_boolean || $a == true))) { - resolved_keys = $scope.get('COMPOSITE_SUBS')['$[]'](key) - } else if ((($a = ($b = (($c = type['$==']("inline")) ? key.$length()['$=='](1) : type['$==']("inline")), $b !== false && $b !== nil ?($scope.get('SUB_SYMBOLS')['$key?'](key)) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - resolved_key = $scope.get('SUB_SYMBOLS')['$[]'](key); - if ((($a = (candidate = $scope.get('COMPOSITE_SUBS')['$[]'](resolved_key))) !== nil && (!$a.$$is_boolean || $a == true))) { - resolved_keys = candidate - } else { - resolved_keys = [resolved_key] - }; - } else { - resolved_keys = [key] - }; - if (modifier_operation !== false && modifier_operation !== nil) { - ((($a = candidates) !== false && $a !== nil) ? $a : candidates = ((function() {if (defaults !== false && defaults !== nil) { - return defaults.$dup() - } else { - return [] - }; return nil; })())); - return (function() {$case = modifier_operation;if ("append"['$===']($case)) {return candidates = $rb_plus(candidates, resolved_keys)}else if ("prepend"['$===']($case)) {return candidates = $rb_plus(resolved_keys, candidates)}else if ("remove"['$===']($case)) {return candidates = $rb_minus(candidates, resolved_keys)}else { return nil }})(); - } else { - ((($a = candidates) !== false && $a !== nil) ? $a : candidates = []); - return candidates = $rb_plus(candidates, resolved_keys); - };}, TMP_42.$$s = self, TMP_42), $a).call($b); - resolved = candidates['$&']($scope.get('SUB_OPTIONS')['$[]'](type)); - if ((($a = ($rb_minus(candidates, resolved))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - invalid = $rb_minus(candidates, resolved); - self.$warn("asciidoctor: WARNING: invalid substitution type" + ((function() {if ($rb_gt(invalid.$size(), 1)) { - return "s" - } else { - return "" - }; return nil; })()) + ((function() {if (subject !== false && subject !== nil) { - return " for " - } else { - return nil - }; return nil; })()) + (subject) + ": " + ($rb_times(invalid, ", "))); - }; - return resolved; - }); - - Opal.defn(self, '$resolve_block_subs', function(subs, defaults, subject) { - var self = this; - - return self.$resolve_subs(subs, "block", defaults, subject); - }); - - Opal.defn(self, '$resolve_pass_subs', function(subs) { - var self = this; - - return self.$resolve_subs(subs, "inline", nil, "passthrough macro"); - }); - - Opal.defn(self, '$highlight_source', function(source, process_callouts, highlighter) { - var $a, $b, TMP_43, $c, TMP_45, self = this, $case = nil, highlighter_loaded = nil, lineno = nil, callout_on_last = nil, callout_marks = nil, last = nil, callout_rx = nil, linenums_mode = nil, highlight_lines = nil, result = nil, lexer = nil, opts = nil, reached_code = nil; - if (self.document == null) self.document = nil; - if (self.passthroughs == null) self.passthroughs = nil; - - if (highlighter == null) { - highlighter = nil - } - $case = (((($a = highlighter) !== false && $a !== nil) ? $a : highlighter = self.document.$attributes()['$[]']("source-highlighter")));if ("coderay"['$===']($case)) {if ((($a = ((($b = (highlighter_loaded = (Opal.Object.$$scope.CodeRay == null ? nil : 'constant'))) !== false && $b !== nil) ? $b : self.document.$attributes()['$[]']("coderay-unavailable"))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else if ((($a = ($scope.get('Helpers').$require_library("coderay", true, "warn"))['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.document.$set_attr("coderay-unavailable", true) - } else { - highlighter_loaded = true - }}else if ("pygments"['$===']($case)) {if ((($a = ((($b = (highlighter_loaded = (Opal.Object.$$scope.Pygments == null ? nil : 'constant'))) !== false && $b !== nil) ? $b : self.document.$attributes()['$[]']("pygments-unavailable"))) !== nil && (!$a.$$is_boolean || $a == true))) { - } else if ((($a = ($scope.get('Helpers').$require_library("pygments", "pygments.rb", "warn"))['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - self.document.$set_attr("pygments-unavailable", true) - } else { - highlighter_loaded = true - }}else {highlighter_loaded = false}; - if (highlighter_loaded !== false && highlighter_loaded !== nil) { - } else { - return self.$sub_source(source, process_callouts) - }; - lineno = 0; - callout_on_last = false; - if (process_callouts !== false && process_callouts !== nil) { - callout_marks = $hash2([], {}); - last = -1; - callout_rx = (function() {if ((($a = (self['$attr?']("line-comment"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return (new RegExp("(?:" + Opal.get('Regexp').$escape(self.$attr("line-comment")) + " )?" + $scope.get('CalloutExtractRxt'))) - } else { - return $scope.get('CalloutExtractRx') - }; return nil; })(); - source = $rb_times(($a = ($b = source.$split($scope.get('EOL'))).$map, $a.$$p = (TMP_43 = function(line){var self = TMP_43.$$s || this, $a, $b, TMP_44; -if (line == null) line = nil; - lineno = $rb_plus(lineno, 1); - return ($a = ($b = line).$gsub, $a.$$p = (TMP_44 = function(){var self = TMP_44.$$s || this, $a, $b, $c, m = nil; - if ($gvars["~"] == null) $gvars["~"] = nil; - - m = $gvars["~"]; - if (m['$[]'](1)['$==']("\\")) { - return m['$[]'](0).$sub("\\", "") - } else { - (($a = lineno, $b = callout_marks, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, []))))['$<<'](m['$[]'](3)); - last = lineno; - return nil; - };}, TMP_44.$$s = self, TMP_44), $a).call($b, callout_rx);}, TMP_43.$$s = self, TMP_43), $a).call($b), $scope.get('EOL')); - callout_on_last = (last['$=='](lineno)); - if ((($a = callout_marks['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - callout_marks = nil}; - } else { - callout_marks = nil - }; - linenums_mode = nil; - highlight_lines = nil; - $case = highlighter;if ("coderay"['$===']($case)) {if ((($a = (linenums_mode = (function() {if ((($c = (self['$attr?']("linenums"))) !== nil && (!$c.$$is_boolean || $c == true))) { - return (((($c = self.document.$attributes()['$[]']("coderay-linenums-mode")) !== false && $c !== nil) ? $c : "table")).$to_sym() - } else { - return nil - }; return nil; })())) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = self['$attr?']("highlight", nil, false)) !== nil && (!$a.$$is_boolean || $a == true))) { - highlight_lines = self.$resolve_lines_to_highlight(self.$attr("highlight", nil, false))}}; - result = ((Opal.get('CodeRay')).$$scope.get('Duo'))['$[]'](self.$attr("language", "text", false).$to_sym(), "html", $hash2(["css", "line_numbers", "line_number_anchors", "highlight_lines", "bold_every"], {"css": (((($a = self.document.$attributes()['$[]']("coderay-css")) !== false && $a !== nil) ? $a : "class")).$to_sym(), "line_numbers": linenums_mode, "line_number_anchors": false, "highlight_lines": highlight_lines, "bold_every": false})).$highlight(source);}else if ("pygments"['$===']($case)) {lexer = ((($a = ((Opal.get('Pygments')).$$scope.get('Lexer'))['$[]'](self.$attr("language", nil, false))) !== false && $a !== nil) ? $a : ((Opal.get('Pygments')).$$scope.get('Lexer'))['$[]']("text")); - opts = $hash2(["cssclass", "classprefix", "nobackground"], {"cssclass": "pyhl", "classprefix": "tok-", "nobackground": true}); - if ((((($a = self.document.$attributes()['$[]']("pygments-css")) !== false && $a !== nil) ? $a : "class"))['$==']("class")) { - } else { - opts['$[]=']("noclasses", true); - opts['$[]=']("style", (((($a = self.document.$attributes()['$[]']("pygments-style")) !== false && $a !== nil) ? $a : (($scope.get('Stylesheets')).$$scope.get('DEFAULT_PYGMENTS_STYLE'))))); - }; - if ((($a = self['$attr?']("highlight", nil, false)) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = ((highlight_lines = self.$resolve_lines_to_highlight(self.$attr("highlight", nil, false))))['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - opts['$[]=']("hl_lines", $rb_times(highlight_lines, " ")) - }}; - if ((($a = self['$attr?']("linenums")) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((opts['$[]=']("linenos", ((($a = self.document.$attributes()['$[]']("pygments-linenums-mode")) !== false && $a !== nil) ? $a : "table")))['$==']("table")) { - linenums_mode = "table"; - result = lexer.$highlight(source, $hash2(["options"], {"options": opts})).$sub(/
(.*)<\/div>/m, "\\1").$gsub(/]*>(.*?)<\/pre>\s*/m, "\\1"); - } else { - result = lexer.$highlight(source, $hash2(["options"], {"options": opts})).$sub(/
]*>(.*?)<\/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['$<<']("
"); - if (node.$doctype()['$==']("manpage")) { - result['$<<']("

" + (node.$doctitle()) + " Manual Page

"); - if ((($a = ($b = (($c = sectioned !== false && sectioned !== nil) ? (node['$attr?']("toc")) : sectioned), $b !== false && $b !== nil ?(node['$attr?']("toc-placement", "auto")) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<']("
\n
" + (node.$attr("toc-title")) + "
\n" + (self.$outline(node)) + "\n
")}; - result['$<<']("

" + (node.$attr("manname-title")) + "

\n
\n

" + (node.$attr("manname")) + " - " + (node.$attr("manpurpose")) + "

\n
"); - } else { - if ((($a = node['$has_header?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - if ((($a = node.$notitle()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - result['$<<']("

" + (node.$header().$title()) + "

") - }; - details = []; - if ((($a = node['$attr?']("author")) !== nil && (!$a.$$is_boolean || $a == true))) { - details['$<<']("" + (node.$attr("author")) + "" + (br)); - if ((($a = node['$attr?']("email")) !== nil && (!$a.$$is_boolean || $a == true))) { - details['$<<']("" + (node.$sub_macros(node.$attr("email"))) + "" + (br))}; - if ($rb_gt((authorcount = (node.$attr("authorcount")).$to_i()), 1)) { - ($a = ($b = ($range(2, authorcount, false))).$each, $a.$$p = (TMP_1 = function(idx){var self = TMP_1.$$s || this, $a; -if (idx == null) idx = nil; - details['$<<']("" + (node.$attr("author_" + (idx))) + "" + (br)); - if ((($a = node['$attr?']("email_" + (idx))) !== nil && (!$a.$$is_boolean || $a == true))) { - return details['$<<']("" + (node.$sub_macros(node.$attr("email_" + (idx)))) + "" + (br)) - } else { - return nil - };}, TMP_1.$$s = self, TMP_1), $a).call($b)};}; - if ((($a = node['$attr?']("revnumber")) !== nil && (!$a.$$is_boolean || $a == true))) { - details['$<<']("" + ((((($a = (node.$attr("version-label"))) !== false && $a !== nil) ? $a : "")).$downcase()) + " " + (node.$attr("revnumber")) + ((function() {if ((($a = (node['$attr?']("revdate"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "," - } else { - return "" - }; return nil; })()) + "")}; - if ((($a = node['$attr?']("revdate")) !== nil && (!$a.$$is_boolean || $a == true))) { - details['$<<']("" + (node.$attr("revdate")) + "")}; - if ((($a = node['$attr?']("revremark")) !== nil && (!$a.$$is_boolean || $a == true))) { - details['$<<']("" + (br) + "" + (node.$attr("revremark")) + "")}; - if ((($a = details['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - result['$<<']("
"); - result.$concat(details); - result['$<<']("
"); - };}; - if ((($a = ($c = (($d = sectioned !== false && sectioned !== nil) ? (node['$attr?']("toc")) : sectioned), $c !== false && $c !== nil ?(node['$attr?']("toc-placement", "auto")) : $c)) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<']("
\n
" + (node.$attr("toc-title")) + "
\n" + (self.$outline(node)) + "\n
")}; - }; - 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['$<<']("
\n"); - ($a = ($c = node.$footnotes()).$each, $a.$$p = (TMP_2 = function(footnote){var self = TMP_2.$$s || this; -if (footnote == null) footnote = nil; - return result['$<<']("
\n" + (footnote.$index()) + ". " + (footnote.$text()) + "\n
")}, TMP_2.$$s = self, TMP_2), $a).call($c); - result['$<<']("
");}; - if ((($a = node.$nofooter()) !== nil && (!$a.$$is_boolean || $a == true))) { - } else { - result['$<<']("
"); - result['$<<']("
"); - if ((($a = node['$attr?']("revnumber")) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<']("" + (node.$attr("version-label")) + " " + (node.$attr("revnumber")) + (br))}; - if ((($a = ($d = (node['$attr?']("last-update-label")), $d !== false && $d !== nil ?(node['$attr?']("reproducible"))['$!']() : $d)) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<']("" + (node.$attr("last-update-label")) + " " + (node.$attr("docdatetime")))}; - result['$<<']("
"); - 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['$<<']("
\n"); - ($a = ($b = node.$footnotes()).$each, $a.$$p = (TMP_3 = function(footnote){var self = TMP_3.$$s || this; -if (footnote == null) footnote = nil; - return result['$<<']("
\n" + (footnote.$index()) + ". " + (footnote.$text()) + "\n
")}, TMP_3.$$s = self, TMP_3), $a).call($b); - 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) + "\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\n\n
\n" + (caption) + "\n\n" + (title_element) + (node.$content()) + "\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\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\n\n");}, TMP_5.$$s = self, TMP_5), $a).call($b); - result['$<<']("
" + (num_element) + "" + (item.$text()) + "
"); - } 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['$<<']("
  1. \n

    " + (item.$text()) + "

    \n
  2. ")}, 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['$<<']("
  1. "); - ($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['$<<']("
  2. ");}, 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['$<<'](""); - result['$<<'](""); - return result['$<<']("");}, TMP_9.$$s = self, TMP_9), $a).call($c); - 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['$<<'](""); - 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['$<<']("
");}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()) + ""; - }); - - 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['$<<']("
  1. "); - result['$<<']("

    " + (item.$text()) + "

    "); - if ((($a = item['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<'](item.$content())}; - return result['$<<']("
  2. ");}, 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 ""; - }); - - 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 = "
" + (cell.$text()) + "
"}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) + "");}, 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['$<<'](""); - ($a = ($b = node.$items()).$each, $a.$$p = (TMP_21 = function(item){var self = TMP_21.$$s || this, $a, $b; -if (item == null) item = nil; - result['$<<']("
  • "); - if ((($a = (($b = checklist !== false && checklist !== nil) ? (item['$attr?']("checkbox")) : checklist)) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<']("

    " + ((function() {if ((($a = (item['$attr?']("checked"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return marker_checked - } else { - return marker_unchecked - }; return nil; })()) + (item.$text()) + "

    ") - } else { - result['$<<']("

    " + (item.$text()) + "

    ") - }; - if ((($a = item['$blocks?']()) !== nil && (!$a.$$is_boolean || $a == true))) { - result['$<<'](item.$content())}; - return result['$<<']("
  • ");}, TMP_21.$$s = self, TMP_21), $a).call($b); - 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\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 "[" + (index) + "]" - } 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 "[" + (index) + "]"; - } - } else if (node.$type()['$==']("xref")) { - return "[" + (node.$text()) + "]" - } 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 "" + (submenu) + " ▸ "}, TMP_25.$$s = self, TMP_25), $a).call($b).$join().$chop(); - return "" + (menu) + " ▸ " + (submenu_path) + " " + (node.$attr("menuitem")) + ""; - } else if ((($a = (menuitem = node.$attr("menuitem"))) !== nil && (!$a.$$is_boolean || $a == true))) { - return "" + (menu) + " ▸ " + (menuitem) + "" - } else { - return "" + (menu) + "" - }; - }); - - 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("^(?:" + $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("^" + $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: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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 '' - + text - + '\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 + '\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 + '\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 = '
    '; - return out; -}; - -Renderer.prototype.image = function(href, title, text) { - var out = '' + text + '' : '>'; - 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( "" ) + ""; - } - } - }; - - - // 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( "^(.*?)()", '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: - // - // "
    a\n
    b\n
    c\n
    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*)()(\\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 ();