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

a

\n
\n
\n

b

\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"), "
\n\n

-winter melons

\n

abcdefg

\n\n
\n\n

a

", "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

-winter melons

\n

abcdefg

\n\n
\n\n

a

", "unordered lists test 1"); + +test_assert_equal(parse_md_to_html("- a**b**\n- cd\n- \[a]"), "", "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"), "
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n

5. should fail

\n
\n
    \n
  1. d
  2. \n
  3. e
  4. \n
\n
\n

3. 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;