]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Trim trailing newlines in definition blocks
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 4 Aug 2018 19:54:54 +0000 (15:54 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 4 Aug 2018 19:54:54 +0000 (15:54 -0400)
Sources/libMultiMarkdown/writer.c
tests/MMD6Tests/Citations.fodt
tests/MMD6Tests/Citations.html
tests/MMD6Tests/Citations.opml [new file with mode: 0644]
tests/MMD6Tests/Citations.tex
tests/MMD6Tests/Integrated.fodt
tests/MMD6Tests/Integrated.html
tests/MMD6Tests/Integrated.opml [new file with mode: 0644]
tests/MMD6Tests/Integrated.tex

index 64b80a2a0b1da38b6ac3d22f42041ac01f1438ff..14442883cc95534d52480af36777f9cf6f87ff58 100644 (file)
@@ -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;
index 025ea08f1628437c531b76440737aa245be45981..620170d4c0c4400e9499f8dd97789b43016ab10a 100644 (file)
@@ -280,8 +280,7 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 <office:text>
 <text:h text:outline-level="1"><text:bookmark text:name="citep"/>citep </text:h>
 
-<text:p text:style-name="Standard"><text:note text:id="cite1" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">John Doe. <text:span text:style-name="MMD-Italic">A Totally Fake Book 1</text:span>. Vanity Press, 2006.
-</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="Standard"><text:note text:id="cite1" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">John Doe. <text:span text:style-name="MMD-Italic">A Totally Fake Book 1</text:span>. Vanity Press, 2006.</text:p></text:note-body></text:note></text:p>
 
 <text:p text:style-name="Standard"><text:span text:style-name="Footnote_20_anchor"><text:note-ref text:note-class="endnote" text:reference-format="text" text:ref-name="cite1">1</text:note-ref></text:span>[]</text:p>
 
@@ -291,8 +290,7 @@ office:mimetype="application/vnd.oasis.opendocument.text">
 
 <text:p text:style-name="Standard"><text:span text:style-name="Footnote_20_anchor"><text:note-ref text:note-class="endnote" text:reference-format="text" text:ref-name="cite1">1</text:note-ref></text:span></text:p>
 
-<text:p text:style-name="Standard"><text:span text:style-name="Footnote_20_anchor"><text:note-ref text:note-class="endnote" text:reference-format="text" text:ref-name="cite1">1</text:note-ref></text:span><text:note text:id="cite2" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">John Doe. <text:span text:style-name="MMD-Italic">A Totally Fake Book 2</text:span>. Vanity Press, 2006.
-</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="Standard"><text:span text:style-name="Footnote_20_anchor"><text:note-ref text:note-class="endnote" text:reference-format="text" text:ref-name="cite1">1</text:note-ref></text:span><text:note text:id="cite2" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">John Doe. <text:span text:style-name="MMD-Italic">A Totally Fake Book 2</text:span>. Vanity Press, 2006.</text:p></text:note-body></text:note></text:p>
 
 <text:h text:outline-level="1"><text:bookmark text:name="citet"/>citet </text:h>
 
index 4f8cc6a033cc10e48b9b93d8c38e24c63eeee3ac..597471468446532e1d07f1b050e9b542ee7d7dbe 100644 (file)
 <ol>
 
 <li id="cn:1">
-<p>John Doe. <em>A Totally Fake Book 1</em>. Vanity Press, 2006.
- <a href="#cnref:1" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
+<p>John Doe. <em>A Totally Fake Book 1</em>. Vanity Press, 2006. <a href="#cnref:1" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
 </li>
 
 <li id="cn:2">
-<p>John Doe. <em>A Totally Fake Book 2</em>. Vanity Press, 2006.
- <a href="#cnref:2" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
+<p>John Doe. <em>A Totally Fake Book 2</em>. Vanity Press, 2006. <a href="#cnref:2" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
 </li>
 
 <li id="cn:3">
diff --git a/tests/MMD6Tests/Citations.opml b/tests/MMD6Tests/Citations.opml
new file mode 100644 (file)
index 0000000..d5c482d
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.0">
+<head><title>Citations</title></head>
+<body>
+<outline text="(Untitled Preamble)" _note="&#10;"></outline>
+<outline text="citep " _note="&#10;[#foo1]&#10;&#10;[#foo1][]&#10;&#10;[p. 123][#foo1]&#10;&#10;[][#foo1]&#10;&#10;[foo\]\[bar][#foo1]&#10;&#10;[#foo1][#foo2]&#10;&#10;&#10;"></outline>
+<outline text="citet " _note="&#10;[#foo1;]&#10;&#10;[#foo1;][]&#10;&#10;[p. 123][#foo1;]&#10;&#10;[][#foo1;]&#10;&#10;[foo\]\[bar][#foo1;]&#10;&#10;[#foo1;][#foo2;]&#10;&#10;&#10;[Not Cited][#foo3]&#10;&#10;&#10;[#foo1]: John Doe. *A Totally Fake Book 1*.  Vanity Press, 2006.&#10;&#10;[#foo2]: John Doe. *A Totally Fake Book 2*.  Vanity Press, 2006.&#10;&#10;[#foo3]: John Doe. *A Totally Fake Book 3*.  Vanity Press, 2006.&#10;"></outline>
+<outline text="Metadata">
+<outline text="title" _note="Citations"/>
+<outline text="latexconfig" _note="article"/>
+</outline>
+</body>
+</opml>
+
index 06997f85785896b51c83ae9c7449c4e3bc9c88a5..14a5b4b7b33c1b7dcc7c8a0fb1d534ec49ec087e 100644 (file)
 \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}
