trilium/libraries/commonmark.min.js

2 lines
100 KiB
JavaScript
Raw Normal View History

2018-09-03 05:02:01 +08:00
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).commonmark=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var Node=require("./node"),unescapeString=require("./common").unescapeString,OPENTAG=require("./common").OPENTAG,CLOSETAG=require("./common").CLOSETAG,InlineParser=require("./inlines"),reHtmlBlockOpen=[/./,/^<(?:script|pre|style)(?:\s|>|$)/i,/^<!--/,/^<[?]/,/^<![A-Z]/,/^<!\[CDATA\[/,/^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)/i,new RegExp("^(?:"+OPENTAG+"|"+CLOSETAG+")\\s*$","i")],reHtmlBlockClose=[/./,/<\/(?:script|pre|style)>/i,/-->/,/\?>/,/>/,/\]\]>/],reThematicBreak=/^(?:(?:\*[ \t]*){3,}|(?:_[ \t]*){3,}|(?:-[ \t]*){3,})[ \t]*$/,reMaybeSpecial=/^[#`~*+_=<>0-9-]/,reNonSpace=/[^ \t\f\v\r\n]/,reBulletListMarker=/^[*+-]/,reOrderedListMarker=/^(\d{1,9})([.)])/,reATXHeadingMarker=/^#{1,6}(?:[ \t]+|$)/,reCodeFence=/^`{3,}(?!.*`)|^~{3,}(?!.*~)/,reClosingCodeFence=/^(?:`{3,}|~{3,})(?= *$)/,reSetextHeadingLine=/^(?:=+|-+)[ \t]*$/,reLineEnding=/\r\n|\n|\r/,isBlank=function(s){return!reNonSpace.test(s)},isSpaceOrTab=function(c){return 32===c||9===c},peek=function(ln,pos){return pos<ln.length?ln.charCodeAt(pos):-1},endsWithBlankLine=function(block){for(;block;){if(block._lastLineBlank)return!0;var t=block.type;if("list"!==t&&"item"!==t)break;block=block._lastChild}return!1},addLine=function(){if(this.partiallyConsumedTab){this.offset+=1;var charsToTab=4-this.column%4;this.tip._string_content+=" ".repeat(charsToTab)}this.tip._string_content+=this.currentLine.slice(this.offset)+"\n"},addChild=function(tag,offset){for(;!this.blocks[this.tip.type].canContain(tag);)this.finalize(this.tip,this.lineNumber-1);var column_number=offset+1,newBlock=new Node(tag,[[this.lineNumber,column_number],[0,0]]);return newBlock._string_content="",this.tip.appendChild(newBlock),this.tip=newBlock,newBlock},parseListMarker=function(parser,container){var match,nextc,spacesStartCol,spacesStartOffset,rest=parser.currentLine.slice(parser.nextNonspace),data={type:null,tight:!0,bulletChar:null,start:null,delimiter:null,padding:null,markerOffset:parser.indent};if(match=rest.match(reBulletListMarker))data.type="bullet",data.bulletChar=match[0][0];else{if(!(match=rest.match(reOrderedListMarker))||"paragraph"===container.type&&"1"!==match[1])return null;data.type="ordered",data.start=parseInt(match[1]),data.delimiter=match[2]}if(-1!==(nextc=peek(parser.currentLine,parser.nextNonspace+match[0].length))&&9!==nextc&&32!==nextc)return null;if("paragraph"===container.type&&!parser.currentLine.slice(parser.nextNonspace+match[0].length).match(reNonSpace))return null;parser.advanceNextNonspace(),parser.advanceOffset(match[0].length,!0),spacesStartCol=parser.column,spacesStartOffset=parser.offset;do{parser.advanceOffset(1,!0),nextc=peek(parser.currentLine,parser.offset)}while(parser.column-spacesStartCol<5&&isSpaceOrTab(nextc));var blank_item=-1===peek(parser.currentLine,parser.offset),spaces_after_marker=parser.column-spacesStartCol;return spaces_after_marker>=5||spaces_after_marker<1||blank_item?(data.padding=match[0].length+1,parser.column=spacesStartCol,parser.offset=spac