varshowdown,version,fs=require("fs"),path=require("path"),Command=require("commander").Command,program=newCommand,path1=path.resolve(__dirname+"/../dist/showdown.js"),path2=path.resolve(__dirname+"/../../.build/showdown.js");functionMessenger(o,t,e){"use strict";t=!!t||!!e,e=!!e,this._print="stdout"===(o=o||"stderr")?console.log:console.error,this.errorExit=function(o){e||(console.error("ERROR: "+o.message),console.error("Run 'showdown <command> -h' for help")),process.exit(1)},this.okExit=function(){e||(this._print("\n"),this._print("DONE!")),process.exit(0)},this.printMsg=function(o){t||e||!o||this._print(o)},this.printError=function(o){e||console.error(o)}}functionshowShowdownOptions(){"use strict";varo,t=showdown.getDefaultOptions(!1);for(oinconsole.log("\nshowdown makehtml config options:"),t)t.hasOwnProperty(o)&&console.log(" "+o+":","[default="+t[o].defaultValue+"]",t[o].describe);console.log('\n\nExample: showdown makehtml -c openLinksInNewWindow ghMentions ghMentionsLink="https://google.com"')}functionparseShowdownOptions(o,t){"use strict";vare=t;if(o)for(varn=0;n<o.length;++n){varr=o[n],i=o[n],s=!0;/=/.test(r)&&(i=r.split("=")[0],s=r.split("=")[1]),e[i]=s}returne}functionreadFromStdIn(o){"use strict";o=o||"utf8";try{returnfs.readFileSync(process.stdin.fd,o).toString()}catch(o){thrownewError("Could not read from stdin, reason: "+o.message)}}functionreadFromFile(t,o){"use strict";try{returnfs.readFileSync(t,o)}catch(o){thrownewError("Could not read from file "+t+", reason: "+o.message)}}functionwriteToStdOut(o){"use strict";if(!process.stdout.write(o))thrownewError("Could not write to StdOut")}functionwriteToFile(o,t,e){"use strict";e=e?fs.appendFileSync:fs.writeFileSync;try{e(t,o)}catch(o){thrownewError("Could not write to file "+t+", readon: "+o.message)}}functionmakehtmlCommand(t,o){"use strict";if(t.configHelp)showShowdownOptions();else{vare,n,r,i=!!o.parent._optionValues.quiet,o=!!o.parent._optionValues.mute,s=t.input&&""!==t.input&&!0!==t.input?"file":"stdin",a=t.output&&""!==t.output&&!0!==t.output?"file":"stdout",d=newMessenger("file"==a?"stdout":"stderr",i,o),i=showdown.getDefaultOptions(!0);if(t.flavor){if(d.printMsg("Enabling flavor "+t.flavor+"..."),!(i=showdown.getFlavorOptions(t.flavor)))returnvoidd.errorExit(newError("Flavor "+t.flavor+" is not recognised"));d.printMsg("OK!")}for(nint.config=parseShowdownOptions(t.config,i),t.config)t.config.hasOwnProperty(n)&&!0===t.config[n]&&d.printMsg("Enabling option "+n);d.printMsg("\nInitializing converter...");try{r=newshowdown.Converter(t.config)}catch(o){returnvoidd.errorExit(o)}if(d.printMsg("OK!"),t.extensions){d.printMsg("\nLoading extensions...");for(varp=0;p<t.extensions.length;++p)try{d.printMsg(t.extensions[p]);varu=require(t.extensions[p]);r.addExtension(u,t.extensions[p]),d.printMsg(t.extensions[p]+" loaded...")}catch(o){d.printError("ERROR: Could not load extension "+t.extensions[p]+". Reason:"),d.errorExit(o)}}if(d.printMsg("..."),d.printMsg("Reading data from "+s+"..."),"stdin"==s)try{e=readFromStdIn(t.encoding)}catch(o){returnvoidd.errorExit(o)}elsetry{e=readFromFile(t.input,t.encoding)}catch(o){returnvoidd.errorExit(o)}if(d.printMsg("Parsing markdown..."),o=r.makeHtml(e),d.printMsg("Writing data to "+a+"..."),"stdout"==a)try{writeToStdOut(o)}catch(o){returnvoidd.errorExit(o)}elsetry{writeToFile(o,t.output,t.append)}catch(o){returnvoidd.errorExit(o)}d.okExit()}}version=fs.existsSync(path1)?(showdown=require(path1),require(path.resolve(__dirname+"/../package.json")).version):fs.existsSync(path2)?(showdown=require(path2),require(path.resolve(__dirname+"/../../package.json")).version):(showdown=require("../../dist/showdown"),require("../../package.json")),program.name("showdown").description("CLI to Showdownjs markdown parser v"+version).version(version).usage("<command> [options]").option("-q, --quiet","Quiet mode. Only print errors").option("-m, --mute","Mute mode. Does not print anything"),program.command("makehtml").description("Converts markdown into html").addHelpText("after","\n\nExamples