index b6f7f7917f561b8f328fd1f34a4e1bddcddcca56..3485b51ec8653fd87b0fa4cfb5dd44144c3ac30a 100644 (file)
@@ -331,9 +331,7 @@ list</text:p></text:list-item>
 
 <text:p text:style-name="Standard">Cite.<text:note text:id="cite1" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">Inline Citation</text:p></text:note-body></text:note></text:p>
 
-<text:p text:style-name="Standard">Cite.<text:note text:id="cite2" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">bar
-
-</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="Standard">Cite.<text:note text:id="cite2" text:note-class="endnote"><text:note-body><text:p text:style-name="Footnote">bar</text:p></text:note-body></text:note></text:p>
 
 <text:h text:outline-level="1"><text:bookmark text:name="linksandimages"/>Links and Images </text:h>
 
index d29dfb690e326451fcb56b04002bf79275ff7f5a..30487ab2da6c79991f8e20fb3bb2b99052fd9a88 100644 (file)
@@ -158,9 +158,7 @@ term: <p>A term to be defined. <a href="#gnref:1" title="return to body" class="
 </li>
 
 <li id="cn:2">
-<p>bar
-
- <a href="#cnref:2" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
+<p>bar <a href="#cnref:2" title="return to body" class="reversecitation">&#160;&#8617;</a></p>
 </li>
 
 </ol>
diff --git a/tests/MMD6Tests/Integrated.opml b/tests/MMD6Tests/Integrated.opml
new file mode 100644 (file)
index 0000000..b9ae80c
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.0">
+<head><title>Integrated</title></head>
+<body>
+<outline text="(Untitled Preamble)" _note="&#10;This file is a designed as a single test that incorporates most of the&#10;*commonly* used MultiMarkdown features. This allows a single test file to&#10;identify common structures that are not supported yet -- particularly useful&#10;when developing a new output format.&#10;"></outline>
+<outline text="Basic Blocks " _note="&#10;paragraph&#10;&#10;* list&#10;* items&#10;&#10;```&#10;fenced&#10;code&#10;```&#10;&#10;&#9;indented&#10;&#9;code&#10;&#10;&gt; blockquote&#10;&#10;`code span`&#10;&#10;&#10;*emph* and **strong** and ***both***&#10;&#10;_emph_ and __strong__ and ___both___&#10;&#10;&#10;"><outline text="Escapes [escaped]" _note="&#10;1. \$&#10;&#10;2. \#&#10;&#10;3. \[&#10;&#10;&#10;"></outline>
+</outline>
+<outline text="Footnotes " _note="&#10;Foo.[^This is an inline footnote]&#10;&#10;Bar.[^foot]&#10;&#10;[^foot]: And a reference footnote.&#10;&#10;Cite.[#Inline Citation]&#10;&#10;Cite.[#foo]&#10;&#10;[#foo]: bar&#10;&#10;&#10;"></outline>
+<outline text="Links and Images " _note="&#10;[link](http://foo.net/) and [link]&#10;&#10;[link]: http://bar.net &quot;title&quot; class=&quot;custom&quot;&#10;&#10;![test](http://foo.bar/ &quot;title&quot; width=&quot;40px&quot; height=400px)&#10;&#10;[Math]&#10;&#10;[foo][math]&#10;&#10;[bar][foo1]&#10;&#10;[bar][foo2]&#10;&#10;[foo1]:  #bar&#10;[foo2]: #bar&#10;&#10;&#10;"></outline>
+<outline text="Math " _note="&#10;foo \\({e}^{i\pi }+1=0\\) bar&#10;&#10;\\[ {x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a} \\]&#10;&#10;foo ${e}^{i\pi }+1=0$ bar&#10;&#10;foo ${e}^{i\pi }+1=0$, bar&#10;&#10;$${x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}$$&#10;&#10;&#10;"></outline>
+<outline text="Smart Quotes " _note="&#10;&quot;foo&quot; and &apos;bar&apos; -- with --- dashes...&#10;&#10;&#10;"></outline>
+<outline text="CriticMarkup " _note="&#10;{++foo++}&#10;&#10;{--bar--}&#10;&#10;{~~foo~&gt;bar~~}&#10;&#10;{&gt;&gt;foo&lt;&lt;}&#10;&#10;{==bar==}&#10;&#10;&#10;"></outline>
+<outline text="Definition Lists " _note="&#10;foo&#10;bar&#10;:&#9;*foo bar&#10;:&#9;baz bat*&#10;&#10;&#10;"></outline>
+<outline text="Horizontal Rules " _note="&#10;----&#10;&#10;&#10;"></outline>
+<outline text="Glossary " _note="&#10;[?term]&#10;&#10;[?term]: A term to be defined.&#10;&#10;"></outline>
+<outline text="Abbreviations" _note="&#10;[&gt;MMD]&#10;&#10;[&gt;MMD]: MultiMarkdown&#10;&#10;"></outline>
+<outline text="Metadata">
+<outline text="title" _note="Integrated"/>
+<outline text="latexconfig" _note="article"/>
+</outline>
+</body>
+</opml>
+
index d41ea9b276b7e15bdb48d241fda50948d9506cb1..28b181a2904d99d7a41fbad1b06bdff4d41e5113 100644 (file)
@@ -151,8 +151,6 @@ Inline Citation
 
 \bibitem{foo}
 bar
-
-
 \end{thebibliography}
 
 \input{mmd6-article-footer}