From: Fletcher T. Penney Date: Sat, 4 Aug 2018 19:54:54 +0000 (-0400) Subject: FIXED: Trim trailing newlines in definition blocks X-Git-Tag: 6.4.0^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1720ce48d0532730117e76da829b583d8d2479ae;p=multimarkdown FIXED: Trim trailing newlines in definition blocks --- diff --git a/Sources/libMultiMarkdown/writer.c b/Sources/libMultiMarkdown/writer.c index 64b80a2..1444288 100644 --- a/Sources/libMultiMarkdown/writer.c +++ b/Sources/libMultiMarkdown/writer.c @@ -1060,6 +1060,7 @@ link * explicit_link(scratch_pad * scratch, token * bracket, token * paren, cons footnote * footnote_new(const char * source, token * label, token * content, bool lowercase) { footnote * f = malloc(sizeof(footnote)); + token * walker; if (f) { f->label = label; @@ -1078,6 +1079,24 @@ footnote * footnote_new(const char * source, token * label, token * content, boo token_trim_leading_whitespace(content, source); default: + // Trim trailing newlines + walker = content->tail; + while (walker) { + switch (walker->type) { + case TEXT_NL: + case TEXT_NL_SP: + content->tail = walker->prev; + token_free(walker); + walker = content->tail; + walker->next = NULL; + break; + + default: + walker = NULL; + break; + } + } + f->content = token_new_parent(content, BLOCK_PARA); f->free_para = true; break; diff --git a/tests/MMD6Tests/Citations.fodt b/tests/MMD6Tests/Citations.fodt index 025ea08..620170d 100644 --- a/tests/MMD6Tests/Citations.fodt +++ b/tests/MMD6Tests/Citations.fodt @@ -280,8 +280,7 @@ office:mimetype="application/vnd.oasis.opendocument.text"> citep -John Doe. A Totally Fake Book 1. Vanity Press, 2006. - +John Doe. A Totally Fake Book 1. Vanity Press, 2006. 1[] @@ -291,8 +290,7 @@ office:mimetype="application/vnd.oasis.opendocument.text"> 1 -1John Doe. A Totally Fake Book 2. Vanity Press, 2006. - +1John Doe. A Totally Fake Book 2. Vanity Press, 2006. citet diff --git a/tests/MMD6Tests/Citations.html b/tests/MMD6Tests/Citations.html index 4f8cc6a..5974714 100644 --- a/tests/MMD6Tests/Citations.html +++ b/tests/MMD6Tests/Citations.html @@ -41,13 +41,11 @@
  1. -

    John Doe. A Totally Fake Book 1. Vanity Press, 2006. -  ↩

    +

    John Doe. A Totally Fake Book 1. Vanity Press, 2006.  ↩

  2. -

    John Doe. A Totally Fake Book 2. Vanity Press, 2006. -  ↩

    +

    John Doe. A Totally Fake Book 2. Vanity Press, 2006.  ↩

  3. diff --git a/tests/MMD6Tests/Citations.opml b/tests/MMD6Tests/Citations.opml new file mode 100644 index 0000000..d5c482d --- /dev/null +++ b/tests/MMD6Tests/Citations.opml @@ -0,0 +1,14 @@ + + +Citations + + + + + + + + + + + diff --git a/tests/MMD6Tests/Citations.tex b/tests/MMD6Tests/Citations.tex index 06997f8..14a5b4b 100644 --- a/tests/MMD6Tests/Citations.tex +++ b/tests/MMD6Tests/Citations.tex @@ -39,11 +39,9 @@ \bibitem{foo1} John Doe. \emph{A Totally Fake Book 1}. Vanity Press, 2006. - \bibitem{foo2} John Doe. \emph{A Totally Fake Book 2}. Vanity Press, 2006. - \bibitem{foo3} John Doe. \emph{A Totally Fake Book 3}. Vanity Press, 2006. \end{thebibliography} diff --git a/tests/MMD6Tests/Integrated.fodt b/tests/MMD6Tests/Integrated.fodt index b6f7f79..3485b51 100644 --- a/tests/MMD6Tests/Integrated.fodt +++ b/tests/MMD6Tests/Integrated.fodt @@ -331,9 +331,7 @@ list Cite.Inline Citation -Cite.bar - - +Cite.bar Links and Images diff --git a/tests/MMD6Tests/Integrated.html b/tests/MMD6Tests/Integrated.html index d29dfb6..30487ab 100644 --- a/tests/MMD6Tests/Integrated.html +++ b/tests/MMD6Tests/Integrated.html @@ -158,9 +158,7 @@ term:

    A term to be defined. -

    bar - -  ↩

    +

    bar  ↩

diff --git a/tests/MMD6Tests/Integrated.opml b/tests/MMD6Tests/Integrated.opml new file mode 100644 index 0000000..b9ae80c --- /dev/null +++ b/tests/MMD6Tests/Integrated.opml @@ -0,0 +1,23 @@ + + +Integrated + + + + + + + + + + + + + + + + + + + + diff --git a/tests/MMD6Tests/Integrated.tex b/tests/MMD6Tests/Integrated.tex index d41ea9b..28b181a 100644 --- a/tests/MMD6Tests/Integrated.tex +++ b/tests/MMD6Tests/Integrated.tex @@ -151,8 +151,6 @@ Inline Citation \bibitem{foo} bar - - \end{thebibliography} \input{mmd6-article-footer}