From: Fletcher T. Penney Date: Sun, 4 Feb 2018 20:21:26 +0000 (-0500) Subject: FIXED: Fix issue with list bullets in fenced code blocks X-Git-Tag: 6.3.0^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb28cb95c396bc67b8ae5d2c7fe82f805cc38e0d;p=multimarkdown FIXED: Fix issue with list bullets in fenced code blocks --- diff --git a/Sources/libMultiMarkdown/fodt.c b/Sources/libMultiMarkdown/fodt.c index 6c80f84..956d987 100644 --- a/Sources/libMultiMarkdown/fodt.c +++ b/Sources/libMultiMarkdown/fodt.c @@ -1873,6 +1873,8 @@ void mmd_export_token_odf_raw(DString * out, const char * source, token * t, scr return; } + char * temp; + switch (t->type) { case AMPERSAND: print_const("&"); @@ -1904,6 +1906,25 @@ void mmd_export_token_odf_raw(DString * out, const char * source, token * t, scr print_const(""); break; + case MARKER_LIST_BULLET: + case MARKER_LIST_ENUMERATOR: + print_token(t); + + temp = NULL; + if (t->next) { + temp = (char *) &source[t->next->start]; + } + + source = (char *) &source[t->start + t->len]; + + while (char_is_whitespace(*source) && + ((temp == NULL) || + (source < temp))) { + print_char(*source); + source++; + } + break; + case QUOTE_DOUBLE: print_const("""); break; diff --git a/Sources/libMultiMarkdown/html.c b/Sources/libMultiMarkdown/html.c index fa782f8..5b9fafb 100644 --- a/Sources/libMultiMarkdown/html.c +++ b/Sources/libMultiMarkdown/html.c @@ -2052,6 +2052,7 @@ void mmd_export_token_html_raw(DString * out, const char * source, token * t, sc if (t == NULL) { return; } + char * temp; switch (t->type) { case BACKTICK: @@ -2104,6 +2105,25 @@ void mmd_export_token_html_raw(DString * out, const char * source, token * t, sc d_string_append_c_array(out, &(source[t->start + 1]), t->len - 1); break; + case MARKER_LIST_BULLET: + case MARKER_LIST_ENUMERATOR: + print_token(t); + + temp = NULL; + if (t->next) { + temp = (char *) &source[t->next->start]; + } + + source = (char *) &source[t->start + t->len]; + + while (char_is_whitespace(*source) && + ((temp == NULL) || + (source < temp))) { + print_char(*source); + source++; + } + break; + case MATH_BRACKET_OPEN: print_const("\\\\["); break; diff --git a/Sources/libMultiMarkdown/latex.c b/Sources/libMultiMarkdown/latex.c index 1393839..cbd6e20 100644 --- a/Sources/libMultiMarkdown/latex.c +++ b/Sources/libMultiMarkdown/latex.c @@ -1985,6 +1985,8 @@ void mmd_export_token_latex_raw(DString * out, const char * source, token * t, s return; } + char * temp; + switch (t->type) { case ESCAPED_CHARACTER: print_const("\\"); @@ -1996,6 +1998,25 @@ void mmd_export_token_latex_raw(DString * out, const char * source, token * t, s print_token(t); break; + case MARKER_LIST_BULLET: + case MARKER_LIST_ENUMERATOR: + print_token(t); + + temp = NULL; + if (t->next) { + temp = (char *) &source[t->next->start]; + } + + source = (char *) &source[t->start + t->len]; + + while (char_is_whitespace(*source) && + ((temp == NULL) || + (source < temp))) { + print_char(*source); + source++; + } + break; + case SUBSCRIPT: if (t->child) { print_const("\\ensuremath{\\sim}"); diff --git a/Sources/libMultiMarkdown/opendocument-content.c b/Sources/libMultiMarkdown/opendocument-content.c index 9fc6a91..9f21a5c 100644 --- a/Sources/libMultiMarkdown/opendocument-content.c +++ b/Sources/libMultiMarkdown/opendocument-content.c @@ -291,6 +291,8 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token return; } + char * temp; + switch (t->type) { case AMPERSAND: print_const("&"); @@ -326,6 +328,25 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token print_const("""); break; + case MARKER_LIST_BULLET: + case MARKER_LIST_ENUMERATOR: + print_token(t); + + temp = NULL; + if (t->next) { + temp = (char *) &source[t->next->start]; + } + + source = (char *) &source[t->start + t->len]; + + while (char_is_whitespace(*source) && + ((temp == NULL) || + (source < temp))) { + print_char(*source); + source++; + } + break; + case MATH_BRACKET_OPEN: case MATH_BRACKET_CLOSE: case MATH_PAREN_OPEN: diff --git a/tests/MMD6Tests/Fenced Code Blocks.fodt b/tests/MMD6Tests/Fenced Code Blocks.fodt index f674b0d..9dde1ef 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.fodt +++ b/tests/MMD6Tests/Fenced Code Blocks.fodt @@ -305,6 +305,8 @@ office:mimetype="application/vnd.oasis.opendocument.text"> foobar bar foo +* foo+ bar- baz* foo+ bar- baz1. foo2. bar3. baz + foo diff --git a/tests/MMD6Tests/Fenced Code Blocks.html b/tests/MMD6Tests/Fenced Code Blocks.html index e52a091..0c29c80 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.html +++ b/tests/MMD6Tests/Fenced Code Blocks.html @@ -47,6 +47,18 @@ bar foo +
* foo
++  bar
+-   baz
+*    foo
++     bar
+-      baz
+
+1.   foo
+2.    bar
+3.     baz
+
+
foo
 
diff --git a/tests/MMD6Tests/Fenced Code Blocks.htmlc b/tests/MMD6Tests/Fenced Code Blocks.htmlc index e0d5990..f33be07 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.htmlc +++ b/tests/MMD6Tests/Fenced Code Blocks.htmlc @@ -47,5 +47,23 @@ foo

```

+

```

+ + + +
    +
  1. foo
  2. +
  3. bar
  4. +
  5. baz +```
  6. +
+

``` foo

diff --git a/tests/MMD6Tests/Fenced Code Blocks.tex b/tests/MMD6Tests/Fenced Code Blocks.tex index 4a710c3..c76070e 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.tex +++ b/tests/MMD6Tests/Fenced Code Blocks.tex @@ -53,6 +53,19 @@ foo foo \end{verbatim} +\begin{verbatim} +* foo ++ bar +- baz +* foo ++ bar +- baz + +1. foo +2. bar +3. baz +\end{verbatim} + \begin{verbatim} foo \end{verbatim} diff --git a/tests/MMD6Tests/Fenced Code Blocks.text b/tests/MMD6Tests/Fenced Code Blocks.text index 2919400..21ce397 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.text +++ b/tests/MMD6Tests/Fenced Code Blocks.text @@ -49,6 +49,19 @@ foo foo ``` +``` +* foo ++ bar +- baz +* foo ++ bar +- baz + +1. foo +2. bar +3. baz +``` + ``` foo