Merge branch 'master' into npm
This commit is contained in:
4
index.ts
4
index.ts
@@ -94,7 +94,9 @@ test_assert_equal(parse_md_to_html("> ```\n> alert('e')\n> ```"), "<blockquote>\
|
||||
|
||||
test_assert_equal(parse_md_to_html("> a\n\n> b"), "<blockquote>\n<p>a</p>\n</blockquote>\n<blockquote>\n<p>b</p>\n</blockquote>", "block quote test 3");
|
||||
|
||||
test_assert_equal(parse_md_to_html("> - burger\n> -winter melons\n> abcdefg\n> - fries\n- p**i**zza\na"), "<blockquote>\n<ul>\n<li>burger</li>\n</ul>\n<p>-winter melons</p>\n<p>abcdefg</p>\n<ul>\n<li>fries</li>\n</ul>\n</blockquote>\n<ul>\n<li>p<b>i</b>zza</li>\n</ul>\n<p>a</p>", "unordered lists test");
|
||||
test_assert_equal(parse_md_to_html("> - burger\n> -winter melons\n> abcdefg\n> - fries\n- p**i**zza\na"), "<blockquote>\n<ul>\n<li>burger</li>\n</ul>\n<p>-winter melons</p>\n<p>abcdefg</p>\n<ul>\n<li>fries</li>\n</ul>\n</blockquote>\n<ul>\n<li>p<b>i</b>zza</li>\n</ul>\n<p>a</p>", "unordered lists test 1");
|
||||
|
||||
test_assert_equal(parse_md_to_html("- a**b**\n- cd\n- \[a]"), "<ul>\n<li>a<b>b</b></li>\n<li>cd</li>\n<li>[a]</li>\n</ul>", "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"), "<ol>\n<li>a</li>\n<li>b</li>\n<li>c</li>\n</ol>\n<p>5. should <i>fail</i></p>\n<blockquote>\n<ol>\n<li>d</li>\n<li>e</li>\n</ol>\n</blockquote>\n<p>3. should fail too</p>", "ordered lists test 1")
|
||||
|
||||
|
||||
@@ -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("<p>")) {
|
||||
if (!html_line.startsWith("<p>") && !in_unordered_list && !in_ordered_list) {
|
||||
html_line = "<p>"+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 </ul> 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 += "</ul>\n";
|
||||
in_unordered_list = false;
|
||||
blockquote_list = false;
|
||||
|
||||
Reference in New Issue
Block a user