Comparing version 0.1.19 to 0.2.0
@@ -1,2 +0,2 @@ | ||
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
"use strict"; | ||
@@ -76,2 +76,3 @@ | ||
if (this.tryOrderedList(walk)) return; | ||
if (this.tryDefinitionList(walk)) return; | ||
if (this.tryHeading(walk)) return; | ||
@@ -370,2 +371,76 @@ if (this.tryCodeBlock(walk)) return; | ||
/* Definition lists start with either `= ` or `- ` which are rendered as | ||
`dt` and `dd` respectively. Indentation is required for nested blocks. */ | ||
tryDefinitionList: function(walk) { | ||
if (!walk.at("= ") && !walk.at('- ')) return false; | ||
var startIdx = walk.position; | ||
var found = false; | ||
// Find the end of the block, checking for nested subblocks | ||
while (!found && walk.hasCurrent()) { | ||
walk.scrollToTerm().skipBlankLines(); | ||
if (walk.atSpaces(this.blockIndent)) { | ||
var i = walk.position; | ||
walk.skip(this.blockIndent); | ||
if (!walk.at("= ") && !walk.at('- ') && !walk.atSpace()) { | ||
found = true; | ||
walk.startFrom(i); | ||
} | ||
} else found = true; | ||
} | ||
// We got DL region, emit it | ||
var dl = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDl(dl); | ||
return true; | ||
}, | ||
emitDl: function(walk) { | ||
this.out.push("<dl"); | ||
this.emitSelector(); | ||
this.out.push(">"); | ||
// Parsing dt and dd | ||
var startIdx = walk.position; | ||
while (walk.hasCurrent()) { | ||
walk.scrollToEol().skipBlankLines(); | ||
if (walk.atSpaces(this.blockIndent)) { | ||
walk.skip(this.blockIndent); | ||
if (walk.at('= ') || walk.at('- ')) { | ||
var elem = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDtDd(elem); | ||
startIdx = walk.position; | ||
} | ||
} | ||
} | ||
// Emit last element | ||
var last = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDtDd(last); | ||
// All items emitted | ||
this.out.push("</dl>\n"); | ||
}, | ||
// emits either `dt` or `dd` depending on the marker | ||
emitDtDd: function(walk) { | ||
var tag = walk.at('= ') ? 'dt' : 'dd'; | ||
walk.skip(2); | ||
this.out.push("<"); | ||
this.out.push(tag); | ||
this.emitSelector(); | ||
this.out.push(">"); | ||
// Determine, whether the contents is inline or block | ||
var b = walk.lookahead(function(w) { | ||
w.scrollToTerm().skipWhitespaces(); | ||
return w.hasCurrent(); // In other words, there is a blank line inside | ||
}); | ||
var indent = this.blockIndent; | ||
if (b) { | ||
while (walk.hasCurrent()) | ||
this.emitBlock(walk); | ||
this.blockIndent = indent; | ||
} else this.emitInline(walk); | ||
this.out.push('</'); | ||
this.out.push(tag); | ||
this.out.push('>'); | ||
}, | ||
/* Headings start with `#`, the amount of pounds designate the level. */ | ||
@@ -627,2 +702,3 @@ | ||
var tableEndRe = /^-{3,}$/; | ||
},{"./defaults":3,"./extend":4,"./inline":5,"./walker":6}],2:[function(require,module,exports){ | ||
@@ -1526,5 +1602,5 @@ /* # Rho for browser */ | ||
found = c == "" || c == "\\" || c == "&" || c == "<" || | ||
c == ">" || c == "`" || c == "$" || c == '%' || c == "_" || | ||
c == ">" || c == "`" || c == "$" || c == "%" || c == "_" || | ||
c == "*" || c == "!" || c == "[" || c == "(" || c == "{" || | ||
c == "-" || c == "\""; | ||
c == "-" || c == "\"" || c == "="; | ||
if (!found) | ||
@@ -1571,4 +1647,4 @@ this.skip(); | ||
while (!found && w.hasCurrent()) { | ||
if (w.at("\\" + marker)) | ||
w.skip(marker.length + 1); | ||
if (w.at("\\")) | ||
w.skip(2); | ||
else if (w.at(marker)) | ||
@@ -1825,3 +1901,2 @@ found = true; | ||
},{"./extend":4}]},{},[2]) | ||
; | ||
},{"./extend":4}]},{},[2]); |
@@ -1,2 +0,2 @@ | ||
/*! Rho v.0.1.18 by Boris Okunskiy <boris@okunskiy.name> */ | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=a("./defaults"),e=a("./inline"),f=a("./walker").Walker,g=a("./walker").SubWalker,h=b.exports=c=function(b){this.options=a("./extend")({},d.options,b),this.reset()};h.prototype={InlineCompiler:e,toHtml:function(a){return this.reset().append(a).outToString()},reset:function(){return this.out=[],this.selector={},this.blockIndent=0,this.inline=new this.InlineCompiler(this.options,this),this.inline.out=this.out,this},append:function(a){return this.processBlocks(new f(a))},processBlocks:function(a){for(;a.hasCurrent();)this.emitBlock(a);return this},outToString:function(){for(var a="",b=0;b<this.out.length;b++)a+=this.out[b];return a},emitBlock:function(a){a.skipBlankLines(),this.countBlockIndent(a),this.tryUnorderedList(a)||this.tryOrderedList(a)||this.tryHeading(a)||this.tryCodeBlock(a)||this.tryDiv(a)||this.tryHtml(a)||this.tryHrTable(a)||this.emitParagraph(a)},emitInline:function(a){return this.inline.processInlines(a),this},countBlockIndent:function(a){for(this.blockIndent=0;a.hasCurrent()&&a.at(" ");)this.blockIndent+=1,a.skip()},stripSelector:function(a){this.selector={};for(var b=a.position;a.hasCurrent()&&!a.atNewLine();)if(a.at("\\{"))a.skip(2);else{if(a.at("{")){var c=a.position;for(a.skip(),this.trySelectorId(a);this.trySelectorClass(a););if(!a.at("}"))break;a.skip().skipSpaces();var d=a.position;return a.startFrom(b).exclude(c,d)}a.skip()}return this.selector={},a.startFrom(b),a},trySelectorId:function(a){if(!a.at("#"))return!1;a.skip();var b=a.lookahead(function(a){for(;a.hasCurrent()&&a.atIdentifier();)a.skip();return a.position});return this.selector.id=a.yieldUntil(b),!0},trySelectorClass:function(a){if(!a.at("."))return!1;a.skip();var b=a.lookahead(function(a){for(;a.hasCurrent()&&a.atIdentifier();)a.skip();return a.position});return Array.isArray(this.selector.classes)||(this.selector.classes=[]),this.selector.classes.push(a.yieldUntil(b)),!0},emitSelector:function(){if("string"==typeof this.selector.id&&this.out.push(' id="'+this.selector.id+'"'),Array.isArray(this.selector.classes)){this.out.push(' class="');for(var a in this.selector.classes)a>0&&this.out.push(" "),this.out.push(this.selector.classes[a]);this.out.push('"')}},tryCodeBlock:function(a){if(!a.at("```"))return!1;a.skip(3);var b=a.position,c=a.indexOf("```");if(null===c)return a.startFrom(b-3),!1;var d=this.stripSelector(new g(a,b,c));return this.out.push("<pre"),this.emitSelector(),this.out.push("><code>"),this.emitCode(d),this.out.push("</code></pre>"),a.startFrom(c+3).skipBlankLines(),!0},emitCode:function(a){for(a.skipBlankLines(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent);a.hasCurrent();)a.atNewLine()?(a.skipNewLine(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent),a.hasCurrent()&&this.out.push("\n")):this.inline.emitCode(a)},tryDiv:function(a){if(!a.at("~~~"))return!1;a.skip(3);var b=a.position,c=a.indexOf("~~~");if(null===c)return a.startFrom(b-3),!1;var d=this.stripSelector(new g(a,b,c));for(this.out.push("<div"),this.emitSelector(),this.out.push(">");d.hasCurrent();)this.emitBlock(d);return this.out.push("</div>\n"),a.startFrom(c+3).skipBlankLines(),!0},tryUnorderedList:function(a){if(!a.at("* "))return!1;for(var b=a.position,c=!1;!c&&a.hasCurrent();)if(a.scrollToTerm().skipBlankLines(),a.atSpaces(this.blockIndent)){var d=a.position;a.skip(this.blockIndent),a.at("* ")||a.atSpace()||(c=!0,a.startFrom(d))}else c=!0;var e=this.stripSelector(new g(a,b,a.position));return this.emitUl(e),!0},emitUl:function(a){this.out.push("<ul"),this.emitSelector(),this.out.push(">"),a.skip(2);for(var b=a.position;a.hasCurrent();)if(a.scrollToEol().skipBlankLines(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent).at("* ")){var c=this.stripSelector(new g(a,b,a.position));this.emitLi(c),a.skip(2),b=a.position}var d=this.stripSelector(new g(a,b,a.position));this.emitLi(d),this.out.push("</ul>\n")},tryOrderedList:function(a){if(!a.at("1. "))return!1;for(var b=a.position,c=!1;!c&&a.hasCurrent();)if(a.scrollToTerm().skipBlankLines(),a.atSpaces(this.blockIndent)){var d=a.position;a.skip(this.blockIndent),this.lookingAtOlMarker(a)||a.atSpace()||(c=!0,a.startFrom(d))}else c=!0;var e=this.stripSelector(new g(a,b,a.position));return this.emitOl(e),!0},lookingAtOlMarker:function(a){return a.atDigit()?a.lookahead(function(a){for(;a.atDigit();)a.skip();return a.at(". ")}):!1},emitOl:function(a){this.out.push("<ol"),this.emitSelector(),this.out.push(">"),a.skipDigits().skip(2);for(var b=a.position;a.hasCurrent();)if(a.scrollToEol().skipBlankLines(),a.atSpaces(this.blockIndent)&&this.lookingAtOlMarker(a.skip(this.blockIndent))){var c=this.stripSelector(new g(a,b,a.position));this.emitLi(c),a.skipDigits().skip(2),b=a.position}var d=this.stripSelector(new g(a,b,a.position));this.emitLi(d),this.out.push("</ol>\n")},emitLi:function(a){this.out.push("<li"),this.emitSelector(),this.out.push(">");var b=a.lookahead(function(a){return a.scrollToTerm().skipWhitespaces(),a.hasCurrent()}),c=this.blockIndent;if(b){for(;a.hasCurrent();)this.emitBlock(a);this.blockIndent=c}else this.emitInline(a);this.out.push("</li>")},tryHeading:function(a){if(!a.at("#"))return!1;for(var b=a.position,c=0;a.at("#");)a.skip(),c+=1;if(!a.at(" "))return a.startFrom(b),!1;var d="h"+c.toString();a.skip(),b=a.position,a.scrollToTerm();var e=this.stripSelector(new g(a,b,a.position));return this.out.push("<"),this.out.push(d),this.emitSelector(),this.out.push(">"),this.emitInline(e),this.out.push("</"),this.out.push(d),this.out.push(">"),!0},tryHtml:function(a){if(!a.at("<"))return!1;var b=a.indexOf(">");if(null===b)return!1;var c=a.substring(a.position,b+1),d=j.exec(c);if(null===d)return k.test(c)?(this.out.push(c),a.startFrom(b+1).skipBlankLines(),!0):!1;var e=d[1].toLowerCase();if(-1==i.indexOf(e))return!1;var f=a.position;a.startFrom(b),this.scrollToClosingTag(a,e);for(var h=new g(a,f,a.position);h.hasCurrent();)this.inline.emitPlain(h);return!0},scrollToClosingTag:function(a,b){for(var c="<"+b,d="</"+b,e=!1;!e&&a.hasCurrent();){if(a.atInsensitive(d))return a.skip(d.length).scrollTo(">").skip(),void 0;a.atInsensitive(c)?(a.skip(c.length).scrollTo(">").skip(),this.scrollToClosingTag(a,b)):a.skip()}},tryHrTable:function(a){if(!a.at("---"))return!1;var b=a.position;a.scrollToTerm();var c=this.stripSelector(new g(a,b,a.position));return"---"==c.toString().trim()?this.emitHr(c):this.emitTable(c),!0},emitHr:function(){this.out.push("<hr"),this.emitSelector(),this.out.push("/>")},emitTable:function(a){function b(){if(m.test(h.toString().trim()))return!0;for(var a=c.readCells(h);a.length>e;)a.pop();for(;a.length<e;)a.push("");return c.emitRow("td",a,f),!1}var c=this;for(this.out.push("<table"),this.emitSelector();a.at("-");)a.skip();a.at(">")&&(this.out.push(' width="100%"'),a.skip()),this.out.push(">"),a.skipWhitespaces();var d=this.readCells(a.readLine()),e=d.length,f=[],g=!1,h=a.readLine();if(l.test(h.toString().trim())){g=!0;var i=this.readCells(h);i.forEach(function(a,b){var c=a.trim(),d=":"==c[0],e=":"==c[c.length-1];d&&e?f[b]=' class="align-center"':d?f[b]=' class="align-left"':e&&(f[b]=' class="align-right"')})}g&&(this.out.push("<thead>"),this.emitRow("th",d,f),this.out.push("</thead>")),this.out.push("<tbody>");var j=!1;for(g||(this.emitRow("td",d,f),j=b());!j&&a.hasCurrent();)a.skipWhitespaces(),h=a.readLine(),j=b();this.out.push("</tbody>"),this.out.push("</table>")},emitRow:function(a,b,c){this.out.push("<tr"),this.emitSelector(),this.out.push(">");for(var d=0;d<b.length;d++){var e=b[d],g=c[d];this.out.push("<"),this.out.push(a),g&&this.out.push(g),this.out.push(">"),e.length&&this.emitInline(new f(e)),this.out.push("</"),this.out.push(a),this.out.push(">")}this.out.push("</tr>")},readCells:function(a){a=this.stripSelector(a);var b=[];a.skipWhitespaces(),a.at("|")&&a.skip();for(var c=a.position;a.hasCurrent()&&!a.atNewLine();)a.at("\\|")?a.skip(2):a.at("|")?(b.push(a.substring(c,a.position)),a.skip(),c=a.position):a.skip();var d=a.substring(c,a.position).trim();return""!=d&&b.push(d),a.skipWhitespaces(),b},emitParagraph:function(a){if(a.hasCurrent()){var b=a.position;a.scrollToTerm();var c=this.stripSelector(new g(a,b,a.position));this.out.push("<p"),this.emitSelector(),this.out.push(">"),this.emitInline(c),this.out.push("</p>\n")}}};var i=["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","noscript","ol","output","p","pre","section","table","ul","style","script"],j=/^<\/?([a-zA-Z]+)\b[\s\S]*?(\/)?>$/,k=/^<!--[\s\S]*?-->$/,l=/^[- :|]+$/,m=/^-{3,}$/},{"./defaults":3,"./extend":4,"./inline":5,"./walker":6}],2:[function(a){window.rho={options:a("./defaults"),BlockCompiler:a("./block"),InlineCompiler:a("./inline"),toHtml:function(a){return new rho.BlockCompiler(this.options).toHtml(a)},toInlineHtml:function(a){return new rho.InlineCompiler(this.options).toHtml(a)}}},{"./block":1,"./defaults":3,"./inline":5}],3:[function(a,b,c){"use strict";c.options={resolveLink:function(){return null},resolveImage:function(){return null},stripInvalidXmlChars:!0,typographics:{enabled:!0,mdash:"—",copy:"©",reg:"®",trade:"™",larr:"←",rarr:"→",ldquo:"“",rdquo:"”"}}},{}],4:[function(a,b){"use strict";var c=b.exports=function(){var a=arguments[0]||{},b=arguments.length;"object"!=typeof a&&(a={});for(var d=1;b>d;d++){var e=arguments[d];if(e)for(var f in e){var g=a[f];a[f]="object"==typeof g?c(g,e[f]):e[f]}}return a}},{}],5:[function(a,b,c){"use strict";function d(a){return"string"==typeof a&&(a=a.charCodeAt(0)),a>=1&&8>=a||a>=11&&12>=a||a>=14&&31>=a||a>=127&&132>=a||a>=134&&159>=a||a>=64976&&64991>=a||65534==a%65536||65535==a%65536}function e(a){return a.replace(n,"&").replace("<","<").replace(">",">").replace('"',""").replace("'","'")}var f=a("./defaults"),g=a("./walker").Walker,h=a("./walker").SubWalker,i=b.exports=c=function(b){this.options=a("./extend")({},f.options,b),this.reset()};i.prototype={toHtml:function(a){return this.reset().append(a).outToString()},reset:function(){return this.out=[],this},append:function(a){return this.processInlines(new g(a))},processInlines:function(a){for(;a.hasCurrent();)this.emitNormal(a);return this},outToString:function(){for(var a="",b=0;b<this.out.length;b++)a+=this.out[b];return a},emitNormal:function(a){this.emitText(a)||this.tryBackslashEscape(a)||this.options.typographics.enabled&&this.tryTypographics(a)||this.tryAmp(a)||this.tryLt(a)||this.tryGt(a)||this.tryTripleCodeSpan(a)||this.tryCodeSpan(a)||this.tryFormula(a)||this.tryEm(a)||this.tryStrong(a)||this.tryHeadlessLink(a)||this.tryLink(a)||this.tryImg(a)||this.emitChar(a)},emitChar:function(a){var b=a.current();this.options.stripInvalidXmlChars&&d(b)||this.out.push(b),a.skip()},emitText:function(a){var b=a.yieldText();return b.length>0&&this.out.push(b),!a.hasCurrent()},tryBackslashEscape:function(a){return a.at("\\")?(a.skip(),a.matchSome(j)?(this.out.push(a.current()),a.skip()):this.out.push("\\"),!0):!1},tryTypographics:function(a){if(a.at("--"))return a.skip(2),this.out.push(this.options.typographics.mdash),!0;if(a.at("(c)")||a.at("(C)"))return a.skip(3),this.out.push(this.options.typographics.copy),!0;if(a.at("(r)")||a.at("(R)"))return a.skip(3),this.out.push(this.options.typographics.reg),!0;if(a.at("(tm)")||a.at("(TM)"))return a.skip(4),this.out.push(this.options.typographics.trade),!0;if(a.at("<-"))return a.skip(2),this.out.push(this.options.typographics.larr),!0;if(a.at("<-"))return a.skip(5),this.out.push(this.options.typographics.larr),!0;if(a.at("->"))return a.skip(2),this.out.push(this.options.typographics.rarr),!0;if(a.at("->"))return a.skip(5),this.out.push(this.options.typographics.rarr),!0;if(a.at('"')){a.skip();var b=this.out[this.out.length-1]||"",c=b[b.length-1]||"";return""==c.trim()?this.out.push(this.options.typographics.ldquo):this.out.push(this.options.typographics.rdquo),!0}return!1},tryAmp:function(a){if(!a.at("&"))return!1;var b=a.lookahead(function(b){a.skip();var c=k;if(a.matchSome(["#x","#X"])?(c=l,a.skip(2)):a.at("#")&&(c=m,a.skip()),";"==b.current())return null;for(;b.hasCurrent();){var d=b.current();if(";"==d)return b.skip(),b.position;if(!b.matchSome(c))return null;b.skip()}return null});return null!==b?this.out.push(a.yieldUntil(b)):(this.out.push("&"),a.skip()),!0},tryLt:function(a){return a.at("<")?this.tryHtmlTag(a)?!0:this.tryHtmlComment(a)?!0:(this.out.push("<"),a.skip(),!0):!1},tryHtmlTag:function(a){var b=a.lookahead(function(a){if(a.skip(),a.at("/")&&a.skip(),!a.atLatin())return null;for(;a.atLatin();)a.skip();for(;a.hasCurrent();){if(a.at(">"))return a.skip(),a.position;if(a.at("/>"))return a.skip(2),a.position;a.skip()}return null});if(null===b)return!1;for(var c=new h(a,a.position,b);c.hasCurrent();)this.emitHtmlTag(c);return a.startFrom(b),!0},tryHtmlComment:function(a){if(!a.at("<!--"))return!1;var b=a.lookahead(function(a){for(a.skip(4);a.hasCurrent();){if(a.at("-->"))return a.position+3;a.skip()}return null});return null===b?!1:(this.out.push(a.yieldUntil(b)),!0)},emitHtmlTag:function(a){this.emitText(a)||this.tryAmp(a)||this.tryLinkAttr(a)||this.emitChar(a)},emitPlain:function(a){this.emitText(a)||this.emitChar(a)},tryGt:function(a){return a.at(">")?(this.out.push(">"),a.skip(),!0):!1},tryLtEscape:function(a){return a.at("<")?(this.out.push("<"),a.skip(),!0):!1},tryBracing:function(a,b,c,d){if(!a.at(b))return!1;a.skip(b.length);var e=a.indexOf(c);if(null===e)this.out.push(b);else{var f=new h(a,a.position,e);d.call(this,f),a.startFrom(e+c.length)}return!0},tryTripleCodeSpan:function(a){return this.tryBracing(a,"```","```",function(a){for(this.out.push("<code>");a.hasCurrent();)this.emitPlain(a);this.out.push("</code>")})},tryCodeSpan:function(a){return this.tryBracing(a,"`","`",function(a){for(this.out.push("<code>");a.hasCurrent();)this.emitCode(a);this.out.push("</code>")})},emitCode:function(a){this.tryBackslashEscape(a)||this.tryAmp(a)||this.tryLtEscape(a)||this.tryGt(a)||this.emitChar(a)},tryFormula:function(a){return this.tryFormulaM(a,"%%")||this.tryFormulaM(a,"$$")},tryFormulaM:function(a,b){return this.tryBracing(a,b,b,function(a){for(this.out.push(b);a.hasCurrent();)this.emitFormula(a);this.out.push(b)})},emitFormula:function(a){this.tryAmp(a)||this.tryLtEscape(a)||this.tryGt(a)||this.emitChar(a)},tryEm:function(a){return this.tryBracing(a,"_","_",function(a){for(this.out.push("<em>");a.hasCurrent();)this.emitNormal(a);this.out.push("</em>")})},tryStrong:function(a){return this.tryBracing(a,"*","*",function(a){for(this.out.push("<strong>");a.hasCurrent();)this.emitNormal(a);this.out.push("</strong>")})},emitLink:function(a,b){var c=b.url,d=b.external||this.options.externalLinks;c||(c=b.toString()),this.out.push('<a href="'+c+'"'),b.title&&this.out.push(' title="'+e(b.title)+'"'),d&&this.out.push(' target="_blank"');var f=new i(this.options).toHtml(a);this.out.push(">"+f+"</a>")},tryHeadlessLink:function(a){if(!a.at("[["))return!1;a.skip(2);var b=a.indexOf("]]");if(null===b)return this.out.push("[["),!0;var c=a.yieldUntil(b),d=this.options.resolveLink(c);return d?this.emitLink(d.title,d):this.out.push("[["+c+"]]"),a.skip(2),!0},tryLink:function(a){if(!a.at("["))return!1;a.skip();var b=a.position,c=a.indexOf("]");if(null===c)return this.out.push("["),!0;var d=a.yieldUntil(c);return a.skip(),this.tryInlineLink(d,a)?!0:this.tryRefLink(d,a)?!0:(a.startFrom(b),this.out.push("["),!0)},tryInlineLink:function(a,b){if(!b.at("("))return!1;var c=b.indexOf(")");if(null===c)return!1;b.skip();var d=b.yieldUntil(c);return b.skip(),this.emitLink(a,d),!0},tryRefLink:function(a,b){if(!b.at("["))return!1;var c=b.position;b.skip();var d=b.indexOf("]");if(null!==d){var e=b.yieldUntil(d),f=this.options.resolveLink(e);if(f)return this.emitLink(a,f),b.skip(),!0}return b.startFrom(c),!1},emitImg:function(a,b){if(b.html)return this.out.push(b.html),void 0;var c=b.url;c||(c=b.toString()),this.out.push('<img src="'+c+'" alt="'+e(a)+'"'),b.title&&this.out.push(' title="'+e(b.title)+'"'),this.out.push("/>")},tryImg:function(a){if(!a.at("!["))return!1;a.skip(2);var b=a.position,c=a.indexOf("]");if(null===c)return this.out.push("!["),!0;var d=a.yieldUntil(c);return a.skip(),this.tryInlineImg(d,a)?!0:this.tryRefImg(d,a)?!0:(a.startFrom(b),this.out.push("!["),!0)},tryInlineImg:function(a,b){if(!b.at("("))return!1;var c=b.indexOf(")");if(null===c)return!1;b.skip();var d=b.yieldUntil(c);return b.skip(),this.emitImg(a,d),!0},tryRefImg:function(a,b){if(!b.at("["))return!1;var c=b.position;b.skip();var d=b.indexOf("]");if(null!==d){var e=b.yieldUntil(d),f=this.options.resolveImage(e);if(f)return this.emitImg(a,f),b.skip(),!0}return b.startFrom(c),!1},tryLinkAttr:function(a){if(!a.at("["))return!1;var b=a.position;a.skip();var c=a.indexOf("]");if(null!==c){var d=a.yieldUntil(c),e=this.options.resolveLink(d);if(e){var f=e.url;return f||(f=e.toString()),this.out.push(f),a.skip(),!0}}return a.startFrom(b),!1}};var j="\\.+*[]()`{}_!-|~'\"",k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="0123456789abcdefABCDEF",m="0123456789",n=/&(?!(?:[a-zA-Z]+|#[0-9]+|#[xX][0-9a-fA-F]+);)/g},{"./defaults":3,"./extend":4,"./walker":6}],6:[function(a,b,c){"use strict";var d=a("./extend"),e=c.Walker=function(a){this.source=a||"",this.position=0,this.length=this.source.length};e.prototype={charAt:function(a){return a>=this.length?"":this.source.charAt(a)},substring:function(a,b){return"undefined"==typeof b&&(b=this.source.length),this.source.substring(a,b)},toString:function(){return this.source.toString()},exclude:function(a,b){if(0==b-a)return this;if(0==a&&b==this.length)return new e("");if(0==a)return new f(this,b,this.length);if(b==this.length)return new f(this,0,a);var c=new f(this,0,a),d=new f(this,b,this.length);return new g([c,d])},current:function(){return this.charAt(this.position)},hasCurrent:function(){return this.position>=0&&this.position<this.length},hasNext:function(){return this.position+1<this.length},skip:function(a){return"undefined"==typeof a&&(a=1),this.position+=a,this},peek:function(){return this.charAt(this.position+1)},reset:function(){return this.position=0,this},startFrom:function(a){return this.position=a,this},lookahead:function(a){var b=this.position,c=a(this);return this.position=b,c},yieldUntil:function(a){if(a<=this.position)return"";var b=this.substring(this.position,a);return this.startFrom(a),b},yieldText:function(){for(var a=!1,b=this.position;!a&&this.hasCurrent();){var c=this.current();a=""==c||"\\"==c||"&"==c||"<"==c||">"==c||"`"==c||"$"==c||"%"==c||"_"==c||"*"==c||"!"==c||"["==c||"("==c||"{"==c||"-"==c||'"'==c,a||this.skip()}return this.substring(b,this.position)},scrollToEol:function(){for(;this.hasCurrent()&&!this.atNewLine();)this.skip();return this},scrollToTerm:function(){for(var a=!1;this.hasCurrent()&&!a;)if(this.atNewLine()){var b=this.position;this.skipNewLine().skipSpaces().atNewLine()?(this.startFrom(b),a=!0):this.skip()}else this.skip();return this},scrollTo:function(a){for(;this.hasCurrent()&&!this.at(a);)this.skip();return this},indexOf:function(a){return this.lookahead(function(b){for(var c=!1;!c&&b.hasCurrent();)b.at("\\"+a)?b.skip(a.length+1):b.at(a)?c=!0:b.skip();return c?b.position:null})},at:function(a){var b=this.position+a.length;return b>this.length?!1:this.substring(this.position,b)==a},atInsensitive:function(a){var b=this.position+a.length;return b>this.length?!1:this.substring(this.position,b).toLowerCase()==a.toLowerCase()},matchSome:function(a){for(var b=0;b<a.length;b++)if(this.at(a[b]))return a[b];return null},atDigit:function(){var a=this.current();return a>="0"&&"9">=a},skipDigits:function(){for(;this.atDigit();)this.skip();return this},atLatin:function(){var a=this.current();return a>="A"&&"z">=a},atIdentifier:function(){var a=this.current();return a>="0"&&"9">=a||a>="A"&&"z">=a||"_"==a||"-"==a},atNewLine:function(){return this.at("\r\n")||this.at("\n")||this.at("\r")},skipNewLine:function(){return this.at("\r\n")?this.skip(2):this.atNewLine()&&this.skip(),this},skipNewLines:function(){for(;this.atNewLine();)this.skipNewLine();return this},atSpace:function(){return this.at(" ")||this.at(" ")},atSpaces:function(a){return this.lookahead(function(b){for(var c=0;a>c;c++){if(!b.hasCurrent()||!b.at(" "))return!1;b.skip()}return!0})},skipSpace:function(){return this.atSpace()&&this.skip(),this},skipSpaces:function(){for(;this.atSpace();)this.skip();return this},atWhitespace:function(){return this.atNewLine()||this.atSpace()},skipWhitespace:function(){var a=this.position;return this.skipNewLine(),this.position==a&&this.skipSpace(),this},skipWhitespaces:function(){for(;this.atWhitespace();)this.skip();return this},skipBlankLines:function(){for(var a=!1;this.hasCurrent()&&!a;){var b=this.position;this.skipSpaces(),this.atNewLine()?this.skipNewLines():(this.position=b,a=!0)}return this},readLine:function(){var a=this.position;return this.scrollToEol().skipNewLine(),new f(this,a,this.position)}};var f=c.SubWalker=function(a,b,c){this.source=a,this.start=b,("undefined"==typeof b||this.start<0)&&(this.start=0),this.end=c,("undefined"==typeof c||this.end>a.length)&&(this.end=a.length),this.length=this.end-this.start};f.prototype=d({},new e,{charAt:function(a){return a>=this.length?"":this.source.charAt(this.start+a)},substring:function(a,b){return"undefined"==typeof b&&(b=this.length),this.source.substring(this.start+a,this.start+b)},toString:function(){return this.source.substring(this.start,this.end)}});var g=c.MultiWalker=function(a){this.regions=Array.isArray(a)?a:[a];var b=0;this.regions.forEach(function(a){b+=a.length}),this.length=b,this.string=function(){for(var a="",b=0;b<this.regions.length;b++)a+=this.regions[b];return a}.call(this)};g.prototype=d({},new e,{charAt:function(a){return this.string.charAt(a)},substring:function(a,b){return 0==this.regions.length?"":this.string.substring(a,b)},toString:function(){return this.string}})},{"./extend":4}]},{},[2]); | ||
/*! Rho v.0.1.19 by Boris Okunskiy <boris@okunskiy.name> */ | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=a("./defaults"),e=a("./inline"),f=a("./walker").Walker,g=a("./walker").SubWalker,h=b.exports=c=function(b){this.options=a("./extend")({},d.options,b),this.reset()};h.prototype={InlineCompiler:e,toHtml:function(a){return this.reset().append(a).outToString()},reset:function(){return this.out=[],this.selector={},this.blockIndent=0,this.inline=new this.InlineCompiler(this.options,this),this.inline.out=this.out,this},append:function(a){return this.processBlocks(new f(a))},processBlocks:function(a){for(;a.hasCurrent();)this.emitBlock(a);return this},outToString:function(){for(var a="",b=0;b<this.out.length;b++)a+=this.out[b];return a},emitBlock:function(a){a.skipBlankLines(),this.countBlockIndent(a),this.tryUnorderedList(a)||this.tryOrderedList(a)||this.tryDefinitionList(a)||this.tryHeading(a)||this.tryCodeBlock(a)||this.tryDiv(a)||this.tryHtml(a)||this.tryHrTable(a)||this.emitParagraph(a)},emitInline:function(a){return this.inline.processInlines(a),this},countBlockIndent:function(a){for(this.blockIndent=0;a.hasCurrent()&&a.at(" ");)this.blockIndent+=1,a.skip()},stripSelector:function(a){this.selector={};for(var b=a.position;a.hasCurrent()&&!a.atNewLine();)if(a.at("\\{"))a.skip(2);else{if(a.at("{")){var c=a.position;for(a.skip(),this.trySelectorId(a);this.trySelectorClass(a););if(!a.at("}"))break;a.skip().skipSpaces();var d=a.position;return a.startFrom(b).exclude(c,d)}a.skip()}return this.selector={},a.startFrom(b),a},trySelectorId:function(a){if(!a.at("#"))return!1;a.skip();var b=a.lookahead(function(a){for(;a.hasCurrent()&&a.atIdentifier();)a.skip();return a.position});return this.selector.id=a.yieldUntil(b),!0},trySelectorClass:function(a){if(!a.at("."))return!1;a.skip();var b=a.lookahead(function(a){for(;a.hasCurrent()&&a.atIdentifier();)a.skip();return a.position});return Array.isArray(this.selector.classes)||(this.selector.classes=[]),this.selector.classes.push(a.yieldUntil(b)),!0},emitSelector:function(){if("string"==typeof this.selector.id&&this.out.push(' id="'+this.selector.id+'"'),Array.isArray(this.selector.classes)){this.out.push(' class="');for(var a in this.selector.classes)a>0&&this.out.push(" "),this.out.push(this.selector.classes[a]);this.out.push('"')}},tryCodeBlock:function(a){if(!a.at("```"))return!1;a.skip(3);var b=a.position,c=a.indexOf("```");if(null===c)return a.startFrom(b-3),!1;var d=this.stripSelector(new g(a,b,c));return this.out.push("<pre"),this.emitSelector(),this.out.push("><code>"),this.emitCode(d),this.out.push("</code></pre>"),a.startFrom(c+3).skipBlankLines(),!0},emitCode:function(a){for(a.skipBlankLines(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent);a.hasCurrent();)a.atNewLine()?(a.skipNewLine(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent),a.hasCurrent()&&this.out.push("\n")):this.inline.emitCode(a)},tryDiv:function(a){if(!a.at("~~~"))return!1;a.skip(3);var b=a.position,c=a.indexOf("~~~");if(null===c)return a.startFrom(b-3),!1;var d=this.stripSelector(new g(a,b,c));for(this.out.push("<div"),this.emitSelector(),this.out.push(">");d.hasCurrent();)this.emitBlock(d);return this.out.push("</div>\n"),a.startFrom(c+3).skipBlankLines(),!0},tryUnorderedList:function(a){if(!a.at("* "))return!1;for(var b=a.position,c=!1;!c&&a.hasCurrent();)if(a.scrollToTerm().skipBlankLines(),a.atSpaces(this.blockIndent)){var d=a.position;a.skip(this.blockIndent),a.at("* ")||a.atSpace()||(c=!0,a.startFrom(d))}else c=!0;var e=this.stripSelector(new g(a,b,a.position));return this.emitUl(e),!0},emitUl:function(a){this.out.push("<ul"),this.emitSelector(),this.out.push(">"),a.skip(2);for(var b=a.position;a.hasCurrent();)if(a.scrollToEol().skipBlankLines(),a.atSpaces(this.blockIndent)&&a.skip(this.blockIndent).at("* ")){var c=this.stripSelector(new g(a,b,a.position));this.emitLi(c),a.skip(2),b=a.position}var d=this.stripSelector(new g(a,b,a.position));this.emitLi(d),this.out.push("</ul>\n")},tryOrderedList:function(a){if(!a.at("1. "))return!1;for(var b=a.position,c=!1;!c&&a.hasCurrent();)if(a.scrollToTerm().skipBlankLines(),a.atSpaces(this.blockIndent)){var d=a.position;a.skip(this.blockIndent),this.lookingAtOlMarker(a)||a.atSpace()||(c=!0,a.startFrom(d))}else c=!0;var e=this.stripSelector(new g(a,b,a.position));return this.emitOl(e),!0},lookingAtOlMarker:function(a){return a.atDigit()?a.lookahead(function(a){for(;a.atDigit();)a.skip();return a.at(". ")}):!1},emitOl:function(a){this.out.push("<ol"),this.emitSelector(),this.out.push(">"),a.skipDigits().skip(2);for(var b=a.position;a.hasCurrent();)if(a.scrollToEol().skipBlankLines(),a.atSpaces(this.blockIndent)&&this.lookingAtOlMarker(a.skip(this.blockIndent))){var c=this.stripSelector(new g(a,b,a.position));this.emitLi(c),a.skipDigits().skip(2),b=a.position}var d=this.stripSelector(new g(a,b,a.position));this.emitLi(d),this.out.push("</ol>\n")},emitLi:function(a){this.out.push("<li"),this.emitSelector(),this.out.push(">");var b=a.lookahead(function(a){return a.scrollToTerm().skipWhitespaces(),a.hasCurrent()}),c=this.blockIndent;if(b){for(;a.hasCurrent();)this.emitBlock(a);this.blockIndent=c}else this.emitInline(a);this.out.push("</li>")},tryDefinitionList:function(a){if(!a.at("= ")&&!a.at("- "))return!1;for(var b=a.position,c=!1;!c&&a.hasCurrent();)if(a.scrollToTerm().skipBlankLines(),a.atSpaces(this.blockIndent)){var d=a.position;a.skip(this.blockIndent),a.at("= ")||a.at("- ")||a.atSpace()||(c=!0,a.startFrom(d))}else c=!0;var e=this.stripSelector(new g(a,b,a.position));return this.emitDl(e),!0},emitDl:function(a){this.out.push("<dl"),this.emitSelector(),this.out.push(">");for(var b=a.position;a.hasCurrent();)if(a.scrollToEol().skipBlankLines(),a.atSpaces(this.blockIndent)&&(a.skip(this.blockIndent),a.at("= ")||a.at("- "))){var c=this.stripSelector(new g(a,b,a.position));this.emitDtDd(c),b=a.position}var d=this.stripSelector(new g(a,b,a.position));this.emitDtDd(d),this.out.push("</dl>\n")},emitDtDd:function(a){var b=a.at("= ")?"dt":"dd";a.skip(2),this.out.push("<"),this.out.push(b),this.emitSelector(),this.out.push(">");var c=a.lookahead(function(a){return a.scrollToTerm().skipWhitespaces(),a.hasCurrent()}),d=this.blockIndent;if(c){for(;a.hasCurrent();)this.emitBlock(a);this.blockIndent=d}else this.emitInline(a);this.out.push("</"),this.out.push(b),this.out.push(">")},tryHeading:function(a){if(!a.at("#"))return!1;for(var b=a.position,c=0;a.at("#");)a.skip(),c+=1;if(!a.at(" "))return a.startFrom(b),!1;var d="h"+c.toString();a.skip(),b=a.position,a.scrollToTerm();var e=this.stripSelector(new g(a,b,a.position));return this.out.push("<"),this.out.push(d),this.emitSelector(),this.out.push(">"),this.emitInline(e),this.out.push("</"),this.out.push(d),this.out.push(">"),!0},tryHtml:function(a){if(!a.at("<"))return!1;var b=a.indexOf(">");if(null===b)return!1;var c=a.substring(a.position,b+1),d=j.exec(c);if(null===d)return k.test(c)?(this.out.push(c),a.startFrom(b+1).skipBlankLines(),!0):!1;var e=d[1].toLowerCase();if(-1==i.indexOf(e))return!1;var f=a.position;a.startFrom(b),this.scrollToClosingTag(a,e);for(var h=new g(a,f,a.position);h.hasCurrent();)this.inline.emitPlain(h);return!0},scrollToClosingTag:function(a,b){for(var c="<"+b,d="</"+b,e=!1;!e&&a.hasCurrent();){if(a.atInsensitive(d))return void a.skip(d.length).scrollTo(">").skip();a.atInsensitive(c)?(a.skip(c.length).scrollTo(">").skip(),this.scrollToClosingTag(a,b)):a.skip()}},tryHrTable:function(a){if(!a.at("---"))return!1;var b=a.position;a.scrollToTerm();var c=this.stripSelector(new g(a,b,a.position));return"---"==c.toString().trim()?this.emitHr(c):this.emitTable(c),!0},emitHr:function(){this.out.push("<hr"),this.emitSelector(),this.out.push("/>")},emitTable:function(a){function b(){if(m.test(h.toString().trim()))return!0;for(var a=c.readCells(h);a.length>e;)a.pop();for(;a.length<e;)a.push("");return c.emitRow("td",a,f),!1}var c=this;for(this.out.push("<table"),this.emitSelector();a.at("-");)a.skip();a.at(">")&&(this.out.push(' width="100%"'),a.skip()),this.out.push(">"),a.skipWhitespaces();var d=this.readCells(a.readLine()),e=d.length,f=[],g=!1,h=a.readLine();if(l.test(h.toString().trim())){g=!0;var i=this.readCells(h);i.forEach(function(a,b){var c=a.trim(),d=":"==c[0],e=":"==c[c.length-1];d&&e?f[b]=' class="align-center"':d?f[b]=' class="align-left"':e&&(f[b]=' class="align-right"')})}g&&(this.out.push("<thead>"),this.emitRow("th",d,f),this.out.push("</thead>")),this.out.push("<tbody>");var j=!1;for(g||(this.emitRow("td",d,f),j=b());!j&&a.hasCurrent();)a.skipWhitespaces(),h=a.readLine(),j=b();this.out.push("</tbody>"),this.out.push("</table>")},emitRow:function(a,b,c){this.out.push("<tr"),this.emitSelector(),this.out.push(">");for(var d=0;d<b.length;d++){var e=b[d],g=c[d];this.out.push("<"),this.out.push(a),g&&this.out.push(g),this.out.push(">"),e.length&&this.emitInline(new f(e)),this.out.push("</"),this.out.push(a),this.out.push(">")}this.out.push("</tr>")},readCells:function(a){a=this.stripSelector(a);var b=[];a.skipWhitespaces(),a.at("|")&&a.skip();for(var c=a.position;a.hasCurrent()&&!a.atNewLine();)a.at("\\|")?a.skip(2):a.at("|")?(b.push(a.substring(c,a.position)),a.skip(),c=a.position):a.skip();var d=a.substring(c,a.position).trim();return""!=d&&b.push(d),a.skipWhitespaces(),b},emitParagraph:function(a){if(a.hasCurrent()){var b=a.position;a.scrollToTerm();var c=this.stripSelector(new g(a,b,a.position));this.out.push("<p"),this.emitSelector(),this.out.push(">"),this.emitInline(c),this.out.push("</p>\n")}}};var i=["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","noscript","ol","output","p","pre","section","table","ul","style","script"],j=/^<\/?([a-zA-Z]+)\b[\s\S]*?(\/)?>$/,k=/^<!--[\s\S]*?-->$/,l=/^[- :|]+$/,m=/^-{3,}$/},{"./defaults":3,"./extend":4,"./inline":5,"./walker":6}],2:[function(a){window.rho={options:a("./defaults"),BlockCompiler:a("./block"),InlineCompiler:a("./inline"),toHtml:function(a){return new rho.BlockCompiler(this.options).toHtml(a)},toInlineHtml:function(a){return new rho.InlineCompiler(this.options).toHtml(a)}}},{"./block":1,"./defaults":3,"./inline":5}],3:[function(a,b,c){"use strict";c.options={resolveLink:function(){return null},resolveImage:function(){return null},stripInvalidXmlChars:!0,typographics:{enabled:!0,mdash:"—",copy:"©",reg:"®",trade:"™",larr:"←",rarr:"→",ldquo:"“",rdquo:"”"}}},{}],4:[function(a,b){"use strict";var c=b.exports=function(){var a=arguments[0]||{},b=arguments.length;"object"!=typeof a&&(a={});for(var d=1;b>d;d++){var e=arguments[d];if(e)for(var f in e){var g=a[f];a[f]="object"==typeof g?c(g,e[f]):e[f]}}return a}},{}],5:[function(a,b,c){"use strict";function d(a){return"string"==typeof a&&(a=a.charCodeAt(0)),a>=1&&8>=a||a>=11&&12>=a||a>=14&&31>=a||a>=127&&132>=a||a>=134&&159>=a||a>=64976&&64991>=a||a%65536==65534||a%65536==65535}function e(a){return a.replace(n,"&").replace("<","<").replace(">",">").replace('"',""").replace("'","'")}var f=a("./defaults"),g=a("./walker").Walker,h=a("./walker").SubWalker,i=b.exports=c=function(b){this.options=a("./extend")({},f.options,b),this.reset()};i.prototype={toHtml:function(a){return this.reset().append(a).outToString()},reset:function(){return this.out=[],this},append:function(a){return this.processInlines(new g(a))},processInlines:function(a){for(;a.hasCurrent();)this.emitNormal(a);return this},outToString:function(){for(var a="",b=0;b<this.out.length;b++)a+=this.out[b];return a},emitNormal:function(a){this.emitText(a)||this.tryBackslashEscape(a)||this.options.typographics.enabled&&this.tryTypographics(a)||this.tryAmp(a)||this.tryLt(a)||this.tryGt(a)||this.tryTripleCodeSpan(a)||this.tryCodeSpan(a)||this.tryFormula(a)||this.tryEm(a)||this.tryStrong(a)||this.tryHeadlessLink(a)||this.tryLink(a)||this.tryImg(a)||this.emitChar(a)},emitChar:function(a){var b=a.current();this.options.stripInvalidXmlChars&&d(b)||this.out.push(b),a.skip()},emitText:function(a){var b=a.yieldText();return b.length>0&&this.out.push(b),!a.hasCurrent()},tryBackslashEscape:function(a){return a.at("\\")?(a.skip(),a.matchSome(j)?(this.out.push(a.current()),a.skip()):this.out.push("\\"),!0):!1},tryTypographics:function(a){if(a.at("--"))return a.skip(2),this.out.push(this.options.typographics.mdash),!0;if(a.at("(c)")||a.at("(C)"))return a.skip(3),this.out.push(this.options.typographics.copy),!0;if(a.at("(r)")||a.at("(R)"))return a.skip(3),this.out.push(this.options.typographics.reg),!0;if(a.at("(tm)")||a.at("(TM)"))return a.skip(4),this.out.push(this.options.typographics.trade),!0;if(a.at("<-"))return a.skip(2),this.out.push(this.options.typographics.larr),!0;if(a.at("<-"))return a.skip(5),this.out.push(this.options.typographics.larr),!0;if(a.at("->"))return a.skip(2),this.out.push(this.options.typographics.rarr),!0;if(a.at("->"))return a.skip(5),this.out.push(this.options.typographics.rarr),!0;if(a.at('"')){a.skip();var b=this.out[this.out.length-1]||"",c=b[b.length-1]||"";return this.out.push(""==c.trim()?this.options.typographics.ldquo:this.options.typographics.rdquo),!0}return!1},tryAmp:function(a){if(!a.at("&"))return!1;var b=a.lookahead(function(b){a.skip();var c=k;if(a.matchSome(["#x","#X"])?(c=l,a.skip(2)):a.at("#")&&(c=m,a.skip()),";"==b.current())return null;for(;b.hasCurrent();){var d=b.current();if(";"==d)return b.skip(),b.position;if(!b.matchSome(c))return null;b.skip()}return null});return null!==b?this.out.push(a.yieldUntil(b)):(this.out.push("&"),a.skip()),!0},tryLt:function(a){return a.at("<")?this.tryHtmlTag(a)?!0:this.tryHtmlComment(a)?!0:(this.out.push("<"),a.skip(),!0):!1},tryHtmlTag:function(a){var b=a.lookahead(function(a){if(a.skip(),a.at("/")&&a.skip(),!a.atLatin())return null;for(;a.atLatin();)a.skip();for(;a.hasCurrent();){if(a.at(">"))return a.skip(),a.position;if(a.at("/>"))return a.skip(2),a.position;a.skip()}return null});if(null===b)return!1;for(var c=new h(a,a.position,b);c.hasCurrent();)this.emitHtmlTag(c);return a.startFrom(b),!0},tryHtmlComment:function(a){if(!a.at("<!--"))return!1;var b=a.lookahead(function(a){for(a.skip(4);a.hasCurrent();){if(a.at("-->"))return a.position+3;a.skip()}return null});return null===b?!1:(this.out.push(a.yieldUntil(b)),!0)},emitHtmlTag:function(a){this.emitText(a)||this.tryAmp(a)||this.tryLinkAttr(a)||this.emitChar(a)},emitPlain:function(a){this.emitText(a)||this.emitChar(a)},tryGt:function(a){return a.at(">")?(this.out.push(">"),a.skip(),!0):!1},tryLtEscape:function(a){return a.at("<")?(this.out.push("<"),a.skip(),!0):!1},tryBracing:function(a,b,c,d){if(!a.at(b))return!1;a.skip(b.length);var e=a.indexOf(c);if(null===e)this.out.push(b);else{var f=new h(a,a.position,e);d.call(this,f),a.startFrom(e+c.length)}return!0},tryTripleCodeSpan:function(a){return this.tryBracing(a,"```","```",function(a){for(this.out.push("<code>");a.hasCurrent();)this.emitPlain(a);this.out.push("</code>")})},tryCodeSpan:function(a){return this.tryBracing(a,"`","`",function(a){for(this.out.push("<code>");a.hasCurrent();)this.emitCode(a);this.out.push("</code>")})},emitCode:function(a){this.tryBackslashEscape(a)||this.tryAmp(a)||this.tryLtEscape(a)||this.tryGt(a)||this.emitChar(a)},tryFormula:function(a){return this.tryFormulaM(a,"%%")||this.tryFormulaM(a,"$$")},tryFormulaM:function(a,b){return this.tryBracing(a,b,b,function(a){for(this.out.push(b);a.hasCurrent();)this.emitFormula(a);this.out.push(b)})},emitFormula:function(a){this.tryAmp(a)||this.tryLtEscape(a)||this.tryGt(a)||this.emitChar(a)},tryEm:function(a){return this.tryBracing(a,"_","_",function(a){for(this.out.push("<em>");a.hasCurrent();)this.emitNormal(a);this.out.push("</em>")})},tryStrong:function(a){return this.tryBracing(a,"*","*",function(a){for(this.out.push("<strong>");a.hasCurrent();)this.emitNormal(a);this.out.push("</strong>")})},emitLink:function(a,b){var c=b.url,d=b.external||this.options.externalLinks;c||(c=b.toString()),this.out.push('<a href="'+c+'"'),b.title&&this.out.push(' title="'+e(b.title)+'"'),d&&this.out.push(' target="_blank"');var f=new i(this.options).toHtml(a);this.out.push(">"+f+"</a>")},tryHeadlessLink:function(a){if(!a.at("[["))return!1;a.skip(2);var b=a.indexOf("]]");if(null===b)return this.out.push("[["),!0;var c=a.yieldUntil(b),d=this.options.resolveLink(c);return d?this.emitLink(d.title,d):this.out.push("[["+c+"]]"),a.skip(2),!0},tryLink:function(a){if(!a.at("["))return!1;a.skip();var b=a.position,c=a.indexOf("]");if(null===c)return this.out.push("["),!0;var d=a.yieldUntil(c);return a.skip(),this.tryInlineLink(d,a)?!0:this.tryRefLink(d,a)?!0:(a.startFrom(b),this.out.push("["),!0)},tryInlineLink:function(a,b){if(!b.at("("))return!1;var c=b.indexOf(")");if(null===c)return!1;b.skip();var d=b.yieldUntil(c);return b.skip(),this.emitLink(a,d),!0},tryRefLink:function(a,b){if(!b.at("["))return!1;var c=b.position;b.skip();var d=b.indexOf("]");if(null!==d){var e=b.yieldUntil(d),f=this.options.resolveLink(e);if(f)return this.emitLink(a,f),b.skip(),!0}return b.startFrom(c),!1},emitImg:function(a,b){if(b.html)return void this.out.push(b.html);var c=b.url;c||(c=b.toString()),this.out.push('<img src="'+c+'" alt="'+e(a)+'"'),b.title&&this.out.push(' title="'+e(b.title)+'"'),this.out.push("/>")},tryImg:function(a){if(!a.at("!["))return!1;a.skip(2);var b=a.position,c=a.indexOf("]");if(null===c)return this.out.push("!["),!0;var d=a.yieldUntil(c);return a.skip(),this.tryInlineImg(d,a)?!0:this.tryRefImg(d,a)?!0:(a.startFrom(b),this.out.push("!["),!0)},tryInlineImg:function(a,b){if(!b.at("("))return!1;var c=b.indexOf(")");if(null===c)return!1;b.skip();var d=b.yieldUntil(c);return b.skip(),this.emitImg(a,d),!0},tryRefImg:function(a,b){if(!b.at("["))return!1;var c=b.position;b.skip();var d=b.indexOf("]");if(null!==d){var e=b.yieldUntil(d),f=this.options.resolveImage(e);if(f)return this.emitImg(a,f),b.skip(),!0}return b.startFrom(c),!1},tryLinkAttr:function(a){if(!a.at("["))return!1;var b=a.position;a.skip();var c=a.indexOf("]");if(null!==c){var d=a.yieldUntil(c),e=this.options.resolveLink(d);if(e){var f=e.url;return f||(f=e.toString()),this.out.push(f),a.skip(),!0}}return a.startFrom(b),!1}};var j="\\.+*[]()`{}_!-|~'\"",k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="0123456789abcdefABCDEF",m="0123456789",n=/&(?!(?:[a-zA-Z]+|#[0-9]+|#[xX][0-9a-fA-F]+);)/g},{"./defaults":3,"./extend":4,"./walker":6}],6:[function(a,b,c){"use strict";var d=a("./extend"),e=c.Walker=function(a){this.source=a||"",this.position=0,this.length=this.source.length};e.prototype={charAt:function(a){return a>=this.length?"":this.source.charAt(a)},substring:function(a,b){return"undefined"==typeof b&&(b=this.source.length),this.source.substring(a,b)},toString:function(){return this.source.toString()},exclude:function(a,b){if(b-a==0)return this;if(0==a&&b==this.length)return new e("");if(0==a)return new f(this,b,this.length);if(b==this.length)return new f(this,0,a);var c=new f(this,0,a),d=new f(this,b,this.length);return new g([c,d])},current:function(){return this.charAt(this.position)},hasCurrent:function(){return this.position>=0&&this.position<this.length},hasNext:function(){return this.position+1<this.length},skip:function(a){return"undefined"==typeof a&&(a=1),this.position+=a,this},peek:function(){return this.charAt(this.position+1)},reset:function(){return this.position=0,this},startFrom:function(a){return this.position=a,this},lookahead:function(a){var b=this.position,c=a(this);return this.position=b,c},yieldUntil:function(a){if(a<=this.position)return"";var b=this.substring(this.position,a);return this.startFrom(a),b},yieldText:function(){for(var a=!1,b=this.position;!a&&this.hasCurrent();){var c=this.current();a=""==c||"\\"==c||"&"==c||"<"==c||">"==c||"`"==c||"$"==c||"%"==c||"_"==c||"*"==c||"!"==c||"["==c||"("==c||"{"==c||"-"==c||'"'==c||"="==c,a||this.skip()}return this.substring(b,this.position)},scrollToEol:function(){for(;this.hasCurrent()&&!this.atNewLine();)this.skip();return this},scrollToTerm:function(){for(var a=!1;this.hasCurrent()&&!a;)if(this.atNewLine()){var b=this.position;this.skipNewLine().skipSpaces().atNewLine()?(this.startFrom(b),a=!0):this.skip()}else this.skip();return this},scrollTo:function(a){for(;this.hasCurrent()&&!this.at(a);)this.skip();return this},indexOf:function(a){return this.lookahead(function(b){for(var c=!1;!c&&b.hasCurrent();)b.at("\\")?b.skip(2):b.at(a)?c=!0:b.skip();return c?b.position:null})},at:function(a){var b=this.position+a.length;return b>this.length?!1:this.substring(this.position,b)==a},atInsensitive:function(a){var b=this.position+a.length;return b>this.length?!1:this.substring(this.position,b).toLowerCase()==a.toLowerCase()},matchSome:function(a){for(var b=0;b<a.length;b++)if(this.at(a[b]))return a[b];return null},atDigit:function(){var a=this.current();return a>="0"&&"9">=a},skipDigits:function(){for(;this.atDigit();)this.skip();return this},atLatin:function(){var a=this.current();return a>="A"&&"z">=a},atIdentifier:function(){var a=this.current();return a>="0"&&"9">=a||a>="A"&&"z">=a||"_"==a||"-"==a},atNewLine:function(){return this.at("\r\n")||this.at("\n")||this.at("\r")},skipNewLine:function(){return this.at("\r\n")?this.skip(2):this.atNewLine()&&this.skip(),this},skipNewLines:function(){for(;this.atNewLine();)this.skipNewLine();return this},atSpace:function(){return this.at(" ")||this.at(" ")},atSpaces:function(a){return this.lookahead(function(b){for(var c=0;a>c;c++){if(!b.hasCurrent()||!b.at(" "))return!1;b.skip()}return!0})},skipSpace:function(){return this.atSpace()&&this.skip(),this},skipSpaces:function(){for(;this.atSpace();)this.skip();return this},atWhitespace:function(){return this.atNewLine()||this.atSpace()},skipWhitespace:function(){var a=this.position;return this.skipNewLine(),this.position==a&&this.skipSpace(),this},skipWhitespaces:function(){for(;this.atWhitespace();)this.skip();return this},skipBlankLines:function(){for(var a=!1;this.hasCurrent()&&!a;){var b=this.position;this.skipSpaces(),this.atNewLine()?this.skipNewLines():(this.position=b,a=!0)}return this},readLine:function(){var a=this.position;return this.scrollToEol().skipNewLine(),new f(this,a,this.position)}};var f=c.SubWalker=function(a,b,c){this.source=a,this.start=b,("undefined"==typeof b||this.start<0)&&(this.start=0),this.end=c,("undefined"==typeof c||this.end>a.length)&&(this.end=a.length),this.length=this.end-this.start};f.prototype=d({},new e,{charAt:function(a){return a>=this.length?"":this.source.charAt(this.start+a)},substring:function(a,b){return"undefined"==typeof b&&(b=this.length),this.source.substring(this.start+a,this.start+b)},toString:function(){return this.source.substring(this.start,this.end)}});var g=c.MultiWalker=function(a){this.regions=Array.isArray(a)?a:[a];var b=0;this.regions.forEach(function(a){b+=a.length}),this.length=b,this.string=function(){for(var a="",b=0;b<this.regions.length;b++)a+=this.regions[b];return a}.call(this)};g.prototype=d({},new e,{charAt:function(a){return this.string.charAt(a)},substring:function(a,b){return 0==this.regions.length?"":this.string.substring(a,b)},toString:function(){return this.string}})},{"./extend":4}]},{},[2]); |
@@ -75,2 +75,3 @@ "use strict"; | ||
if (this.tryOrderedList(walk)) return; | ||
if (this.tryDefinitionList(walk)) return; | ||
if (this.tryHeading(walk)) return; | ||
@@ -369,2 +370,76 @@ if (this.tryCodeBlock(walk)) return; | ||
/* Definition lists start with either `= ` or `- ` which are rendered as | ||
`dt` and `dd` respectively. Indentation is required for nested blocks. */ | ||
tryDefinitionList: function(walk) { | ||
if (!walk.at("= ") && !walk.at('- ')) return false; | ||
var startIdx = walk.position; | ||
var found = false; | ||
// Find the end of the block, checking for nested subblocks | ||
while (!found && walk.hasCurrent()) { | ||
walk.scrollToTerm().skipBlankLines(); | ||
if (walk.atSpaces(this.blockIndent)) { | ||
var i = walk.position; | ||
walk.skip(this.blockIndent); | ||
if (!walk.at("= ") && !walk.at('- ') && !walk.atSpace()) { | ||
found = true; | ||
walk.startFrom(i); | ||
} | ||
} else found = true; | ||
} | ||
// We got DL region, emit it | ||
var dl = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDl(dl); | ||
return true; | ||
}, | ||
emitDl: function(walk) { | ||
this.out.push("<dl"); | ||
this.emitSelector(); | ||
this.out.push(">"); | ||
// Parsing dt and dd | ||
var startIdx = walk.position; | ||
while (walk.hasCurrent()) { | ||
walk.scrollToEol().skipBlankLines(); | ||
if (walk.atSpaces(this.blockIndent)) { | ||
walk.skip(this.blockIndent); | ||
if (walk.at('= ') || walk.at('- ')) { | ||
var elem = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDtDd(elem); | ||
startIdx = walk.position; | ||
} | ||
} | ||
} | ||
// Emit last element | ||
var last = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); | ||
this.emitDtDd(last); | ||
// All items emitted | ||
this.out.push("</dl>\n"); | ||
}, | ||
// emits either `dt` or `dd` depending on the marker | ||
emitDtDd: function(walk) { | ||
var tag = walk.at('= ') ? 'dt' : 'dd'; | ||
walk.skip(2); | ||
this.out.push("<"); | ||
this.out.push(tag); | ||
this.emitSelector(); | ||
this.out.push(">"); | ||
// Determine, whether the contents is inline or block | ||
var b = walk.lookahead(function(w) { | ||
w.scrollToTerm().skipWhitespaces(); | ||
return w.hasCurrent(); // In other words, there is a blank line inside | ||
}); | ||
var indent = this.blockIndent; | ||
if (b) { | ||
while (walk.hasCurrent()) | ||
this.emitBlock(walk); | ||
this.blockIndent = indent; | ||
} else this.emitInline(walk); | ||
this.out.push('</'); | ||
this.out.push(tag); | ||
this.out.push('>'); | ||
}, | ||
/* Headings start with `#`, the amount of pounds designate the level. */ | ||
@@ -625,2 +700,2 @@ | ||
var tableSeparatorLineRe = /^[- :|]+$/; | ||
var tableEndRe = /^-{3,}$/; | ||
var tableEndRe = /^-{3,}$/; |
@@ -146,5 +146,5 @@ "use strict"; | ||
found = c == "" || c == "\\" || c == "&" || c == "<" || | ||
c == ">" || c == "`" || c == "$" || c == '%' || c == "_" || | ||
c == ">" || c == "`" || c == "$" || c == "%" || c == "_" || | ||
c == "*" || c == "!" || c == "[" || c == "(" || c == "{" || | ||
c == "-" || c == "\""; | ||
c == "-" || c == "\"" || c == "="; | ||
if (!found) | ||
@@ -191,4 +191,4 @@ this.skip(); | ||
while (!found && w.hasCurrent()) { | ||
if (w.at("\\" + marker)) | ||
w.skip(marker.length + 1); | ||
if (w.at("\\")) | ||
w.skip(2); | ||
else if (w.at(marker)) | ||
@@ -195,0 +195,0 @@ found = true; |
{ | ||
"name": "rho", | ||
"version": "0.1.19", | ||
"version": "0.2.0", | ||
"description": "Easy-to-{read,write,understand} semantic markup language for Node", | ||
@@ -5,0 +5,0 @@ "author": "Boris Okunskiy <boris@okunskiy.name>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159773
3483