? ?(['"].*['"])?\)$/m))I="";else if(!I){if(I="#"+(C=C||A.toLowerCase().replace(/ ?\n/g," ")),v.helper.isUndefined(n.gUrls[C]))return g;I=n.gUrls[C],v.helper.isUndefined(n.gTitles[C])||(t=n.gTitles[C])}return g='"+A+" "}return g=(g=(g=(g=(g=n.converter._dispatch("anchors.before",g,a,n)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g,A)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,A)).replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g,A)).replace(/\[([^\[\]]+)]()()()()()/g,A),a.ghMentions&&(g=g.replace(/(^|\s)(\\)?(@([a-z\d\-]+))(?=[.!?;,[\]()]|\s|$)/gim,function(g,A,C,I,e){if("\\"===C)return A+I;if(v.helper.isString(a.ghMentionsLink))return C="",A+'"+I+" ";throw new Error("ghMentionsLink option must be a string")})),g=n.converter._dispatch("anchors.after",g,a,n)});var a=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi,n=/([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi,o=/()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi,p=/(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gim,h=/<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;v.subParser("autoLinks",function(g,A,C){"use strict";return g=(g=(g=C.converter._dispatch("autoLinks.before",g,A,C)).replace(o,r(A))).replace(h,t(A,C)),g=C.converter._dispatch("autoLinks.after",g,A,C)}),v.subParser("simplifiedAutoLinks",function(g,A,C){"use strict";return A.simplifiedAutoLink&&(g=C.converter._dispatch("simplifiedAutoLinks.before",g,A,C),g=(g=A.excludeTrailingPunctuationFromURLs?g.replace(n,r(A)):g.replace(a,r(A))).replace(p,t(A,C)),g=C.converter._dispatch("simplifiedAutoLinks.after",g,A,C)),g}),v.subParser("blockGamut",function(g,A,C){"use strict";return g=C.converter._dispatch("blockGamut.before",g,A,C),g=v.subParser("blockQuotes")(g,A,C),g=v.subParser("headers")(g,A,C),g=v.subParser("horizontalRule")(g,A,C),g=v.subParser("lists")(g,A,C),g=v.subParser("codeBlocks")(g,A,C),g=v.subParser("tables")(g,A,C),g=v.subParser("hashHTMLBlocks")(g,A,C),g=v.subParser("paragraphs")(g,A,C),g=C.converter._dispatch("blockGamut.after",g,A,C)}),v.subParser("blockQuotes",function(g,A,C){"use strict";g=C.converter._dispatch("blockQuotes.before",g,A,C);var I=/(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm;return A.splitAdjacentBlockquotes&&(I=/^ {0,3}>[\s\S]*?(?:\n\n)/gm),g=(g+="\n\n").replace(I,function(g){return g=(g=(g=g.replace(/^[ \t]*>[ \t]?/gm,"")).replace(/\xa80/g,"")).replace(/^[ \t]+$/gm,""),g=v.subParser("githubCodeBlocks")(g,A,C),g=(g=(g=v.subParser("blockGamut")(g,A,C)).replace(/(^|\n)/g,"$1 ")).replace(/(\s*[^\r]+?<\/pre>)/gm,function(g,A){return A.replace(/^ /gm,"\xa80").replace(/\xa80/g,"")}),v.subParser("hashBlock")("\n"+g+"\n ",A,C)}),g=C.converter._dispatch("blockQuotes.after",g,A,C)}),v.subParser("codeBlocks",function(g,e,r){"use strict";g=r.converter._dispatch("codeBlocks.before",g,e,r);return g=(g=(g+="\xa80").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=\xa80))/g,function(g,A,C){var I="\n",A=v.subParser("outdent")(A,e,r);return A=v.subParser("encodeCode")(A,e,r),A=""+(A=(A=(A=v.subParser("detab")(A,e,r)).replace(/^\n+/g,"")).replace(/\n+$/g,""))+(I=e.omitExtraWLInCodeBlocks?"":I)+"
",v.subParser("hashBlock")(A,e,r)+C})).replace(/\xa80/,""),g=r.converter._dispatch("codeBlocks.after",g,e,r)}),v.subParser("codeSpans",function(g,e,r){"use strict";return g=(g=void 0===(g=r.converter._dispatch("codeSpans.before",g,e,r))?"":g).replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(g,A,C,I){return I=(I=I.replace(/^([ \t]*)/g,"")).replace(/[ \t]*$/g,""),I=A+""+(I=v.subParser("encodeCode")(I,e,r))+"
",I=v.subParser("hashHTMLSpans")(I,e,r)}),g=r.converter._dispatch("codeSpans.after",g,e,r)}),v.subParser("completeHTMLDocument",function(g,A,C){"use strict";if(A.completeHTMLDocument){g=C.converter._dispatch("completeHTMLDocument.before",g,A,C);var I,e="html",r="\n",t="",a=' \n',n="",o="";for(I in void 0!==C.metadata.parsed.doctype&&(r="\n","html"!==(e=C.metadata.parsed.doctype.toString().toLowerCase())&&"html5"!==e||(a=' ')),C.metadata.parsed)if(C.metadata.parsed.hasOwnProperty(I))switch(I.toLowerCase()){case"doctype":break;case"title":t=""+C.metadata.parsed.title+" \n";break;case"charset":a="html"===e||"html5"===e?' \n':' \n';break;case"language":case"lang":n=' lang="'+C.metadata.parsed[I]+'"',o+=' \n';break;default:o+=' \n'}g=r+"\n\n"+t+a+o+"\n\n"+g.trim()+"\n\n",g=C.converter._dispatch("completeHTMLDocument.after",g,A,C)}return g}),v.subParser("detab",function(g,A,C){"use strict";return g=(g=(g=(g=(g=(g=C.converter._dispatch("detab.before",g,A,C)).replace(/\t(?=\t)/g," ")).replace(/\t/g,"\xa8A\xa8B")).replace(/\xa8B(.+?)\xa8A/g,function(g,A){for(var C=A,I=4-C.length%4,e=0;e/g,">"),g=C.converter._dispatch("encodeAmpsAndAngles.after",g,A,C)}),v.subParser("encodeBackslashEscapes",function(g,A,C){"use strict";return g=(g=(g=C.converter._dispatch("encodeBackslashEscapes.before",g,A,C)).replace(/\\(\\)/g,v.helper.escapeCharactersCallback)).replace(/\\([`*_{}\[\]()>#+.!~=|-])/g,v.helper.escapeCharactersCallback),g=C.converter._dispatch("encodeBackslashEscapes.after",g,A,C)}),v.subParser("encodeCode",function(g,A,C){"use strict";return g=(g=C.converter._dispatch("encodeCode.before",g,A,C)).replace(/&/g,"&").replace(//g,">").replace(/([*_{}\[\]\\=~-])/g,v.helper.escapeCharactersCallback),g=C.converter._dispatch("encodeCode.after",g,A,C)}),v.subParser("escapeSpecialCharsWithinTagAttributes",function(g,A,C){"use strict";return g=(g=(g=C.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before",g,A,C)).replace(/<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi,function(g){return g.replace(/(.)<\/?code>(?=.)/g,"$1`").replace(/([\\`*_~=|])/g,v.helper.escapeCharactersCallback)})).replace(/-]|-[^>])(?:[^-]|-[^-])*)--)>/gi,function(g){return g.replace(/([\\`*_~=|])/g,v.helper.escapeCharactersCallback)}),g=C.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after",g,A,C)}),v.subParser("githubCodeBlocks",function(g,r,t){"use strict";return r.ghCodeBlocks?(g=t.converter._dispatch("githubCodeBlocks.before",g,r,t),g=(g=(g+="\xa80").replace(/(?:^|\n)(```+|~~~+)([^\s`~]*)\n([\s\S]*?)\n\1/g,function(g,A,C,I){var e=r.omitExtraWLInCodeBlocks?"":"\n";return I=v.subParser("encodeCode")(I,r,t),I=""+(I=(I=(I=v.subParser("detab")(I,r,t)).replace(/^\n+/g,"")).replace(/\n+$/g,""))+e+"
",I=v.subParser("hashBlock")(I,r,t),"\n\n\xa8G"+(t.ghCodeBlocks.push({text:g,codeblock:I})-1)+"G\n\n"})).replace(/\xa80/,""),t.converter._dispatch("githubCodeBlocks.after",g,r,t)):g}),v.subParser("hashBlock",function(g,A,C){"use strict";return g=(g=C.converter._dispatch("hashBlock.before",g,A,C)).replace(/(^\n+|\n+$)/g,""),g="\n\n\xa8K"+(C.gHtmlBlocks.push(g)-1)+"K\n\n",g=C.converter._dispatch("hashBlock.after",g,A,C)}),v.subParser("hashCodeTags",function(g,e,r){"use strict";g=r.converter._dispatch("hashCodeTags.before",g,e,r);return g=v.helper.replaceRecursiveRegExp(g,function(g,A,C,I){C=C+v.subParser("encodeCode")(A,e,r)+I;return"\xa8C"+(r.gHtmlSpans.push(C)-1)+"C"},"]*>","
","gim"),g=r.converter._dispatch("hashCodeTags.after",g,e,r)}),v.subParser("hashElement",function(g,A,C){"use strict";return function(g,A){return A=(A=(A=A.replace(/\n\n/g,"\n")).replace(/^\n/,"")).replace(/\n+$/g,""),A="\n\n\xa8K"+(C.gHtmlBlocks.push(A)-1)+"K\n\n"}}),v.subParser("hashHTMLBlocks",function(g,A,e){"use strict";g=e.converter._dispatch("hashHTMLBlocks.before",g,A,e);function C(g,A,C,I){return-1!==C.search(/\bmarkdown\b/)&&(g=C+e.converter.makeHtml(A)+I),"\n\n\xa8K"+(e.gHtmlBlocks.push(g)-1)+"K\n\n"}var I=["pre","div","h1","h2","h3","h4","h5","h6","blockquote","table","dl","ol","ul","script","noscript","form","fieldset","iframe","math","style","section","header","footer","nav","article","aside","address","audio","canvas","figure","hgroup","output","video","p"];A.backslashEscapesHTMLTags&&(g=g.replace(/\\<(\/?[^>]+?)>/g,function(g,A){return"<"+A+">"}));for(var r=0;r]*>)","im"),a="<"+I[r]+"\\b[^>]*>",n=""+I[r]+">";-1!==(o=v.helper.regexIndexOf(g,t));){var o=v.helper.splitAtIndex(g,o),s=v.helper.replaceRecursiveRegExp(o[1],C,a,n,"im");if(s===o[1])break;g=o[0].concat(s)}return g=g.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,v.subParser("hashElement")(g,A,e)),g=(g=v.helper.replaceRecursiveRegExp(g,function(g){return"\n\n\xa8K"+(e.gHtmlBlocks.push(g)-1)+"K\n\n"},"^ {0,3}\x3c!--","--\x3e","gm")).replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,v.subParser("hashElement")(g,A,e)),g=e.converter._dispatch("hashHTMLBlocks.after",g,A,e)}),v.subParser("hashHTMLSpans",function(g,A,C){"use strict";function I(g){return"\xa8C"+(C.gHtmlSpans.push(g)-1)+"C"}return g=(g=(g=(g=(g=C.converter._dispatch("hashHTMLSpans.before",g,A,C)).replace(/<[^>]+?\/>/gi,I)).replace(/<([^>]+?)>[\s\S]*?<\/\1>/g,I)).replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g,I)).replace(/<[^>]+?>/gi,I),g=C.converter._dispatch("hashHTMLSpans.after",g,A,C)}),v.subParser("unhashHTMLSpans",function(g,A,C){"use strict";g=C.converter._dispatch("unhashHTMLSpans.before",g,A,C);for(var I=0;I]*>\\s*]*>","^ {0,3}
\\s* ","gim"),g=r.converter._dispatch("hashPreCodeTags.after",g,e,r)}),v.subParser("headers",function(g,e,r){"use strict";g=r.converter._dispatch("headers.before",g,e,r);var t=isNaN(parseInt(e.headerLevelStart))?1:parseInt(e.headerLevelStart),A=e.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,C=e.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm,A=(g=(g=g.replace(A,function(g,A){var C=v.subParser("spanGamut")(A,e,r),A=e.noHeaderId?"":' id="'+a(A)+'"',A=""+C+" ";return v.subParser("hashBlock")(A,e,r)})).replace(C,function(g,A){var C=v.subParser("spanGamut")(A,e,r),A=e.noHeaderId?"":' id="'+a(A)+'"',I=t+1,A=""+C+" ";return v.subParser("hashBlock")(A,e,r)}),e.requireSpaceBeforeHeadingText?/^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm:/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm);function a(g){var A=g=e.customizedHeaderId&&(A=g.match(/\{([^{]+?)}\s*$/))&&A[1]?A[1]:g,g=v.helper.isString(e.prefixHeaderId)?e.prefixHeaderId:!0===e.prefixHeaderId?"section-":"";return e.rawPrefixHeaderId||(A=g+A),A=(e.ghCompatibleHeaderId?A.replace(/ /g,"-").replace(/&/g,"").replace(/\xa8T/g,"").replace(/\xa8D/g,"").replace(/[&+$,\/:;=?@"#{}|^\xa8~\[\]`\\*)(%.!'<>]/g,""):e.rawHeaderId?A.replace(/ /g,"-").replace(/&/g,"&").replace(/\xa8T/g,"\xa8").replace(/\xa8D/g,"$").replace(/["']/g,"-"):A.replace(/[^\w]/g,"")).toLowerCase(),e.rawPrefixHeaderId&&(A=g+A),r.hashLinkCounts[A]?A=A+"-"+r.hashLinkCounts[A]++:r.hashLinkCounts[A]=1,A}return g=g.replace(A,function(g,A,C){var I=C,I=(e.customizedHeaderId&&(I=C.replace(/\s?\{([^{]+?)}\s*$/,"")),v.subParser("spanGamut")(I,e,r)),C=e.noHeaderId?"":' id="'+a(C)+'"',A=t-1+A.length,C=""+I+" ";return v.subParser("hashBlock")(C,e,r)}),g=r.converter._dispatch("headers.after",g,e,r)}),v.subParser("horizontalRule",function(g,A,C){"use strict";g=C.converter._dispatch("horizontalRule.before",g,A,C);var I=v.subParser("hashBlock")(" ",A,C);return g=(g=(g=g.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm,I)).replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm,I)).replace(/^ {0,2}( ?_){3,}[ \t]*$/gm,I),g=C.converter._dispatch("horizontalRule.after",g,A,C)}),v.subParser("images",function(g,A,i){"use strict";function n(g,A,C,I,e,r,t,a){var n=i.gUrls,o=i.gTitles,s=i.gDimensions;if(C=C.toLowerCase(),a=a||"",-1? ?(['"].*['"])?\)$/m))I="";else if(""===I||null===I){if(I="#"+(C=""!==C&&null!==C?C:A.toLowerCase().replace(/ ?\n/g," ")),v.helper.isUndefined(n[C]))return g;I=n[C],v.helper.isUndefined(o[C])||(a=o[C]),v.helper.isUndefined(s[C])||(e=s[C].width,r=s[C].height)}A=A.replace(/"/g,""").replace(v.helper.regexes.asteriskDashAndColon,v.helper.escapeCharactersCallback);g=' "}return g=(g=(g=(g=(g=(g=i.converter._dispatch("images.before",g,A,i)).replace(/!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g,n)).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,function(g,A,C,I,e,r,t,a){return n(g,A,C,I=I.replace(/\s/g,""),e,r,0,a)})).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g,n)).replace(/!\[([^\]]*?)][ \t]*()\([ \t]?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g,n)).replace(/!\[([^\[\]]+)]()()()()()/g,n),g=i.converter._dispatch("images.after",g,A,i)}),v.subParser("italicsAndBold",function(g,A,C){"use strict";return g=C.converter._dispatch("italicsAndBold.before",g,A,C),g=A.literalMidWordUnderscores?(g=(g=g.replace(/\b___(\S[\s\S]*)___\b/g,function(g,A){return""+A+" "})).replace(/\b__(\S[\s\S]*)__\b/g,function(g,A){return""+A+" "})).replace(/\b_(\S[\s\S]*?)_\b/g,function(g,A){return""+A+" "}):(g=(g=g.replace(/___(\S[\s\S]*?)___/g,function(g,A){return/\S$/.test(A)?""+A+" ":g})).replace(/__(\S[\s\S]*?)__/g,function(g,A){return/\S$/.test(A)?""+A+" ":g})).replace(/_([^\s_][\s\S]*?)_/g,function(g,A){return/\S$/.test(A)?""+A+" ":g}),g=A.literalMidWordAsterisks?(g=(g=g.replace(/([^*]|^)\B\*\*\*(\S[\s\S]+?)\*\*\*\B(?!\*)/g,function(g,A,C){return A+""+C+" "})).replace(/([^*]|^)\B\*\*(\S[\s\S]+?)\*\*\B(?!\*)/g,function(g,A,C){return A+""+C+" "})).replace(/([^*]|^)\B\*(\S[\s\S]+?)\*\B(?!\*)/g,function(g,A,C){return A+""+C+" "}):(g=(g=g.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g,function(g,A){return/\S$/.test(A)?""+A+" ":g})).replace(/\*\*(\S[\s\S]*?)\*\*/g,function(g,A){return/\S$/.test(A)?""+A+" ":g})).replace(/\*([^\s*][\s\S]*?)\*/g,function(g,A){return/\S$/.test(A)?""+A+" ":g}),g=C.converter._dispatch("italicsAndBold.after",g,A,C)}),v.subParser("lists",function(g,i,o){"use strict";function l(g,A){o.gListLevel++,g=g.replace(/\n{2,}$/,"\n");var C=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(\xa80| {0,3}([*+-]|\d+[.])[ \t]+))/gm,n=/\n[ \t]*\n(?!\xa80)/.test(g+="\xa80");return i.disableForced4SpacesIndentedSublists&&(C=/(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(\xa80|\2([*+-]|\d+[.])[ \t]+))/gm),g=(g=g.replace(C,function(g,A,C,I,e,r,t){t=t&&""!==t.trim();var e=v.subParser("outdent")(e,i,o),a="";return r&&i.tasklists&&(a=' class="task-list-item" style="list-style-type: none;"',e=e.replace(/^[ \t]*\[(x|X| )?]/m,function(){var g=' "})),e=e.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g,function(g){return"\xa8A"+g}),e=""+(e=(e=(A||-1\n"})).replace(/\xa80/g,""),o.gListLevel--,g=A?g.replace(/\s+$/,""):g}function c(g,A){if("ol"===A){A=g.match(/^ *(\d+)\./);if(A&&"1"!==A[1])return' start="'+A[1]+'"'}return""}function e(e,r,t){var g,a=i.disableForced4SpacesIndentedSublists?/^ ?\d+\.[ \t]/gm:/^ {0,3}\d+\.[ \t]/gm,n=i.disableForced4SpacesIndentedSublists?/^ ?[*+-][ \t]/gm:/^ {0,3}[*+-][ \t]/gm,o="ul"===r?a:n,s="";return-1!==e.search(o)?function g(A){var C=A.search(o),I=c(e,r);-1!==C?(s+="\n\n<"+r+I+">\n"+l(A.slice(0,C),!!t)+""+r+">\n",o="ul"===(r="ul"===r?"ol":"ul")?a:n,g(A.slice(C))):s+="\n\n<"+r+I+">\n"+l(A,!!t)+""+r+">\n"}(e):(g=c(e,r),s="\n\n<"+r+g+">\n"+l(e,!!t)+""+r+">\n"),s}return g=o.converter._dispatch("lists.before",g,i,o),g+="\xa80",g=(g=o.gListLevel?g.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(\xa80|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,function(g,A,C){return e(A,-1"),e.push(a+=""))}for(r=e.length,t=0;t]*>\s*]*>/.test(o)&&(s=!0)}e[t]=o}return g=(g=(g=e.join("\n")).replace(/^\n+/g,"")).replace(/\n+$/g,""),C.converter._dispatch("paragraphs.after",g,A,C)}),v.subParser("runExtension",function(g,A,C,I){"use strict";return g.filter?A=g.filter(A,I.converter,C):g.regex&&((I=g.regex)instanceof RegExp||(I=new RegExp(I,"g")),A=A.replace(I,g.replace)),A}),v.subParser("spanGamut",function(g,A,C){"use strict";return g=C.converter._dispatch("spanGamut.before",g,A,C),g=v.subParser("codeSpans")(g,A,C),g=v.subParser("escapeSpecialCharsWithinTagAttributes")(g,A,C),g=v.subParser("encodeBackslashEscapes")(g,A,C),g=v.subParser("images")(g,A,C),g=v.subParser("anchors")(g,A,C),g=v.subParser("autoLinks")(g,A,C),g=v.subParser("simplifiedAutoLinks")(g,A,C),g=v.subParser("emoji")(g,A,C),g=v.subParser("underline")(g,A,C),g=v.subParser("italicsAndBold")(g,A,C),g=v.subParser("strikethrough")(g,A,C),g=v.subParser("ellipsis")(g,A,C),g=v.subParser("hashHTMLSpans")(g,A,C),g=v.subParser("encodeAmpsAndAngles")(g,A,C),A.simpleLineBreaks?/\n\n\xa8K/.test(g)||(g=g.replace(/\n+/g," \n")):g=g.replace(/ +\n/g," \n"),g=C.converter._dispatch("spanGamut.after",g,A,C)}),v.subParser("strikethrough",function(g,C,I){"use strict";return C.strikethrough&&(g=(g=I.converter._dispatch("strikethrough.before",g,C,I)).replace(/(?:~){2}([\s\S]+?)(?:~){2}/g,function(g,A){return A=A,""+(A=C.simplifiedAutoLink?v.subParser("simplifiedAutoLinks")(A,C,I):A)+""}),g=I.converter._dispatch("strikethrough.after",g,C,I)),g}),v.subParser("stripLinkDefinitions",function(g,a,n){"use strict";function A(g,A,C,I,e,r,t){return A=A.toLowerCase(),C.match(/^data:.+?\/.+?;base64,/)?n.gUrls[A]=C.replace(/\s/g,""):n.gUrls[A]=v.subParser("encodeAmpsAndAngles")(C,a,n),r?r+t:(t&&(n.gTitles[A]=t.replace(/"|'/g,""")),a.parseImgDimensions&&I&&e&&(n.gDimensions[A]={width:I,height:e}),"")}return g=(g=(g=(g+="\xa80").replace(/^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=\xa80)|(?=\n\[))/gm,A)).replace(/^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=\xa80))/gm,A)).replace(/\xa80/,"")}),v.subParser("tables",function(g,w,k){"use strict";return w.tables&&(g=(g=(g=(g=k.converter._dispatch("tables.before",g,w,k)).replace(/\\(\|)/g,v.helper.escapeCharactersCallback)).replace(/^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|\xa80)/gm,A)).replace(/^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|\xa80)/gm,A),g=k.converter._dispatch("tables.after",g,w,k)),g;function A(g){for(var A=g.split("\n"),C=0;C"+(e=v.subParser("spanGamut")(e,w,k))+"\n"));for(C=0;C"+v.subParser("spanGamut")(a,w,k)+"\n"));c.push(u)}for(var p=i,h=c,m="\n\n\n",_=p.length,b=0;b<_;++b)m+=p[b];for(m+=" \n \n\n",b=0;b\n";for(var f=0;f<_;++f)m+=h[b][f];m+="\n"}return m+=" \n
\n"}}),v.subParser("underline",function(g,A,C){"use strict";return A.underline&&(g=C.converter._dispatch("underline.before",g,A,C),g=(g=A.literalMidWordUnderscores?g.replace(/\b_?__(\S[\s\S]*)___?\b/g,function(g,A){return""+A+" "}):g.replace(/_?__(\S[\s\S]*?)___?/g,function(g,A){return/\S$/.test(A)?""+A+" ":g})).replace(/(_)/g,v.helper.escapeCharactersCallback),g=C.converter._dispatch("underline.after",g,A,C)),g}),v.subParser("unescapeSpecialChars",function(g,A,C){"use strict";return g=(g=C.converter._dispatch("unescapeSpecialChars.before",g,A,C)).replace(/\xa8E(\d+)E/g,function(g,A){A=parseInt(A);return String.fromCharCode(A)}),g=C.converter._dispatch("unescapeSpecialChars.after",g,A,C)});"function"==typeof define&&define.amd?define(function(){"use strict";return v}):"undefined"!=typeof module&&module.exports?module.exports=v:this.showdown=v}.call(this),String.prototype.includes||(String.prototype.includes=function(g,A){"use strict";if(g instanceof RegExp)throw TypeError("first argument must not be a RegExp");return-1!==this.indexOf(g,A=void 0===A?0:A)}),[Element.prototype,Document.prototype,DocumentFragment.prototype].forEach(function(g){g.hasOwnProperty("prepend")||Object.defineProperty(g,"prepend",{configurable:!0,enumerable:!0,writable:!0,value:function(){var g=Array.prototype.slice.call(arguments),C=document.createDocumentFragment();g.forEach(function(g){var A=g instanceof Node;C.appendChild(A?g:document.createTextNode(String(g)))}),this.insertBefore(C,this.firstChild)}})}),document.addEventListener("DOMContentLoaded",function(){var g=document.createElement("style"),A='body { padding: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;} ',A=(A+"blockquote { padding: 0 1em; color: #6a737d; border-left: 0.25em solid #dfe2e5;} "+"code { padding: 0.2em 0.4em; background: rgba(27,31,35,0.05); border-radius: 3px;} "+"pre > code { background: none } "+"pre { padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; } "+"table { border-collapse: collapse; } "+"td, th { border: 1px solid #ddd; padding: 10px 13px; } ",g.innerHTML='body { padding: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;} blockquote { padding: 0 1em; color: #6a737d; border-left: 0.25em solid #dfe2e5;} code { padding: 0.2em 0.4em; background: rgba(27,31,35,0.05); border-radius: 3px;} pre > code { background: none } pre { padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; } table { border-collapse: collapse; } td, th { border: 1px solid #ddd; padding: 10px 13px; } ',document.head.prepend(g),document.createElement("meta")),g=(A.setAttribute("name","viewport"),A.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),document.head.appendChild(A),document.createElement("meta"));g.setAttribute("charset","UTF-8"),document.head.appendChild(g);window.navigator.userAgent.indexOf("MSIE ")?(A=document.querySelector("noscript"),(g=document.createElement("pre")).appendChild(A),C=g.textContent||g.innerText,delete A,delete g):C=document.querySelector("noscript").innerText;var C,A=new showdown.Converter({emoji:!0,underline:!0}),g=(A.setFlavor("github"),A.addExtension(function(){return[{type:"output",regex:/]+>/g,replace:function(g){var A=g.match(/"(.*?)"/)[1];return A.includes(window.location.hostname)||"/"==A[0]||"."==A[0]||"#"==A[0]?g:' '}}]},"externalLink"),A.makeHtml(C));document.body.innerHTML=g,document.title=document.title||document.body.firstElementChild.innerText.trim(),setTimeout(function(){var g=window.location.hash;window.location.hash="",window.location.hash=g},100)});
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "md-page",
3 | "author": "oscarmorrison",
4 | "version": "1.0.0",
5 | "description": "create a webpage with just markdown",
6 | "homepage": "https://github.com/oscarmorrison/md-page.git#readme",
7 | "bugs": {
8 | "url": "https://github.com/oscarmorrison/md-page.git/issues"
9 | },
10 | "devDependencies": {
11 | "jest": "^24.9.0",
12 | "jsdom": "^16.4.0",
13 | "uglify-js": "^3.6.1"
14 | },
15 | "files": [
16 | "src/*"
17 | ],
18 | "directories": {
19 | "doc": "docs",
20 | "src": "src",
21 | "test": "test"
22 | },
23 | "scripts": {
24 | "test": "jest --watchAll",
25 | "test-ci": "jest",
26 | "build": "uglifyjs -c -m -o md-page.js src/showdown.js src/script.js -b beautify=false,ascii_only=true"
27 | },
28 | "repository": {
29 | "type": "git",
30 | "url": "git+https://github.com/oscarmorrison/md-page.git"
31 | },
32 | "license": "MIT"
33 | }
34 |
--------------------------------------------------------------------------------
/src/script.js:
--------------------------------------------------------------------------------
1 | // Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
2 | if (!String.prototype.includes) {
3 | String.prototype.includes = function(search, start) {
4 | 'use strict';
5 |
6 | if (search instanceof RegExp) {
7 | throw TypeError('first argument must not be a RegExp');
8 | }
9 | if (start === undefined) { start = 0; }
10 | return this.indexOf(search, start) !== -1;
11 | };
12 | }
13 |
14 | // Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/prepend#Polyfill
15 | (function (arr) {
16 | arr.forEach(function (item) {
17 | if (item.hasOwnProperty('prepend')) {
18 | return;
19 | }
20 | Object.defineProperty(item, 'prepend', {
21 | configurable: true,
22 | enumerable: true,
23 | writable: true,
24 | value: function prepend() {
25 | var argArr = Array.prototype.slice.call(arguments),
26 | docFrag = document.createDocumentFragment();
27 |
28 | argArr.forEach(function (argItem) {
29 | var isNode = argItem instanceof Node;
30 | docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
31 | });
32 |
33 | this.insertBefore(docFrag, this.firstChild);
34 | }
35 | });
36 | });
37 | })([Element.prototype, Document.prototype, DocumentFragment.prototype]);
38 |
39 | document.addEventListener("DOMContentLoaded", function() {
40 |
41 | // Styles
42 | var sheet = document.createElement('style')
43 | var styles = 'body { padding: 20px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;} '
44 | styles += 'blockquote { padding: 0 1em; color: #6a737d; border-left: 0.25em solid #dfe2e5;} '
45 | styles += 'code { padding: 0.2em 0.4em; background: rgba(27,31,35,0.05); border-radius: 3px;} '
46 | styles += 'pre > code { background: none } '
47 | styles += 'pre { padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; } '
48 | styles += 'table { border-collapse: collapse; } '
49 | styles += 'td, th { border: 1px solid #ddd; padding: 10px 13px; } '
50 | sheet.innerHTML = styles
51 | document.head.prepend(sheet)
52 |
53 | // Viewport
54 | var viewportMeta = document.createElement('meta')
55 | viewportMeta.setAttribute('name', 'viewport')
56 | viewportMeta.setAttribute('content', 'width=device-width, initial-scale=1, shrink-to-fit=no')
57 | document.head.appendChild(viewportMeta)
58 |
59 | var meta = document.createElement('meta')
60 | meta.setAttribute('charset', 'UTF-8')
61 | document.head.appendChild(meta)
62 |
63 | /* Workaround for IE11 to preserve new line */
64 | var isIE = window.navigator.userAgent.indexOf("MSIE ")
65 | if (isIE) {
66 | // https://stackoverflow.com/questions/656605/jquery-text-call-preserves-newlines-in-firefox-but-not-in-ie
67 | var cloned = document.querySelector('noscript')
68 | var pre = document.createElement("pre") // IE11 will preserve formatting from pre or textarea
69 | pre.appendChild(cloned)
70 | var markdown = pre.textContent ? pre.textContent: pre.innerText;
71 | delete cloned
72 | delete pre
73 | } else {
74 | var markdown = document.querySelector('noscript').innerText
75 | }
76 |
77 | var converter = new showdown.Converter({
78 | emoji: true,
79 | underline: true,
80 | })
81 | converter.setFlavor('github')
82 |
83 | converter.addExtension(function () {
84 | return [{
85 | type: 'output',
86 | regex: / ]+>/g,
87 | replace : function (text) {
88 | var url = text.match(/"(.*?)"/)[1]
89 | if(url.includes(window.location.hostname) || url[0] == '/' || url[0] == '.' || url[0] == '#'){
90 | return text
91 | }
92 | return ' '
93 | }
94 | }]
95 | }, 'externalLink')
96 |
97 |
98 | var html = converter.makeHtml(markdown)
99 | document.body.innerHTML = html
100 | document.title = document.title || document.body.firstElementChild.innerText.trim()
101 |
102 | // Handle hash linking
103 | setTimeout(function() {
104 | var hash = window.location.hash
105 | window.location.hash = ''
106 | window.location.hash = hash
107 | }, 100)
108 | })
109 |
--------------------------------------------------------------------------------
/test/__snapshots__/script.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`HTML Rendering Tests: Ensures Blockquotes are rendered accurately It should render a single blockquote 1`] = `
4 | "
5 | This should be a blockquote
6 | "
7 | `;
8 |
9 | exports[`HTML Rendering Tests: Ensures Blockquotes are rendered accurately It should render multiple-line blockquotes 1`] = `
10 | "
11 | Line 1
12 | Line 2
13 | Line 3
14 | "
15 | `;
16 |
17 | exports[`HTML Rendering Tests: Ensures Emphasis syntax renders accurately It should render **text** as bold 1`] = `"This text will be bold
"`;
18 |
19 | exports[`HTML Rendering Tests: Ensures Emphasis syntax renders accurately It should render *text* as italics 1`] = `"This text will be italic
"`;
20 |
21 | exports[`HTML Rendering Tests: Ensures Emphasis syntax renders accurately It should render __text__ as underlined 1`] = `"This text will be underlined
"`;
22 |
23 | exports[`HTML Rendering Tests: Ensures Emphasis syntax renders accurately It should render _text_ as italics 1`] = `"_This text will not be italic_
"`;
24 |
25 | exports[`HTML Rendering Tests: Ensures Emphasis syntax renders accurately It should render a combined bold and italics string __text **text**__ 1`] = `"_You can combine them_
"`;
26 |
27 | exports[`HTML Rendering Tests: Ensures Images and Links are rendered accurately It should render images 1`] = `"
"`;
28 |
29 | exports[`HTML Rendering Tests: Ensures Images and Links are rendered accurately It should render links 1`] = `"md-page
"`;
30 |
31 | exports[`HTML Rendering Tests: Ensures Lists syntax renders accurately It should render unordered lists of a single item 1`] = `
32 | ""
35 | `;
36 |
37 | exports[`HTML Rendering Tests: Ensures Lists syntax renders accurately It should render unordered lists of multiple items 1`] = `
38 | ""
43 | `;
44 |
45 | exports[`HTML Rendering Tests: Ensures Lists syntax renders accurately It should render unordered lists of multiple items with indented items 1`] = `
46 | ""
53 | `;
54 |
55 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render # as 1`] = `""`;
56 |
57 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render ## as 1`] = `""`;
58 |
59 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render ### as 1`] = `""`;
60 |
61 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render #### as 1`] = `""`;
62 |
63 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render ##### as 1`] = `""`;
64 |
65 | exports[`HTML Rendering Tests: Ensures header syntax renders accurately. It should render ###### as 1`] = `""`;
66 |
--------------------------------------------------------------------------------
/test/script.test.js:
--------------------------------------------------------------------------------
1 | const { JSDOM } = require('jsdom');
2 | const baseHtml = ``
3 | const options = { resources: 'usable', runScripts: 'dangerously' };
4 |
5 | describe("HTML Rendering Tests: Ensures header syntax renders accurately.", () => {
6 | beforeAll(() => {
7 | spyOn(console, "error"); // silences the error console.
8 | });
9 |
10 | test('It should render # as ', async (done) => {
11 | let dom = new JSDOM(`${baseHtml}# header`, options);
12 | // We need to delay so we can read the second DOMContentLoaded from the script.
13 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
14 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
15 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
16 | done();
17 | });
18 | });
19 |
20 | test('It should render ## as ', async (done) => {
21 | let dom = new JSDOM(`${baseHtml}## header`, options);
22 | // We need to delay so we can read the second DOMContentLoaded from the script.
23 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
24 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
25 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
26 | done();
27 | });
28 | });
29 |
30 | test('It should render ### as ', async (done) => {
31 | let dom = new JSDOM(`${baseHtml}### header`, options);
32 | // We need to delay so we can read the second DOMContentLoaded from the script.
33 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
34 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
35 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
36 | done();
37 | });
38 | });
39 |
40 | test('It should render #### as ', async (done) => {
41 | let dom = new JSDOM(`${baseHtml}#### header`, options);
42 | // We need to delay so we can read the second DOMContentLoaded from the script.
43 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
44 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
45 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
46 | done();
47 | });
48 | });
49 |
50 | test('It should render ##### as ', async (done) => {
51 | let dom = new JSDOM(`${baseHtml}##### header`, options);
52 | // We need to delay so we can read the second DOMContentLoaded from the script.
53 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
54 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
55 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
56 | done();
57 | });
58 | });
59 |
60 | test('It should render ###### as ', async (done) => {
61 | let dom = new JSDOM(`${baseHtml}###### header`, options);
62 | // We need to delay so we can read the second DOMContentLoaded from the script.
63 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
64 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
65 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
66 | done();
67 | });
68 | });
69 | });
70 |
71 | describe("HTML Rendering Tests: Ensures Emphasis syntax renders accurately ", () => {
72 | beforeAll(() => {
73 | spyOn(console, "error"); // silences the error console.
74 | });
75 |
76 | test("It should render *text* as italics", async (done) => {
77 | let dom = new JSDOM(`${baseHtml}*This text will be italic*`, options);
78 | // We need to delay so we can read the second DOMContentLoaded from the script.
79 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
80 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
81 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
82 | done();
83 | });
84 | });
85 |
86 | test("It should render _text_ as italics", async (done) => {
87 | let dom = new JSDOM(`${baseHtml}_This text will not be italic_`, options);
88 | // We need to delay so we can read the second DOMContentLoaded from the script.
89 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
90 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
91 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
92 | done();
93 | });
94 | });
95 |
96 | test("It should render **text** as bold", async (done) => {
97 | let dom = new JSDOM(`${baseHtml}**This text will be bold**`, options);
98 | // We need to delay so we can read the second DOMContentLoaded from the script.
99 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
100 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
101 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
102 | done();
103 | });
104 | });
105 |
106 | test("It should render __text__ as underlined", async (done) => {
107 | let dom = new JSDOM(`${baseHtml}__This text will be underlined__`, options);
108 | // We need to delay so we can read the second DOMContentLoaded from the script.
109 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
110 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
111 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
112 | done();
113 | });
114 | });
115 |
116 | test("It should render a combined bold and italics string __text **text**__", async (done) => {
117 | let dom = new JSDOM(`${baseHtml}_You **can** combine them_`, options);
118 | // We need to delay so we can read the second DOMContentLoaded from the script.
119 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
120 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
121 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
122 | done();
123 | });
124 | });
125 | });
126 |
127 | describe("HTML Rendering Tests: Ensures Lists syntax renders accurately", () => {
128 | beforeAll(() => {
129 | spyOn(console, "error"); // silences the error console.
130 | });
131 |
132 | test("It should render unordered lists of a single item", async (done) => {
133 | let dom = new JSDOM(`${baseHtml}* Item 1`, options);
134 | // We need to delay so we can read the second DOMContentLoaded from the script.
135 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
136 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
137 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
138 | done();
139 | });
140 | });
141 |
142 | test("It should render unordered lists of multiple items", async (done) => {
143 | let dom = new JSDOM(`${baseHtml}* Item 1\n * Item 2\n * Item 3`, options);
144 | // We need to delay so we can read the second DOMContentLoaded from the script.
145 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
146 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
147 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
148 | done();
149 | });
150 | });
151 |
152 | test("It should render unordered lists of multiple items with indented items", async (done) => {
153 | let dom = new JSDOM(`${baseHtml}* Item 1\n * Item 2\n * Item 3 \n\t * Item 4\n\t * Item 5`, options);
154 | // We need to delay so we can read the second DOMContentLoaded from the script.
155 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
156 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
157 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
158 | done();
159 | });
160 | });
161 | });
162 |
163 | describe("HTML Rendering Tests: Ensures Images and Links are rendered accurately", () => {
164 | beforeAll(() => {
165 | spyOn(console, "error"); // silences the error console.
166 | });
167 |
168 | test("It should render images", async (done) => {
169 | let dom = new JSDOM(`${baseHtml}`, options);
170 | // We need to delay so we can read the second DOMContentLoaded from the script.
171 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
172 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
173 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
174 | done();
175 | });
176 | });
177 |
178 | test("It should render links", async (done) => {
179 | let dom = new JSDOM(`${baseHtml}[md-page](https://github.com/oscarmorrison/md-page)`, options);
180 | // We need to delay so we can read the second DOMContentLoaded from the script.
181 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
182 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
183 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
184 | done();
185 | });
186 | });
187 | });
188 |
189 | describe("HTML Rendering Tests: Ensures Blockquotes are rendered accurately", () => {
190 | beforeAll(() => {
191 | spyOn(console, "error"); // silences the error console.
192 | });
193 |
194 | test("It should render a single blockquote", async (done) => {
195 | let dom = new JSDOM(`${baseHtml}>This should be a blockquote`, options);
196 | // We need to delay so we can read the second DOMContentLoaded from the script.
197 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
198 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
199 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
200 | done();
201 | });
202 | });
203 |
204 | test("It should render multiple-line blockquotes", async (done) => {
205 | let dom = new JSDOM(`${baseHtml}>Line 1\nLine 2\nLine 3`, options);
206 | // We need to delay so we can read the second DOMContentLoaded from the script.
207 | await dom.window.document.addEventListener('DOMContentLoaded', async () => {
208 | await setImmediate(() => { }); // This is required for the second DOMContentLoaded.
209 | expect(dom.window.document.body.innerHTML).toMatchSnapshot();
210 | done();
211 | });
212 | });
213 | });
--------------------------------------------------------------------------------