From: Fletcher T. Penney Date: Thu, 3 May 2018 00:08:05 +0000 (-0400) Subject: FIXED: Preserve tabs following leading hashes in code blocks X-Git-Tag: 6.4.0^2~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5562ca52448937fdd2329afb3f424d5bd0d7fd7e;p=multimarkdown FIXED: Preserve tabs following leading hashes in code blocks --- diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c index 6db9dac..6a42c46 100644 --- a/Sources/libMultiMarkdown/mmd.c +++ b/Sources/libMultiMarkdown/mmd.c @@ -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) && diff --git a/Sources/libMultiMarkdown/opendocument-content.c b/Sources/libMultiMarkdown/opendocument-content.c index d6e6447..18e2792 100644 --- a/Sources/libMultiMarkdown/opendocument-content.c +++ b/Sources/libMultiMarkdown/opendocument-content.c @@ -336,6 +336,34 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token print_const("""); 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(""); + 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(""); break; diff --git a/tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt# b/tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt# new file mode 100644 index 0000000..20d4c0d --- /dev/null +++ b/tests/MMD6Tests/.~lock.Fenced Code Blocks.fodt# @@ -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 diff --git a/tests/MMD6Tests/Fenced Code Blocks.fodt b/tests/MMD6Tests/Fenced Code Blocks.fodt index 9dde1ef..56c2bf7 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.fodt +++ b/tests/MMD6Tests/Fenced Code Blocks.fodt @@ -307,6 +307,8 @@ office:mimetype="application/vnd.oasis.opendocument.text"> * foo+ bar- baz* foo+ bar- baz1. foo2. bar3. baz +# foo##bar### baz #####foo## #####bar######## baz# + foo diff --git a/tests/MMD6Tests/Fenced Code Blocks.html b/tests/MMD6Tests/Fenced Code Blocks.html index 0c29c80..5827d11 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.html +++ b/tests/MMD6Tests/Fenced Code Blocks.html @@ -59,6 +59,14 @@ bar 3. baz +
# foo
+##	bar
+### baz #
+####	foo	##  
+#####		bar		##	
+###### baz#
+
+
foo
 
diff --git a/tests/MMD6Tests/Fenced Code Blocks.htmlc b/tests/MMD6Tests/Fenced Code Blocks.htmlc index f33be07..ff18e4a 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.htmlc +++ b/tests/MMD6Tests/Fenced Code Blocks.htmlc @@ -65,5 +65,21 @@ foo

``` +

```

+ +

foo

+ +

bar

+ +

baz

+ +

foo ##

+ +
bar ##
+ +
baz
+ +

```

+

``` foo

diff --git a/tests/MMD6Tests/Fenced Code Blocks.tex b/tests/MMD6Tests/Fenced Code Blocks.tex index c76070e..e4a5a74 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.tex +++ b/tests/MMD6Tests/Fenced Code Blocks.tex @@ -66,6 +66,15 @@ foo 3. baz \end{verbatim} +\begin{verbatim} +# foo +## bar +### baz # +#### foo ## +##### bar ## +###### 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 21ce397..67e2f88 100644 --- a/tests/MMD6Tests/Fenced Code Blocks.text +++ b/tests/MMD6Tests/Fenced Code Blocks.text @@ -62,6 +62,14 @@ foo 3. baz ``` +``` +# foo +## bar +### baz # +#### foo ## +##### bar ## +###### baz# +``` ``` foo diff --git a/tests/MMD6Tests/Markdown Syntax.fodt b/tests/MMD6Tests/Markdown Syntax.fodt index d67535c..d81be5f 100644 --- a/tests/MMD6Tests/Markdown Syntax.fodt +++ b/tests/MMD6Tests/Markdown Syntax.fodt @@ -721,8 +721,7 @@ title for the link, surrounded in quotes. For example: If you’re referring to a local resource on the same server, you can use relative paths: -See my [About](/about/) page for details. - +See my [About](/about/) page for details. Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link: