diff --git a/npm/index.js b/npm/index.js index c2ab588..db5391a 100644 --- a/npm/index.js +++ b/npm/index.js @@ -123,7 +123,7 @@ function parse_md_to_html_with_warnings(md) { } //if link was never completed if (link_content !== undefined) { - if (!html_line.startsWith("

")) { + if (!html_line.startsWith("

") && !in_unordered_list && !in_ordered_list) { html_line = "

" + html_line; } html_line += "[" + link_content; @@ -309,8 +309,8 @@ function parse_md_to_html_with_warnings(md) { if (char === "\n") { line_number++; } - //check to see if unordered list is ending - if (in_unordered_list && char === "\n" && ((chars.slice(i + 1, i + 3) !== "- " && !blockquote_list) || (chars.slice(i + 1, i + 5) !== "> - " && blockquote_list))) { + //check to see if unordered list is ending, and we are not on last char because then has already been added + 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 += "\n"; in_unordered_list = false; blockquote_list = false; diff --git a/npm/index.ts b/npm/index.ts index 65ce48f..b65a547 100644 --- a/npm/index.ts +++ b/npm/index.ts @@ -132,7 +132,7 @@ export function parse_md_to_html_with_warnings(md: string): ParseResult { } //if link was never completed if (link_content !== undefined) { - if (!html_line.startsWith("

")) { + if (!html_line.startsWith("

") && !in_unordered_list && !in_ordered_list) { html_line = "

"+html_line; } html_line += "["+link_content; @@ -309,8 +309,8 @@ export function parse_md_to_html_with_warnings(md: string): ParseResult { if (char === "\n") { line_number++; } - //check to see if unordered list is ending - if (in_unordered_list && char === "\n" && ((chars.slice(i+1, i+3) !== "- " && !blockquote_list) || (chars.slice(i+1, i+5) !== "> - " && blockquote_list))) { + //check to see if unordered list is ending, and we are not on last char because then has already been added + 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 += "\n"; in_unordered_list = false; blockquote_list = false; diff --git a/npm/package.json b/npm/package.json index 3207c79..4461c2e 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "makoto", - "version": "1.0.0", + "version": "1.0.1", "description": "Markdown to HTML parser", "main": "index.js", "types": "index.d.ts",