(kind)
| 3025 | const flushCode = () => { |
| 3026 | if (!inCode) return; |
| 3027 | out.push(`<pre><code>${escapeHtml(codeLines.join("\n"))}</code></pre>`); |
| 3028 | inCode = false; |
| 3029 | codeLines = []; |
| 3030 | }; |
| 3031 | |
| 3032 | for (const rawLine of lines) { |
| 3033 | const line = rawLine.replace(/\t/g, " "); |
| 3034 | const trimmed = line.trim(); |
| 3035 | if (trimmed.startsWith("```")) { |
| 3036 | flushParagraph(); |
| 3037 | flushList(); |
| 3038 | flushQuote(); |
| 3039 | if (inCode) flushCode(); |
| 3040 | else { |
| 3041 | inCode = true; |
| 3042 | codeLines = []; |
| 3043 | } |
| 3044 | continue; |
| 3045 | } |
| 3046 | if (inCode) { |
| 3047 | codeLines.push(line); |
| 3048 | continue; |
| 3049 | } |
| 3050 | if (!trimmed) { |
| 3051 | flushParagraph(); |
| 3052 | flushList(); |
| 3053 | flushQuote(); |
| 3054 | continue; |
| 3055 | } |
| 3056 | const heading = trimmed.match(/^(#{1,6})\s+(.*)$/); |
| 3057 | if (heading) { |
| 3058 | flushParagraph(); |
| 3059 | flushList(); |
| 3060 | flushQuote(); |
| 3061 | const level = heading[1].length; |
| 3062 | out.push(`<h${level}>${renderInlineMarkdown(heading[2])}</h${level}>`); |
| 3063 | continue; |
| 3064 | } |
| 3065 | const quote = trimmed.match(/^>\s?(.*)$/); |
| 3066 | if (quote) { |
| 3067 | flushParagraph(); |
| 3068 | flushList(); |
| 3069 | quoteLines.push(quote[1]); |
| 3070 | continue; |
| 3071 | } |
| 3072 | const unordered = trimmed.match(/^[-*]\s+(.*)$/); |
| 3073 | if (unordered) { |
| 3074 | flushParagraph(); |
| 3075 | flushQuote(); |
| 3076 | if (listType && listType !== "ul") flushList(); |
| 3077 | listType = "ul"; |
| 3078 | listItems.push(unordered[1]); |
| 3079 | continue; |
| 3080 | } |
| 3081 | const ordered = trimmed.match(/^\d+\.\s+(.*)$/); |
| 3082 | if (ordered) { |
| 3083 | flushParagraph(); |
| 3084 | flushQuote(); |
no test coverage detected