+
+
+
+ diff --git a/blog.html b/blog.html new file mode 100644 index 0000000..15138a1 --- /dev/null +++ b/blog.html @@ -0,0 +1,115 @@ + + +
+ + + + + +$1");
+ html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1');
+ html = html.replace(/\*\*([^*]+)\*\*/g, "$1");
+ html = html.replace(/\*([^*]+)\*/g, "$1");
+ return html;
+ }
+
+ function simpleMarkdownToHtml(md) {
+ var lines = String(md || "").replace(/\r\n?/g, "\n").split("\n");
+ var out = [];
+ var inCode = false;
+ var inHtmlComment = false;
+ var codeBuf = [];
+ var paraBuf = [];
+ var listBuf = [];
+ var listType = null;
+
+ function flushParagraph() {
+ if (!paraBuf.length) return;
+ out.push("" + parseInlineMarkdown(paraBuf.join(" ")) + "
"); + paraBuf = []; + } + + function flushList() { + if (!listBuf.length) return; + var tag = listType === "ol" ? "ol" : "ul"; + out.push("<" + tag + ">"); + listBuf.forEach(function (item) { + out.push("" + escapeHtml(codeBuf.join("\n")) + "");
+ inCode = false;
+ codeBuf = [];
+ }
+
+ function isTableSeparator(line) {
+ return /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(line || "");
+ }
+
+ function parseTableCells(line) {
+ var text = String(line || "").trim();
+ if (text.startsWith("|")) text = text.slice(1);
+ if (text.endsWith("|")) text = text.slice(0, -1);
+ return text.split("|").map(function (c) { return c.trim(); });
+ }
+
+ function isLikelyTableRow(line) {
+ return /^\s*\|.*\|\s*$/.test(line || "");
+ }
+
+ function isHtmlStartWithoutClose(line) {
+ return /^\s*<[A-Za-z][^>]*$/.test(line || "");
+ }
+
+ for (var i = 0; i < lines.length; i += 1) {
+ var line = lines[i];
+ if (!inCode) {
+ if (inHtmlComment) {
+ if (line.indexOf("-->") !== -1) inHtmlComment = false;
+ continue;
+ }
+ if (line.indexOf("") === -1 || line.indexOf("")) {
+ inHtmlComment = true;
+ }
+ // Ignore HTML comments in fallback mode.
+ continue;
+ }
+ }
+
+ if (/^\s*```/.test(line)) {
+ flushParagraph();
+ flushList();
+ if (inCode) {
+ flushCode();
+ } else {
+ inCode = true;
+ codeBuf = [];
+ }
+ continue;
+ }
+
+ if (inCode) {
+ codeBuf.push(line);
+ continue;
+ }
+
+ var heading = line.match(/^(#{1,6})\s+(.*)$/);
+ if (heading) {
+ flushParagraph();
+ flushList();
+ var level = heading[1].length;
+ out.push(""); + continue; + } + + // Keep raw HTML blocks (e.g." + parseInlineMarkdown(blockquote[1]) + "