]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Preserve tabs following leading hashes in code blocks
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 3 May 2018 00:08:05 +0000 (20:08 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 3 May 2018 00:08:05 +0000 (20:08 -0400)
Sources/libMultiMarkdown/mmd.c
Sources/libMultiMarkdown/opendocument-content.c
tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt# [new file with mode: 0644]
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
tests/MMD6Tests/Markdown Syntax.fodt

index 6db9dac663e3744bf75cb9225897be01d545f4d3..6a42c463b4c0070f647c6153d0c11dddb9a71ce6 100644 (file)
@@ -510,9 +510,6 @@ void mmd_assign_line_type(mmd_engine * e, token * line) {
                                line->type = (first_child->type - HASH1) + LINE_ATX_1;
                                first_child->type = (line->type - LINE_ATX_1) + MARKER_H1;
 
-                               // Strip trailing whitespace from '#' sequence
-                               first_child->len = first_child->type - MARKER_H1 + 1;
-
                                // Strip trailing '#' sequence if present
                                if (line->child->tail->type == TEXT_NL) {
                                        if ((line->child->tail->prev->type >= HASH1) &&
index d6e6447f669669d1ea89cb4ec183e93e2096fd13..18e2792e0869c3f3f4e154e8c224ee4d0a269d58 100644 (file)
@@ -336,6 +336,34 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
                        print_const("&quot;");
                        break;
 
+               case MARKER_H1:
+               case MARKER_H2:
+               case MARKER_H3:
+               case MARKER_H4:
+               case MARKER_H5:
+               case MARKER_H6:
+                       temp = (char *) &source[t->start];
+                       while (temp) {
+                               switch (*temp) {
+                                       case '#':
+                                               print_const("#");
+                                               temp++;
+                                               break;
+                                       case ' ':
+                                               print_const(" ");
+                                               temp++;
+                                               break;
+                                       case '\t':
+                                               print_const("<text:tab/>");
+                                               temp++;
+                                               break;
+                                       default:
+                                               temp = NULL;
+                                               break;
+                               }
+                       }
+                       break;
+
                case MARKER_LIST_BULLET:
                case MARKER_LIST_ENUMERATOR:
                        print_token(t);
@@ -392,6 +420,8 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
                case TEXT_EMPTY:
                        break;
 
+               case TEXT_LINEBREAK:
+                       print_const("  ");
                case TEXT_NL:
                        print_const("<text:line-break/>");
                        break;
diff --git a/tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt# b/tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt#
new file mode 100644 (file)
index 0000000..20d4c0d
--- /dev/null
@@ -0,0 +1 @@
+Fletcher Penney,fletcher,minime.private,02.05.2018 19:53,file:///Users/fletcher/Library/Application%20Support/LibreOffice/4;
\ No newline at end of file
index 9dde1efa83adb8545af62dc9e5ec0b0f696a3fd3..56c2bf79ad774b19f46f1d88276a410c9fabd0c4 100644 (file)
@@ -307,6 +307,8 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 
 <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:tab/>bar<text:line-break/>### baz #<text:line-break/>####<text:tab/>foo<text:tab/>##  <text:line-break/>#####<text:tab/><text:tab/>bar<text:tab/><text:tab/>##<text:tab/><text:line-break/>###### baz#<text:line-break/></text:p>
+
 <text:p text:style-name="Preformatted Text">foo<text:line-break/></text:p>
 </office:text>
 </office:body>
index 0c29c80985fcccd684b252a92aa36d89c2f2f641..5827d115637210f2fc09cdf90ae3abbd2b8bf8a5 100644 (file)
@@ -59,6 +59,14 @@ bar
 3.     baz
 </code></pre>
 
+<pre><code># foo
+##     bar
+### baz #
+####   foo     ##  
+#####          bar             ##      
+###### baz#
+</code></pre>
+
 <pre><code>foo
 </code></pre>
 
index f33be07829448330f930cd09d41cb16293f6dae1..ff18e4a5ea0de9f4020c7331880f506a393c5159 100644 (file)
@@ -65,5 +65,21 @@ foo</p>
 ```</li>
 </ol>
 
+<p>```</p>
+
+<h1>foo</h1>
+
+<h2>bar</h2>
+
+<h3>baz </h3>
+
+<h4>foo        ##</h4>
+
+<h5>bar                ##      </h5>
+
+<h6>baz</h6>
+
+<p>```</p>
+
 <p>```
 foo</p>
index c76070ed6321c06fb1ac16812012ccc070e6e72e..e4a5a74e68538df5acfbd9094c6305e5d49c57e9 100644 (file)
@@ -66,6 +66,15 @@ foo
 3.     baz
 \end{verbatim}
 
+\begin{verbatim}
+# foo
+##     bar
+### baz #
+####   foo     ##  
+#####          bar             ##      
+###### baz#
+\end{verbatim}
+
 \begin{verbatim}
 foo
 \end{verbatim}
index 21ce39717c42a45ebce8fde91c54c17bb87ea4ad..67e2f883542896d06dc4dfbfe05e7b7070b5af8a 100644 (file)
@@ -62,6 +62,14 @@ foo
 3.     baz
 ```
 
+```
+# foo
+##     bar
+### baz #
+####   foo     ##  
+#####          bar             ##      
+###### baz#
+```
 
 ```
 foo
index d67535cfffce81d4c5bf12c430d81096b3112550..d81be5fe116d97aa6c706545e40242d01b28ebfe 100644 (file)
@@ -721,8 +721,7 @@ title for the link, surrounded in quotes. For example:</text:p>
 <text:p text:style-name="Standard">If you&#8217;re referring to a local resource on the same server, you can
 use relative paths:</text:p>
 
-<text:p text:style-name="Preformatted Text">See my [About](/about/) page for details.   
-</text:p>
+<text:p text:style-name="Preformatted Text">See my [About](/about/) page for details.  <text:line-break/></text:p>
 
 <text:p text:style-name="Standard">Reference-style links use a second set of square brackets, inside
 which you place a label of your choosing to identify the link:</text:p>