//simpleMarkdown 显示 Markdown import web.form; import string.markdown; namespace web.form; class simpleMarkdown{ ctor(...){{ this = ..web.form(...); this.noScriptErr = true; this.loadcode(`
if _WIN7_LATER { ?> } ?> `) this.wait(); var lastElement; var markdownText = ""; this.getMarkdown = function(){ return markdownText; }; this.setMarkdown = function(md){ markdownText = md; this.write(md); } var markdown = ..string.markdown(,,0x400/*_MD_HTML_TASK_ENABLED*/); var katexParse; this.enableKatex = function(enabled){ if(enabled ){ katexParse = function(md){ return ..string.replaceUnmatched(md ,"<$[""'`$]?![^$]+$>|<$$[^$]+$$>|<%<\\\(><\\\)>>|<%<\\\[><\\]>>" ,function(text){ var t,e = ..string.match(text,"^(<<\\\[>|<\\\(>|<$$>|$>)(.+)<<\\\]>|<\\\)>|<$$>|$>$"); if(#e) return ..string.crlf(this.xcall("katex.renderToString",e,{ throwOnError: false, displayMode: t=='[' || t =='$' }),""); } ,"!\N([ \t]*)(```+)<\a\w+>?(.+?)!\N\s*\2![^`\S]" ,"%``" ,"\