tildefriends/apps/wiki/commonmark.min.js

1 line
248 KiB
JavaScript
Raw Normal View History

function isContainer(e){switch(e._type){case"document":case"block_quote":case"list":case"item":case"paragraph":case"heading":case"emph":case"strong":case"link":case"image":case"custom_inline":case"custom_block":return!0;default:return!1}}var resumeAt=function(e,r){this.current=e,this.entering=!0===r},next=function(){var e,r=this.current,t=this.entering;return null===r?null:(e=isContainer(r),t&&e?r._firstChild?(this.current=r._firstChild,this.entering=!0):this.entering=!1:r===this.root?this.current=null:null===r._next?(this.current=r._parent,this.entering=!1):(this.current=r._next,this.entering=!0),{entering:t,node:r})},NodeWalker=function(e){return{current:e,root:e,entering:!0,next:next,resumeAt:resumeAt}},Node=function(e,r){this._type=e,this._parent=null,this._firstChild=null,this._lastChild=null,this._prev=null,this._next=null,this._sourcepos=r,this._open=!0,this._string_content=null,this._literal=null,this._listData={},this._info=null,this._destination=null,this._title=null,this._isFenced=!1,this._fenceChar=null,this._fenceLength=0,this._fenceOffset=null,this._level=null,this._onEnter=null,this._onExit=null},proto=Node.prototype,encodeCache=(Object.defineProperty(proto,"isContainer",{get:function(){return isContainer(this)}}),Object.defineProperty(proto,"type",{get:function(){return this._type}}),Object.defineProperty(proto,"firstChild",{get:function(){return this._firstChild}}),Object.defineProperty(proto,"lastChild",{get:function(){return this._lastChild}}),Object.defineProperty(proto,"next",{get:function(){return this._next}}),Object.defineProperty(proto,"prev",{get:function(){return this._prev}}),Object.defineProperty(proto,"parent",{get:function(){return this._parent}}),Object.defineProperty(proto,"sourcepos",{get:function(){return this._sourcepos}}),Object.defineProperty(proto,"literal",{get:function(){return this._literal},set:function(e){this._literal=e}}),Object.defineProperty(proto,"destination",{get:function(){return this._destination},set:function(e){this._destination=e}}),Object.defineProperty(proto,"title",{get:function(){return this._title},set:function(e){this._title=e}}),Object.defineProperty(proto,"info",{get:function(){return this._info},set:function(e){this._info=e}}),Object.defineProperty(proto,"level",{get:function(){return this._level},set:function(e){this._level=e}}),Object.defineProperty(proto,"listType",{get:function(){return this._listData.type},set:function(e){this._listData.type=e}}),Object.defineProperty(proto,"listTight",{get:function(){return this._listData.tight},set:function(e){this._listData.tight=e}}),Object.defineProperty(proto,"listStart",{get:function(){return this._listData.start},set:function(e){this._listData.start=e}}),Object.defineProperty(proto,"listDelimiter",{get:function(){return this._listData.delimiter},set:function(e){this._listData.delimiter=e}}),Object.defineProperty(proto,"onEnter",{get:function(){return this._onEnter},set:function(e){this._onEnter=e}}),Object.defineProperty(proto,"onExit",{get:function(){return this._onExit},set:function(e){this._onExit=e}}),Node.prototype.appendChild=function(e){e.unlink(),(e._parent=this)._lastChild?(this._lastChild._next=e)._prev=this._lastChild:this._firstChild=e,this._lastChild=e},Node.prototype.prependChild=function(e){e.unlink(),(e._parent=this)._firstChild?((this._firstChild._prev=e)._next=this._firstChild,this._firstChild=e):(this._firstChild=e,this._lastChild=e)},Node.prototype.unlink=function(){this._prev?this._prev._next=this._next:this._parent&&(this._parent._firstChild=this._next),this._next?this._next._prev=this._prev:this._parent&&(this._parent._lastChild=this._prev),this._parent=null,this._next=null,this._prev=null},Node.prototype.insertAfter=function(e){e.unlink(),e._next=this._next,e._next&&(e._next._prev=e),((e._prev=this)._next=e)._parent=this._parent,e._next||(e._parent._lastChild=e)},Node.prototype.insertBefore=function(e){e.unlink(),e._prev=this._prev,e._prev&&(e._prev._next=e),((e._next=this)._prev=e)._parent=this._parent,e._prev||(e._parent._firstChild=e)},Node.prototype.walker=function(){return new Node