]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Fix issue with list bullets in fenced code blocks
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sun, 4 Feb 2018 20:21:26 +0000 (15:21 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sun, 4 Feb 2018 20:21:26 +0000 (15:21 -0500)
Sources/libMultiMarkdown/fodt.c
Sources/libMultiMarkdown/html.c
Sources/libMultiMarkdown/latex.c
Sources/libMultiMarkdown/opendocument-content.c
tests/MMD6Tests/Fenced Code Blocks.fodt
tests/MMD6Tests/Fenced Code Blocks.html
tests/MMD6Tests/Fenced Code Blocks.htmlc
tests/MMD6Tests/Fenced Code Blocks.tex
tests/MMD6Tests/Fenced Code Blocks.text

index 6c80f84328c6049bdfb2820d4a6fcc8c0a27359e..956d987a4ac20f3d57dde98ce1dd6e2dae64bd8f 100644 (file)
@@ -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("&amp;");
@@ -1904,6 +1906,25 @@ void mmd_export_token_odf_raw(DString * out, const char * source, token * t, scr
                        print_const("<text:tab/>");
                        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("&quot;");
                        break;
index fa782f867ab2d7678ddddd9682ae883c845d731c..5b9fafb232a4b861ef37a271ca11eebdcf947f89 100644 (file)
@@ -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;
index 1393839b076943a9f7f9586cf2e546ab33312297..cbd6e206c01f38c8f98c2ecdb730c1cd882c3824 100644 (file)
@@ -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}");
index 9fc6a91a252623b9be8d1049b4093826907cafc0..9f21a5ceddc486410fbae227eff74a16df27fb97 100644 (file)
@@ -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("&amp;");
@@ -326,6 +328,25 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
                        print_const("&quot;");
                        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:
index f674b0d2a076a274b8fe4ed9f4173e817f9d7c14..9dde1efa83adb8545af62dc9e5ec0b0f696a3fd3 100644 (file)
@@ -305,6 +305,8 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 
 <text:p text:style-name="Preformatted Text">foo<text:line-break/><text:line-break/><text:tab/>bar<text:line-break/><text:line-break/>  bar<text:line-break/><text:line-break/>    foo<text:line-break/></text:p>
 
+<text:p text:style-name="Preformatted Text">* foo<text:line-break/>+  bar<text:line-break/>-   baz<text:line-break/>*    foo<text:line-break/>+     bar<text:line-break/>-      baz<text:line-break/><text:line-break/>1.   foo<text:line-break/>2.    bar<text:line-break/>3.     baz<text:line-break/></text:p>
+
 <text:p text:style-name="Preformatted Text">foo<text:line-break/></text:p>
 </office:text>
 </office:body>
index e52a091b19bfc02e12dfec89dcd1a7397cd68124..0c29c80985fcccd684b252a92aa36d89c2f2f641 100644 (file)
@@ -47,6 +47,18 @@ bar
     foo
 </code></pre>
 
+<pre><code>* foo
++  bar
+-   baz
+*    foo
++     bar
+-      baz
+
+1.   foo
+2.    bar
+3.     baz
+</code></pre>
+
 <pre><code>foo
 </code></pre>
 
index e0d5990f2035643b3d2d8eeab944c14549695222..f33be07829448330f930cd09d41cb16293f6dae1 100644 (file)
@@ -47,5 +47,23 @@ foo</p>
 
 <p>```</p>
 
+<p>```</p>
+
+<ul>
+<li>foo</li>
+<li>bar</li>
+<li>baz</li>
+<li>foo</li>
+<li> bar</li>
+<li>baz</li>
+</ul>
+
+<ol>
+<li>foo</li>
+<li>bar</li>
+<li> baz
+```</li>
+</ol>
+
 <p>```
 foo</p>
index 4a710c39c58d82b2dc8e0040d90b2c0a17ba5ebb..c76070ed6321c06fb1ac16812012ccc070e6e72e 100644 (file)
@@ -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}
index 2919400a1b0c04943b6c9ee46de29caf71b4f6ad..21ce39717c42a45ebce8fde91c54c17bb87ea4ad 100644 (file)
@@ -49,6 +49,19 @@ foo
     foo
 ```
 
+```
+* foo
++  bar
+-   baz
+*    foo
++     bar
+-      baz
+
+1.   foo
+2.    bar
+3.     baz
+```
+
 
 ```
 foo