From 41675a50992e7d5fe6af279dd2a340f5185a6792 Mon Sep 17 00:00:00 2001 From: jetstream0 <49297268+jetstream0@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:59:07 -0700 Subject: [PATCH] bug fixes --- index.ts | 4 +++- makoto.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 24764ff..d2f1147 100644 --- a/index.ts +++ b/index.ts @@ -94,7 +94,9 @@ test_assert_equal(parse_md_to_html("> ```\n> alert('e')\n> ```"), "
\ test_assert_equal(parse_md_to_html("> a\n\n> b"), "\n\na
\n\n", "block quote test 3"); -test_assert_equal(parse_md_to_html("> - burger\n> -winter melons\n> abcdefg\n> - fries\n- p**i**zza\na"), "b
\n\n\n\n
\n- burger
\n-winter melons
\nabcdefg
\n\n
\n- fries
\n\n
\n- pizza
\na
", "unordered lists test"); +test_assert_equal(parse_md_to_html("> - burger\n> -winter melons\n> abcdefg\n> - fries\n- p**i**zza\na"), "\n\n\n
\n- burger
\n-winter melons
\nabcdefg
\n\n
\n- fries
\n\n
\n- pizza
\na
", "unordered lists test 1"); + +test_assert_equal(parse_md_to_html("- a**b**\n- cd\n- \[a]"), "\n
", "unordered lists test 2"); test_assert_equal(parse_md_to_html("1. a\n2. b\n3. c\n5. should *fail*\n> 1. d\n> 2. e\n3. should fail too"), "- ab
\n- cd
\n- [a]
\n\n
\n- a
\n- b
\n- c
\n5. should fail
\n\n\n\n
\n- d
\n- e
\n3. should fail too
", "ordered lists test 1") diff --git a/makoto.ts b/makoto.ts index fe6bf6d..744f2f4 100644 --- a/makoto.ts +++ b/makoto.ts @@ -127,7 +127,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; @@ -304,8 +304,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;