This commit is contained in:
jetstream0
2023-07-31 11:04:28 -07:00
parent de4dde65d6
commit 8f7be04eab
3 changed files with 7 additions and 7 deletions

View File

@@ -123,7 +123,7 @@ function parse_md_to_html_with_warnings(md) {
} }
//if link was never completed //if link was never completed
if (link_content !== undefined) { if (link_content !== undefined) {
if (!html_line.startsWith("<p>")) { if (!html_line.startsWith("<p>") && !in_unordered_list && !in_ordered_list) {
html_line = "<p>" + html_line; html_line = "<p>" + html_line;
} }
html_line += "[" + link_content; html_line += "[" + link_content;
@@ -309,8 +309,8 @@ function parse_md_to_html_with_warnings(md) {
if (char === "\n") { if (char === "\n") {
line_number++; line_number++;
} }
//check to see if unordered list is ending //check to see if unordered list is ending, and we are not on last char because then </ul> has already been added
if (in_unordered_list && char === "\n" && ((chars.slice(i + 1, i + 3) !== "- " && !blockquote_list) || (chars.slice(i + 1, i + 5) !== "> - " && blockquote_list))) { if (in_unordered_list && i !== chars.length - 1 && char === "\n" && ((chars.slice(i + 1, i + 3) !== "- " && !blockquote_list) || (chars.slice(i + 1, i + 5) !== "> - " && blockquote_list))) {
html += "</ul>\n"; html += "</ul>\n";
in_unordered_list = false; in_unordered_list = false;
blockquote_list = false; blockquote_list = false;

View File

@@ -132,7 +132,7 @@ export function parse_md_to_html_with_warnings(md: string): ParseResult {
} }
//if link was never completed //if link was never completed
if (link_content !== undefined) { if (link_content !== undefined) {
if (!html_line.startsWith("<p>")) { if (!html_line.startsWith("<p>") && !in_unordered_list && !in_ordered_list) {
html_line = "<p>"+html_line; html_line = "<p>"+html_line;
} }
html_line += "["+link_content; html_line += "["+link_content;
@@ -309,8 +309,8 @@ export function parse_md_to_html_with_warnings(md: string): ParseResult {
if (char === "\n") { if (char === "\n") {
line_number++; line_number++;
} }
//check to see if unordered list is ending //check to see if unordered list is ending, and we are not on last char because then </ul> has already been added
if (in_unordered_list && char === "\n" && ((chars.slice(i+1, i+3) !== "- " && !blockquote_list) || (chars.slice(i+1, i+5) !== "> - " && blockquote_list))) { if (in_unordered_list && i !== chars.length-1 && char === "\n" && ((chars.slice(i+1, i+3) !== "- " && !blockquote_list) || (chars.slice(i+1, i+5) !== "> - " && blockquote_list))) {
html += "</ul>\n"; html += "</ul>\n";
in_unordered_list = false; in_unordered_list = false;
blockquote_list = false; blockquote_list = false;

View File

@@ -1,6 +1,6 @@
{ {
"name": "makoto", "name": "makoto",
"version": "1.0.0", "version": "1.0.1",
"description": "Markdown to HTML parser", "description": "Markdown to HTML parser",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",