rails-bootstrap-markdown 1.0.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,329 @@
1
+ /*! http://mths.be/he v0.5.0 by @mathias | MIT license */
2
+ ;(function(root) {
3
+
4
+ // Detect free variables `exports`.
5
+ var freeExports = typeof exports == 'object' && exports;
6
+
7
+ // Detect free variable `module`.
8
+ var freeModule = typeof module == 'object' && module &&
9
+ module.exports == freeExports && module;
10
+
11
+ // Detect free variable `global`, from Node.js or Browserified code,
12
+ // and use it as `root`.
13
+ var freeGlobal = typeof global == 'object' && global;
14
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
15
+ root = freeGlobal;
16
+ }
17
+
18
+ /*--------------------------------------------------------------------------*/
19
+
20
+ // All astral symbols.
21
+ var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
22
+ // All ASCII symbols (not just printable ASCII) except those listed in the
23
+ // first column of the overrides table.
24
+ // http://whatwg.org/html/tokenization.html#table-charref-overrides
25
+ var regexAsciiWhitelist = /[\x01-\x7F]/g;
26
+ // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
27
+ // code points listed in the first column of the overrides table on
28
+ // http://whatwg.org/html/tokenization.html#table-charref-overrides.
29
+ var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
30
+
31
+ var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
32
+ var encodeMap = {'\xC1':'Aacute','\xE1':'aacute','\u0102':'Abreve','\u0103':'abreve','\u223E':'ac','\u223F':'acd','\u223E\u0333':'acE','\xC2':'Acirc','\xE2':'acirc','\xB4':'acute','\u0410':'Acy','\u0430':'acy','\xC6':'AElig','\xE6':'aelig','\u2061':'af','\uD835\uDD04':'Afr','\uD835\uDD1E':'afr','\xC0':'Agrave','\xE0':'agrave','\u2135':'aleph','\u0391':'Alpha','\u03B1':'alpha','\u0100':'Amacr','\u0101':'amacr','\u2A3F':'amalg','&':'amp','\u2A55':'andand','\u2A53':'And','\u2227':'and','\u2A5C':'andd','\u2A58':'andslope','\u2A5A':'andv','\u2220':'ang','\u29A4':'ange','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u2221':'angmsd','\u221F':'angrt','\u22BE':'angrtvb','\u299D':'angrtvbd','\u2222':'angsph','\xC5':'angst','\u237C':'angzarr','\u0104':'Aogon','\u0105':'aogon','\uD835\uDD38':'Aopf','\uD835\uDD52':'aopf','\u2A6F':'apacir','\u2248':'ap','\u2A70':'apE','\u224A':'ape','\u224B':'apid','\'':'apos','\xE5':'aring','\uD835\uDC9C':'Ascr','\uD835\uDCB6':'ascr','\u2254':'colone','*':'ast','\u224D':'CupCap','\xC3':'Atilde','\xE3':'atilde','\xC4':'Auml','\xE4':'auml','\u2233':'awconint','\u2A11':'awint','\u224C':'bcong','\u03F6':'bepsi','\u2035':'bprime','\u223D':'bsim','\u22CD':'bsime','\u2216':'setmn','\u2AE7':'Barv','\u22BD':'barvee','\u2305':'barwed','\u2306':'Barwed','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u0411':'Bcy','\u0431':'bcy','\u201E':'bdquo','\u2235':'becaus','\u29B0':'bemptyv','\u212C':'Bscr','\u0392':'Beta','\u03B2':'beta','\u2136':'beth','\u226C':'twixt','\uD835\uDD05':'Bfr','\uD835\uDD1F':'bfr','\u22C2':'xcap','\u25EF':'xcirc','\u22C3':'xcup','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A06':'xsqcup','\u2605':'starf','\u25BD':'xdtri','\u25B3':'xutri','\u2A04':'xuplus','\u22C1':'Vee','\u22C0':'Wedge','\u290D':'rbarr','\u29EB':'lozf','\u25AA':'squf','\u25B4':'utrif','\u25BE':'dtrif','\u25C2':'ltrif','\u25B8':'rtrif','\u2423':'blank','\u2592':'blk12','\u2591':'blk14','\u2593':'blk34','\u2588':'block','=\u20E5':'bne','\u2261\u20E5':'bnequiv','\u2AED':'bNot','\u2310':'bnot','\uD835\uDD39':'Bopf','\uD835\uDD53':'bopf','\u22A5':'bot','\u22C8':'bowtie','\u29C9':'boxbox','\u2510':'boxdl','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u250C':'boxdr','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2500':'boxh','\u2550':'boxH','\u252C':'boxhd','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2534':'boxhu','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u229F':'minusb','\u229E':'plusb','\u22A0':'timesb','\u2518':'boxul','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u2514':'boxur','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u2502':'boxv','\u2551':'boxV','\u253C':'boxvh','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2524':'boxvl','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u251C':'boxvr','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u02D8':'breve','\xA6':'brvbar','\uD835\uDCB7':'bscr','\u204F':'bsemi','\u29C5':'bsolb','\\':'bsol','\u27C8':'bsolhsub','\u2022':'bull','\u224E':'bump','\u2AAE':'bumpE','\u224F':'bumpe','\u0106':'Cacute','\u0107':'cacute','\u2A44':'capand','\u2A49':'capbrcup','\u2A4B':'capcap','\u2229':'cap','\u22D2':'Cap','\u2A47':'capcup','\u2A40':'capdot','\u2145':'DD','\u2229\uFE00':'caps','\u2041':'caret','\u02C7':'caron','\u212D':'Cfr','\u2A4D':'ccaps','\u010C':'Ccaron','\u010D':'ccaron','\xC7':'Ccedil','\xE7':'ccedil','\u0108':'Ccirc','\u0109':'ccirc','\u2230':'Cconint','\u2A4C':'ccups','\u2A50':'ccupssm','\u010A':'Cdot','\u010B':'cdot','\xB8':'cedil','\u29B2':'cemptyv','\xA2':'cent','\xB7':'middot','\uD835\uDD20':'cfr','\u0427':'CHcy','\u0447':'chcy','\u2713':'check','\u03A7':'Chi','\u03C7':'chi','\u02C6':'circ','\u2257':'cire','\u21BA':'olarr','\u21BB':'orarr','\u229B':'oast','\u229A':'ocir','\u229D':'odash','\u2299':'odot','\xAE':'reg','\u24C8':'oS','\u2296':'ominus','\u2295':'oplus','\u2297':'otimes','\u25CB':'cir','\u29C3':'cirE','\u2A10':'cirfnint','\u2AEF':'cirmid','\u29C2':'cirscir','\u2232':'cwconint','\u201D':'rdquo','\u2019':'rsquo','\u2663':'clubs',':':'colon','\u2237':'Colon','\u2A74':'Colone',',':'comma','@':'commat','\u2201':'comp','\u2218':'compfn','\u2102':'Copf','\u2245':'cong','\u2A6D':'congdot','\u2261':'equiv','\u222E':'oint','\u222F':'Conint','\uD835\uDD54':'copf','\u2210':'coprod','\xA9':'copy','\u2117':'copysr','\u21B5':'crarr','\u2717':'cross','\u2A2F':'Cross','\uD835\uDC9E':'Cscr','\uD835\uDCB8':'cscr','\u2ACF':'csub','\u2AD1':'csube','\u2AD0':'csup','\u2AD2':'csupe','\u22EF':'ctdot','\u2938':'cudarrl','\u2935':'cudarrr','\u22DE':'cuepr','\u22DF':'cuesc','\u21B6':'cularr','\u293D':'cularrp','\u2A48':'cupbrcap','\u2A46':'cupcap','\u222A':'cup','\u22D3':'Cup','\u2A4A':'cupcup','\u228D':'cupdot','\u2A45':'cupor','\u222A\uFE00':'cups','\u21B7':'curarr','\u293C':'curarrm','\u22CE':'cuvee','\u22CF':'cuwed','\xA4':'curren','\u2231':'cwint','\u232D':'cylcty','\u2020':'dagger','\u2021':'Dagger','\u2138':'daleth','\u2193':'darr','\u21A1':'Darr','\u21D3':'dArr','\u2010':'dash','\u2AE4':'Dashv','\u22A3':'dashv','\u290F':'rBarr','\u02DD':'dblac','\u010E':'Dcaron','\u010F':'dcaron','\u0414':'Dcy','\u0434':'dcy','\u21CA':'ddarr','\u2146':'dd','\u2911':'DDotrahd','\u2A77':'eDDot','\xB0':'deg','\u2207':'Del','\u0394':'Delta','\u03B4':'delta','\u29B1':'demptyv','\u297F':'dfisht','\uD835\uDD07':'Dfr','\uD835\uDD21':'dfr','\u2965':'dHar','\u21C3':'dharl','\u21C2':'dharr','\u02D9':'dot','`':'grave','\u02DC':'tilde','\u22C4':'diam','\u2666':'diams','\xA8':'die','\u03DD':'gammad','\u22F2':'disin','\xF7':'div','\u22C7':'divonx','\u0402':'DJcy','\u0452':'djcy','\u231E':'dlcorn','\u230D':'dlcrop','$':'dollar','\uD835\uDD3B':'Dopf','\uD835\uDD55':'dopf','\u20DC':'DotDot','\u2250':'doteq','\u2251':'eDot','\u2238':'minusd','\u2214':'plusdo','\u22A1':'sdotb','\u21D0':'lArr','\u21D4':'iff','\u27F8':'xlArr','\u27FA':'xhArr','\u27F9':'xrArr','\u21D2':'rArr','\u22A8':'vDash','\u21D1':'uArr','\u21D5':'vArr','\u2225':'par','\u2913':'DownArrowBar','\u21F5':'duarr','\u0311':'DownBreve','\u2950':'DownLeftRightVector','\u295E':'DownLeftTeeVector','\u2956':'DownLeftVectorBar','\u21BD':'lhard','\u295F':'DownRightTeeVector','\u2957':'DownRightVectorBar','\u21C1':'rhard','\u21A7':'mapstodown','\u22A4':'top','\u2910':'RBarr','\u231F':'drcorn','\u230C':'drcrop','\uD835\uDC9F':'Dscr','\uD835\uDCB9':'dscr','\u0405':'DScy','\u0455':'dscy','\u29F6':'dsol','\u0110':'Dstrok','\u0111':'dstrok','\u22F1':'dtdot','\u25BF':'dtri','\u296F':'duhar','\u29A6':'dwangle','\u040F':'DZcy','\u045F':'dzcy','\u27FF':'dzigrarr','\xC9':'Eacute','\xE9':'eacute','\u2A6E':'easter','\u011A':'Ecaron','\u011B':'ecaron','\xCA':'Ecirc','\xEA':'ecirc','\u2256':'ecir','\u2255':'ecolon','\u042D':'Ecy','\u044D':'ecy','\u0116':'Edot','\u0117':'edot','\u2147':'ee','\u2252':'efDot','\uD835\uDD08':'Efr','\uD835\uDD22':'efr','\u2A9A':'eg','\xC8':'Egrave','\xE8':'egrave','\u2A96':'egs','\u2A98':'egsdot','\u2A99':'el','\u2208':'in','\u23E7':'elinters','\u2113':'ell','\u2A95':'els','\u2A97':'elsdot','\u0112':'Emacr','\u0113':'emacr','\u2205':'empty','\u25FB':'EmptySmallSquare','\u25AB':'EmptyVerySmallSquare','\u2004':'emsp13','\u2005':'emsp14','\u2003':'emsp','\u014A':'ENG','\u014B':'eng','\u2002':'ensp','\u0118':'Eogon','\u0119':'eogon','\uD835\uDD3C':'Eopf','\uD835\uDD56':'eopf','\u22D5':'epar','\u29E3':'eparsl','\u2A71':'eplus','\u03B5':'epsi','\u0395':'Epsilon','\u03F5':'epsiv','\u2242':'esim','\u2A75':'Equal','=':'equals','\u225F':'equest','\u21CC':'rlhar','\u2A78':'equivDD','\u29E5':'eqvparsl','\u2971':'erarr','\u2253':'erDot','\u212F':'escr','\u2130':'Escr','\u2A73':'Esim','\u0397':'Eta','\u03B7':'eta','\xD0':'ETH','\xF0':'eth','\xCB':'Euml','\xEB':'euml','\u20AC':'euro','!':'excl','\u2203':'exist','\u0424':'Fcy','\u0444':'fcy','\u2640':'female','\uFB03':'ffilig','\uFB00':'fflig','\uFB04':'ffllig','\uD835\uDD09':'Ffr','\uD835\uDD23':'ffr','\uFB01':'filig','\u25FC':'FilledSmallSquare','fj':'fjlig','\u266D':'flat','\uFB02':'fllig','\u25B1':'fltns','\u0192':'fnof','\uD835\uDD3D':'Fopf','\uD835\uDD57':'fopf','\u2200':'forall','\u22D4':'fork','\u2AD9':'forkv','\u2131':'Fscr','\u2A0D':'fpartint','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\u2154':'frac23','\u2156':'frac25','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\u2044':'frasl','\u2322':'frown','\uD835\uDCBB':'fscr','\u01F5':'gacute','\u0393':'Gamma','\u03B3':'gamma','\u03DC':'Gammad','\u2A86':'gap','\u011E':'Gbreve','\u011F':'gbreve','\u0122':'Gcedil','\u011C':'Gcirc','\u011D':'gcirc','\u0413':'Gcy','\u0433':'gcy','\u0120':'Gdot','\u0121':'gdot','\u2265':'ge','\u2267':'gE','\u2A8C':'gEl','\u22DB':'gel','\u2A7E':'ges','\u2AA9':'gescc','\u2A80':'gesdot','\u2A82':'gesdoto','\u2A84':'gesdotol','\u22DB\uFE00':'gesl','\u2A94':'gesles','\uD835\uDD0A':'Gfr','\uD835\uDD24':'gfr','\u226B':'gg','\u22D9':'Gg','\u2137':'gimel','\u0403':'GJcy','\u0453':'gjcy','\u2AA5':'gla','\u2277':'gl','\u2A92':'glE','\u2AA4':'glj','\u2A8A':'gnap','\u2A88':'gne','\u2269':'gnE','\u22E7':'gnsim','\uD835\uDD3E':'Gopf','\uD835\uDD58':'gopf','\u2AA2':'GreaterGreater','\u2273':'gsim','\uD835\uDCA2':'Gscr','\u210A':'gscr','\u2A8E':'gsime','\u2A90':'gsiml','\u2AA7':'gtcc','\u2A7A':'gtcir','>':'gt','\u22D7':'gtdot','\u2995':'gtlPar','\u2A7C':'gtquest','\u2978':'gtrarr','\u2269\uFE00':'gvnE','\u200A':'hairsp','\u210B':'Hscr','\u042A':'HARDcy','\u044A':'hardcy','\u2948':'harrcir','\u2194':'harr','\u21AD':'harrw','^':'Hat','\u210F':'hbar','\u0124':'Hcirc','\u0125':'hcirc','\u2665':'hearts','\u2026':'mldr','\u22B9':'hercon','\uD835\uDD25':'hfr','\u210C':'Hfr','\u2925':'searhk','\u2926':'swarhk','\u21FF':'hoarr','\u223B':'homtht','\u21A9':'larrhk','\u21AA':'rarrhk','\uD835\uDD59':'hopf','\u210D':'Hopf','\u2015':'horbar','\uD835\uDCBD':'hscr','\u0126':'Hstrok','\u0127':'hstrok','\u2043':'hybull','\xCD':'Iacute','\xED':'iacute','\u2063':'ic','\xCE':'Icirc','\xEE':'icirc','\u0418':'Icy','\u0438':'icy','\u0130':'Idot','\u0415':'IEcy','\u0435':'iecy','\xA1':'iexcl','\uD835\uDD26':'ifr','\u2111':'Im','\xCC':'Igrave','\xEC':'igrave','\u2148':'ii','\u2A0C':'qint','\u222D':'tint','\u29DC':'iinfin','\u2129':'iiota','\u0132':'IJlig','\u0133':'ijlig','\u012A':'Imacr','\u012B':'imacr','\u2110':'Iscr','\u0131':'imath','\u22B7':'imof','\u01B5':'imped','\u2105':'incare','\u221E':'infin','\u29DD':'infintie','\u22BA':'intcal','\u222B':'int','\u222C':'Int','\u2124':'Zopf','\u2A17':'intlarhk','\u2A3C':'iprod','\u2062':'it','\u0401':'IOcy','\u0451':'iocy','\u012E':'Iogon','\u012F':'iogon','\uD835\uDD40':'Iopf','\uD835\uDD5A':'iopf','\u0399':'Iota','\u03B9':'iota','\xBF':'iquest','\uD835\uDCBE':'iscr','\u22F5':'isindot','\u22F9':'isinE','\u22F4':'isins','\u22F3':'isinsv','\u0128':'Itilde','\u0129':'itilde','\u0406':'Iukcy','\u0456':'iukcy','\xCF':'Iuml','\xEF':'iuml','\u0134':'Jcirc','\u0135':'jcirc','\u0419':'Jcy','\u0439':'jcy','\uD835\uDD0D':'Jfr','\uD835\uDD27':'jfr','\u0237':'jmath','\uD835\uDD41':'Jopf','\uD835\uDD5B':'jopf','\uD835\uDCA5':'Jscr','\uD835\uDCBF':'jscr','\u0408':'Jsercy','\u0458':'jsercy','\u0404':'Jukcy','\u0454':'jukcy','\u039A':'Kappa','\u03BA':'kappa','\u03F0':'kappav','\u0136':'Kcedil','\u0137':'kcedil','\u041A':'Kcy','\u043A':'kcy','\uD835\uDD0E':'Kfr','\uD835\uDD28':'kfr','\u0138':'kgreen','\u0425':'KHcy','\u0445':'khcy','\u040C':'KJcy','\u045C':'kjcy','\uD835\uDD42':'Kopf','\uD835\uDD5C':'kopf','\uD835\uDCA6':'Kscr','\uD835\uDCC0':'kscr','\u21DA':'lAarr','\u0139':'Lacute','\u013A':'lacute','\u29B4':'laemptyv','\u2112':'Lscr','\u039B':'Lambda','\u03BB':'lambda','\u27E8':'lang','\u27EA':'Lang','\u2991':'langd','\u2A85':'lap','\xAB':'laquo','\u21E4':'larrb','\u291F':'larrbfs','\u2190':'larr','\u219E':'Larr','\u291D':'larrfs','\u21AB':'larrlp','\u2939':'larrpl','\u2973':'larrsim','\u21A2':'larrtl','\u2919':'latail','\u291B':'lAtail','\u2AAB':'lat','\u2AAD':'late','\u2AAD\uFE00':'lates','\u290C':'lbarr','\u290E':'lBarr','\u2772':'lbbrk','{':'lcub','[':'lsqb','\u298B':'lbrke','\u298F':'lbrksld','\u298D':'lbrkslu','\u013D':'Lcaron','\u013E':'lcaron','\u013B':'Lcedil','\u013C':'lcedil','\u2308':'lceil','\u041B':'Lcy','\u043B':'lcy','\u2936':'ldca','\u201C':'ldquo','\u2967':'ldrdhar','\u294B':'ldrushar','\u21B2':'ldsh','\u2264':'le','\u2266':'lE','\u21C6':'lrarr','\u27E6':'lobrk','\u2961':'LeftDownTeeVector','\u2959':'LeftDownVectorBar','\u230A':'lfloor','\u21BC':'lharu','\u21C7':'llarr','\u21CB':'lrhar','\u294E':'LeftRightVector','\u21A4':'mapstoleft','\u295A':'LeftTeeVector','\u22CB':'lthree','\u29CF':'LeftTriangleBar','\u22B2':'vltri','\u22B4':'ltrie','\u2951':'LeftUpDownVector','\u2960':'LeftUpTeeVector','\u2958':'LeftUpVectorBar','\u21BF':'uharl','\u2952':'LeftVectorBar','\u2A8B':'lEg','\u22DA':'leg','\u2A7D':'les','\u2AA8':'lescc','\u2A7F':'lesdot','\u2A81':'lesdoto','\u2A83':'lesdotor','\u22DA\uFE00':'lesg','\u2A93':'lesges','\u22D6':'ltdot','\u2276':'lg','\u2AA1':'LessLess','\u2272':'lsim','\u297C':'lfisht','\uD835\uDD0F':'Lfr','\uD835\uDD29':'lfr','\u2A91':'lgE','\u2962':'lHar','\u296A':'lharul','\u2584':'lhblk','\u0409':'LJcy','\u0459':'ljcy','\u226A':'ll','\u22D8':'Ll','\u296B':'llhard','\u25FA':'lltri','\u013F':'Lmidot','\u0140':'lmidot','\u23B0':'lmoust','\u2A89':'lnap','\u2A87':'lne','\u2268':'lnE','\u22E6':'lnsim','\u27EC':'loang','\u21FD':'loarr','\u27F5':'xlarr','\u27F7':'xharr','\u27FC':'xmap','\u27F6':'xrarr','\u21AC':'rarrlp','\u2985':'lopar','\uD835\uDD43':'Lopf','\uD835\uDD5D':'lopf','\u2A2D':'loplus','\u2A34':'lotimes','\u2217':'lowast','_':'lowbar','\u2199':'swarr','\u2198':'searr','\u25CA':'loz','(':'lpar','\u2993':'lparlt','\u296D':'lrhard','\u200E':'lrm','\u22BF':'lrtri','\u2039':'lsaquo','\uD835\uDCC1':'lscr','\u21B0':'lsh','\u2A8D':'lsime','\u2A8F':'lsimg','\u2018':'lsquo','\u201A':'sbquo','\u0141':'Lstrok','\u0142':'lstrok','\u2AA6':'ltcc','\u2A79':'ltcir','<':'lt','\u22C9':'ltimes','\u2976':'ltlarr','\u2A7B':'ltquest','\u25C3':'ltri','\u2996':'ltrPar','\u294A':'lurdshar','\u2966':'luruhar','\u2268\uFE00':'lvnE','\xAF':'macr','\u2642':'male','\u2720':'malt','\u2905':'Map','\u21A6':'map','\u21A5':'mapstoup','\u25AE':'marker','\u2A29':'mcomma','\u041C':'Mcy','\u043C':'mcy','\u2014':'mdash','\u223A':'mDDot','\u205F':'MediumSpace','\u2133':'Mscr','\uD835\uDD10':'Mfr','\uD835\uDD2A':'mfr','\u2127':'mho','\xB5':'micro','\u2AF0':'midcir','\u2223':'mid','\u2212':'minus','\u2A2A':'minusdu','\u2213':'mp','\u2ADB':'mlcp','\u22A7':'models','\uD835\uDD44':'Mopf','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\u039C':'Mu','\u03BC':'mu','\u22B8':'mumap','\u0143':'Nacute','\u0144':'nacute','\u2220\u20D2':'nang','\u2249':'nap','\u2A70\u0338':'napE','\u224B\u0338':'napid','\u0149':'napos','\u266E':'natur','\u2115':'Nopf','\xA0':'nbsp','\u224E\u0338':'nbump','\u224F\u0338':'nbumpe','\u2A43':'ncap','\u0147':'Ncaron','\u0148':'ncaron','\u0145':'Ncedil','\u0146':'ncedil','\u2247':'ncong','\u2A6D\u0338':'ncongdot','\u2A42':'ncup','\u041D':'Ncy','\u043D':'ncy','\u2013':'ndash','\u2924':'nearhk','\u2197':'nearr','\u21D7':'neArr','\u2260':'ne','\u2250\u0338':'nedot','\u200B':'ZeroWidthSpace','\u2262':'nequiv','\u2928':'toea','\u2242\u0338':'nesim','\n':'NewLine','\u2204':'nexist','\uD835\uDD11':'Nfr','\uD835\uDD2B':'nfr','\u2267\u0338':'ngE','\u2271':'nge','\u2A7E\u0338':'nges','\u22D9\u0338':'nGg','\u2275':'ngsim','\u226B\u20D2':'nGt','\u226F':'ngt','\u226B\u0338':'nGtv','\u21AE':'nharr','\u21CE':'nhArr','\u2AF2':'nhpar','\u220B':'ni','\u22FC':'nis','\u22FA':'nisd','\u040A':'NJcy','\u045A':'njcy','\u219A':'nlarr','\u21CD':'nlArr','\u2025':'nldr','\u2266\u0338':'nlE','\u2270':'nle','\u2A7D\u0338':'nles','\u226E':'nlt','\u22D8\u0338':'nLl','\u2274':'nlsim','\u226A\u20D2':'nLt','\u22EA':'nltri','\u22EC':'nltrie','\u226A\u0338':'nLtv','\u2224':'nmid','\u2060':'NoBreak','\uD835\uDD5F':'nopf','\u2AEC':'Not','\xAC':'not','\u226D':'NotCupCap','\u2226':'npar','\u2209':'notin','\u2279':'ntgl','\u22F5\u0338':'notindot','\u22F9\u0338':'notinE','\u22F7':'notinvb','\u22F6':'notinvc','\u29CF\u0338':'NotLeftTriangleBar','\u2278':'ntlg','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA1\u0338':'NotNestedLessLess','\u220C':'notni','\u22FE':'notnivb','\u22FD':'notnivc','\u2280':'npr','\u2AAF\u0338':'npre','\u22E0':'nprcue','\u29D0\u0338':'NotRightTriangleBar','\u22EB':'nrtri','\u22ED':'nrtrie','\u228F\u0338':'NotSquareSubset','\u22E2':'nsqsube','\u2290\u0338':'NotSquareSuperset','\u22E3':'nsqsupe','\u2282\u20D2':'vnsub','\u2288':'nsube','\u2281':'nsc','\u2AB0\u0338':'nsce','\u22E1':'nsccue','\u227F\u0338':'NotSucceedsTilde','\u2283\u20D2':'vnsup','\u2289':'nsupe','\u2241':'nsim','\u2244':'nsime','\u2AFD\u20E5':'nparsl','\u2202\u0338':'npart','\u2A14':'npolint','\u2933\u0338':'nrarrc','\u219B':'nrarr','\u21CF':'nrArr','\u219D\u0338':'nrarrw','\uD835\uDCA9':'Nscr','\uD835\uDCC3':'nscr','\u2284':'nsub','\u2AC5\u0338':'nsubE','\u2285':'nsup','\u2AC6\u0338':'nsupE','\xD1':'Ntilde','\xF1':'ntilde','\u039D':'Nu','\u03BD':'nu','#':'num','\u2116':'numero','\u2007':'numsp','\u224D\u20D2':'nvap','\u22AC':'nvdash','\u22AD':'nvDash','\u22AE':'nVdash','\u22AF':'nVDash','\u2265\u20D2':'nvge','>\u20D2':'nvgt','\u2904':'nvHarr','\u29DE':'nvinfin','\u2902':'nvlArr','\u2264\u20D2':'nvle','<\u20D2':'nvlt','\u22B4\u20D2':'nvltrie','\u2903':'nvrArr','\u22B5\u20D2':'nvrtrie','\u223C\u20D2':'nvsim','\u2923':'nwarhk','\u2196':'nwarr','\u21D6':'nwArr','\u2927':'nwnear','\xD3':'Oacute','\xF3':'oacute','\xD4':'Ocirc','\xF4':'ocirc','\u041E':'Ocy','\u043E':'ocy','\u0150':'Odblac','\u0151':'odblac','\u2A38':'odiv','\u29BC':'odsold','\u0152':'OElig','\u0153':'oelig','\u29BF':'ofcir','\uD835\uDD12':'Ofr','\uD835\uDD2C':'ofr','\u02DB':'ogon','\xD2':'Ograve','\xF2':'ograve','\u29C1':'ogt','\u29B5':'ohbar','\u03A9':'ohm','\u29BE':'olcir','\u29BB':'olcross','\u203E':'oline','\u29C0':'olt','\u014C':'Omacr','\u014D':'omacr','\u03C9':'omega','\u039F':'Omicron','\u03BF':'omicron','\u29B6':'omid','\uD835\uDD46':'Oopf','\uD835\uDD60':'oopf','\u29B7':'opar','\u29B9':'operp','\u2A54':'Or','\u2228':'or','\u2A5D':'ord','\u2134':'oscr','\xAA':'ordf','\xBA':'ordm','\u22B6':'origof','\u2A56':'oror','\u2A57':'orslope','\u2A5B':'orv','\uD835\uDCAA':'Oscr','\xD8':'Oslash','\xF8':'oslash','\u2298':'osol','\xD5':'Otilde','\xF5':'otilde','\u2A36':'otimesas','\u2A37':'Otimes','\xD6':'Ouml','\xF6':'ouml','\u233D':'ovbar','\u23DE':'OverBrace','\u23B4':'tbrk','\u23DC':'OverParenthesis','\xB6':'para','\u2AF3':'parsim','\u2AFD':'parsl','\u2202':'part','\u041F':'Pcy','\u043F':'pcy','%':'percnt','.':'period','\u2030':'permil','\u2031':'pertenk','\uD835\uDD13':'Pfr','\uD835\uDD2D':'pfr','\u03A6':'Phi','\u03C6':'phi','\u03D5':'phiv','\u260E':'phone','\u03A0':'Pi','\u03C0':'pi','\u03D6':'piv','\u210E':'planckh','\u2A23':'plusacir','\u2A22':'pluscir','+':'plus','\u2A25':'plusdu','\u2A72':'pluse','\xB1':'pm','\u2A26':'plussim','\u2A27':'plustwo','\u2A15':'pointint','\uD835\uDD61':'popf','\u2119':'Popf','\xA3':'pound','\u2AB7':'prap','\u2ABB':'Pr','\u227A':'pr','\u227C':'prcue','\u2AAF':'pre','\u227E':'prsim','\u2AB9':'prnap','\u2AB5':'prnE','\u22E8':'prnsim','\u2AB3':'prE','\u2032':'prime','\u2033':'Prime','\u220F':'prod','\u232E':'profalar','\u2312':'profline','\u2313':'profsurf','\u221D':'prop','\u22B0':'prurel','\uD835\uDCAB':'Pscr','\uD835\uDCC5':'pscr','\u03A8':'Psi','\u03C8':'psi','\u2008':'puncsp','\uD835\uDD14':'Qfr','\uD835\uDD2E':'qfr','\uD835\uDD62':'qopf','\u211A':'Qopf','\u2057':'qprime','\uD835\uDCAC':'Qscr','\uD835\uDCC6':'qscr','\u2A16':'quatint','?':'quest','"':'quot','\u21DB':'rAarr','\u223D\u0331':'race','\u0154':'Racute','\u0155':'racute','\u221A':'Sqrt','\u29B3':'raemptyv','\u27E9':'rang','\u27EB':'Rang','\u2992':'rangd','\u29A5':'range','\xBB':'raquo','\u2975':'rarrap','\u21E5':'rarrb','\u2920':'rarrbfs','\u2933':'rarrc','\u2192':'rarr','\u21A0':'Rarr','\u291E':'rarrfs','\u2945':'rarrpl','\u2974':'rarrsim','\u2916':'Rarrtl','\u21A3':'rarrtl','\u219D':'rarrw','\u291A':'ratail','\u291C':'rAtail','\u2236':'ratio','\u2773':'rbbrk','}':'rcub',']':'rsqb','\u298C':'rbrke','\u298E':'rbrksld','\u2990':'rbrkslu','\u0158':'Rcaron','\u0159':'rcaron','\u0156':'Rcedil','\u0157':'rcedil','\u2309':'rceil','\u0420':'Rcy','\u0440':'rcy','\u2937':'rdca','\u2969':'rdldhar','\u21B3':'rdsh','\u211C':'Re','\u211B':'Rscr','\u211D':'Ropf','\u25AD':'rect','\u297D':'rfisht','\u230B':'rfloor','\uD835\uDD2F':'rfr','\u2964':'rHar','\u21C0':'rharu','\u296C':'rharul','\u03A1':'Rho','\u03C1':'rho','\u03F1':'rhov','\u21C4':'rlarr','\u27E7':'robrk','\u295D':'RightDownTeeVector','\u2955':'RightDownVectorBar','\u21C9':'rrarr','\u22A2':'vdash','\u295B':'RightTeeVector','\u22CC':'rthree','\u29D0':'RightTriangleBar','\u22B3':'vrtri','\u22B5':'rtrie','\u294F':'RightUpDownVector','\u295C':'RightUpTeeVector','\u2954':'RightUpVectorBar','\u21BE':'uharr','\u2953':'RightVectorBar','\u02DA':'ring','\u200F':'rlm','\u23B1':'rmoust','\u2AEE':'rnmid','\u27ED':'roang','\u21FE':'roarr','\u2986':'ropar','\uD835\uDD63':'ropf','\u2A2E':'roplus','\u2A35':'rotimes','\u2970':'RoundImplies',')':'rpar','\u2994':'rpargt','\u2A12':'rppolint','\u203A':'rsaquo','\uD835\uDCC7':'rscr','\u21B1':'rsh','\u22CA':'rtimes','\u25B9':'rtri','\u29CE':'rtriltri','\u29F4':'RuleDelayed','\u2968':'ruluhar','\u211E':'rx','\u015A':'Sacute','\u015B':'sacute','\u2AB8':'scap','\u0160':'Scaron','\u0161':'scaron','\u2ABC':'Sc','\u227B':'sc','\u227D':'sccue','\u2AB0':'sce','\u2AB4':'scE','\u015E':'Scedil','\u015F':'scedil','\u015C':'Scirc','\u015D':'scirc','\u2ABA':'scnap','\u2AB6':'scnE','\u22E9':'scnsim','\u2A13':'scpolint','\u227F':'scsim','\u0421':'Scy','\u0441':'scy','\u22C5':'sdot','\u2A66':'sdote','\u21D8':'seArr','\xA7':'sect',';':'semi','\u2929':'tosa','\u2736':'sext','\uD835\uDD16':'Sfr','\uD835\uDD30':'sfr','\u266F':'sharp','\u0429':'SHCHcy','\u0449':'shchcy','\u0428':'SHcy','\u0448':'shcy','\u2191':'uarr','\xAD':'shy','\u03A3':'Sigma','\u03C3':'sigma','\u03C2':'sigmaf','\u223C':'sim','\u2A6A':'simdot','\u2243':'sime','\u2A9E':'simg','\u2AA0':'simgE','\u2A9D':'siml','\u2A9F':'simlE','\u2246':'simne','\u2A24':'simplus','\u2972':'simrarr','\u2A33':'smashp','\u29E4':'smeparsl','\u2323':'smile','\u2AAA':'smt','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u042C':'SOFTcy','\u044C':'softcy','\u233F':'solbar','\u29C4':'solb','/':'sol','\uD835\uDD4A':'Sopf','\uD835\uDD64':'sopf','\u2660':'spades','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u228F':'sqsub','\u2291':'sqsube','\u2290':'sqsup','\u2292':'sqsupe','\u25A1':'squ','\uD835\uDCAE':'Sscr','\uD835\uDCC8':'sscr','\u22C6':'Star','\u2606':'star','\u2282':'sub','\u22D0':'Sub','\u2ABD':'subdot','\u2AC5':'subE','\u2286':'sube','\u2AC3':'subedot','\u2AC1':'submult','\u2ACB':'subnE','\u228A':'subne','\u2ABF':'subplus','\u2979':'subrarr','\u2AC7':'subsim','\u2AD5':'subsub','\u2AD3':'subsup','\u2211':'sum','\u266A':'sung','\xB9':'sup1','\xB2':'sup2','\xB3':'sup3','\u2283':'sup','\u22D1':'Sup','\u2ABE':'supdot','\u2AD8':'supdsub','\u2AC6':'supE','\u2287':'supe','\u2AC4':'supedot','\u27C9':'suphsol','\u2AD7':'suphsub','\u297B':'suplarr','\u2AC2':'supmult','\u2ACC':'supnE','\u228B':'supne','\u2AC0':'supplus','\u2AC8':'supsim','\u2AD4':'supsub','\u2AD6':'supsup','\u21D9':'swArr','\u292A':'swnwar','\xDF':'szlig','\t':'Tab','\u2316':'target','\u03A4':'Tau','\u03C4':'tau','\u0164':'Tcaron','\u0165':'tcaron','\u0162':'Tcedil','\u0163':'tcedil','\u0422':'Tcy','\u0442':'tcy','\u20DB':'tdot','\u2315':'telrec','\uD835\uDD17':'Tfr','\uD835\uDD31':'tfr','\u2234':'there4','\u0398':'Theta','\u03B8':'theta','\u03D1':'thetav','\u205F\u200A':'ThickSpace','\u2009':'thinsp','\xDE':'THORN','\xFE':'thorn','\u2A31':'timesbar','\xD7':'times','\u2A30':'timesd','\u2336':'topbot','\u2AF1':'topcir','\uD835\uDD4B':'Topf','\uD835\uDD65':'topf','\u2ADA':'topfork','\u2034':'tprime','\u2122':'trade','\u25B5':'utri','\u225C':'trie','\u25EC':'tridot','\u2A3A':'triminus','\u2A39':'triplus','\u29CD':'trisb','\u2A3B':'tritime','\u23E2':'trpezium','\uD835\uDCAF':'Tscr','\uD835\uDCC9':'tscr','\u0426':'TScy','\u0446':'tscy','\u040B':'TSHcy','\u045B':'tshcy','\u0166':'Tstrok','\u0167':'tstrok','\xDA':'Uacute','\xFA':'uacute','\u219F':'Uarr','\u2949':'Uarrocir','\u040E':'Ubrcy','\u045E':'ubrcy','\u016C':'Ubreve','\u016D':'ubreve','\xDB':'Ucirc','\xFB':'ucirc','\u0423':'Ucy','\u0443':'ucy','\u21C5':'udarr','\u0170':'Udblac','\u0171':'udblac','\u296E':'udhar','\u297E':'ufisht','\uD835\uDD18':'Ufr','\uD835\uDD32':'ufr','\xD9':'Ugrave','\xF9':'ugrave','\u2963':'uHar','\u2580':'uhblk','\u231C':'ulcorn','\u230F':'ulcrop','\u25F8':'ultri','\u016A':'Umacr','\u016B':'umacr','\u23DF':'UnderBrace','\u23DD':'UnderParenthesis','\u228E':'uplus','\u0172':'Uogon','\u0173':'uogon','\uD835\uDD4C':'Uopf','\uD835\uDD66':'uopf','\u2912':'UpArrowBar','\u2195':'varr','\u03C5':'upsi','\u03D2':'Upsi','\u03A5':'Upsilon','\u21C8':'uuarr','\u231D':'urcorn','\u230E':'urcrop','\u016E':'Uring','\u016F':'uring','\u25F9':'urtri','\uD835\uDCB0':'Uscr','\uD835\uDCCA':'uscr','\u22F0':'utdot','\u0168':'Utilde','\u0169':'utilde','\xDC':'Uuml','\xFC':'uuml','\u29A7':'uwangle','\u299C':'vangrt','\u228A\uFE00':'vsubne','\u2ACB\uFE00':'vsubnE','\u228B\uFE00':'vsupne','\u2ACC\uFE00':'vsupnE','\u2AE8':'vBar','\u2AEB':'Vbar','\u2AE9':'vBarv','\u0412':'Vcy','\u0432':'vcy','\u22A9':'Vdash','\u22AB':'VDash','\u2AE6':'Vdashl','\u22BB':'veebar','\u225A':'veeeq','\u22EE':'vellip','|':'vert','\u2016':'Vert','\u2758':'VerticalSeparator','\u2240':'wr','\uD835\uDD19':'Vfr','\uD835\uDD33':'vfr','\uD835\uDD4D':'Vopf','\uD835\uDD67':'vopf','\uD835\uDCB1':'Vscr','\uD835\uDCCB':'vscr','\u22AA':'Vvdash','\u299A':'vzigzag','\u0174':'Wcirc','\u0175':'wcirc','\u2A5F':'wedbar','\u2259':'wedgeq','\u2118':'wp','\uD835\uDD1A':'Wfr','\uD835\uDD34':'wfr','\uD835\uDD4E':'Wopf','\uD835\uDD68':'wopf','\uD835\uDCB2':'Wscr','\uD835\uDCCC':'wscr','\uD835\uDD1B':'Xfr','\uD835\uDD35':'xfr','\u039E':'Xi','\u03BE':'xi','\u22FB':'xnis','\uD835\uDD4F':'Xopf','\uD835\uDD69':'xopf','\uD835\uDCB3':'Xscr','\uD835\uDCCD':'xscr','\xDD':'Yacute','\xFD':'yacute','\u042F':'YAcy','\u044F':'yacy','\u0176':'Ycirc','\u0177':'ycirc','\u042B':'Ycy','\u044B':'ycy','\xA5':'yen','\uD835\uDD1C':'Yfr','\uD835\uDD36':'yfr','\u0407':'YIcy','\u0457':'yicy','\uD835\uDD50':'Yopf','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDCCE':'yscr','\u042E':'YUcy','\u044E':'yucy','\xFF':'yuml','\u0178':'Yuml','\u0179':'Zacute','\u017A':'zacute','\u017D':'Zcaron','\u017E':'zcaron','\u0417':'Zcy','\u0437':'zcy','\u017B':'Zdot','\u017C':'zdot','\u2128':'Zfr','\u0396':'Zeta','\u03B6':'zeta','\uD835\uDD37':'zfr','\u0416':'ZHcy','\u0436':'zhcy','\u21DD':'zigrarr','\uD835\uDD6B':'zopf','\uD835\uDCB5':'Zscr','\uD835\uDCCF':'zscr','\u200D':'zwj','\u200C':'zwnj'};
33
+
34
+ var regexEscape = /["&'<>`]/g;
35
+ var escapeMap = {
36
+ '"': '&quot;',
37
+ '&': '&amp;',
38
+ '\'': '&#x27;',
39
+ '<': '&lt;',
40
+ // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
41
+ // following is not strictly necessary unless it’s part of a tag or an
42
+ // unquoted attribute value. We’re only escaping it to support those
43
+ // situations, and for XML support.
44
+ '>': '&gt;',
45
+ // In Internet Explorer ≤ 8, the backtick character can be used
46
+ // to break out of (un)quoted attribute values or HTML comments.
47
+ // See http://html5sec.org/#102, http://html5sec.org/#108, and
48
+ // http://html5sec.org/#133.
49
+ '`': '&#x60;'
50
+ };
51
+
52
+ var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
53
+ var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
54
+ var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(Aacute|iacute|Uacute|plusmn|otilde|Otilde|Agrave|agrave|yacute|Yacute|oslash|Oslash|Atilde|atilde|brvbar|Ccedil|ccedil|ograve|curren|divide|Eacute|eacute|Ograve|oacute|Egrave|egrave|ugrave|frac12|frac14|frac34|Ugrave|Oacute|Iacute|ntilde|Ntilde|uacute|middot|Igrave|igrave|iquest|aacute|laquo|THORN|micro|iexcl|icirc|Icirc|Acirc|ucirc|ecirc|Ocirc|ocirc|Ecirc|Ucirc|aring|Aring|aelig|AElig|acute|pound|raquo|acirc|times|thorn|szlig|cedil|COPY|Auml|ordf|ordm|uuml|macr|Uuml|auml|Ouml|ouml|para|nbsp|Euml|quot|QUOT|euml|yuml|cent|sect|copy|sup1|sup2|sup3|Iuml|iuml|shy|eth|reg|not|yen|amp|AMP|REG|uml|ETH|deg|gt|GT|LT|lt)([=a-zA-Z0-9])?/g;
55
+ var decodeMap = {'Aacute':'\xC1','aacute':'\xE1','Abreve':'\u0102','abreve':'\u0103','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','Acy':'\u0410','acy':'\u0430','AElig':'\xC6','aelig':'\xE6','af':'\u2061','Afr':'\uD835\uDD04','afr':'\uD835\uDD1E','Agrave':'\xC0','agrave':'\xE0','alefsym':'\u2135','aleph':'\u2135','Alpha':'\u0391','alpha':'\u03B1','Amacr':'\u0100','amacr':'\u0101','amalg':'\u2A3F','amp':'&','AMP':'&','andand':'\u2A55','And':'\u2A53','and':'\u2227','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angmsd':'\u2221','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','Aogon':'\u0104','aogon':'\u0105','Aopf':'\uD835\uDD38','aopf':'\uD835\uDD52','apacir':'\u2A6F','ap':'\u2248','apE':'\u2A70','ape':'\u224A','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','Aring':'\xC5','aring':'\xE5','Ascr':'\uD835\uDC9C','ascr':'\uD835\uDCB6','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','Bcy':'\u0411','bcy':'\u0431','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','Beta':'\u0392','beta':'\u03B2','beth':'\u2136','between':'\u226C','Bfr':'\uD835\uDD05','bfr':'\uD835\uDD1F','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bNot':'\u2AED','bnot':'\u2310','Bopf':'\uD835\uDD39','bopf':'\uD835\uDD53','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxHd':'\u2564','boxhD':'\u2565','boxHD':'\u2566','boxhu':'\u2534','boxHu':'\u2567','boxhU':'\u2568','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsolb':'\u29C5','bsol':'\\','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpE':'\u2AAE','bumpe':'\u224F','Bumpeq':'\u224E','bumpeq':'\u224F','Cacute':'\u0106','cacute':'\u0107','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','cap':'\u2229','Cap':'\u22D2','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','Ccaron':'\u010C','ccaron':'\u010D','Ccedil':'\xC7','ccedil':'\xE7','Ccirc':'\u0108','ccirc':'\u0109','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','Cdot':'\u010A','cdot':'\u010B','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','CHcy':'\u0427','chcy':'\u0447','check':'\u2713','checkmark':'\u2713','Chi':'\u03A7','chi':'\u03C7','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cir':'\u25CB','cirE':'\u29C3','cire':'\u2257','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','Colone':'\u2A74','colone':'\u2254','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','Cscr':'\uD835\uDC9E','cscr':'\uD835\uDCB8','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cup':'\u222A','Cup':'\u22D3','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','Darr':'\u21A1','dArr':'\u21D3','dash':'\u2010','Dashv':'\u2AE4','dashv':'\u22A3','dbkarow':'\u290F','dblac':'\u02DD','Dcaron':'\u010E','dcaron':'\u010F','Dcy':'\u0414','dcy':'\u0434','ddagger':'\u2021','ddarr':'\u21CA','DD':'\u2145','dd':'\u2146','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','Delta':'\u0394','delta':'\u03B4','demptyv':'\u29B1','dfisht':'\u297F','Dfr':'\uD835\uDD07','dfr':'\uD835\uDD21','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','DJcy':'\u0402','djcy':'\u0452','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','Dopf':'\uD835\uDD3B','dopf':'\uD835\uDD55','Dot':'\xA8','dot':'\u02D9','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','DownArrowBar':'\u2913','downarrow':'\u2193','DownArrow':'\u2193','Downarrow':'\u21D3','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVectorBar':'\u2956','DownLeftVector':'\u21BD','DownRightTeeVector':'\u295F','DownRightVectorBar':'\u2957','DownRightVector':'\u21C1','DownTeeArrow':'\u21A7','DownTee':'\u22A4','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','Dscr':'\uD835\uDC9F','dscr':'\uD835\uDCB9','DScy':'\u0405','dscy':'\u0455','dsol':'\u29F6','Dstrok':'\u0110','dstrok':'\u0111','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','DZcy':'\u040F','dzcy':'\u045F','dzigrarr':'\u27FF','Eacute':'\xC9','eacute':'\xE9','easter':'\u2A6E','Ecaron':'\u011A','ecaron':'\u011B','Ecirc':'\xCA','ecirc':'\xEA','ecir':'\u2256','ecolon':'\u2255','Ecy':'\u042D','ecy':'\u044D','eDDot':'\u2A77','Edot':'\u0116','edot':'\u0117','eDot':'\u2251','ee':'\u2147','efDot':'\u2252','Efr':'\uD835\uDD08','efr':'\uD835\uDD22','eg':'\u2A9A','Egrave':'\xC8','egrave':'\xE8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','Emacr':'\u0112','emacr':'\u0113','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp13':'\u2004','emsp14':'\u2005','emsp':'\u2003','ENG':'\u014A','eng':'\u014B','ensp':'\u2002','Eogon':'\u0118','eogon':'\u0119','Eopf':'\uD835\uDD3C','eopf':'\uD835\uDD56','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','Epsilon':'\u0395','epsilon':'\u03B5','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','Esim':'\u2A73','esim':'\u2242','Eta':'\u0397','eta':'\u03B7','ETH':'\xD0','eth':'\xF0','Euml':'\xCB','euml':'\xEB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','Fcy':'\u0424','fcy':'\u0444','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','Ffr':'\uD835\uDD09','ffr':'\uD835\uDD23','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','Fopf':'\uD835\uDD3D','fopf':'\uD835\uDD57','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','Gamma':'\u0393','gamma':'\u03B3','Gammad':'\u03DC','gammad':'\u03DD','gap':'\u2A86','Gbreve':'\u011E','gbreve':'\u011F','Gcedil':'\u0122','Gcirc':'\u011C','gcirc':'\u011D','Gcy':'\u0413','gcy':'\u0433','Gdot':'\u0120','gdot':'\u0121','ge':'\u2265','gE':'\u2267','gEl':'\u2A8C','gel':'\u22DB','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','gescc':'\u2AA9','ges':'\u2A7E','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','Gfr':'\uD835\uDD0A','gfr':'\uD835\uDD24','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','GJcy':'\u0403','gjcy':'\u0453','gla':'\u2AA5','gl':'\u2277','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','Gopf':'\uD835\uDD3E','gopf':'\uD835\uDD58','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','Gscr':'\uD835\uDCA2','gscr':'\u210A','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gtcc':'\u2AA7','gtcir':'\u2A7A','gt':'>','GT':'>','Gt':'\u226B','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','HARDcy':'\u042A','hardcy':'\u044A','harrcir':'\u2948','harr':'\u2194','hArr':'\u21D4','harrw':'\u21AD','Hat':'^','hbar':'\u210F','Hcirc':'\u0124','hcirc':'\u0125','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','Hstrok':'\u0126','hstrok':'\u0127','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','Iacute':'\xCD','iacute':'\xED','ic':'\u2063','Icirc':'\xCE','icirc':'\xEE','Icy':'\u0418','icy':'\u0438','Idot':'\u0130','IEcy':'\u0415','iecy':'\u0435','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','Igrave':'\xCC','igrave':'\xEC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','IJlig':'\u0132','ijlig':'\u0133','Imacr':'\u012A','imacr':'\u012B','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','Im':'\u2111','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','incare':'\u2105','in':'\u2208','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','intcal':'\u22BA','int':'\u222B','Int':'\u222C','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','IOcy':'\u0401','iocy':'\u0451','Iogon':'\u012E','iogon':'\u012F','Iopf':'\uD835\uDD40','iopf':'\uD835\uDD5A','Iota':'\u0399','iota':'\u03B9','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','Itilde':'\u0128','itilde':'\u0129','Iukcy':'\u0406','iukcy':'\u0456','Iuml':'\xCF','iuml':'\xEF','Jcirc':'\u0134','jcirc':'\u0135','Jcy':'\u0419','jcy':'\u0439','Jfr':'\uD835\uDD0D','jfr':'\uD835\uDD27','jmath':'\u0237','Jopf':'\uD835\uDD41','jopf':'\uD835\uDD5B','Jscr':'\uD835\uDCA5','jscr':'\uD835\uDCBF','Jsercy':'\u0408','jsercy':'\u0458','Jukcy':'\u0404','jukcy':'\u0454','Kappa':'\u039A','kappa':'\u03BA','kappav':'\u03F0','Kcedil':'\u0136','kcedil':'\u0137','Kcy':'\u041A','kcy':'\u043A','Kfr':'\uD835\uDD0E','kfr':'\uD835\uDD28','kgreen':'\u0138','KHcy':'\u0425','khcy':'\u0445','KJcy':'\u040C','kjcy':'\u045C','Kopf':'\uD835\uDD42','kopf':'\uD835\uDD5C','Kscr':'\uD835\uDCA6','kscr':'\uD835\uDCC0','lAarr':'\u21DA','Lacute':'\u0139','lacute':'\u013A','laemptyv':'\u29B4','lagran':'\u2112','Lambda':'\u039B','lambda':'\u03BB','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larrb':'\u21E4','larrbfs':'\u291F','larr':'\u2190','Larr':'\u219E','lArr':'\u21D0','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','latail':'\u2919','lAtail':'\u291B','lat':'\u2AAB','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','Lcaron':'\u013D','lcaron':'\u013E','Lcedil':'\u013B','lcedil':'\u013C','lceil':'\u2308','lcub':'{','Lcy':'\u041B','lcy':'\u043B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','LeftArrowBar':'\u21E4','leftarrow':'\u2190','LeftArrow':'\u2190','Leftarrow':'\u21D0','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVectorBar':'\u2959','LeftDownVector':'\u21C3','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','LeftRightArrow':'\u2194','Leftrightarrow':'\u21D4','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTeeArrow':'\u21A4','LeftTee':'\u22A3','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangleBar':'\u29CF','LeftTriangle':'\u22B2','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVectorBar':'\u2958','LeftUpVector':'\u21BF','LeftVectorBar':'\u2952','LeftVector':'\u21BC','lEg':'\u2A8B','leg':'\u22DA','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','lescc':'\u2AA8','les':'\u2A7D','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','Lfr':'\uD835\uDD0F','lfr':'\uD835\uDD29','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','LJcy':'\u0409','ljcy':'\u0459','llarr':'\u21C7','ll':'\u226A','Ll':'\u22D8','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','Lmidot':'\u013F','lmidot':'\u0140','lmoustache':'\u23B0','lmoust':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','LongLeftArrow':'\u27F5','Longleftarrow':'\u27F8','longleftrightarrow':'\u27F7','LongLeftRightArrow':'\u27F7','Longleftrightarrow':'\u27FA','longmapsto':'\u27FC','longrightarrow':'\u27F6','LongRightArrow':'\u27F6','Longrightarrow':'\u27F9','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','Lopf':'\uD835\uDD43','lopf':'\uD835\uDD5D','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','Lstrok':'\u0141','lstrok':'\u0142','ltcc':'\u2AA6','ltcir':'\u2A79','lt':'<','LT':'<','Lt':'\u226A','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','Map':'\u2905','map':'\u21A6','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','Mcy':'\u041C','mcy':'\u043C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','Mfr':'\uD835\uDD10','mfr':'\uD835\uDD2A','mho':'\u2127','micro':'\xB5','midast':'*','midcir':'\u2AF0','mid':'\u2223','middot':'\xB7','minusb':'\u229F','minus':'\u2212','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','Mopf':'\uD835\uDD44','mopf':'\uD835\uDD5E','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','Mu':'\u039C','mu':'\u03BC','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','Nacute':'\u0143','nacute':'\u0144','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natural':'\u266E','naturals':'\u2115','natur':'\u266E','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','Ncaron':'\u0147','ncaron':'\u0148','Ncedil':'\u0145','ncedil':'\u0146','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','Ncy':'\u041D','ncy':'\u043D','ndash':'\u2013','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','ne':'\u2260','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','Nfr':'\uD835\uDD11','nfr':'\uD835\uDD2B','ngE':'\u2267\u0338','nge':'\u2271','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','nGt':'\u226B\u20D2','ngt':'\u226F','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','NJcy':'\u040A','njcy':'\u045A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nlE':'\u2266\u0338','nle':'\u2270','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nLt':'\u226A\u20D2','nlt':'\u226E','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','Not':'\u2AEC','not':'\xAC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangle':'\u22EA','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangle':'\u22EB','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','nparallel':'\u2226','npar':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','nprec':'\u2280','npreceq':'\u2AAF\u0338','npre':'\u2AAF\u0338','nrarrc':'\u2933\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','Nscr':'\uD835\uDCA9','nscr':'\uD835\uDCC3','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsubE':'\u2AC5\u0338','nsube':'\u2288','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupE':'\u2AC6\u0338','nsupe':'\u2289','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','Ntilde':'\xD1','ntilde':'\xF1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','Nu':'\u039D','nu':'\u03BD','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','Oacute':'\xD3','oacute':'\xF3','oast':'\u229B','Ocirc':'\xD4','ocirc':'\xF4','ocir':'\u229A','Ocy':'\u041E','ocy':'\u043E','odash':'\u229D','Odblac':'\u0150','odblac':'\u0151','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','OElig':'\u0152','oelig':'\u0153','ofcir':'\u29BF','Ofr':'\uD835\uDD12','ofr':'\uD835\uDD2C','ogon':'\u02DB','Ograve':'\xD2','ograve':'\xF2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','Omacr':'\u014C','omacr':'\u014D','Omega':'\u03A9','omega':'\u03C9','Omicron':'\u039F','omicron':'\u03BF','omid':'\u29B6','ominus':'\u2296','Oopf':'\uD835\uDD46','oopf':'\uD835\uDD60','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','orarr':'\u21BB','Or':'\u2A54','or':'\u2228','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','Oscr':'\uD835\uDCAA','oscr':'\u2134','Oslash':'\xD8','oslash':'\xF8','osol':'\u2298','Otilde':'\xD5','otilde':'\xF5','otimesas':'\u2A36','Otimes':'\u2A37','otimes':'\u2297','Ouml':'\xD6','ouml':'\xF6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','para':'\xB6','parallel':'\u2225','par':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','Pcy':'\u041F','pcy':'\u043F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','Pfr':'\uD835\uDD13','pfr':'\uD835\uDD2D','Phi':'\u03A6','phi':'\u03C6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','Pi':'\u03A0','pi':'\u03C0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plus':'+','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','prap':'\u2AB7','Pr':'\u2ABB','pr':'\u227A','prcue':'\u227C','precapprox':'\u2AB7','prec':'\u227A','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','pre':'\u2AAF','prE':'\u2AB3','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportional':'\u221D','Proportion':'\u2237','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','Pscr':'\uD835\uDCAB','pscr':'\uD835\uDCC5','Psi':'\u03A8','psi':'\u03C8','puncsp':'\u2008','Qfr':'\uD835\uDD14','qfr':'\uD835\uDD2E','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','Qscr':'\uD835\uDCAC','qscr':'\uD835\uDCC6','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','Racute':'\u0154','racute':'\u0155','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarr':'\u2192','Rarr':'\u21A0','rArr':'\u21D2','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','Rarrtl':'\u2916','rarrtl':'\u21A3','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','Rcaron':'\u0158','rcaron':'\u0159','Rcedil':'\u0156','rcedil':'\u0157','rceil':'\u2309','rcub':'}','Rcy':'\u0420','rcy':'\u0440','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','Re':'\u211C','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','Rho':'\u03A1','rho':'\u03C1','rhov':'\u03F1','RightAngleBracket':'\u27E9','RightArrowBar':'\u21E5','rightarrow':'\u2192','RightArrow':'\u2192','Rightarrow':'\u21D2','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVectorBar':'\u2955','RightDownVector':'\u21C2','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTeeArrow':'\u21A6','RightTee':'\u22A2','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangleBar':'\u29D0','RightTriangle':'\u22B3','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVectorBar':'\u2954','RightUpVector':'\u21BE','RightVectorBar':'\u2953','RightVector':'\u21C0','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoustache':'\u23B1','rmoust':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','Sacute':'\u015A','sacute':'\u015B','sbquo':'\u201A','scap':'\u2AB8','Scaron':'\u0160','scaron':'\u0161','Sc':'\u2ABC','sc':'\u227B','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','Scedil':'\u015E','scedil':'\u015F','Scirc':'\u015C','scirc':'\u015D','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','Scy':'\u0421','scy':'\u0441','sdotb':'\u22A1','sdot':'\u22C5','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','Sfr':'\uD835\uDD16','sfr':'\uD835\uDD30','sfrown':'\u2322','sharp':'\u266F','SHCHcy':'\u0429','shchcy':'\u0449','SHcy':'\u0428','shcy':'\u0448','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','Sigma':'\u03A3','sigma':'\u03C3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','SOFTcy':'\u042C','softcy':'\u044C','solbar':'\u233F','solb':'\u29C4','sol':'/','Sopf':'\uD835\uDD4A','sopf':'\uD835\uDD64','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squ':'\u25A1','squf':'\u25AA','srarr':'\u2192','Sscr':'\uD835\uDCAE','sscr':'\uD835\uDCC8','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','Star':'\u22C6','star':'\u2606','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','subE':'\u2AC5','sube':'\u2286','subedot':'\u2AC3','submult':'\u2AC1','subnE':'\u2ACB','subne':'\u228A','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succapprox':'\u2AB8','succ':'\u227B','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','sup':'\u2283','Sup':'\u22D1','supdot':'\u2ABE','supdsub':'\u2AD8','supE':'\u2AC6','supe':'\u2287','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supnE':'\u2ACC','supne':'\u228B','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','Tau':'\u03A4','tau':'\u03C4','tbrk':'\u23B4','Tcaron':'\u0164','tcaron':'\u0165','Tcedil':'\u0162','tcedil':'\u0163','Tcy':'\u0422','tcy':'\u0442','tdot':'\u20DB','telrec':'\u2315','Tfr':'\uD835\uDD17','tfr':'\uD835\uDD31','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','Theta':'\u0398','theta':'\u03B8','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','ThinSpace':'\u2009','thinsp':'\u2009','thkap':'\u2248','thksim':'\u223C','THORN':'\xDE','thorn':'\xFE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','timesbar':'\u2A31','timesb':'\u22A0','times':'\xD7','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','topbot':'\u2336','topcir':'\u2AF1','top':'\u22A4','Topf':'\uD835\uDD4B','topf':'\uD835\uDD65','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','Tscr':'\uD835\uDCAF','tscr':'\uD835\uDCC9','TScy':'\u0426','tscy':'\u0446','TSHcy':'\u040B','tshcy':'\u045B','Tstrok':'\u0166','tstrok':'\u0167','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','Uacute':'\xDA','uacute':'\xFA','uarr':'\u2191','Uarr':'\u219F','uArr':'\u21D1','Uarrocir':'\u2949','Ubrcy':'\u040E','ubrcy':'\u045E','Ubreve':'\u016C','ubreve':'\u016D','Ucirc':'\xDB','ucirc':'\xFB','Ucy':'\u0423','ucy':'\u0443','udarr':'\u21C5','Udblac':'\u0170','udblac':'\u0171','udhar':'\u296E','ufisht':'\u297E','Ufr':'\uD835\uDD18','ufr':'\uD835\uDD32','Ugrave':'\xD9','ugrave':'\xF9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','Umacr':'\u016A','umacr':'\u016B','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','Uogon':'\u0172','uogon':'\u0173','Uopf':'\uD835\uDD4C','uopf':'\uD835\uDD66','UpArrowBar':'\u2912','uparrow':'\u2191','UpArrow':'\u2191','Uparrow':'\u21D1','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','UpDownArrow':'\u2195','Updownarrow':'\u21D5','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','Upsilon':'\u03A5','upsilon':'\u03C5','UpTeeArrow':'\u21A5','UpTee':'\u22A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','Uring':'\u016E','uring':'\u016F','urtri':'\u25F9','Uscr':'\uD835\uDCB0','uscr':'\uD835\uDCCA','utdot':'\u22F0','Utilde':'\u0168','utilde':'\u0169','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','Uuml':'\xDC','uuml':'\xFC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','Vcy':'\u0412','vcy':'\u0432','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','veebar':'\u22BB','vee':'\u2228','Vee':'\u22C1','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','Vfr':'\uD835\uDD19','vfr':'\uD835\uDD33','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','Vopf':'\uD835\uDD4D','vopf':'\uD835\uDD67','vprop':'\u221D','vrtri':'\u22B3','Vscr':'\uD835\uDCB1','vscr':'\uD835\uDCCB','vsubnE':'\u2ACB\uFE00','vsubne':'\u228A\uFE00','vsupnE':'\u2ACC\uFE00','vsupne':'\u228B\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','Wcirc':'\u0174','wcirc':'\u0175','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','Wfr':'\uD835\uDD1A','wfr':'\uD835\uDD34','Wopf':'\uD835\uDD4E','wopf':'\uD835\uDD68','wp':'\u2118','wr':'\u2240','wreath':'\u2240','Wscr':'\uD835\uDCB2','wscr':'\uD835\uDCCC','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','Xfr':'\uD835\uDD1B','xfr':'\uD835\uDD35','xharr':'\u27F7','xhArr':'\u27FA','Xi':'\u039E','xi':'\u03BE','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','Xopf':'\uD835\uDD4F','xopf':'\uD835\uDD69','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','Xscr':'\uD835\uDCB3','xscr':'\uD835\uDCCD','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','Yacute':'\xDD','yacute':'\xFD','YAcy':'\u042F','yacy':'\u044F','Ycirc':'\u0176','ycirc':'\u0177','Ycy':'\u042B','ycy':'\u044B','yen':'\xA5','Yfr':'\uD835\uDD1C','yfr':'\uD835\uDD36','YIcy':'\u0407','yicy':'\u0457','Yopf':'\uD835\uDD50','yopf':'\uD835\uDD6A','Yscr':'\uD835\uDCB4','yscr':'\uD835\uDCCE','YUcy':'\u042E','yucy':'\u044E','yuml':'\xFF','Yuml':'\u0178','Zacute':'\u0179','zacute':'\u017A','Zcaron':'\u017D','zcaron':'\u017E','Zcy':'\u0417','zcy':'\u0437','Zdot':'\u017B','zdot':'\u017C','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','Zeta':'\u0396','zeta':'\u03B6','zfr':'\uD835\uDD37','Zfr':'\u2128','ZHcy':'\u0416','zhcy':'\u0436','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','Zscr':'\uD835\uDCB5','zscr':'\uD835\uDCCF','zwj':'\u200D','zwnj':'\u200C'};
56
+ var decodeMapLegacy = {'Aacute':'\xC1','aacute':'\xE1','Acirc':'\xC2','acirc':'\xE2','acute':'\xB4','AElig':'\xC6','aelig':'\xE6','Agrave':'\xC0','agrave':'\xE0','amp':'&','AMP':'&','Aring':'\xC5','aring':'\xE5','Atilde':'\xC3','atilde':'\xE3','Auml':'\xC4','auml':'\xE4','brvbar':'\xA6','Ccedil':'\xC7','ccedil':'\xE7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','Eacute':'\xC9','eacute':'\xE9','Ecirc':'\xCA','ecirc':'\xEA','Egrave':'\xC8','egrave':'\xE8','ETH':'\xD0','eth':'\xF0','Euml':'\xCB','euml':'\xEB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','Iacute':'\xCD','iacute':'\xED','Icirc':'\xCE','icirc':'\xEE','iexcl':'\xA1','Igrave':'\xCC','igrave':'\xEC','iquest':'\xBF','Iuml':'\xCF','iuml':'\xEF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','Ntilde':'\xD1','ntilde':'\xF1','Oacute':'\xD3','oacute':'\xF3','Ocirc':'\xD4','ocirc':'\xF4','Ograve':'\xD2','ograve':'\xF2','ordf':'\xAA','ordm':'\xBA','Oslash':'\xD8','oslash':'\xF8','Otilde':'\xD5','otilde':'\xF5','Ouml':'\xD6','ouml':'\xF6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','THORN':'\xDE','thorn':'\xFE','times':'\xD7','Uacute':'\xDA','uacute':'\xFA','Ucirc':'\xDB','ucirc':'\xFB','Ugrave':'\xD9','ugrave':'\xF9','uml':'\xA8','Uuml':'\xDC','uuml':'\xFC','Yacute':'\xDD','yacute':'\xFD','yen':'\xA5','yuml':'\xFF'};
57
+ var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
58
+ var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
59
+
60
+ /*--------------------------------------------------------------------------*/
61
+
62
+ var stringFromCharCode = String.fromCharCode;
63
+
64
+ var object = {};
65
+ var hasOwnProperty = object.hasOwnProperty;
66
+ var has = function(object, propertyName) {
67
+ return hasOwnProperty.call(object, propertyName);
68
+ };
69
+
70
+ var contains = function(array, value) {
71
+ var index = -1;
72
+ var length = array.length;
73
+ while (++index < length) {
74
+ if (array[index] == value) {
75
+ return true;
76
+ }
77
+ }
78
+ return false;
79
+ };
80
+
81
+ var merge = function(options, defaults) {
82
+ if (!options) {
83
+ return defaults;
84
+ }
85
+ var result = {};
86
+ var key;
87
+ for (key in defaults) {
88
+ // A `hasOwnProperty` check is not needed here, since only recognized
89
+ // option names are used anyway. Any others are ignored.
90
+ result[key] = has(options, key) ? options[key] : defaults[key];
91
+ }
92
+ return result;
93
+ };
94
+
95
+ // Modified version of `ucs2encode`; see http://mths.be/punycode.
96
+ var codePointToSymbol = function(codePoint, strict) {
97
+ var output = '';
98
+ if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
99
+ // See issue #4:
100
+ // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
101
+ // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
102
+ // REPLACEMENT CHARACTER.”
103
+ if (strict) {
104
+ parseError('character reference outside the permissible Unicode range');
105
+ }
106
+ return '\uFFFD';
107
+ }
108
+ if (has(decodeMapNumeric, codePoint)) {
109
+ if (strict) {
110
+ parseError('disallowed character reference');
111
+ }
112
+ return decodeMapNumeric[codePoint];
113
+ }
114
+ if (strict && contains(invalidReferenceCodePoints, codePoint)) {
115
+ parseError('disallowed character reference');
116
+ }
117
+ if (codePoint > 0xFFFF) {
118
+ codePoint -= 0x10000;
119
+ output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
120
+ codePoint = 0xDC00 | codePoint & 0x3FF;
121
+ }
122
+ output += stringFromCharCode(codePoint);
123
+ return output;
124
+ };
125
+
126
+ var hexEscape = function(symbol) {
127
+ return '&#x' + symbol.charCodeAt(0).toString(16).toUpperCase() + ';';
128
+ };
129
+
130
+ var parseError = function(message) {
131
+ throw Error('Parse error: ' + message);
132
+ };
133
+
134
+ /*--------------------------------------------------------------------------*/
135
+
136
+ var encode = function(string, options) {
137
+ options = merge(options, encode.options);
138
+ var strict = options.strict;
139
+ if (strict && regexInvalidRawCodePoint.test(string)) {
140
+ parseError('forbidden code point');
141
+ }
142
+ var encodeEverything = options.encodeEverything;
143
+ var useNamedReferences = options.useNamedReferences;
144
+ var allowUnsafeSymbols = options.allowUnsafeSymbols;
145
+ if (encodeEverything) {
146
+ // Encode ASCII symbols.
147
+ string = string.replace(regexAsciiWhitelist, function(symbol) {
148
+ // Use named references if requested & possible.
149
+ if (useNamedReferences && has(encodeMap, symbol)) {
150
+ return '&' + encodeMap[symbol] + ';';
151
+ }
152
+ return hexEscape(symbol);
153
+ });
154
+ // Shorten a few escapes that represent two symbols, of which at least one
155
+ // is within the ASCII range.
156
+ if (useNamedReferences) {
157
+ string = string
158
+ .replace(/&gt;\u20D2/g, '&nvgt;')
159
+ .replace(/&lt;\u20D2/g, '&nvlt;')
160
+ .replace(/&#x66;&#x6A;/g, '&fjlig;');
161
+ }
162
+ // Encode non-ASCII symbols.
163
+ if (useNamedReferences) {
164
+ // Encode non-ASCII symbols that can be replaced with a named reference.
165
+ string = string.replace(regexEncodeNonAscii, function(string) {
166
+ // Note: there is no need to check `has(encodeMap, string)` here.
167
+ return '&' + encodeMap[string] + ';';
168
+ });
169
+ }
170
+ // Note: any remaining non-ASCII symbols are handled outside of the `if`.
171
+ } else if (useNamedReferences) {
172
+ // Apply named character references.
173
+ // Encode `<>"'&` using named character references.
174
+ if (!allowUnsafeSymbols) {
175
+ string = string.replace(regexEscape, function(string) {
176
+ return '&' + encodeMap[string] + ';'; // no need to check `has()` here
177
+ });
178
+ }
179
+ // Shorten escapes that represent two symbols, of which at least one is
180
+ // `<>"'&`.
181
+ string = string
182
+ .replace(/&gt;\u20D2/g, '&nvgt;')
183
+ .replace(/&lt;\u20D2/g, '&nvlt;');
184
+ // Encode non-ASCII symbols that can be replaced with a named reference.
185
+ string = string.replace(regexEncodeNonAscii, function(string) {
186
+ // Note: there is no need to check `has(encodeMap, string)` here.
187
+ return '&' + encodeMap[string] + ';';
188
+ });
189
+ } else if (!allowUnsafeSymbols) {
190
+ // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
191
+ // using named character references.
192
+ string = string.replace(regexEscape, hexEscape);
193
+ }
194
+ return string
195
+ // Encode astral symbols.
196
+ .replace(regexAstralSymbols, function($0) {
197
+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
198
+ var high = $0.charCodeAt(0);
199
+ var low = $0.charCodeAt(1);
200
+ var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
201
+ return '&#x' + codePoint.toString(16).toUpperCase() + ';';
202
+ })
203
+ // Encode any remaining BMP symbols that are not printable ASCII symbols
204
+ // using a hexadecimal escape.
205
+ .replace(regexBmpWhitelist, hexEscape);
206
+ };
207
+ // Expose default options (so they can be overridden globally).
208
+ encode.options = {
209
+ 'allowUnsafeSymbols': false,
210
+ 'encodeEverything': false,
211
+ 'strict': false,
212
+ 'useNamedReferences': false
213
+ };
214
+
215
+ var decode = function(html, options) {
216
+ options = merge(options, decode.options);
217
+ var strict = options.strict;
218
+ if (strict && regexInvalidEntity.test(html)) {
219
+ parseError('malformed character reference');
220
+ }
221
+ return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) {
222
+ var codePoint;
223
+ var semicolon;
224
+ var hexDigits;
225
+ var reference;
226
+ var next;
227
+ if ($1) {
228
+ // Decode decimal escapes, e.g. `&#119558;`.
229
+ codePoint = $1;
230
+ semicolon = $2;
231
+ if (strict && !semicolon) {
232
+ parseError('character reference was not terminated by a semicolon');
233
+ }
234
+ return codePointToSymbol(codePoint, strict);
235
+ }
236
+ if ($3) {
237
+ // Decode hexadecimal escapes, e.g. `&#x1D306;`.
238
+ hexDigits = $3;
239
+ semicolon = $4;
240
+ if (strict && !semicolon) {
241
+ parseError('character reference was not terminated by a semicolon');
242
+ }
243
+ codePoint = parseInt(hexDigits, 16);
244
+ return codePointToSymbol(codePoint, strict);
245
+ }
246
+ if ($5) {
247
+ // Decode named character references with trailing `;`, e.g. `&copy;`.
248
+ reference = $5;
249
+ if (has(decodeMap, reference)) {
250
+ return decodeMap[reference];
251
+ } else {
252
+ // Ambiguous ampersand; see http://mths.be/notes/ambiguous-ampersands.
253
+ if (strict) {
254
+ parseError(
255
+ 'named character reference was not terminated by a semicolon'
256
+ );
257
+ }
258
+ return $0;
259
+ }
260
+ }
261
+ // If we’re still here, it’s a legacy reference for sure. No need for an
262
+ // extra `if` check.
263
+ // Decode named character references without trailing `;`, e.g. `&amp`
264
+ // This is only a parse error if it gets converted to `&`, or if it is
265
+ // followed by `=` in an attribute context.
266
+ reference = $6;
267
+ next = $7;
268
+ if (next && options.isAttributeValue) {
269
+ if (strict && next == '=') {
270
+ parseError('`&` did not start a character reference');
271
+ }
272
+ return $0;
273
+ } else {
274
+ if (strict) {
275
+ parseError(
276
+ 'named character reference was not terminated by a semicolon'
277
+ );
278
+ }
279
+ // Note: there is no need to check `has(decodeMapLegacy, reference)`.
280
+ return decodeMapLegacy[reference] + (next || '');
281
+ }
282
+ });
283
+ };
284
+ // Expose default options (so they can be overridden globally).
285
+ decode.options = {
286
+ 'isAttributeValue': false,
287
+ 'strict': false
288
+ };
289
+
290
+ var escape = function(string) {
291
+ return string.replace(regexEscape, function($0) {
292
+ // Note: there is no need to check `has(escapeMap, $0)` here.
293
+ return escapeMap[$0];
294
+ });
295
+ };
296
+
297
+ /*--------------------------------------------------------------------------*/
298
+
299
+ var he = {
300
+ 'version': '0.5.0',
301
+ 'encode': encode,
302
+ 'decode': decode,
303
+ 'escape': escape,
304
+ 'unescape': decode
305
+ };
306
+
307
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
308
+ // like the following:
309
+ if (
310
+ typeof define == 'function' &&
311
+ typeof define.amd == 'object' &&
312
+ define.amd
313
+ ) {
314
+ define(function() {
315
+ return he;
316
+ });
317
+ } else if (freeExports && !freeExports.nodeType) {
318
+ if (freeModule) { // in Node.js or RingoJS v0.8.0+
319
+ freeModule.exports = he;
320
+ } else { // in Narwhal or RingoJS v0.7.0-
321
+ for (var key in he) {
322
+ has(he, key) && (freeExports[key] = he[key]);
323
+ }
324
+ }
325
+ } else { // in Rhino or a web browser
326
+ root.he = he;
327
+ }
328
+
329
+ }(this));
@@ -2,40 +2,125 @@
2
2
  // Copyright (c) 2009-2010 Dominic Baggott
3
3
  // Copyright (c) 2009-2010 Ash Berlin
4
4
  // Copyright (c) 2011 Christoph Dorn <christoph@christophdorn.com> (http://www.christophdorn.com)
5
+ // Date: 2013-09-15T16:12Z
5
6
 
6
- /*jshint browser:true, devel:true */
7
-
8
- (function( expose ) {
9
-
10
- /**
11
- * class Markdown
12
- *
13
- * Markdown processing in Javascript done right. We have very particular views
14
- * on what constitutes 'right' which include:
15
- *
16
- * - produces well-formed HTML (this means that em and strong nesting is
17
- * important)
18
- *
19
- * - has an intermediate representation to allow processing of parsed data (We
20
- * in fact have two, both as [JsonML]: a markdown tree and an HTML tree).
21
- *
22
- * - is easily extensible to add new dialects without having to rewrite the
23
- * entire parsing mechanics
24
- *
25
- * - has a good test suite
26
- *
27
- * This implementation fulfills all of these (except that the test suite could
28
- * do with expanding to automatically run all the fixtures from other Markdown
29
- * implementations.)
30
- *
31
- * ##### Intermediate Representation
32
- *
33
- * *TODO* Talk about this :) Its JsonML, but document the node names we use.
34
- *
35
- * [JsonML]: http://jsonml.org/ "JSON Markup Language"
36
- **/
37
- var Markdown = expose.Markdown = function(dialect) {
38
- switch (typeof dialect) {
7
+ (function(expose) {
8
+
9
+
10
+
11
+
12
+ var MarkdownHelpers = {};
13
+
14
+ // For Spidermonkey based engines
15
+ function mk_block_toSource() {
16
+ return "Markdown.mk_block( " +
17
+ uneval(this.toString()) +
18
+ ", " +
19
+ uneval(this.trailing) +
20
+ ", " +
21
+ uneval(this.lineNumber) +
22
+ " )";
23
+ }
24
+
25
+ // node
26
+ function mk_block_inspect() {
27
+ var util = require("util");
28
+ return "Markdown.mk_block( " +
29
+ util.inspect(this.toString()) +
30
+ ", " +
31
+ util.inspect(this.trailing) +
32
+ ", " +
33
+ util.inspect(this.lineNumber) +
34
+ " )";
35
+
36
+ }
37
+
38
+ MarkdownHelpers.mk_block = function(block, trail, line) {
39
+ // Be helpful for default case in tests.
40
+ if ( arguments.length === 1 )
41
+ trail = "\n\n";
42
+
43
+ // We actually need a String object, not a string primitive
44
+ /* jshint -W053 */
45
+ var s = new String(block);
46
+ s.trailing = trail;
47
+ // To make it clear its not just a string
48
+ s.inspect = mk_block_inspect;
49
+ s.toSource = mk_block_toSource;
50
+
51
+ if ( line !== undefined )
52
+ s.lineNumber = line;
53
+
54
+ return s;
55
+ };
56
+
57
+
58
+ var isArray = MarkdownHelpers.isArray = Array.isArray || function(obj) {
59
+ return Object.prototype.toString.call(obj) === "[object Array]";
60
+ };
61
+
62
+ // Don't mess with Array.prototype. Its not friendly
63
+ if ( Array.prototype.forEach ) {
64
+ MarkdownHelpers.forEach = function forEach( arr, cb, thisp ) {
65
+ return arr.forEach( cb, thisp );
66
+ };
67
+ }
68
+ else {
69
+ MarkdownHelpers.forEach = function forEach(arr, cb, thisp) {
70
+ for (var i = 0; i < arr.length; i++)
71
+ cb.call(thisp || arr, arr[i], i, arr);
72
+ };
73
+ }
74
+
75
+ MarkdownHelpers.isEmpty = function isEmpty( obj ) {
76
+ for ( var key in obj ) {
77
+ if ( hasOwnProperty.call( obj, key ) )
78
+ return false;
79
+ }
80
+ return true;
81
+ };
82
+
83
+ MarkdownHelpers.extract_attr = function extract_attr( jsonml ) {
84
+ return isArray(jsonml)
85
+ && jsonml.length > 1
86
+ && typeof jsonml[ 1 ] === "object"
87
+ && !( isArray(jsonml[ 1 ]) )
88
+ ? jsonml[ 1 ]
89
+ : undefined;
90
+ };
91
+
92
+
93
+
94
+
95
+ /**
96
+ * class Markdown
97
+ *
98
+ * Markdown processing in Javascript done right. We have very particular views
99
+ * on what constitutes 'right' which include:
100
+ *
101
+ * - produces well-formed HTML (this means that em and strong nesting is
102
+ * important)
103
+ *
104
+ * - has an intermediate representation to allow processing of parsed data (We
105
+ * in fact have two, both as [JsonML]: a markdown tree and an HTML tree).
106
+ *
107
+ * - is easily extensible to add new dialects without having to rewrite the
108
+ * entire parsing mechanics
109
+ *
110
+ * - has a good test suite
111
+ *
112
+ * This implementation fulfills all of these (except that the test suite could
113
+ * do with expanding to automatically run all the fixtures from other Markdown
114
+ * implementations.)
115
+ *
116
+ * ##### Intermediate Representation
117
+ *
118
+ * *TODO* Talk about this :) Its JsonML, but document the node names we use.
119
+ *
120
+ * [JsonML]: http://jsonml.org/ "JSON Markup Language"
121
+ **/
122
+ var Markdown = function(dialect) {
123
+ switch (typeof dialect) {
39
124
  case "undefined":
40
125
  this.dialect = Markdown.dialects.Gruber;
41
126
  break;
@@ -43,1138 +128,1361 @@ var Markdown = expose.Markdown = function(dialect) {
43
128
  this.dialect = dialect;
44
129
  break;
45
130
  default:
46
- if ( dialect in Markdown.dialects ) {
131
+ if ( dialect in Markdown.dialects )
47
132
  this.dialect = Markdown.dialects[dialect];
48
- }
49
- else {
133
+ else
50
134
  throw new Error("Unknown Markdown dialect '" + String(dialect) + "'");
51
- }
52
135
  break;
53
- }
54
- this.em_state = [];
55
- this.strong_state = [];
56
- this.debug_indent = "";
57
- };
58
-
59
- /**
60
- * parse( markdown, [dialect] ) -> JsonML
61
- * - markdown (String): markdown string to parse
62
- * - dialect (String | Dialect): the dialect to use, defaults to gruber
63
- *
64
- * Parse `markdown` and return a markdown document as a Markdown.JsonML tree.
65
- **/
66
- expose.parse = function( source, dialect ) {
67
- // dialect will default if undefined
68
- var md = new Markdown( dialect );
69
- return md.toTree( source );
70
- };
71
-
72
- /**
73
- * toHTML( markdown, [dialect] ) -> String
74
- * toHTML( md_tree ) -> String
75
- * - markdown (String): markdown string to parse
76
- * - md_tree (Markdown.JsonML): parsed markdown tree
77
- *
78
- * Take markdown (either as a string or as a JsonML tree) and run it through
79
- * [[toHTMLTree]] then turn it into a well-formated HTML fragment.
80
- **/
81
- expose.toHTML = function toHTML( source , dialect , options ) {
82
- var input = expose.toHTMLTree( source , dialect , options );
83
-
84
- return expose.renderJsonML( input );
85
- };
86
-
87
- /**
88
- * toHTMLTree( markdown, [dialect] ) -> JsonML
89
- * toHTMLTree( md_tree ) -> JsonML
90
- * - markdown (String): markdown string to parse
91
- * - dialect (String | Dialect): the dialect to use, defaults to gruber
92
- * - md_tree (Markdown.JsonML): parsed markdown tree
93
- *
94
- * Turn markdown into HTML, represented as a JsonML tree. If a string is given
95
- * to this function, it is first parsed into a markdown tree by calling
96
- * [[parse]].
97
- **/
98
- expose.toHTMLTree = function toHTMLTree( input, dialect , options ) {
99
- // convert string input to an MD tree
100
- if ( typeof input ==="string" ) input = this.parse( input, dialect );
101
-
102
- // Now convert the MD tree to an HTML tree
103
-
104
- // remove references from the tree
105
- var attrs = extract_attr( input ),
106
- refs = {};
107
-
108
- if ( attrs && attrs.references ) {
109
- refs = attrs.references;
110
- }
136
+ }
137
+ this.em_state = [];
138
+ this.strong_state = [];
139
+ this.debug_indent = "";
140
+ };
141
+
142
+ /**
143
+ * Markdown.dialects
144
+ *
145
+ * Namespace of built-in dialects.
146
+ **/
147
+ Markdown.dialects = {};
111
148
 
112
- var html = convert_tree_to_html( input, refs , options );
113
- merge_text_nodes( html );
114
- return html;
115
- };
116
-
117
- // For Spidermonkey based engines
118
- function mk_block_toSource() {
119
- return "Markdown.mk_block( " +
120
- uneval(this.toString()) +
121
- ", " +
122
- uneval(this.trailing) +
123
- ", " +
124
- uneval(this.lineNumber) +
125
- " )";
126
- }
127
-
128
- // node
129
- function mk_block_inspect() {
130
- var util = require("util");
131
- return "Markdown.mk_block( " +
132
- util.inspect(this.toString()) +
133
- ", " +
134
- util.inspect(this.trailing) +
135
- ", " +
136
- util.inspect(this.lineNumber) +
137
- " )";
138
-
139
- }
140
-
141
- var mk_block = Markdown.mk_block = function(block, trail, line) {
142
- // Be helpful for default case in tests.
143
- if ( arguments.length == 1 ) trail = "\n\n";
144
-
145
- var s = new String(block);
146
- s.trailing = trail;
147
- // To make it clear its not just a string
148
- s.inspect = mk_block_inspect;
149
- s.toSource = mk_block_toSource;
150
-
151
- if ( line != undefined )
152
- s.lineNumber = line;
153
-
154
- return s;
155
- };
156
-
157
- function count_lines( str ) {
158
- var n = 0, i = -1;
159
- while ( ( i = str.indexOf("\n", i + 1) ) !== -1 ) n++;
160
- return n;
161
- }
162
-
163
- // Internal - split source into rough blocks
164
- Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) {
165
- input = input.replace(/(\r\n|\n|\r)/g, "\n");
166
- // [\s\S] matches _anything_ (newline or space)
167
- var re = /([\s\S]+?)($|\n(?:\s*\n|$)+)/g,
168
- blocks = [],
169
- m;
170
-
171
- var line_no = 1;
172
-
173
- if ( ( m = /^(\s*\n)/.exec(input) ) != null ) {
174
- // skip (but count) leading blank lines
175
- line_no += count_lines( m[0] );
176
- re.lastIndex = m[0].length;
177
- }
178
149
 
179
- while ( ( m = re.exec(input) ) !== null ) {
180
- blocks.push( mk_block( m[1], m[2], line_no ) );
181
- line_no += count_lines( m[0] );
182
- }
183
150
 
184
- return blocks;
185
- };
186
-
187
- /**
188
- * Markdown#processBlock( block, next ) -> undefined | [ JsonML, ... ]
189
- * - block (String): the block to process
190
- * - next (Array): the following blocks
191
- *
192
- * Process `block` and return an array of JsonML nodes representing `block`.
193
- *
194
- * It does this by asking each block level function in the dialect to process
195
- * the block until one can. Succesful handling is indicated by returning an
196
- * array (with zero or more JsonML nodes), failure by a false value.
197
- *
198
- * Blocks handlers are responsible for calling [[Markdown#processInline]]
199
- * themselves as appropriate.
200
- *
201
- * If the blocks were split incorrectly or adjacent blocks need collapsing you
202
- * can adjust `next` in place using shift/splice etc.
203
- *
204
- * If any of this default behaviour is not right for the dialect, you can
205
- * define a `__call__` method on the dialect that will get invoked to handle
206
- * the block processing.
207
- */
208
- Markdown.prototype.processBlock = function processBlock( block, next ) {
209
- var cbs = this.dialect.block,
210
- ord = cbs.__order__;
211
-
212
- if ( "__call__" in cbs ) {
213
- return cbs.__call__.call(this, block, next);
151
+
152
+ // Imported functions
153
+ var mk_block = Markdown.mk_block = MarkdownHelpers.mk_block,
154
+ isArray = MarkdownHelpers.isArray;
155
+
156
+ /**
157
+ * parse( markdown, [dialect] ) -> JsonML
158
+ * - markdown (String): markdown string to parse
159
+ * - dialect (String | Dialect): the dialect to use, defaults to gruber
160
+ *
161
+ * Parse `markdown` and return a markdown document as a Markdown.JsonML tree.
162
+ **/
163
+ Markdown.parse = function( source, dialect ) {
164
+ // dialect will default if undefined
165
+ var md = new Markdown( dialect );
166
+ return md.toTree( source );
167
+ };
168
+
169
+ function count_lines( str ) {
170
+ var n = 0,
171
+ i = -1;
172
+ while ( ( i = str.indexOf("\n", i + 1) ) !== -1 )
173
+ n++;
174
+ return n;
214
175
  }
215
176
 
216
- for ( var i = 0; i < ord.length; i++ ) {
217
- //D:this.debug( "Testing", ord[i] );
218
- var res = cbs[ ord[i] ].call( this, block, next );
219
- if ( res ) {
220
- //D:this.debug(" matched");
221
- if ( !isArray(res) || ( res.length > 0 && !( isArray(res[0]) ) ) )
222
- this.debug(ord[i], "didn't return a proper array");
223
- //D:this.debug( "" );
224
- return res;
177
+ // Internal - split source into rough blocks
178
+ Markdown.prototype.split_blocks = function splitBlocks( input ) {
179
+ input = input.replace(/(\r\n|\n|\r)/g, "\n");
180
+ // [\s\S] matches _anything_ (newline or space)
181
+ // [^] is equivalent but doesn't work in IEs.
182
+ var re = /([\s\S]+?)($|\n#|\n(?:\s*\n|$)+)/g,
183
+ blocks = [],
184
+ m;
185
+
186
+ var line_no = 1;
187
+
188
+ if ( ( m = /^(\s*\n)/.exec(input) ) !== null ) {
189
+ // skip (but count) leading blank lines
190
+ line_no += count_lines( m[0] );
191
+ re.lastIndex = m[0].length;
225
192
  }
226
- }
227
193
 
228
- // Uhoh! no match! Should we throw an error?
229
- return [];
230
- };
231
-
232
- Markdown.prototype.processInline = function processInline( block ) {
233
- return this.dialect.inline.__call__.call( this, String( block ) );
234
- };
235
-
236
- /**
237
- * Markdown#toTree( source ) -> JsonML
238
- * - source (String): markdown source to parse
239
- *
240
- * Parse `source` into a JsonML tree representing the markdown document.
241
- **/
242
- // custom_tree means set this.tree to `custom_tree` and restore old value on return
243
- Markdown.prototype.toTree = function toTree( source, custom_root ) {
244
- var blocks = source instanceof Array ? source : this.split_blocks( source );
245
-
246
- // Make tree a member variable so its easier to mess with in extensions
247
- var old_tree = this.tree;
248
- try {
249
- this.tree = custom_root || this.tree || [ "markdown" ];
250
-
251
- blocks:
252
- while ( blocks.length ) {
253
- var b = this.processBlock( blocks.shift(), blocks );
254
-
255
- // Reference blocks and the like won't return any content
256
- if ( !b.length ) continue blocks;
257
-
258
- this.tree.push.apply( this.tree, b );
194
+ while ( ( m = re.exec(input) ) !== null ) {
195
+ if (m[2] === "\n#") {
196
+ m[2] = "\n";
197
+ re.lastIndex--;
198
+ }
199
+ blocks.push( mk_block( m[1], m[2], line_no ) );
200
+ line_no += count_lines( m[0] );
259
201
  }
260
- return this.tree;
261
- }
262
- finally {
263
- if ( custom_root ) {
264
- this.tree = old_tree;
202
+
203
+ return blocks;
204
+ };
205
+
206
+ /**
207
+ * Markdown#processBlock( block, next ) -> undefined | [ JsonML, ... ]
208
+ * - block (String): the block to process
209
+ * - next (Array): the following blocks
210
+ *
211
+ * Process `block` and return an array of JsonML nodes representing `block`.
212
+ *
213
+ * It does this by asking each block level function in the dialect to process
214
+ * the block until one can. Succesful handling is indicated by returning an
215
+ * array (with zero or more JsonML nodes), failure by a false value.
216
+ *
217
+ * Blocks handlers are responsible for calling [[Markdown#processInline]]
218
+ * themselves as appropriate.
219
+ *
220
+ * If the blocks were split incorrectly or adjacent blocks need collapsing you
221
+ * can adjust `next` in place using shift/splice etc.
222
+ *
223
+ * If any of this default behaviour is not right for the dialect, you can
224
+ * define a `__call__` method on the dialect that will get invoked to handle
225
+ * the block processing.
226
+ */
227
+ Markdown.prototype.processBlock = function processBlock( block, next ) {
228
+ var cbs = this.dialect.block,
229
+ ord = cbs.__order__;
230
+
231
+ if ( "__call__" in cbs )
232
+ return cbs.__call__.call(this, block, next);
233
+
234
+ for ( var i = 0; i < ord.length; i++ ) {
235
+ //D:this.debug( "Testing", ord[i] );
236
+ var res = cbs[ ord[i] ].call( this, block, next );
237
+ if ( res ) {
238
+ //D:this.debug(" matched");
239
+ if ( !isArray(res) || ( res.length > 0 && !( isArray(res[0]) ) ) )
240
+ this.debug(ord[i], "didn't return a proper array");
241
+ //D:this.debug( "" );
242
+ return res;
243
+ }
265
244
  }
266
- }
267
- };
268
245
 
269
- // Noop by default
270
- Markdown.prototype.debug = function () {
271
- var args = Array.prototype.slice.call( arguments);
272
- args.unshift(this.debug_indent);
273
- if ( typeof print !== "undefined" )
246
+ // Uhoh! no match! Should we throw an error?
247
+ return [];
248
+ };
249
+
250
+ Markdown.prototype.processInline = function processInline( block ) {
251
+ return this.dialect.inline.__call__.call( this, String( block ) );
252
+ };
253
+
254
+ /**
255
+ * Markdown#toTree( source ) -> JsonML
256
+ * - source (String): markdown source to parse
257
+ *
258
+ * Parse `source` into a JsonML tree representing the markdown document.
259
+ **/
260
+ // custom_tree means set this.tree to `custom_tree` and restore old value on return
261
+ Markdown.prototype.toTree = function toTree( source, custom_root ) {
262
+ var blocks = source instanceof Array ? source : this.split_blocks( source );
263
+
264
+ // Make tree a member variable so its easier to mess with in extensions
265
+ var old_tree = this.tree;
266
+ try {
267
+ this.tree = custom_root || this.tree || [ "markdown" ];
268
+
269
+ blocks_loop:
270
+ while ( blocks.length ) {
271
+ var b = this.processBlock( blocks.shift(), blocks );
272
+
273
+ // Reference blocks and the like won't return any content
274
+ if ( !b.length )
275
+ continue blocks_loop;
276
+
277
+ this.tree.push.apply( this.tree, b );
278
+ }
279
+ return this.tree;
280
+ }
281
+ finally {
282
+ if ( custom_root )
283
+ this.tree = old_tree;
284
+ }
285
+ };
286
+
287
+ // Noop by default
288
+ Markdown.prototype.debug = function () {
289
+ var args = Array.prototype.slice.call( arguments);
290
+ args.unshift(this.debug_indent);
291
+ if ( typeof print !== "undefined" )
274
292
  print.apply( print, args );
275
- if ( typeof console !== "undefined" && typeof console.log !== "undefined" )
293
+ if ( typeof console !== "undefined" && typeof console.log !== "undefined" )
276
294
  console.log.apply( null, args );
277
- }
295
+ };
278
296
 
279
- Markdown.prototype.loop_re_over_block = function( re, block, cb ) {
280
- // Dont use /g regexps with this
281
- var m,
282
- b = block.valueOf();
297
+ Markdown.prototype.loop_re_over_block = function( re, block, cb ) {
298
+ // Dont use /g regexps with this
299
+ var m,
300
+ b = block.valueOf();
283
301
 
284
- while ( b.length && (m = re.exec(b) ) != null ) {
285
- b = b.substr( m[0].length );
286
- cb.call(this, m);
287
- }
288
- return b;
289
- };
290
-
291
- /**
292
- * Markdown.dialects
293
- *
294
- * Namespace of built-in dialects.
295
- **/
296
- Markdown.dialects = {};
297
-
298
- /**
299
- * Markdown.dialects.Gruber
300
- *
301
- * The default dialect that follows the rules set out by John Gruber's
302
- * markdown.pl as closely as possible. Well actually we follow the behaviour of
303
- * that script which in some places is not exactly what the syntax web page
304
- * says.
305
- **/
306
- Markdown.dialects.Gruber = {
307
- block: {
308
- atxHeader: function atxHeader( block, next ) {
309
- var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ );
310
-
311
- if ( !m ) return undefined;
312
-
313
- var header = [ "header", { level: m[ 1 ].length } ];
314
- Array.prototype.push.apply(header, this.processInline(m[ 2 ]));
315
-
316
- if ( m[0].length < block.length )
317
- next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
318
-
319
- return [ header ];
320
- },
302
+ while ( b.length && (m = re.exec(b) ) !== null ) {
303
+ b = b.substr( m[0].length );
304
+ cb.call(this, m);
305
+ }
306
+ return b;
307
+ };
321
308
 
322
- setextHeader: function setextHeader( block, next ) {
323
- var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ );
309
+ // Build default order from insertion order.
310
+ Markdown.buildBlockOrder = function(d) {
311
+ var ord = [];
312
+ for ( var i in d ) {
313
+ if ( i === "__order__" || i === "__call__" )
314
+ continue;
315
+ ord.push( i );
316
+ }
317
+ d.__order__ = ord;
318
+ };
324
319
 
325
- if ( !m ) return undefined;
320
+ // Build patterns for inline matcher
321
+ Markdown.buildInlinePatterns = function(d) {
322
+ var patterns = [];
323
+
324
+ for ( var i in d ) {
325
+ // __foo__ is reserved and not a pattern
326
+ if ( i.match( /^__.*__$/) )
327
+ continue;
328
+ var l = i.replace( /([\\.*+?|()\[\]{}])/g, "\\$1" )
329
+ .replace( /\n/, "\\n" );
330
+ patterns.push( i.length === 1 ? l : "(?:" + l + ")" );
331
+ }
326
332
 
327
- var level = ( m[ 2 ] === "=" ) ? 1 : 2;
328
- var header = [ "header", { level : level }, m[ 1 ] ];
333
+ patterns = patterns.join("|");
334
+ d.__patterns__ = patterns;
335
+ //print("patterns:", uneval( patterns ) );
329
336
 
330
- if ( m[0].length < block.length )
331
- next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
337
+ var fn = d.__call__;
338
+ d.__call__ = function(text, pattern) {
339
+ if ( pattern !== undefined )
340
+ return fn.call(this, text, pattern);
341
+ else
342
+ return fn.call(this, text, patterns);
343
+ };
344
+ };
332
345
 
333
- return [ header ];
334
- },
335
346
 
336
- code: function code( block, next ) {
337
- // | Foo
338
- // |bar
339
- // should be a code block followed by a paragraph. Fun
340
- //
341
- // There might also be adjacent code block to merge.
342
347
 
343
- var ret = [],
344
- re = /^(?: {0,3}\t| {4})(.*)\n?/,
345
- lines;
346
348
 
347
- // 4 spaces + content
348
- if ( !block.match( re ) ) return undefined;
349
+ var extract_attr = MarkdownHelpers.extract_attr;
349
350
 
350
- block_search:
351
- do {
352
- // Now pull out the rest of the lines
353
- var b = this.loop_re_over_block(
354
- re, block.valueOf(), function( m ) { ret.push( m[1] ); } );
351
+ /**
352
+ * renderJsonML( jsonml[, options] ) -> String
353
+ * - jsonml (Array): JsonML array to render to XML
354
+ * - options (Object): options
355
+ *
356
+ * Converts the given JsonML into well-formed XML.
357
+ *
358
+ * The options currently understood are:
359
+ *
360
+ * - root (Boolean): wether or not the root node should be included in the
361
+ * output, or just its children. The default `false` is to not include the
362
+ * root itself.
363
+ */
364
+ Markdown.renderJsonML = function( jsonml, options ) {
365
+ options = options || {};
366
+ // include the root element in the rendered output?
367
+ options.root = options.root || false;
355
368
 
356
- if ( b.length ) {
357
- // Case alluded to in first comment. push it back on as a new block
358
- next.unshift( mk_block(b, block.trailing) );
359
- break block_search;
360
- }
361
- else if ( next.length ) {
362
- // Check the next block - it might be code too
363
- if ( !next[0].match( re ) ) break block_search;
369
+ var content = [];
364
370
 
365
- // Pull how how many blanks lines follow - minus two to account for .join
366
- ret.push ( block.trailing.replace(/[^\n]/g, "").substring(2) );
371
+ if ( options.root ) {
372
+ content.push( render_tree( jsonml ) );
373
+ }
374
+ else {
375
+ jsonml.shift(); // get rid of the tag
376
+ if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) )
377
+ jsonml.shift(); // get rid of the attributes
367
378
 
368
- block = next.shift();
369
- }
370
- else {
371
- break block_search;
372
- }
373
- } while ( true );
379
+ while ( jsonml.length )
380
+ content.push( render_tree( jsonml.shift() ) );
381
+ }
374
382
 
375
- return [ [ "code_block", ret.join("\n") ] ];
376
- },
383
+ return content.join( "\n\n" );
384
+ };
377
385
 
378
- horizRule: function horizRule( block, next ) {
379
- // this needs to find any hr in the block to handle abutting blocks
380
- var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ );
381
386
 
382
- if ( !m ) {
383
- return undefined;
384
- }
387
+ /**
388
+ * toHTMLTree( markdown, [dialect] ) -> JsonML
389
+ * toHTMLTree( md_tree ) -> JsonML
390
+ * - markdown (String): markdown string to parse
391
+ * - dialect (String | Dialect): the dialect to use, defaults to gruber
392
+ * - md_tree (Markdown.JsonML): parsed markdown tree
393
+ *
394
+ * Turn markdown into HTML, represented as a JsonML tree. If a string is given
395
+ * to this function, it is first parsed into a markdown tree by calling
396
+ * [[parse]].
397
+ **/
398
+ Markdown.toHTMLTree = function toHTMLTree( input, dialect , options ) {
385
399
 
386
- var jsonml = [ [ "hr" ] ];
400
+ // convert string input to an MD tree
401
+ if ( typeof input === "string" )
402
+ input = this.parse( input, dialect );
387
403
 
388
- // if there's a leading abutting block, process it
389
- if ( m[ 1 ] ) {
390
- jsonml.unshift.apply( jsonml, this.processBlock( m[ 1 ], [] ) );
391
- }
404
+ // Now convert the MD tree to an HTML tree
405
+
406
+ // remove references from the tree
407
+ var attrs = extract_attr( input ),
408
+ refs = {};
409
+
410
+ if ( attrs && attrs.references )
411
+ refs = attrs.references;
412
+
413
+ var html = convert_tree_to_html( input, refs , options );
414
+ merge_text_nodes( html );
415
+ return html;
416
+ };
417
+
418
+ /**
419
+ * toHTML( markdown, [dialect] ) -> String
420
+ * toHTML( md_tree ) -> String
421
+ * - markdown (String): markdown string to parse
422
+ * - md_tree (Markdown.JsonML): parsed markdown tree
423
+ *
424
+ * Take markdown (either as a string or as a JsonML tree) and run it through
425
+ * [[toHTMLTree]] then turn it into a well-formated HTML fragment.
426
+ **/
427
+ Markdown.toHTML = function toHTML( source , dialect , options ) {
428
+ var input = this.toHTMLTree( source , dialect , options );
429
+
430
+ return this.renderJsonML( input );
431
+ };
432
+
433
+
434
+ function escapeHTML( text ) {
435
+ return text.replace( /&/g, "&amp;" )
436
+ .replace( /</g, "&lt;" )
437
+ .replace( />/g, "&gt;" )
438
+ .replace( /"/g, "&quot;" )
439
+ .replace( /'/g, "&#39;" );
440
+ }
441
+
442
+ function render_tree( jsonml ) {
443
+ // basic case
444
+ if ( typeof jsonml === "string" )
445
+ return escapeHTML( jsonml );
446
+
447
+ var tag = jsonml.shift(),
448
+ attributes = {},
449
+ content = [];
450
+
451
+ if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) )
452
+ attributes = jsonml.shift();
453
+
454
+ while ( jsonml.length )
455
+ content.push( render_tree( jsonml.shift() ) );
456
+
457
+ var tag_attrs = "";
458
+ for ( var a in attributes )
459
+ tag_attrs += " " + a + '="' + escapeHTML( attributes[ a ] ) + '"';
460
+
461
+ // be careful about adding whitespace here for inline elements
462
+ if ( tag === "img" || tag === "br" || tag === "hr" )
463
+ return "<"+ tag + tag_attrs + "/>";
464
+ else
465
+ return "<"+ tag + tag_attrs + ">" + content.join( "" ) + "</" + tag + ">";
466
+ }
392
467
 
393
- // if there's a trailing abutting block, stick it into next
394
- if ( m[ 3 ] ) {
395
- next.unshift( mk_block( m[ 3 ] ) );
468
+ function convert_tree_to_html( tree, references, options ) {
469
+ var i;
470
+ options = options || {};
471
+
472
+ // shallow clone
473
+ var jsonml = tree.slice( 0 );
474
+
475
+ if ( typeof options.preprocessTreeNode === "function" )
476
+ jsonml = options.preprocessTreeNode(jsonml, references);
477
+
478
+ // Clone attributes if they exist
479
+ var attrs = extract_attr( jsonml );
480
+ if ( attrs ) {
481
+ jsonml[ 1 ] = {};
482
+ for ( i in attrs ) {
483
+ jsonml[ 1 ][ i ] = attrs[ i ];
396
484
  }
485
+ attrs = jsonml[ 1 ];
486
+ }
397
487
 
488
+ // basic case
489
+ if ( typeof jsonml === "string" )
398
490
  return jsonml;
399
- },
400
491
 
401
- // There are two types of lists. Tight and loose. Tight lists have no whitespace
402
- // between the items (and result in text just in the <li>) and loose lists,
403
- // which have an empty line between list items, resulting in (one or more)
404
- // paragraphs inside the <li>.
405
- //
406
- // There are all sorts weird edge cases about the original markdown.pl's
407
- // handling of lists:
408
- //
409
- // * Nested lists are supposed to be indented by four chars per level. But
410
- // if they aren't, you can get a nested list by indenting by less than
411
- // four so long as the indent doesn't match an indent of an existing list
412
- // item in the 'nest stack'.
413
- //
414
- // * The type of the list (bullet or number) is controlled just by the
415
- // first item at the indent. Subsequent changes are ignored unless they
416
- // are for nested lists
417
- //
418
- lists: (function( ) {
419
- // Use a closure to hide a few variables.
420
- var any_list = "[*+-]|\\d+\\.",
421
- bullet_list = /[*+-]/,
422
- number_list = /\d+\./,
423
- // Capture leading indent as it matters for determining nested lists.
424
- is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ),
425
- indent_re = "(?: {0,3}\\t| {4})";
426
-
427
- // TODO: Cache this regexp for certain depths.
428
- // Create a regexp suitable for matching an li for a given stack depth
429
- function regex_for_depth( depth ) {
430
-
431
- return new RegExp(
432
- // m[1] = indent, m[2] = list_type
433
- "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" +
434
- // m[3] = cont
435
- "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})"
436
- );
492
+ // convert this node
493
+ switch ( jsonml[ 0 ] ) {
494
+ case "header":
495
+ jsonml[ 0 ] = "h" + jsonml[ 1 ].level;
496
+ delete jsonml[ 1 ].level;
497
+ break;
498
+ case "bulletlist":
499
+ jsonml[ 0 ] = "ul";
500
+ break;
501
+ case "numberlist":
502
+ jsonml[ 0 ] = "ol";
503
+ break;
504
+ case "listitem":
505
+ jsonml[ 0 ] = "li";
506
+ break;
507
+ case "para":
508
+ jsonml[ 0 ] = "p";
509
+ break;
510
+ case "markdown":
511
+ jsonml[ 0 ] = "html";
512
+ if ( attrs )
513
+ delete attrs.references;
514
+ break;
515
+ case "code_block":
516
+ jsonml[ 0 ] = "pre";
517
+ i = attrs ? 2 : 1;
518
+ var code = [ "code" ];
519
+ code.push.apply( code, jsonml.splice( i, jsonml.length - i ) );
520
+ jsonml[ i ] = code;
521
+ break;
522
+ case "inlinecode":
523
+ jsonml[ 0 ] = "code";
524
+ break;
525
+ case "img":
526
+ jsonml[ 1 ].src = jsonml[ 1 ].href;
527
+ delete jsonml[ 1 ].href;
528
+ break;
529
+ case "linebreak":
530
+ jsonml[ 0 ] = "br";
531
+ break;
532
+ case "link":
533
+ jsonml[ 0 ] = "a";
534
+ break;
535
+ case "link_ref":
536
+ jsonml[ 0 ] = "a";
537
+
538
+ // grab this ref and clean up the attribute node
539
+ var ref = references[ attrs.ref ];
540
+
541
+ // if the reference exists, make the link
542
+ if ( ref ) {
543
+ delete attrs.ref;
544
+
545
+ // add in the href and title, if present
546
+ attrs.href = ref.href;
547
+ if ( ref.title )
548
+ attrs.title = ref.title;
549
+
550
+ // get rid of the unneeded original text
551
+ delete attrs.original;
437
552
  }
438
- function expand_tab( input ) {
439
- return input.replace( / {0,3}\t/g, " " );
553
+ // the reference doesn't exist, so revert to plain text
554
+ else {
555
+ return attrs.original;
440
556
  }
557
+ break;
558
+ case "img_ref":
559
+ jsonml[ 0 ] = "img";
560
+
561
+ // grab this ref and clean up the attribute node
562
+ var ref = references[ attrs.ref ];
563
+
564
+ // if the reference exists, make the link
565
+ if ( ref ) {
566
+ delete attrs.ref;
441
567
 
442
- // Add inline content `inline` to `li`. inline comes from processInline
443
- // so is an array of content
444
- function add(li, loose, inline, nl) {
445
- if ( loose ) {
446
- li.push( [ "para" ].concat(inline) );
447
- return;
568
+ // add in the href and title, if present
569
+ attrs.src = ref.href;
570
+ if ( ref.title )
571
+ attrs.title = ref.title;
572
+
573
+ // get rid of the unneeded original text
574
+ delete attrs.original;
575
+ }
576
+ // the reference doesn't exist, so revert to plain text
577
+ else {
578
+ return attrs.original;
579
+ }
580
+ break;
581
+ }
582
+
583
+ // convert all the children
584
+ i = 1;
585
+
586
+ // deal with the attribute node, if it exists
587
+ if ( attrs ) {
588
+ // if there are keys, skip over it
589
+ for ( var key in jsonml[ 1 ] ) {
590
+ i = 2;
591
+ break;
592
+ }
593
+ // if there aren't, remove it
594
+ if ( i === 1 )
595
+ jsonml.splice( i, 1 );
596
+ }
597
+
598
+ for ( ; i < jsonml.length; ++i ) {
599
+ jsonml[ i ] = convert_tree_to_html( jsonml[ i ], references, options );
600
+ }
601
+
602
+ return jsonml;
603
+ }
604
+
605
+
606
+ // merges adjacent text nodes into a single node
607
+ function merge_text_nodes( jsonml ) {
608
+ // skip the tag name and attribute hash
609
+ var i = extract_attr( jsonml ) ? 2 : 1;
610
+
611
+ while ( i < jsonml.length ) {
612
+ // if it's a string check the next item too
613
+ if ( typeof jsonml[ i ] === "string" ) {
614
+ if ( i + 1 < jsonml.length && typeof jsonml[ i + 1 ] === "string" ) {
615
+ // merge the second string into the first and remove it
616
+ jsonml[ i ] += jsonml.splice( i + 1, 1 )[ 0 ];
448
617
  }
449
- // Hmmm, should this be any block level element or just paras?
450
- var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para"
451
- ? li[li.length -1]
452
- : li;
453
-
454
- // If there is already some content in this list, add the new line in
455
- if ( nl && li.length > 1 ) inline.unshift(nl);
456
-
457
- for ( var i = 0; i < inline.length; i++ ) {
458
- var what = inline[i],
459
- is_str = typeof what == "string";
460
- if ( is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) {
461
- add_to[ add_to.length-1 ] += what;
462
- }
463
- else {
464
- add_to.push( what );
465
- }
618
+ else {
619
+ ++i;
466
620
  }
467
621
  }
622
+ // if it's not a string recurse
623
+ else {
624
+ merge_text_nodes( jsonml[ i ] );
625
+ ++i;
626
+ }
627
+ }
628
+ };
629
+
630
+
631
+
632
+ var DialectHelpers = {};
633
+ DialectHelpers.inline_until_char = function( text, want ) {
634
+ var consumed = 0,
635
+ nodes = [];
636
+
637
+ while ( true ) {
638
+ if ( text.charAt( consumed ) === want ) {
639
+ // Found the character we were looking for
640
+ consumed++;
641
+ return [ consumed, nodes ];
642
+ }
643
+
644
+ if ( consumed >= text.length ) {
645
+ // No closing char found. Abort.
646
+ return null;
647
+ }
648
+
649
+ var res = this.dialect.inline.__oneElement__.call(this, text.substr( consumed ) );
650
+ consumed += res[ 0 ];
651
+ // Add any returned nodes.
652
+ nodes.push.apply( nodes, res.slice( 1 ) );
653
+ }
654
+ };
655
+
656
+ // Helper function to make sub-classing a dialect easier
657
+ DialectHelpers.subclassDialect = function( d ) {
658
+ function Block() {}
659
+ Block.prototype = d.block;
660
+ function Inline() {}
661
+ Inline.prototype = d.inline;
662
+
663
+ return { block: new Block(), inline: new Inline() };
664
+ };
665
+
666
+
667
+
668
+
669
+ var forEach = MarkdownHelpers.forEach,
670
+ extract_attr = MarkdownHelpers.extract_attr,
671
+ mk_block = MarkdownHelpers.mk_block,
672
+ isEmpty = MarkdownHelpers.isEmpty,
673
+ inline_until_char = DialectHelpers.inline_until_char;
674
+
675
+ /**
676
+ * Gruber dialect
677
+ *
678
+ * The default dialect that follows the rules set out by John Gruber's
679
+ * markdown.pl as closely as possible. Well actually we follow the behaviour of
680
+ * that script which in some places is not exactly what the syntax web page
681
+ * says.
682
+ **/
683
+ var Gruber = {
684
+ block: {
685
+ atxHeader: function atxHeader( block, next ) {
686
+ var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ );
687
+
688
+ if ( !m )
689
+ return undefined;
690
+
691
+ var header = [ "header", { level: m[ 1 ].length } ];
692
+ Array.prototype.push.apply(header, this.processInline(m[ 2 ]));
693
+
694
+ if ( m[0].length < block.length )
695
+ next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
696
+
697
+ return [ header ];
698
+ },
699
+
700
+ setextHeader: function setextHeader( block, next ) {
701
+ var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ );
702
+
703
+ if ( !m )
704
+ return undefined;
705
+
706
+ var level = ( m[ 2 ] === "=" ) ? 1 : 2,
707
+ header = [ "header", { level : level }, m[ 1 ] ];
708
+
709
+ if ( m[0].length < block.length )
710
+ next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
711
+
712
+ return [ header ];
713
+ },
468
714
 
469
- // contained means have an indent greater than the current one. On
470
- // *every* line in the block
471
- function get_contained_blocks( depth, blocks ) {
715
+ code: function code( block, next ) {
716
+ // | Foo
717
+ // |bar
718
+ // should be a code block followed by a paragraph. Fun
719
+ //
720
+ // There might also be adjacent code block to merge.
472
721
 
473
- var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ),
474
- replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"),
475
- ret = [];
722
+ var ret = [],
723
+ re = /^(?: {0,3}\t| {4})(.*)\n?/;
476
724
 
477
- while ( blocks.length > 0 ) {
478
- if ( re.exec( blocks[0] ) ) {
479
- var b = blocks.shift(),
480
- // Now remove that indent
481
- x = b.replace( replace, "");
725
+ // 4 spaces + content
726
+ if ( !block.match( re ) )
727
+ return undefined;
482
728
 
483
- ret.push( mk_block( x, b.trailing, b.lineNumber ) );
729
+ block_search:
730
+ do {
731
+ // Now pull out the rest of the lines
732
+ var b = this.loop_re_over_block(
733
+ re, block.valueOf(), function( m ) { ret.push( m[1] ); } );
734
+
735
+ if ( b.length ) {
736
+ // Case alluded to in first comment. push it back on as a new block
737
+ next.unshift( mk_block(b, block.trailing) );
738
+ break block_search;
739
+ }
740
+ else if ( next.length ) {
741
+ // Check the next block - it might be code too
742
+ if ( !next[0].match( re ) )
743
+ break block_search;
744
+
745
+ // Pull how how many blanks lines follow - minus two to account for .join
746
+ ret.push ( block.trailing.replace(/[^\n]/g, "").substring(2) );
747
+
748
+ block = next.shift();
484
749
  }
485
750
  else {
486
- break;
751
+ break block_search;
487
752
  }
488
- }
489
- return ret;
490
- }
753
+ } while ( true );
491
754
 
492
- // passed to stack.forEach to turn list items up the stack into paras
493
- function paragraphify(s, i, stack) {
494
- var list = s.list;
495
- var last_li = list[list.length-1];
755
+ return [ [ "code_block", ret.join("\n") ] ];
756
+ },
496
757
 
497
- if ( last_li[1] instanceof Array && last_li[1][0] == "para" ) {
498
- return;
499
- }
500
- if ( i + 1 == stack.length ) {
501
- // Last stack frame
502
- // Keep the same array, but replace the contents
503
- last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ) );
504
- }
505
- else {
506
- var sublist = last_li.pop();
507
- last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ), sublist );
508
- }
509
- }
758
+ horizRule: function horizRule( block, next ) {
759
+ // this needs to find any hr in the block to handle abutting blocks
760
+ var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ );
510
761
 
511
- // The matcher function
512
- return function( block, next ) {
513
- var m = block.match( is_list_re );
514
- if ( !m ) return undefined;
762
+ if ( !m )
763
+ return undefined;
515
764
 
516
- function make_list( m ) {
517
- var list = bullet_list.exec( m[2] )
518
- ? ["bulletlist"]
519
- : ["numberlist"];
765
+ var jsonml = [ [ "hr" ] ];
520
766
 
521
- stack.push( { list: list, indent: m[1] } );
522
- return list;
767
+ // if there's a leading abutting block, process it
768
+ if ( m[ 1 ] ) {
769
+ var contained = mk_block( m[ 1 ], "", block.lineNumber );
770
+ jsonml.unshift.apply( jsonml, this.toTree( contained, [] ) );
523
771
  }
524
772
 
773
+ // if there's a trailing abutting block, stick it into next
774
+ if ( m[ 3 ] )
775
+ next.unshift( mk_block( m[ 3 ], block.trailing, block.lineNumber + 1 ) );
525
776
 
526
- var stack = [], // Stack of lists for nesting.
527
- list = make_list( m ),
528
- last_li,
529
- loose = false,
530
- ret = [ stack[0].list ],
531
- i;
532
-
533
- // Loop to search over block looking for inner block elements and loose lists
534
- loose_search:
535
- while ( true ) {
536
- // Split into lines preserving new lines at end of line
537
- var lines = block.split( /(?=\n)/ );
538
-
539
- // We have to grab all lines for a li and call processInline on them
540
- // once as there are some inline things that can span lines.
541
- var li_accumulate = "";
542
-
543
- // Loop over the lines in this block looking for tight lists.
544
- tight_search:
545
- for ( var line_no = 0; line_no < lines.length; line_no++ ) {
546
- var nl = "",
547
- l = lines[line_no].replace(/^\n/, function(n) { nl = n; return ""; });
548
-
549
- // TODO: really should cache this
550
- var line_re = regex_for_depth( stack.length );
551
-
552
- m = l.match( line_re );
553
- //print( "line:", uneval(l), "\nline match:", uneval(m) );
554
-
555
- // We have a list item
556
- if ( m[1] !== undefined ) {
557
- // Process the previous list item, if any
558
- if ( li_accumulate.length ) {
559
- add( last_li, loose, this.processInline( li_accumulate ), nl );
560
- // Loose mode will have been dealt with. Reset it
561
- loose = false;
562
- li_accumulate = "";
563
- }
777
+ return jsonml;
778
+ },
564
779
 
565
- m[1] = expand_tab( m[1] );
566
- var wanted_depth = Math.floor(m[1].length/4)+1;
567
- //print( "want:", wanted_depth, "stack:", stack.length);
568
- if ( wanted_depth > stack.length ) {
569
- // Deep enough for a nested list outright
570
- //print ( "new nested list" );
571
- list = make_list( m );
572
- last_li.push( list );
573
- last_li = list[1] = [ "listitem" ];
574
- }
575
- else {
576
- // We aren't deep enough to be strictly a new level. This is
577
- // where Md.pl goes nuts. If the indent matches a level in the
578
- // stack, put it there, else put it one deeper then the
579
- // wanted_depth deserves.
580
- var found = false;
581
- for ( i = 0; i < stack.length; i++ ) {
582
- if ( stack[ i ].indent != m[1] ) continue;
583
- list = stack[ i ].list;
584
- stack.splice( i+1, stack.length - (i+1) );
585
- found = true;
586
- break;
587
- }
780
+ // There are two types of lists. Tight and loose. Tight lists have no whitespace
781
+ // between the items (and result in text just in the <li>) and loose lists,
782
+ // which have an empty line between list items, resulting in (one or more)
783
+ // paragraphs inside the <li>.
784
+ //
785
+ // There are all sorts weird edge cases about the original markdown.pl's
786
+ // handling of lists:
787
+ //
788
+ // * Nested lists are supposed to be indented by four chars per level. But
789
+ // if they aren't, you can get a nested list by indenting by less than
790
+ // four so long as the indent doesn't match an indent of an existing list
791
+ // item in the 'nest stack'.
792
+ //
793
+ // * The type of the list (bullet or number) is controlled just by the
794
+ // first item at the indent. Subsequent changes are ignored unless they
795
+ // are for nested lists
796
+ //
797
+ lists: (function( ) {
798
+ // Use a closure to hide a few variables.
799
+ var any_list = "[*+-]|\\d+\\.",
800
+ bullet_list = /[*+-]/,
801
+ // Capture leading indent as it matters for determining nested lists.
802
+ is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ),
803
+ indent_re = "(?: {0,3}\\t| {4})";
804
+
805
+ // TODO: Cache this regexp for certain depths.
806
+ // Create a regexp suitable for matching an li for a given stack depth
807
+ function regex_for_depth( depth ) {
808
+
809
+ return new RegExp(
810
+ // m[1] = indent, m[2] = list_type
811
+ "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" +
812
+ // m[3] = cont
813
+ "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})"
814
+ );
815
+ }
816
+ function expand_tab( input ) {
817
+ return input.replace( / {0,3}\t/g, " " );
818
+ }
588
819
 
589
- if (!found) {
590
- //print("not found. l:", uneval(l));
591
- wanted_depth++;
592
- if ( wanted_depth <= stack.length ) {
593
- stack.splice(wanted_depth, stack.length - wanted_depth);
594
- //print("Desired depth now", wanted_depth, "stack:", stack.length);
595
- list = stack[wanted_depth-1].list;
596
- //print("list:", uneval(list) );
597
- }
598
- else {
599
- //print ("made new stack for messy indent");
600
- list = make_list(m);
601
- last_li.push(list);
602
- }
603
- }
820
+ // Add inline content `inline` to `li`. inline comes from processInline
821
+ // so is an array of content
822
+ function add(li, loose, inline, nl) {
823
+ if ( loose ) {
824
+ li.push( [ "para" ].concat(inline) );
825
+ return;
826
+ }
827
+ // Hmmm, should this be any block level element or just paras?
828
+ var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] === "para"
829
+ ? li[li.length -1]
830
+ : li;
831
+
832
+ // If there is already some content in this list, add the new line in
833
+ if ( nl && li.length > 1 )
834
+ inline.unshift(nl);
835
+
836
+ for ( var i = 0; i < inline.length; i++ ) {
837
+ var what = inline[i],
838
+ is_str = typeof what === "string";
839
+ if ( is_str && add_to.length > 1 && typeof add_to[add_to.length-1] === "string" )
840
+ add_to[ add_to.length-1 ] += what;
841
+ else
842
+ add_to.push( what );
843
+ }
844
+ }
604
845
 
605
- //print( uneval(list), "last", list === stack[stack.length-1].list );
606
- last_li = [ "listitem" ];
607
- list.push(last_li);
608
- } // end depth of shenegains
609
- nl = "";
610
- }
846
+ // contained means have an indent greater than the current one. On
847
+ // *every* line in the block
848
+ function get_contained_blocks( depth, blocks ) {
611
849
 
612
- // Add content
613
- if ( l.length > m[0].length ) {
614
- li_accumulate += nl + l.substr( m[0].length );
850
+ var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ),
851
+ replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"),
852
+ ret = [];
853
+
854
+ while ( blocks.length > 0 ) {
855
+ if ( re.exec( blocks[0] ) ) {
856
+ var b = blocks.shift(),
857
+ // Now remove that indent
858
+ x = b.replace( replace, "");
859
+
860
+ ret.push( mk_block( x, b.trailing, b.lineNumber ) );
615
861
  }
616
- } // tight_search
862
+ else
863
+ break;
864
+ }
865
+ return ret;
866
+ }
617
867
 
618
- if ( li_accumulate.length ) {
619
- add( last_li, loose, this.processInline( li_accumulate ), nl );
620
- // Loose mode will have been dealt with. Reset it
621
- loose = false;
622
- li_accumulate = "";
868
+ // passed to stack.forEach to turn list items up the stack into paras
869
+ function paragraphify(s, i, stack) {
870
+ var list = s.list;
871
+ var last_li = list[list.length-1];
872
+
873
+ if ( last_li[1] instanceof Array && last_li[1][0] === "para" )
874
+ return;
875
+ if ( i + 1 === stack.length ) {
876
+ // Last stack frame
877
+ // Keep the same array, but replace the contents
878
+ last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ) );
623
879
  }
880
+ else {
881
+ var sublist = last_li.pop();
882
+ last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ), sublist );
883
+ }
884
+ }
624
885
 
625
- // Look at the next block - we might have a loose list. Or an extra
626
- // paragraph for the current li
627
- var contained = get_contained_blocks( stack.length, next );
886
+ // The matcher function
887
+ return function( block, next ) {
888
+ var m = block.match( is_list_re );
889
+ if ( !m )
890
+ return undefined;
628
891
 
629
- // Deal with code blocks or properly nested lists
630
- if ( contained.length > 0 ) {
631
- // Make sure all listitems up the stack are paragraphs
632
- forEach( stack, paragraphify, this);
892
+ function make_list( m ) {
893
+ var list = bullet_list.exec( m[2] )
894
+ ? ["bulletlist"]
895
+ : ["numberlist"];
633
896
 
634
- last_li.push.apply( last_li, this.toTree( contained, [] ) );
897
+ stack.push( { list: list, indent: m[1] } );
898
+ return list;
635
899
  }
636
900
 
637
- var next_block = next[0] && next[0].valueOf() || "";
638
901
 
639
- if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) {
640
- block = next.shift();
902
+ var stack = [], // Stack of lists for nesting.
903
+ list = make_list( m ),
904
+ last_li,
905
+ loose = false,
906
+ ret = [ stack[0].list ],
907
+ i;
641
908
 
642
- // Check for an HR following a list: features/lists/hr_abutting
643
- var hr = this.dialect.block.horizRule( block, next );
909
+ // Loop to search over block looking for inner block elements and loose lists
910
+ loose_search:
911
+ while ( true ) {
912
+ // Split into lines preserving new lines at end of line
913
+ var lines = block.split( /(?=\n)/ );
644
914
 
645
- if ( hr ) {
646
- ret.push.apply(ret, hr);
647
- break;
648
- }
915
+ // We have to grab all lines for a li and call processInline on them
916
+ // once as there are some inline things that can span lines.
917
+ var li_accumulate = "", nl = "";
649
918
 
650
- // Make sure all listitems up the stack are paragraphs
651
- forEach( stack, paragraphify, this);
919
+ // Loop over the lines in this block looking for tight lists.
920
+ tight_search:
921
+ for ( var line_no = 0; line_no < lines.length; line_no++ ) {
922
+ nl = "";
923
+ var l = lines[line_no].replace(/^\n/, function(n) { nl = n; return ""; });
652
924
 
653
- loose = true;
654
- continue loose_search;
655
- }
656
- break;
657
- } // loose_search
658
925
 
659
- return ret;
660
- };
661
- })(),
926
+ // TODO: really should cache this
927
+ var line_re = regex_for_depth( stack.length );
662
928
 
663
- blockquote: function blockquote( block, next ) {
664
- if ( !block.match( /^>/m ) )
665
- return undefined;
929
+ m = l.match( line_re );
930
+ //print( "line:", uneval(l), "\nline match:", uneval(m) );
666
931
 
667
- var jsonml = [];
932
+ // We have a list item
933
+ if ( m[1] !== undefined ) {
934
+ // Process the previous list item, if any
935
+ if ( li_accumulate.length ) {
936
+ add( last_li, loose, this.processInline( li_accumulate ), nl );
937
+ // Loose mode will have been dealt with. Reset it
938
+ loose = false;
939
+ li_accumulate = "";
940
+ }
668
941
 
669
- // separate out the leading abutting block, if any
670
- if ( block[ 0 ] != ">" ) {
671
- var lines = block.split( /\n/ ),
672
- prev = [];
942
+ m[1] = expand_tab( m[1] );
943
+ var wanted_depth = Math.floor(m[1].length/4)+1;
944
+ //print( "want:", wanted_depth, "stack:", stack.length);
945
+ if ( wanted_depth > stack.length ) {
946
+ // Deep enough for a nested list outright
947
+ //print ( "new nested list" );
948
+ list = make_list( m );
949
+ last_li.push( list );
950
+ last_li = list[1] = [ "listitem" ];
951
+ }
952
+ else {
953
+ // We aren't deep enough to be strictly a new level. This is
954
+ // where Md.pl goes nuts. If the indent matches a level in the
955
+ // stack, put it there, else put it one deeper then the
956
+ // wanted_depth deserves.
957
+ var found = false;
958
+ for ( i = 0; i < stack.length; i++ ) {
959
+ if ( stack[ i ].indent !== m[1] )
960
+ continue;
961
+
962
+ list = stack[ i ].list;
963
+ stack.splice( i+1, stack.length - (i+1) );
964
+ found = true;
965
+ break;
966
+ }
673
967
 
674
- // keep shifting lines until you find a crotchet
675
- while ( lines.length && lines[ 0 ][ 0 ] != ">" ) {
676
- prev.push( lines.shift() );
677
- }
968
+ if (!found) {
969
+ //print("not found. l:", uneval(l));
970
+ wanted_depth++;
971
+ if ( wanted_depth <= stack.length ) {
972
+ stack.splice(wanted_depth, stack.length - wanted_depth);
973
+ //print("Desired depth now", wanted_depth, "stack:", stack.length);
974
+ list = stack[wanted_depth-1].list;
975
+ //print("list:", uneval(list) );
976
+ }
977
+ else {
978
+ //print ("made new stack for messy indent");
979
+ list = make_list(m);
980
+ last_li.push(list);
981
+ }
982
+ }
678
983
 
679
- // reassemble!
680
- block = lines.join( "\n" );
681
- jsonml.push.apply( jsonml, this.processBlock( prev.join( "\n" ), [] ) );
682
- }
984
+ //print( uneval(list), "last", list === stack[stack.length-1].list );
985
+ last_li = [ "listitem" ];
986
+ list.push(last_li);
987
+ } // end depth of shenegains
988
+ nl = "";
989
+ }
683
990
 
684
- // if the next block is also a blockquote merge it in
685
- while ( next.length && next[ 0 ][ 0 ] == ">" ) {
686
- var b = next.shift();
687
- block = new String(block + block.trailing + b);
688
- block.trailing = b.trailing;
689
- }
991
+ // Add content
992
+ if ( l.length > m[0].length )
993
+ li_accumulate += nl + l.substr( m[0].length );
994
+ } // tight_search
690
995
 
691
- // Strip off the leading "> " and re-process as a block.
692
- var input = block.replace( /^> ?/gm, "" ),
693
- old_tree = this.tree,
694
- processedBlock = this.toTree( input, [ "blockquote" ] ),
695
- attr = extract_attr( processedBlock );
696
-
697
- // If any link references were found get rid of them
698
- if ( attr && attr.references ) {
699
- delete attr.references;
700
- // And then remove the attribute object if it's empty
701
- if ( isEmpty( attr ) ) {
702
- processedBlock.splice( 1, 1 );
703
- }
704
- }
996
+ if ( li_accumulate.length ) {
997
+ add( last_li, loose, this.processInline( li_accumulate ), nl );
998
+ // Loose mode will have been dealt with. Reset it
999
+ loose = false;
1000
+ li_accumulate = "";
1001
+ }
705
1002
 
706
- jsonml.push( processedBlock );
707
- return jsonml;
708
- },
1003
+ // Look at the next block - we might have a loose list. Or an extra
1004
+ // paragraph for the current li
1005
+ var contained = get_contained_blocks( stack.length, next );
709
1006
 
710
- referenceDefn: function referenceDefn( block, next) {
711
- var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/;
712
- // interesting matches are [ , ref_id, url, , title, title ]
1007
+ // Deal with code blocks or properly nested lists
1008
+ if ( contained.length > 0 ) {
1009
+ // Make sure all listitems up the stack are paragraphs
1010
+ forEach( stack, paragraphify, this);
713
1011
 
714
- if ( !block.match(re) )
715
- return undefined;
1012
+ last_li.push.apply( last_li, this.toTree( contained, [] ) );
1013
+ }
716
1014
 
717
- // make an attribute node if it doesn't exist
718
- if ( !extract_attr( this.tree ) ) {
719
- this.tree.splice( 1, 0, {} );
720
- }
1015
+ var next_block = next[0] && next[0].valueOf() || "";
721
1016
 
722
- var attrs = extract_attr( this.tree );
1017
+ if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) {
1018
+ block = next.shift();
723
1019
 
724
- // make a references hash if it doesn't exist
725
- if ( attrs.references === undefined ) {
726
- attrs.references = {};
727
- }
1020
+ // Check for an HR following a list: features/lists/hr_abutting
1021
+ var hr = this.dialect.block.horizRule( block, next );
728
1022
 
729
- var b = this.loop_re_over_block(re, block, function( m ) {
1023
+ if ( hr ) {
1024
+ ret.push.apply(ret, hr);
1025
+ break;
1026
+ }
730
1027
 
731
- if ( m[2] && m[2][0] == "<" && m[2][m[2].length-1] == ">" )
732
- m[2] = m[2].substring( 1, m[2].length - 1 );
1028
+ // Make sure all listitems up the stack are paragraphs
1029
+ forEach( stack, paragraphify, this);
1030
+
1031
+ loose = true;
1032
+ continue loose_search;
1033
+ }
1034
+ break;
1035
+ } // loose_search
733
1036
 
734
- var ref = attrs.references[ m[1].toLowerCase() ] = {
735
- href: m[2]
1037
+ return ret;
736
1038
  };
1039
+ })(),
1040
+
1041
+ blockquote: function blockquote( block, next ) {
1042
+ if ( !block.match( /^>/m ) )
1043
+ return undefined;
1044
+
1045
+ var jsonml = [];
1046
+
1047
+ // separate out the leading abutting block, if any. I.e. in this case:
1048
+ //
1049
+ // a
1050
+ // > b
1051
+ //
1052
+ if ( block[ 0 ] !== ">" ) {
1053
+ var lines = block.split( /\n/ ),
1054
+ prev = [],
1055
+ line_no = block.lineNumber;
1056
+
1057
+ // keep shifting lines until you find a crotchet
1058
+ while ( lines.length && lines[ 0 ][ 0 ] !== ">" ) {
1059
+ prev.push( lines.shift() );
1060
+ line_no++;
1061
+ }
1062
+
1063
+ var abutting = mk_block( prev.join( "\n" ), "\n", block.lineNumber );
1064
+ jsonml.push.apply( jsonml, this.processBlock( abutting, [] ) );
1065
+ // reassemble new block of just block quotes!
1066
+ block = mk_block( lines.join( "\n" ), block.trailing, line_no );
1067
+ }
737
1068
 
738
- if ( m[4] !== undefined )
739
- ref.title = m[4];
740
- else if ( m[5] !== undefined )
741
- ref.title = m[5];
742
1069
 
743
- } );
1070
+ // if the next block is also a blockquote merge it in
1071
+ while ( next.length && next[ 0 ][ 0 ] === ">" ) {
1072
+ var b = next.shift();
1073
+ block = mk_block( block + block.trailing + b, b.trailing, block.lineNumber );
1074
+ }
744
1075
 
745
- if ( b.length )
746
- next.unshift( mk_block( b, block.trailing ) );
1076
+ // Strip off the leading "> " and re-process as a block.
1077
+ var input = block.replace( /^> ?/gm, "" ),
1078
+ old_tree = this.tree,
1079
+ processedBlock = this.toTree( input, [ "blockquote" ] ),
1080
+ attr = extract_attr( processedBlock );
1081
+
1082
+ // If any link references were found get rid of them
1083
+ if ( attr && attr.references ) {
1084
+ delete attr.references;
1085
+ // And then remove the attribute object if it's empty
1086
+ if ( isEmpty( attr ) )
1087
+ processedBlock.splice( 1, 1 );
1088
+ }
747
1089
 
748
- return [];
749
- },
1090
+ jsonml.push( processedBlock );
1091
+ return jsonml;
1092
+ },
750
1093
 
751
- para: function para( block, next ) {
752
- // everything's a para!
753
- return [ ["para"].concat( this.processInline( block ) ) ];
754
- }
755
- }
756
- };
1094
+ referenceDefn: function referenceDefn( block, next) {
1095
+ var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/;
1096
+ // interesting matches are [ , ref_id, url, , title, title ]
757
1097
 
758
- Markdown.dialects.Gruber.inline = {
1098
+ if ( !block.match(re) )
1099
+ return undefined;
759
1100
 
760
- __oneElement__: function oneElement( text, patterns_or_re, previous_nodes ) {
761
- var m,
762
- res,
763
- lastIndex = 0;
1101
+ // make an attribute node if it doesn't exist
1102
+ if ( !extract_attr( this.tree ) )
1103
+ this.tree.splice( 1, 0, {} );
764
1104
 
765
- patterns_or_re = patterns_or_re || this.dialect.inline.__patterns__;
766
- var re = new RegExp( "([\\s\\S]*?)(" + (patterns_or_re.source || patterns_or_re) + ")" );
1105
+ var attrs = extract_attr( this.tree );
767
1106
 
768
- m = re.exec( text );
769
- if (!m) {
770
- // Just boring text
771
- return [ text.length, text ];
772
- }
773
- else if ( m[1] ) {
774
- // Some un-interesting text matched. Return that first
775
- return [ m[1].length, m[1] ];
776
- }
1107
+ // make a references hash if it doesn't exist
1108
+ if ( attrs.references === undefined )
1109
+ attrs.references = {};
1110
+
1111
+ var b = this.loop_re_over_block(re, block, function( m ) {
1112
+
1113
+ if ( m[2] && m[2][0] === "<" && m[2][m[2].length-1] === ">" )
1114
+ m[2] = m[2].substring( 1, m[2].length - 1 );
777
1115
 
778
- var res;
779
- if ( m[2] in this.dialect.inline ) {
780
- res = this.dialect.inline[ m[2] ].call(
781
- this,
782
- text.substr( m.index ), m, previous_nodes || [] );
783
- }
784
- // Default for now to make dev easier. just slurp special and output it.
785
- res = res || [ m[2].length, m[2] ];
786
- return res;
787
- },
1116
+ var ref = attrs.references[ m[1].toLowerCase() ] = {
1117
+ href: m[2]
1118
+ };
788
1119
 
789
- __call__: function inline( text, patterns ) {
1120
+ if ( m[4] !== undefined )
1121
+ ref.title = m[4];
1122
+ else if ( m[5] !== undefined )
1123
+ ref.title = m[5];
790
1124
 
791
- var out = [],
792
- res;
1125
+ } );
793
1126
 
794
- function add(x) {
795
- //D:self.debug(" adding output", uneval(x));
796
- if ( typeof x == "string" && typeof out[out.length-1] == "string" )
797
- out[ out.length-1 ] += x;
798
- else
799
- out.push(x);
800
- }
1127
+ if ( b.length )
1128
+ next.unshift( mk_block( b, block.trailing ) );
801
1129
 
802
- while ( text.length > 0 ) {
803
- res = this.dialect.inline.__oneElement__.call(this, text, patterns, out );
804
- text = text.substr( res.shift() );
805
- forEach(res, add )
806
- }
1130
+ return [];
1131
+ },
807
1132
 
808
- return out;
1133
+ para: function para( block ) {
1134
+ // everything's a para!
1135
+ return [ ["para"].concat( this.processInline( block ) ) ];
1136
+ }
809
1137
  },
810
1138
 
811
- // These characters are intersting elsewhere, so have rules for them so that
812
- // chunks of plain text blocks don't include them
813
- "]": function () {},
814
- "}": function () {},
1139
+ inline: {
815
1140
 
816
- "\\": function escaped( text ) {
817
- // [ length of input processed, node/children to add... ]
818
- // Only esacape: \ ` * _ { } [ ] ( ) # * + - . !
819
- if ( text.match( /^\\[\\`\*_{}\[\]()#\+.!\-]/ ) )
820
- return [ 2, text.charAt( 1 ) ];
821
- else
822
- // Not an esacpe
823
- return [ 1, "\\" ];
824
- },
1141
+ __oneElement__: function oneElement( text, patterns_or_re, previous_nodes ) {
1142
+ var m,
1143
+ res;
825
1144
 
826
- "![": function image( text ) {
1145
+ patterns_or_re = patterns_or_re || this.dialect.inline.__patterns__;
1146
+ var re = new RegExp( "([\\s\\S]*?)(" + (patterns_or_re.source || patterns_or_re) + ")" );
827
1147
 
828
- // Unlike images, alt text is plain text only. no other elements are
829
- // allowed in there
1148
+ m = re.exec( text );
1149
+ if (!m) {
1150
+ // Just boring text
1151
+ return [ text.length, text ];
1152
+ }
1153
+ else if ( m[1] ) {
1154
+ // Some un-interesting text matched. Return that first
1155
+ return [ m[1].length, m[1] ];
1156
+ }
830
1157
 
831
- // ![Alt text](/path/to/img.jpg "Optional title")
832
- // 1 2 3 4 <--- captures
833
- var m = text.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ );
1158
+ var res;
1159
+ if ( m[2] in this.dialect.inline ) {
1160
+ res = this.dialect.inline[ m[2] ].call(
1161
+ this,
1162
+ text.substr( m.index ), m, previous_nodes || [] );
1163
+ }
1164
+ // Default for now to make dev easier. just slurp special and output it.
1165
+ res = res || [ m[2].length, m[2] ];
1166
+ return res;
1167
+ },
1168
+
1169
+ __call__: function inline( text, patterns ) {
1170
+
1171
+ var out = [],
1172
+ res;
1173
+
1174
+ function add(x) {
1175
+ //D:self.debug(" adding output", uneval(x));
1176
+ if ( typeof x === "string" && typeof out[out.length-1] === "string" )
1177
+ out[ out.length-1 ] += x;
1178
+ else
1179
+ out.push(x);
1180
+ }
834
1181
 
835
- if ( m ) {
836
- if ( m[2] && m[2][0] == "<" && m[2][m[2].length-1] == ">" )
837
- m[2] = m[2].substring( 1, m[2].length - 1 );
1182
+ while ( text.length > 0 ) {
1183
+ res = this.dialect.inline.__oneElement__.call(this, text, patterns, out );
1184
+ text = text.substr( res.shift() );
1185
+ forEach(res, add );
1186
+ }
838
1187
 
839
- m[2] = this.dialect.inline.__call__.call( this, m[2], /\\/ )[0];
1188
+ return out;
1189
+ },
840
1190
 
841
- var attrs = { alt: m[1], href: m[2] || "" };
842
- if ( m[4] !== undefined)
843
- attrs.title = m[4];
1191
+ // These characters are intersting elsewhere, so have rules for them so that
1192
+ // chunks of plain text blocks don't include them
1193
+ "]": function () {},
1194
+ "}": function () {},
844
1195
 
845
- return [ m[0].length, [ "img", attrs ] ];
846
- }
1196
+ __escape__ : /^\\[\\`\*_{}\[\]()#\+.!\-]/,
847
1197
 
848
- // ![Alt text][id]
849
- m = text.match( /^!\[(.*?)\][ \t]*\[(.*?)\]/ );
1198
+ "\\": function escaped( text ) {
1199
+ // [ length of input processed, node/children to add... ]
1200
+ // Only esacape: \ ` * _ { } [ ] ( ) # * + - . !
1201
+ if ( this.dialect.inline.__escape__.exec( text ) )
1202
+ return [ 2, text.charAt( 1 ) ];
1203
+ else
1204
+ // Not an esacpe
1205
+ return [ 1, "\\" ];
1206
+ },
850
1207
 
851
- if ( m ) {
852
- // We can't check if the reference is known here as it likely wont be
853
- // found till after. Check it in md tree->hmtl tree conversion
854
- return [ m[0].length, [ "img_ref", { alt: m[1], ref: m[2].toLowerCase(), original: m[0] } ] ];
855
- }
1208
+ "![": function image( text ) {
856
1209
 
857
- // Just consume the '!['
858
- return [ 2, "![" ];
859
- },
1210
+ // Unlike images, alt text is plain text only. no other elements are
1211
+ // allowed in there
860
1212
 
861
- "[": function link( text ) {
862
-
863
- var orig = String(text);
864
- // Inline content is possible inside `link text`
865
- var res = Markdown.DialectHelpers.inline_until_char.call( this, text.substr(1), "]" );
866
-
867
- // No closing ']' found. Just consume the [
868
- if ( !res ) return [ 1, "[" ];
869
-
870
- var consumed = 1 + res[ 0 ],
871
- children = res[ 1 ],
872
- link,
873
- attrs;
874
-
875
- // At this point the first [...] has been parsed. See what follows to find
876
- // out which kind of link we are (reference or direct url)
877
- text = text.substr( consumed );
878
-
879
- // [link text](/path/to/img.jpg "Optional title")
880
- // 1 2 3 <--- captures
881
- // This will capture up to the last paren in the block. We then pull
882
- // back based on if there a matching ones in the url
883
- // ([here](/url/(test))
884
- // The parens have to be balanced
885
- var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ );
886
- if ( m ) {
887
- var url = m[1];
888
- consumed += m[0].length;
889
-
890
- if ( url && url[0] == "<" && url[url.length-1] == ">" )
891
- url = url.substring( 1, url.length - 1 );
892
-
893
- // If there is a title we don't have to worry about parens in the url
894
- if ( !m[3] ) {
895
- var open_parens = 1; // One open that isn't in the capture
896
- for ( var len = 0; len < url.length; len++ ) {
897
- switch ( url[len] ) {
898
- case "(":
899
- open_parens++;
900
- break;
901
- case ")":
902
- if ( --open_parens == 0) {
903
- consumed -= url.length - len;
904
- url = url.substring(0, len);
905
- }
906
- break;
907
- }
908
- }
909
- }
1213
+ // ![Alt text](/path/to/img.jpg "Optional title")
1214
+ // 1 2 3 4 <--- captures
1215
+ var m = text.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ );
910
1216
 
911
- // Process escapes only
912
- url = this.dialect.inline.__call__.call( this, url, /\\/ )[0];
1217
+ if ( m ) {
1218
+ if ( m[2] && m[2][0] === "<" && m[2][m[2].length-1] === ">" )
1219
+ m[2] = m[2].substring( 1, m[2].length - 1 );
913
1220
 
914
- attrs = { href: url || "" };
915
- if ( m[3] !== undefined)
916
- attrs.title = m[3];
1221
+ m[2] = this.dialect.inline.__call__.call( this, m[2], /\\/ )[0];
917
1222
 
918
- link = [ "link", attrs ].concat( children );
919
- return [ consumed, link ];
920
- }
1223
+ var attrs = { alt: m[1], href: m[2] || "" };
1224
+ if ( m[4] !== undefined)
1225
+ attrs.title = m[4];
921
1226
 
922
- // [Alt text][id]
923
- // [Alt text] [id]
924
- m = text.match( /^\s*\[(.*?)\]/ );
1227
+ return [ m[0].length, [ "img", attrs ] ];
1228
+ }
925
1229
 
926
- if ( m ) {
1230
+ // ![Alt text][id]
1231
+ m = text.match( /^!\[(.*?)\][ \t]*\[(.*?)\]/ );
927
1232
 
928
- consumed += m[ 0 ].length;
1233
+ if ( m ) {
1234
+ // We can't check if the reference is known here as it likely wont be
1235
+ // found till after. Check it in md tree->hmtl tree conversion
1236
+ return [ m[0].length, [ "img_ref", { alt: m[1], ref: m[2].toLowerCase(), original: m[0] } ] ];
1237
+ }
929
1238
 
930
- // [links][] uses links as its reference
931
- attrs = { ref: ( m[ 1 ] || String(children) ).toLowerCase(), original: orig.substr( 0, consumed ) };
1239
+ // Just consume the '!['
1240
+ return [ 2, "![" ];
1241
+ },
1242
+
1243
+ "[": function link( text ) {
1244
+
1245
+ var orig = String(text);
1246
+ // Inline content is possible inside `link text`
1247
+ var res = inline_until_char.call( this, text.substr(1), "]" );
1248
+
1249
+ // No closing ']' found. Just consume the [
1250
+ if ( !res )
1251
+ return [ 1, "[" ];
1252
+
1253
+ var consumed = 1 + res[ 0 ],
1254
+ children = res[ 1 ],
1255
+ link,
1256
+ attrs;
1257
+
1258
+ // At this point the first [...] has been parsed. See what follows to find
1259
+ // out which kind of link we are (reference or direct url)
1260
+ text = text.substr( consumed );
1261
+
1262
+ // [link text](/path/to/img.jpg "Optional title")
1263
+ // 1 2 3 <--- captures
1264
+ // This will capture up to the last paren in the block. We then pull
1265
+ // back based on if there a matching ones in the url
1266
+ // ([here](/url/(test))
1267
+ // The parens have to be balanced
1268
+ var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ );
1269
+ if ( m ) {
1270
+ var url = m[1];
1271
+ consumed += m[0].length;
1272
+
1273
+ if ( url && url[0] === "<" && url[url.length-1] === ">" )
1274
+ url = url.substring( 1, url.length - 1 );
1275
+
1276
+ // If there is a title we don't have to worry about parens in the url
1277
+ if ( !m[3] ) {
1278
+ var open_parens = 1; // One open that isn't in the capture
1279
+ for ( var len = 0; len < url.length; len++ ) {
1280
+ switch ( url[len] ) {
1281
+ case "(":
1282
+ open_parens++;
1283
+ break;
1284
+ case ")":
1285
+ if ( --open_parens === 0) {
1286
+ consumed -= url.length - len;
1287
+ url = url.substring(0, len);
1288
+ }
1289
+ break;
1290
+ }
1291
+ }
1292
+ }
932
1293
 
933
- link = [ "link_ref", attrs ].concat( children );
1294
+ // Process escapes only
1295
+ url = this.dialect.inline.__call__.call( this, url, /\\/ )[0];
934
1296
 
935
- // We can't check if the reference is known here as it likely wont be
936
- // found till after. Check it in md tree->hmtl tree conversion.
937
- // Store the original so that conversion can revert if the ref isn't found.
938
- return [ consumed, link ];
939
- }
1297
+ attrs = { href: url || "" };
1298
+ if ( m[3] !== undefined)
1299
+ attrs.title = m[3];
940
1300
 
941
- // [id]
942
- // Only if id is plain (no formatting.)
943
- if ( children.length == 1 && typeof children[0] == "string" ) {
1301
+ link = [ "link", attrs ].concat( children );
1302
+ return [ consumed, link ];
1303
+ }
944
1304
 
945
- attrs = { ref: children[0].toLowerCase(), original: orig.substr( 0, consumed ) };
946
- link = [ "link_ref", attrs, children[0] ];
947
- return [ consumed, link ];
948
- }
1305
+ // [Alt text][id]
1306
+ // [Alt text] [id]
1307
+ m = text.match( /^\s*\[(.*?)\]/ );
949
1308
 
950
- // Just consume the "["
951
- return [ 1, "[" ];
952
- },
1309
+ if ( m ) {
953
1310
 
1311
+ consumed += m[ 0 ].length;
954
1312
 
955
- "<": function autoLink( text ) {
956
- var m;
1313
+ // [links][] uses links as its reference
1314
+ attrs = { ref: ( m[ 1 ] || String(children) ).toLowerCase(), original: orig.substr( 0, consumed ) };
957
1315
 
958
- if ( ( m = text.match( /^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/ ) ) != null ) {
959
- if ( m[3] ) {
960
- return [ m[0].length, [ "link", { href: "mailto:" + m[3] }, m[3] ] ];
1316
+ link = [ "link_ref", attrs ].concat( children );
961
1317
 
1318
+ // We can't check if the reference is known here as it likely wont be
1319
+ // found till after. Check it in md tree->hmtl tree conversion.
1320
+ // Store the original so that conversion can revert if the ref isn't found.
1321
+ return [ consumed, link ];
962
1322
  }
963
- else if ( m[2] == "mailto" ) {
964
- return [ m[0].length, [ "link", { href: m[1] }, m[1].substr("mailto:".length ) ] ];
965
- }
966
- else
967
- return [ m[0].length, [ "link", { href: m[1] }, m[1] ] ];
968
- }
969
1323
 
970
- return [ 1, "<" ];
971
- },
1324
+ // [id]
1325
+ // Only if id is plain (no formatting.)
1326
+ if ( children.length === 1 && typeof children[0] === "string" ) {
972
1327
 
973
- "`": function inlineCode( text ) {
974
- // Inline code block. as many backticks as you like to start it
975
- // Always skip over the opening ticks.
976
- var m = text.match( /(`+)(([\s\S]*?)\1)/ );
1328
+ attrs = { ref: children[0].toLowerCase(), original: orig.substr( 0, consumed ) };
1329
+ link = [ "link_ref", attrs, children[0] ];
1330
+ return [ consumed, link ];
1331
+ }
977
1332
 
978
- if ( m && m[2] )
979
- return [ m[1].length + m[2].length, [ "inlinecode", m[3] ] ];
980
- else {
981
- // TODO: No matching end code found - warn!
982
- return [ 1, "`" ];
983
- }
984
- },
1333
+ // Just consume the "["
1334
+ return [ 1, "[" ];
1335
+ },
985
1336
 
986
- " \n": function lineBreak( text ) {
987
- return [ 3, [ "linebreak" ] ];
988
- }
989
1337
 
990
- };
1338
+ "<": function autoLink( text ) {
1339
+ var m;
991
1340
 
992
- // Meta Helper/generator method for em and strong handling
993
- function strong_em( tag, md ) {
1341
+ if ( ( m = text.match( /^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/ ) ) !== null ) {
1342
+ if ( m[3] )
1343
+ return [ m[0].length, [ "link", { href: "mailto:" + m[3] }, m[3] ] ];
1344
+ else if ( m[2] === "mailto" )
1345
+ return [ m[0].length, [ "link", { href: m[1] }, m[1].substr("mailto:".length ) ] ];
1346
+ else
1347
+ return [ m[0].length, [ "link", { href: m[1] }, m[1] ] ];
1348
+ }
994
1349
 
995
- var state_slot = tag + "_state",
996
- other_slot = tag == "strong" ? "em_state" : "strong_state";
1350
+ return [ 1, "<" ];
1351
+ },
997
1352
 
998
- function CloseTag(len) {
999
- this.len_after = len;
1000
- this.name = "close_" + md;
1001
- }
1353
+ "`": function inlineCode( text ) {
1354
+ // Inline code block. as many backticks as you like to start it
1355
+ // Always skip over the opening ticks.
1356
+ var m = text.match( /(`+)(([\s\S]*?)\1)/ );
1002
1357
 
1003
- return function ( text, orig_match ) {
1358
+ if ( m && m[2] )
1359
+ return [ m[1].length + m[2].length, [ "inlinecode", m[3] ] ];
1360
+ else {
1361
+ // TODO: No matching end code found - warn!
1362
+ return [ 1, "`" ];
1363
+ }
1364
+ },
1004
1365
 
1005
- if ( this[state_slot][0] == md ) {
1006
- // Most recent em is of this type
1007
- //D:this.debug("closing", md);
1008
- this[state_slot].shift();
1366
+ " \n": function lineBreak() {
1367
+ return [ 3, [ "linebreak" ] ];
1368
+ }
1009
1369
 
1010
- // "Consume" everything to go back to the recrusion in the else-block below
1011
- return[ text.length, new CloseTag(text.length-md.length) ];
1012
1370
  }
1013
- else {
1014
- // Store a clone of the em/strong states
1015
- var other = this[other_slot].slice(),
1016
- state = this[state_slot].slice();
1371
+ };
1017
1372
 
1018
- this[state_slot].unshift(md);
1373
+ // Meta Helper/generator method for em and strong handling
1374
+ function strong_em( tag, md ) {
1019
1375
 
1020
- //D:this.debug_indent += " ";
1376
+ var state_slot = tag + "_state",
1377
+ other_slot = tag === "strong" ? "em_state" : "strong_state";
1021
1378
 
1022
- // Recurse
1023
- var res = this.processInline( text.substr( md.length ) );
1024
- //D:this.debug_indent = this.debug_indent.substr(2);
1379
+ function CloseTag(len) {
1380
+ this.len_after = len;
1381
+ this.name = "close_" + md;
1382
+ }
1025
1383
 
1026
- var last = res[res.length - 1];
1384
+ return function ( text ) {
1027
1385
 
1028
- //D:this.debug("processInline from", tag + ": ", uneval( res ) );
1386
+ if ( this[state_slot][0] === md ) {
1387
+ // Most recent em is of this type
1388
+ //D:this.debug("closing", md);
1389
+ this[state_slot].shift();
1029
1390
 
1030
- var check = this[state_slot].shift();
1031
- if ( last instanceof CloseTag ) {
1032
- res.pop();
1033
- // We matched! Huzzah.
1034
- var consumed = text.length - last.len_after;
1035
- return [ consumed, [ tag ].concat(res) ];
1391
+ // "Consume" everything to go back to the recrusion in the else-block below
1392
+ return[ text.length, new CloseTag(text.length-md.length) ];
1036
1393
  }
1037
1394
  else {
1038
- // Restore the state of the other kind. We might have mistakenly closed it.
1039
- this[other_slot] = other;
1040
- this[state_slot] = state;
1395
+ // Store a clone of the em/strong states
1396
+ var other = this[other_slot].slice(),
1397
+ state = this[state_slot].slice();
1041
1398
 
1042
- // We can't reuse the processed result as it could have wrong parsing contexts in it.
1043
- return [ md.length, md ];
1044
- }
1045
- }
1046
- }; // End returned function
1047
- }
1399
+ this[state_slot].unshift(md);
1048
1400
 
1049
- Markdown.dialects.Gruber.inline["**"] = strong_em("strong", "**");
1050
- Markdown.dialects.Gruber.inline["__"] = strong_em("strong", "__");
1051
- Markdown.dialects.Gruber.inline["*"] = strong_em("em", "*");
1052
- Markdown.dialects.Gruber.inline["_"] = strong_em("em", "_");
1401
+ //D:this.debug_indent += " ";
1053
1402
 
1403
+ // Recurse
1404
+ var res = this.processInline( text.substr( md.length ) );
1405
+ //D:this.debug_indent = this.debug_indent.substr(2);
1054
1406
 
1055
- // Build default order from insertion order.
1056
- Markdown.buildBlockOrder = function(d) {
1057
- var ord = [];
1058
- for ( var i in d ) {
1059
- if ( i == "__order__" || i == "__call__" ) continue;
1060
- ord.push( i );
1061
- }
1062
- d.__order__ = ord;
1063
- };
1064
-
1065
- // Build patterns for inline matcher
1066
- Markdown.buildInlinePatterns = function(d) {
1067
- var patterns = [];
1068
-
1069
- for ( var i in d ) {
1070
- // __foo__ is reserved and not a pattern
1071
- if ( i.match( /^__.*__$/) ) continue;
1072
- var l = i.replace( /([\\.*+?|()\[\]{}])/g, "\\$1" )
1073
- .replace( /\n/, "\\n" );
1074
- patterns.push( i.length == 1 ? l : "(?:" + l + ")" );
1075
- }
1076
-
1077
- patterns = patterns.join("|");
1078
- d.__patterns__ = patterns;
1079
- //print("patterns:", uneval( patterns ) );
1407
+ var last = res[res.length - 1];
1080
1408
 
1081
- var fn = d.__call__;
1082
- d.__call__ = function(text, pattern) {
1083
- if ( pattern != undefined ) {
1084
- return fn.call(this, text, pattern);
1085
- }
1086
- else
1087
- {
1088
- return fn.call(this, text, patterns);
1089
- }
1090
- };
1091
- };
1092
-
1093
- Markdown.DialectHelpers = {};
1094
- Markdown.DialectHelpers.inline_until_char = function( text, want ) {
1095
- var consumed = 0,
1096
- nodes = [];
1097
-
1098
- while ( true ) {
1099
- if ( text.charAt( consumed ) == want ) {
1100
- // Found the character we were looking for
1101
- consumed++;
1102
- return [ consumed, nodes ];
1103
- }
1409
+ //D:this.debug("processInline from", tag + ": ", uneval( res ) );
1104
1410
 
1105
- if ( consumed >= text.length ) {
1106
- // No closing char found. Abort.
1107
- return null;
1108
- }
1411
+ var check = this[state_slot].shift();
1412
+ if ( last instanceof CloseTag ) {
1413
+ res.pop();
1414
+ // We matched! Huzzah.
1415
+ var consumed = text.length - last.len_after;
1416
+ return [ consumed, [ tag ].concat(res) ];
1417
+ }
1418
+ else {
1419
+ // Restore the state of the other kind. We might have mistakenly closed it.
1420
+ this[other_slot] = other;
1421
+ this[state_slot] = state;
1109
1422
 
1110
- var res = this.dialect.inline.__oneElement__.call(this, text.substr( consumed ) );
1111
- consumed += res[ 0 ];
1112
- // Add any returned nodes.
1113
- nodes.push.apply( nodes, res.slice( 1 ) );
1423
+ // We can't reuse the processed result as it could have wrong parsing contexts in it.
1424
+ return [ md.length, md ];
1425
+ }
1426
+ }
1427
+ }; // End returned function
1114
1428
  }
1115
- }
1116
1429
 
1117
- // Helper function to make sub-classing a dialect easier
1118
- Markdown.subclassDialect = function( d ) {
1119
- function Block() {}
1120
- Block.prototype = d.block;
1121
- function Inline() {}
1122
- Inline.prototype = d.inline;
1430
+ Gruber.inline["**"] = strong_em("strong", "**");
1431
+ Gruber.inline["__"] = strong_em("strong", "__");
1432
+ Gruber.inline["*"] = strong_em("em", "*");
1433
+ Gruber.inline["_"] = strong_em("em", "_");
1123
1434
 
1124
- return { block: new Block(), inline: new Inline() };
1125
- };
1435
+ Markdown.dialects.Gruber = Gruber;
1436
+ Markdown.buildBlockOrder ( Markdown.dialects.Gruber.block );
1437
+ Markdown.buildInlinePatterns( Markdown.dialects.Gruber.inline );
1126
1438
 
1127
- Markdown.buildBlockOrder ( Markdown.dialects.Gruber.block );
1128
- Markdown.buildInlinePatterns( Markdown.dialects.Gruber.inline );
1129
1439
 
1130
- Markdown.dialects.Maruku = Markdown.subclassDialect( Markdown.dialects.Gruber );
1131
1440
 
1132
- Markdown.dialects.Maruku.processMetaHash = function processMetaHash( meta_string ) {
1133
- var meta = split_meta_hash( meta_string ),
1134
- attr = {};
1441
+ var Maruku = DialectHelpers.subclassDialect( Gruber ),
1442
+ extract_attr = MarkdownHelpers.extract_attr,
1443
+ forEach = MarkdownHelpers.forEach;
1135
1444
 
1136
- for ( var i = 0; i < meta.length; ++i ) {
1137
- // id: #foo
1138
- if ( /^#/.test( meta[ i ] ) ) {
1139
- attr.id = meta[ i ].substring( 1 );
1140
- }
1141
- // class: .foo
1142
- else if ( /^\./.test( meta[ i ] ) ) {
1143
- // if class already exists, append the new one
1144
- if ( attr["class"] ) {
1145
- attr["class"] = attr["class"] + meta[ i ].replace( /./, " " );
1445
+ Maruku.processMetaHash = function processMetaHash( meta_string ) {
1446
+ var meta = split_meta_hash( meta_string ),
1447
+ attr = {};
1448
+
1449
+ for ( var i = 0; i < meta.length; ++i ) {
1450
+ // id: #foo
1451
+ if ( /^#/.test( meta[ i ] ) )
1452
+ attr.id = meta[ i ].substring( 1 );
1453
+ // class: .foo
1454
+ else if ( /^\./.test( meta[ i ] ) ) {
1455
+ // if class already exists, append the new one
1456
+ if ( attr["class"] )
1457
+ attr["class"] = attr["class"] + meta[ i ].replace( /./, " " );
1458
+ else
1459
+ attr["class"] = meta[ i ].substring( 1 );
1146
1460
  }
1147
- else {
1148
- attr["class"] = meta[ i ].substring( 1 );
1461
+ // attribute: foo=bar
1462
+ else if ( /\=/.test( meta[ i ] ) ) {
1463
+ var s = meta[ i ].split( /\=/ );
1464
+ attr[ s[ 0 ] ] = s[ 1 ];
1149
1465
  }
1150
1466
  }
1151
- // attribute: foo=bar
1152
- else if ( /\=/.test( meta[ i ] ) ) {
1153
- var s = meta[ i ].split( /\=/ );
1154
- attr[ s[ 0 ] ] = s[ 1 ];
1155
- }
1156
- }
1157
1467
 
1158
- return attr;
1159
- }
1468
+ return attr;
1469
+ };
1160
1470
 
1161
- function split_meta_hash( meta_string ) {
1162
- var meta = meta_string.split( "" ),
1163
- parts = [ "" ],
1164
- in_quotes = false;
1471
+ function split_meta_hash( meta_string ) {
1472
+ var meta = meta_string.split( "" ),
1473
+ parts = [ "" ],
1474
+ in_quotes = false;
1165
1475
 
1166
- while ( meta.length ) {
1167
- var letter = meta.shift();
1168
- switch ( letter ) {
1476
+ while ( meta.length ) {
1477
+ var letter = meta.shift();
1478
+ switch ( letter ) {
1169
1479
  case " " :
1170
1480
  // if we're in a quoted section, keep it
1171
- if ( in_quotes ) {
1481
+ if ( in_quotes )
1172
1482
  parts[ parts.length - 1 ] += letter;
1173
- }
1174
1483
  // otherwise make a new part
1175
- else {
1484
+ else
1176
1485
  parts.push( "" );
1177
- }
1178
1486
  break;
1179
1487
  case "'" :
1180
1488
  case '"' :
@@ -1185,458 +1493,248 @@ function split_meta_hash( meta_string ) {
1185
1493
  // shift off the next letter to be used straight away.
1186
1494
  // it was escaped so we'll keep it whatever it is
1187
1495
  letter = meta.shift();
1496
+ /* falls through */
1188
1497
  default :
1189
1498
  parts[ parts.length - 1 ] += letter;
1190
1499
  break;
1500
+ }
1191
1501
  }
1192
- }
1193
-
1194
- return parts;
1195
- }
1196
-
1197
- Markdown.dialects.Maruku.block.document_meta = function document_meta( block, next ) {
1198
- // we're only interested in the first block
1199
- if ( block.lineNumber > 1 ) return undefined;
1200
-
1201
- // document_meta blocks consist of one or more lines of `Key: Value\n`
1202
- if ( ! block.match( /^(?:\w+:.*\n)*\w+:.*$/ ) ) return undefined;
1203
1502
 
1204
- // make an attribute node if it doesn't exist
1205
- if ( !extract_attr( this.tree ) ) {
1206
- this.tree.splice( 1, 0, {} );
1503
+ return parts;
1207
1504
  }
1208
1505
 
1209
- var pairs = block.split( /\n/ );
1210
- for ( p in pairs ) {
1211
- var m = pairs[ p ].match( /(\w+):\s*(.*)$/ ),
1212
- key = m[ 1 ].toLowerCase(),
1213
- value = m[ 2 ];
1214
-
1215
- this.tree[ 1 ][ key ] = value;
1216
- }
1217
-
1218
- // document_meta produces no content!
1219
- return [];
1220
- };
1221
-
1222
- Markdown.dialects.Maruku.block.block_meta = function block_meta( block, next ) {
1223
- // check if the last line of the block is an meta hash
1224
- var m = block.match( /(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/ );
1225
- if ( !m ) return undefined;
1506
+ Maruku.block.document_meta = function document_meta( block ) {
1507
+ // we're only interested in the first block
1508
+ if ( block.lineNumber > 1 )
1509
+ return undefined;
1226
1510
 
1227
- // process the meta hash
1228
- var attr = this.dialect.processMetaHash( m[ 2 ] );
1511
+ // document_meta blocks consist of one or more lines of `Key: Value\n`
1512
+ if ( ! block.match( /^(?:\w+:.*\n)*\w+:.*$/ ) )
1513
+ return undefined;
1229
1514
 
1230
- var hash;
1515
+ // make an attribute node if it doesn't exist
1516
+ if ( !extract_attr( this.tree ) )
1517
+ this.tree.splice( 1, 0, {} );
1231
1518
 
1232
- // if we matched ^ then we need to apply meta to the previous block
1233
- if ( m[ 1 ] === "" ) {
1234
- var node = this.tree[ this.tree.length - 1 ];
1235
- hash = extract_attr( node );
1519
+ var pairs = block.split( /\n/ );
1520
+ for ( var p in pairs ) {
1521
+ var m = pairs[ p ].match( /(\w+):\s*(.*)$/ ),
1522
+ key = m[ 1 ].toLowerCase(),
1523
+ value = m[ 2 ];
1236
1524
 
1237
- // if the node is a string (rather than JsonML), bail
1238
- if ( typeof node === "string" ) return undefined;
1239
-
1240
- // create the attribute hash if it doesn't exist
1241
- if ( !hash ) {
1242
- hash = {};
1243
- node.splice( 1, 0, hash );
1244
- }
1245
-
1246
- // add the attributes in
1247
- for ( a in attr ) {
1248
- hash[ a ] = attr[ a ];
1525
+ this.tree[ 1 ][ key ] = value;
1249
1526
  }
1250
1527
 
1251
- // return nothing so the meta hash is removed
1528
+ // document_meta produces no content!
1252
1529
  return [];
1253
- }
1254
-
1255
- // pull the meta hash off the block and process what's left
1256
- var b = block.replace( /\n.*$/, "" ),
1257
- result = this.processBlock( b, [] );
1258
-
1259
- // get or make the attributes hash
1260
- hash = extract_attr( result[ 0 ] );
1261
- if ( !hash ) {
1262
- hash = {};
1263
- result[ 0 ].splice( 1, 0, hash );
1264
- }
1265
-
1266
- // attach the attributes to the block
1267
- for ( a in attr ) {
1268
- hash[ a ] = attr[ a ];
1269
- }
1530
+ };
1270
1531
 
1271
- return result;
1272
- };
1273
-
1274
- Markdown.dialects.Maruku.block.definition_list = function definition_list( block, next ) {
1275
- // one or more terms followed by one or more definitions, in a single block
1276
- var tight = /^((?:[^\s:].*\n)+):\s+([\s\S]+)$/,
1277
- list = [ "dl" ],
1278
- i;
1279
-
1280
- // see if we're dealing with a tight or loose block
1281
- if ( ( m = block.match( tight ) ) ) {
1282
- // pull subsequent tight DL blocks out of `next`
1283
- var blocks = [ block ];
1284
- while ( next.length && tight.exec( next[ 0 ] ) ) {
1285
- blocks.push( next.shift() );
1286
- }
1532
+ Maruku.block.block_meta = function block_meta( block ) {
1533
+ // check if the last line of the block is an meta hash
1534
+ var m = block.match( /(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/ );
1535
+ if ( !m )
1536
+ return undefined;
1287
1537
 
1288
- for ( var b = 0; b < blocks.length; ++b ) {
1289
- var m = blocks[ b ].match( tight ),
1290
- terms = m[ 1 ].replace( /\n$/, "" ).split( /\n/ ),
1291
- defns = m[ 2 ].split( /\n:\s+/ );
1538
+ // process the meta hash
1539
+ var attr = this.dialect.processMetaHash( m[ 2 ] ),
1540
+ hash;
1292
1541
 
1293
- // print( uneval( m ) );
1542
+ // if we matched ^ then we need to apply meta to the previous block
1543
+ if ( m[ 1 ] === "" ) {
1544
+ var node = this.tree[ this.tree.length - 1 ];
1545
+ hash = extract_attr( node );
1294
1546
 
1295
- for ( i = 0; i < terms.length; ++i ) {
1296
- list.push( [ "dt", terms[ i ] ] );
1297
- }
1547
+ // if the node is a string (rather than JsonML), bail
1548
+ if ( typeof node === "string" )
1549
+ return undefined;
1298
1550
 
1299
- for ( i = 0; i < defns.length; ++i ) {
1300
- // run inline processing over the definition
1301
- list.push( [ "dd" ].concat( this.processInline( defns[ i ].replace( /(\n)\s+/, "$1" ) ) ) );
1551
+ // create the attribute hash if it doesn't exist
1552
+ if ( !hash ) {
1553
+ hash = {};
1554
+ node.splice( 1, 0, hash );
1302
1555
  }
1303
- }
1304
- }
1305
- else {
1306
- return undefined;
1307
- }
1308
1556
 
1309
- return [ list ];
1310
- };
1557
+ // add the attributes in
1558
+ for ( var a in attr )
1559
+ hash[ a ] = attr[ a ];
1311
1560
 
1312
- Markdown.dialects.Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) {
1313
- if ( !out.length ) {
1314
- return [ 2, "{:" ];
1315
- }
1316
-
1317
- // get the preceeding element
1318
- var before = out[ out.length - 1 ];
1561
+ // return nothing so the meta hash is removed
1562
+ return [];
1563
+ }
1319
1564
 
1320
- if ( typeof before === "string" ) {
1321
- return [ 2, "{:" ];
1322
- }
1565
+ // pull the meta hash off the block and process what's left
1566
+ var b = block.replace( /\n.*$/, "" ),
1567
+ result = this.processBlock( b, [] );
1323
1568
 
1324
- // match a meta hash
1325
- var m = text.match( /^\{:\s*((?:\\\}|[^\}])*)\s*\}/ );
1569
+ // get or make the attributes hash
1570
+ hash = extract_attr( result[ 0 ] );
1571
+ if ( !hash ) {
1572
+ hash = {};
1573
+ result[ 0 ].splice( 1, 0, hash );
1574
+ }
1326
1575
 
1327
- // no match, false alarm
1328
- if ( !m ) {
1329
- return [ 2, "{:" ];
1330
- }
1576
+ // attach the attributes to the block
1577
+ for ( var a in attr )
1578
+ hash[ a ] = attr[ a ];
1331
1579
 
1332
- // attach the attributes to the preceeding element
1333
- var meta = this.dialect.processMetaHash( m[ 1 ] ),
1334
- attr = extract_attr( before );
1580
+ return result;
1581
+ };
1335
1582
 
1336
- if ( !attr ) {
1337
- attr = {};
1338
- before.splice( 1, 0, attr );
1339
- }
1583
+ Maruku.block.definition_list = function definition_list( block, next ) {
1584
+ // one or more terms followed by one or more definitions, in a single block
1585
+ var tight = /^((?:[^\s:].*\n)+):\s+([\s\S]+)$/,
1586
+ list = [ "dl" ],
1587
+ i, m;
1340
1588
 
1341
- for ( var k in meta ) {
1342
- attr[ k ] = meta[ k ];
1343
- }
1589
+ // see if we're dealing with a tight or loose block
1590
+ if ( ( m = block.match( tight ) ) ) {
1591
+ // pull subsequent tight DL blocks out of `next`
1592
+ var blocks = [ block ];
1593
+ while ( next.length && tight.exec( next[ 0 ] ) )
1594
+ blocks.push( next.shift() );
1344
1595
 
1345
- // cut out the string and replace it with nothing
1346
- return [ m[ 0 ].length, "" ];
1347
- };
1596
+ for ( var b = 0; b < blocks.length; ++b ) {
1597
+ var m = blocks[ b ].match( tight ),
1598
+ terms = m[ 1 ].replace( /\n$/, "" ).split( /\n/ ),
1599
+ defns = m[ 2 ].split( /\n:\s+/ );
1348
1600
 
1349
- Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block );
1350
- Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline );
1601
+ // print( uneval( m ) );
1351
1602
 
1352
- var isArray = Array.isArray || function(obj) {
1353
- return Object.prototype.toString.call(obj) == "[object Array]";
1354
- };
1603
+ for ( i = 0; i < terms.length; ++i )
1604
+ list.push( [ "dt", terms[ i ] ] );
1355
1605
 
1356
- var forEach;
1357
- // Don't mess with Array.prototype. Its not friendly
1358
- if ( Array.prototype.forEach ) {
1359
- forEach = function( arr, cb, thisp ) {
1360
- return arr.forEach( cb, thisp );
1361
- };
1362
- }
1363
- else {
1364
- forEach = function(arr, cb, thisp) {
1365
- for (var i = 0; i < arr.length; i++) {
1366
- cb.call(thisp || arr, arr[i], i, arr);
1606
+ for ( i = 0; i < defns.length; ++i ) {
1607
+ // run inline processing over the definition
1608
+ list.push( [ "dd" ].concat( this.processInline( defns[ i ].replace( /(\n)\s+/, "$1" ) ) ) );
1609
+ }
1610
+ }
1367
1611
  }
1368
- }
1369
- }
1370
-
1371
- var isEmpty = function( obj ) {
1372
- for ( var key in obj ) {
1373
- if ( hasOwnProperty.call( obj, key ) ) {
1374
- return false;
1612
+ else {
1613
+ return undefined;
1375
1614
  }
1376
- }
1377
1615
 
1378
- return true;
1379
- }
1380
-
1381
- function extract_attr( jsonml ) {
1382
- return isArray(jsonml)
1383
- && jsonml.length > 1
1384
- && typeof jsonml[ 1 ] === "object"
1385
- && !( isArray(jsonml[ 1 ]) )
1386
- ? jsonml[ 1 ]
1387
- : undefined;
1388
- }
1389
-
1390
-
1391
-
1392
- /**
1393
- * renderJsonML( jsonml[, options] ) -> String
1394
- * - jsonml (Array): JsonML array to render to XML
1395
- * - options (Object): options
1396
- *
1397
- * Converts the given JsonML into well-formed XML.
1398
- *
1399
- * The options currently understood are:
1400
- *
1401
- * - root (Boolean): wether or not the root node should be included in the
1402
- * output, or just its children. The default `false` is to not include the
1403
- * root itself.
1404
- */
1405
- expose.renderJsonML = function( jsonml, options ) {
1406
- options = options || {};
1407
- // include the root element in the rendered output?
1408
- options.root = options.root || false;
1409
-
1410
- var content = [];
1411
-
1412
- if ( options.root ) {
1413
- content.push( render_tree( jsonml ) );
1414
- }
1415
- else {
1416
- jsonml.shift(); // get rid of the tag
1417
- if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) {
1418
- jsonml.shift(); // get rid of the attributes
1419
- }
1616
+ return [ list ];
1617
+ };
1420
1618
 
1421
- while ( jsonml.length ) {
1422
- content.push( render_tree( jsonml.shift() ) );
1619
+ // splits on unescaped instances of @ch. If @ch is not a character the result
1620
+ // can be unpredictable
1621
+
1622
+ Maruku.block.table = function table ( block ) {
1623
+
1624
+ var _split_on_unescaped = function( s, ch ) {
1625
+ ch = ch || '\\s';
1626
+ if ( ch.match(/^[\\|\[\]{}?*.+^$]$/) )
1627
+ ch = '\\' + ch;
1628
+ var res = [ ],
1629
+ r = new RegExp('^((?:\\\\.|[^\\\\' + ch + '])*)' + ch + '(.*)'),
1630
+ m;
1631
+ while ( ( m = s.match( r ) ) ) {
1632
+ res.push( m[1] );
1633
+ s = m[2];
1634
+ }
1635
+ res.push(s);
1636
+ return res;
1637
+ };
1638
+
1639
+ var leading_pipe = /^ {0,3}\|(.+)\n {0,3}\|\s*([\-:]+[\-| :]*)\n((?:\s*\|.*(?:\n|$))*)(?=\n|$)/,
1640
+ // find at least an unescaped pipe in each line
1641
+ no_leading_pipe = /^ {0,3}(\S(?:\\.|[^\\|])*\|.*)\n {0,3}([\-:]+\s*\|[\-| :]*)\n((?:(?:\\.|[^\\|])*\|.*(?:\n|$))*)(?=\n|$)/,
1642
+ i,
1643
+ m;
1644
+ if ( ( m = block.match( leading_pipe ) ) ) {
1645
+ // remove leading pipes in contents
1646
+ // (header and horizontal rule already have the leading pipe left out)
1647
+ m[3] = m[3].replace(/^\s*\|/gm, '');
1648
+ } else if ( ! ( m = block.match( no_leading_pipe ) ) ) {
1649
+ return undefined;
1423
1650
  }
1424
- }
1425
-
1426
- return content.join( "\n\n" );
1427
- };
1428
-
1429
- function escapeHTML( text ) {
1430
- return text.replace( /&/g, "&amp;" )
1431
- .replace( /</g, "&lt;" )
1432
- .replace( />/g, "&gt;" )
1433
- .replace( /"/g, "&quot;" )
1434
- .replace( /'/g, "&#39;" );
1435
- }
1436
-
1437
- function render_tree( jsonml ) {
1438
- // basic case
1439
- if ( typeof jsonml === "string" ) {
1440
- return escapeHTML( jsonml );
1441
- }
1442
-
1443
- var tag = jsonml.shift(),
1444
- attributes = {},
1445
- content = [];
1446
-
1447
- if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) {
1448
- attributes = jsonml.shift();
1449
- }
1450
-
1451
- while ( jsonml.length ) {
1452
- content.push( render_tree( jsonml.shift() ) );
1453
- }
1454
-
1455
- var tag_attrs = "";
1456
- for ( var a in attributes ) {
1457
- tag_attrs += " " + a + '="' + escapeHTML( attributes[ a ] ) + '"';
1458
- }
1459
-
1460
- // be careful about adding whitespace here for inline elements
1461
- if ( tag == "img" || tag == "br" || tag == "hr" ) {
1462
- return "<"+ tag + tag_attrs + "/>";
1463
- }
1464
- else {
1465
- return "<"+ tag + tag_attrs + ">" + content.join( "" ) + "</" + tag + ">";
1466
- }
1467
- }
1468
-
1469
- function convert_tree_to_html( tree, references, options ) {
1470
- var i;
1471
- options = options || {};
1472
-
1473
- // shallow clone
1474
- var jsonml = tree.slice( 0 );
1475
-
1476
- if ( typeof options.preprocessTreeNode === "function" ) {
1477
- jsonml = options.preprocessTreeNode(jsonml, references);
1478
- }
1479
1651
 
1480
- // Clone attributes if they exist
1481
- var attrs = extract_attr( jsonml );
1482
- if ( attrs ) {
1483
- jsonml[ 1 ] = {};
1484
- for ( i in attrs ) {
1485
- jsonml[ 1 ][ i ] = attrs[ i ];
1652
+ var table = [ "table", [ "thead", [ "tr" ] ], [ "tbody" ] ];
1653
+
1654
+ // remove trailing pipes, then split on pipes
1655
+ // (no escaped pipes are allowed in horizontal rule)
1656
+ m[2] = m[2].replace(/\|\s*$/, '').split('|');
1657
+
1658
+ // process alignment
1659
+ var html_attrs = [ ];
1660
+ forEach (m[2], function (s) {
1661
+ if (s.match(/^\s*-+:\s*$/))
1662
+ html_attrs.push({align: "right"});
1663
+ else if (s.match(/^\s*:-+\s*$/))
1664
+ html_attrs.push({align: "left"});
1665
+ else if (s.match(/^\s*:-+:\s*$/))
1666
+ html_attrs.push({align: "center"});
1667
+ else
1668
+ html_attrs.push({});
1669
+ });
1670
+
1671
+ // now for the header, avoid escaped pipes
1672
+ m[1] = _split_on_unescaped(m[1].replace(/\|\s*$/, ''), '|');
1673
+ for (i = 0; i < m[1].length; i++) {
1674
+ table[1][1].push(['th', html_attrs[i] || {}].concat(
1675
+ this.processInline(m[1][i].trim())));
1486
1676
  }
1487
- attrs = jsonml[ 1 ];
1488
- }
1489
-
1490
- // basic case
1491
- if ( typeof jsonml === "string" ) {
1492
- return jsonml;
1493
- }
1494
-
1495
- // convert this node
1496
- switch ( jsonml[ 0 ] ) {
1497
- case "header":
1498
- jsonml[ 0 ] = "h" + jsonml[ 1 ].level;
1499
- delete jsonml[ 1 ].level;
1500
- break;
1501
- case "bulletlist":
1502
- jsonml[ 0 ] = "ul";
1503
- break;
1504
- case "numberlist":
1505
- jsonml[ 0 ] = "ol";
1506
- break;
1507
- case "listitem":
1508
- jsonml[ 0 ] = "li";
1509
- break;
1510
- case "para":
1511
- jsonml[ 0 ] = "p";
1512
- break;
1513
- case "markdown":
1514
- jsonml[ 0 ] = "html";
1515
- if ( attrs ) delete attrs.references;
1516
- break;
1517
- case "code_block":
1518
- jsonml[ 0 ] = "pre";
1519
- i = attrs ? 2 : 1;
1520
- var code = [ "code" ];
1521
- code.push.apply( code, jsonml.splice( i, jsonml.length - i ) );
1522
- jsonml[ i ] = code;
1523
- break;
1524
- case "inlinecode":
1525
- jsonml[ 0 ] = "code";
1526
- break;
1527
- case "img":
1528
- jsonml[ 1 ].src = jsonml[ 1 ].href;
1529
- delete jsonml[ 1 ].href;
1530
- break;
1531
- case "linebreak":
1532
- jsonml[ 0 ] = "br";
1533
- break;
1534
- case "link":
1535
- jsonml[ 0 ] = "a";
1536
- break;
1537
- case "link_ref":
1538
- jsonml[ 0 ] = "a";
1539
1677
 
1540
- // grab this ref and clean up the attribute node
1541
- var ref = references[ attrs.ref ];
1542
-
1543
- // if the reference exists, make the link
1544
- if ( ref ) {
1545
- delete attrs.ref;
1678
+ // now for body contents
1679
+ forEach (m[3].replace(/\|\s*$/mg, '').split('\n'), function (row) {
1680
+ var html_row = ['tr'];
1681
+ row = _split_on_unescaped(row, '|');
1682
+ for (i = 0; i < row.length; i++)
1683
+ html_row.push(['td', html_attrs[i] || {}].concat(this.processInline(row[i].trim())));
1684
+ table[2].push(html_row);
1685
+ }, this);
1546
1686
 
1547
- // add in the href and title, if present
1548
- attrs.href = ref.href;
1549
- if ( ref.title ) {
1550
- attrs.title = ref.title;
1551
- }
1687
+ return [table];
1688
+ };
1552
1689
 
1553
- // get rid of the unneeded original text
1554
- delete attrs.original;
1555
- }
1556
- // the reference doesn't exist, so revert to plain text
1557
- else {
1558
- return attrs.original;
1559
- }
1560
- break;
1561
- case "img_ref":
1562
- jsonml[ 0 ] = "img";
1690
+ Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) {
1691
+ if ( !out.length )
1692
+ return [ 2, "{:" ];
1563
1693
 
1564
- // grab this ref and clean up the attribute node
1565
- var ref = references[ attrs.ref ];
1694
+ // get the preceeding element
1695
+ var before = out[ out.length - 1 ];
1566
1696
 
1567
- // if the reference exists, make the link
1568
- if ( ref ) {
1569
- delete attrs.ref;
1697
+ if ( typeof before === "string" )
1698
+ return [ 2, "{:" ];
1570
1699
 
1571
- // add in the href and title, if present
1572
- attrs.src = ref.href;
1573
- if ( ref.title ) {
1574
- attrs.title = ref.title;
1575
- }
1700
+ // match a meta hash
1701
+ var m = text.match( /^\{:\s*((?:\\\}|[^\}])*)\s*\}/ );
1576
1702
 
1577
- // get rid of the unneeded original text
1578
- delete attrs.original;
1579
- }
1580
- // the reference doesn't exist, so revert to plain text
1581
- else {
1582
- return attrs.original;
1583
- }
1584
- break;
1585
- }
1703
+ // no match, false alarm
1704
+ if ( !m )
1705
+ return [ 2, "{:" ];
1586
1706
 
1587
- // convert all the children
1588
- i = 1;
1707
+ // attach the attributes to the preceeding element
1708
+ var meta = this.dialect.processMetaHash( m[ 1 ] ),
1709
+ attr = extract_attr( before );
1589
1710
 
1590
- // deal with the attribute node, if it exists
1591
- if ( attrs ) {
1592
- // if there are keys, skip over it
1593
- for ( var key in jsonml[ 1 ] ) {
1594
- i = 2;
1595
- }
1596
- // if there aren't, remove it
1597
- if ( i === 1 ) {
1598
- jsonml.splice( i, 1 );
1711
+ if ( !attr ) {
1712
+ attr = {};
1713
+ before.splice( 1, 0, attr );
1599
1714
  }
1600
- }
1601
1715
 
1602
- for ( ; i < jsonml.length; ++i ) {
1603
- jsonml[ i ] = convert_tree_to_html( jsonml[ i ], references, options );
1604
- }
1716
+ for ( var k in meta )
1717
+ attr[ k ] = meta[ k ];
1605
1718
 
1606
- return jsonml;
1607
- }
1719
+ // cut out the string and replace it with nothing
1720
+ return [ m[ 0 ].length, "" ];
1721
+ };
1608
1722
 
1609
1723
 
1610
- // merges adjacent text nodes into a single node
1611
- function merge_text_nodes( jsonml ) {
1612
- // skip the tag name and attribute hash
1613
- var i = extract_attr( jsonml ) ? 2 : 1;
1724
+ Markdown.dialects.Maruku = Maruku;
1725
+ Markdown.dialects.Maruku.inline.__escape__ = /^\\[\\`\*_{}\[\]()#\+.!\-|:]/;
1726
+ Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block );
1727
+ Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline );
1614
1728
 
1615
- while ( i < jsonml.length ) {
1616
- // if it's a string check the next item too
1617
- if ( typeof jsonml[ i ] === "string" ) {
1618
- if ( i + 1 < jsonml.length && typeof jsonml[ i + 1 ] === "string" ) {
1619
- // merge the second string into the first and remove it
1620
- jsonml[ i ] += jsonml.splice( i + 1, 1 )[ 0 ];
1621
- }
1622
- else {
1623
- ++i;
1624
- }
1625
- }
1626
- // if it's not a string recurse
1627
- else {
1628
- merge_text_nodes( jsonml[ i ] );
1629
- ++i;
1630
- }
1631
- }
1632
- }
1633
1729
 
1634
- } )( (function() {
1635
- if ( typeof exports === "undefined" ) {
1636
- window.markdown = {};
1637
- return window.markdown;
1638
- }
1639
- else {
1640
- return exports;
1641
- }
1642
- } )() );
1730
+ // Include all our depndencies and;
1731
+ expose.Markdown = Markdown;
1732
+ expose.parse = Markdown.parse;
1733
+ expose.toHTML = Markdown.toHTML;
1734
+ expose.toHTMLTree = Markdown.toHTMLTree;
1735
+ expose.renderJsonML = Markdown.renderJsonML;
1736
+
1737
+ })(function() {
1738
+ window.markdown = {};
1739
+ return window.markdown;
1740
+ }());