]> granicus.if.org Git - multimarkdown/commitdiff
ADDED: Add smart quote support for other languages (resolves #15)
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 9 Feb 2017 03:44:53 +0000 (22:44 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Thu, 9 Feb 2017 03:44:53 +0000 (22:44 -0500)
19 files changed:
src/writer.c
tests/MMD6Tests/Dutch.html [new file with mode: 0644]
tests/MMD6Tests/Dutch.htmlc [new file with mode: 0644]
tests/MMD6Tests/Dutch.text [new file with mode: 0644]
tests/MMD6Tests/English.html [new file with mode: 0644]
tests/MMD6Tests/English.htmlc [new file with mode: 0644]
tests/MMD6Tests/English.text [new file with mode: 0644]
tests/MMD6Tests/French.html [new file with mode: 0644]
tests/MMD6Tests/French.htmlc [new file with mode: 0644]
tests/MMD6Tests/French.text [new file with mode: 0644]
tests/MMD6Tests/German Guillemets.html [new file with mode: 0644]
tests/MMD6Tests/German Guillemets.htmlc [new file with mode: 0644]
tests/MMD6Tests/German Guillemets.text [new file with mode: 0644]
tests/MMD6Tests/German.html [new file with mode: 0644]
tests/MMD6Tests/German.htmlc [new file with mode: 0644]
tests/MMD6Tests/German.text [new file with mode: 0644]
tests/MMD6Tests/Swedish.html [new file with mode: 0644]
tests/MMD6Tests/Swedish.htmlc [new file with mode: 0644]
tests/MMD6Tests/Swedish.text [new file with mode: 0644]

index 810b1366cd5a53bb7598cad0c3f5c528e1d8a968..b53f8b40821b161b20fb62b2e951d51320038044 100644 (file)
@@ -62,6 +62,7 @@
 #include "char.h"
 #include "d_string.h"
 #include "html.h"
+#include "i18n.h"
 #include "mmd.h"
 #include "scanners.h"
 #include "token.h"
@@ -1147,6 +1148,7 @@ void process_metadata_stack(mmd_engine * e, scratch_pad * scratch) {
 
        meta * m;
        short header_level = -10;
+       char * temp_char = NULL;
 
        for (int i = 0; i < e->metadata_stack->size; ++i)
        {
@@ -1168,7 +1170,49 @@ void process_metadata_stack(mmd_engine * e, scratch_pad * scratch) {
                } else if (strcmp(m->key, "odfheaderlevel") == 0) {
                        if (scratch->output_format == FORMAT_ODF)
                                header_level = atoi(m->value);
+               } else if (strcmp(m->key, "language") == 0) {
+                       temp_char = label_from_string(m->value);
+
+                       if (strcmp(temp_char, "de") == 0) {
+                               scratch->language = LC_DE;
+                               scratch->quotes_lang = GERMAN;
+                       } else if (strcmp(temp_char, "fr") == 0) {
+                               //scratch->language = LC_FR;
+                               scratch->quotes_lang = FRENCH;
+                       } else if (strcmp(temp_char, "nl") == 0) {
+                               //scratch->language = LC_NL;
+                               scratch->quotes_lang = DUTCH;
+                       } else if (strcmp(temp_char, "sv") == 0) {
+                               //scratch->language = LC_SV;
+                               scratch->quotes_lang = SWEDISH;
+                       } else {
+                               scratch->language = LC_EN;
+                               scratch->quotes_lang = ENGLISH;
+                       }
+
+                       free(temp_char);
                } else if (strcmp(m->key, "quoteslanguage") == 0) {
+                       temp_char = label_from_string(m->value);
+
+                       if ((strcmp(temp_char, "dutch") == 0) ||
+                               (strcmp(temp_char, "nl") == 0)) {
+                               scratch->quotes_lang = DUTCH;
+                       } else if ((strcmp(temp_char, "french") == 0) ||
+                               (strcmp(temp_char, "fr") == 0)) {
+                               scratch->quotes_lang = FRENCH;
+                       } else if ((strcmp(temp_char, "german") == 0) ||
+                               (strcmp(temp_char, "de") == 0)) {
+                               scratch->quotes_lang = GERMAN;
+                       } else if (strcmp(temp_char, "germanguillemets") == 0) {
+                               scratch->quotes_lang = GERMANGUILL;
+                       } else if ((strcmp(temp_char, "swedish") == 0) ||
+                               (strcmp(temp_char, "sv") == 0)) {
+                               scratch->quotes_lang = SWEDISH;
+                       } else {
+                               scratch->quotes_lang = ENGLISH;
+                       }
+
+                       free(temp_char);
                } else {
                        // Any other key triggers complete document
                        if (!(scratch->extensions & EXT_SNIPPET))
diff --git a/tests/MMD6Tests/Dutch.html b/tests/MMD6Tests/Dutch.html
new file mode 100644 (file)
index 0000000..bf86374
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#8216;foo&#8217;</p>
+
+<p>&#8222;foo&#8221;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="see citation" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/Dutch.htmlc b/tests/MMD6Tests/Dutch.htmlc
new file mode 100644 (file)
index 0000000..20decdc
--- /dev/null
@@ -0,0 +1,19 @@
+<p>language:   nl</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/Dutch.text b/tests/MMD6Tests/Dutch.text
new file mode 100644 (file)
index 0000000..8f13699
--- /dev/null
@@ -0,0 +1,19 @@
+language:      nl
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]
diff --git a/tests/MMD6Tests/English.html b/tests/MMD6Tests/English.html
new file mode 100644 (file)
index 0000000..40c4da4
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#8216;foo&#8217;</p>
+
+<p>&#8220;foo&#8221;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="see citation" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/English.htmlc b/tests/MMD6Tests/English.htmlc
new file mode 100644 (file)
index 0000000..f5c2b7d
--- /dev/null
@@ -0,0 +1,19 @@
+<p>language:   en</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/English.text b/tests/MMD6Tests/English.text
new file mode 100644 (file)
index 0000000..9172ef1
--- /dev/null
@@ -0,0 +1,19 @@
+language:      en
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]
diff --git a/tests/MMD6Tests/French.html b/tests/MMD6Tests/French.html
new file mode 100644 (file)
index 0000000..3046b5e
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#39;foo&#8217;</p>
+
+<p>&#171;foo&#187;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="see citation" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/French.htmlc b/tests/MMD6Tests/French.htmlc
new file mode 100644 (file)
index 0000000..4314734
--- /dev/null
@@ -0,0 +1,19 @@
+<p>language:   fr</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/French.text b/tests/MMD6Tests/French.text
new file mode 100644 (file)
index 0000000..c496fbc
--- /dev/null
@@ -0,0 +1,19 @@
+language:      fr
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]
diff --git a/tests/MMD6Tests/German Guillemets.html b/tests/MMD6Tests/German Guillemets.html
new file mode 100644 (file)
index 0000000..05627f6
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#8250;foo&#8249;</p>
+
+<p>&#187;foo&#171;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="siehe Fußnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="siehe Zitat" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="zum Haupttext" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="zum Haupttext" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/German Guillemets.htmlc b/tests/MMD6Tests/German Guillemets.htmlc
new file mode 100644 (file)
index 0000000..c62c0af
--- /dev/null
@@ -0,0 +1,20 @@
+<p>language:   de
+quotes language:       germanguillemets</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/German Guillemets.text b/tests/MMD6Tests/German Guillemets.text
new file mode 100644 (file)
index 0000000..fada37f
--- /dev/null
@@ -0,0 +1,20 @@
+language:      de
+quotes language:       germanguillemets
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]
diff --git a/tests/MMD6Tests/German.html b/tests/MMD6Tests/German.html
new file mode 100644 (file)
index 0000000..4b468a1
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#8218;foo&#8216;</p>
+
+<p>&#8222;foo&#8220;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="siehe Fußnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="siehe Zitat" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="zum Haupttext" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="zum Haupttext" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/German.htmlc b/tests/MMD6Tests/German.htmlc
new file mode 100644 (file)
index 0000000..b13d0ee
--- /dev/null
@@ -0,0 +1,19 @@
+<p>language:   de</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/German.text b/tests/MMD6Tests/German.text
new file mode 100644 (file)
index 0000000..c26c033
--- /dev/null
@@ -0,0 +1,19 @@
+language:      de
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]
diff --git a/tests/MMD6Tests/Swedish.html b/tests/MMD6Tests/Swedish.html
new file mode 100644 (file)
index 0000000..07a918c
--- /dev/null
@@ -0,0 +1,39 @@
+<p>&#8217;foo&#8217;</p>
+
+<p>&#8221;foo&#8221;</p>
+
+<p>foo&#8217;s</p>
+
+<p>foo &#8212; bar</p>
+
+<p>foo &#8211; bar</p>
+
+<p>5</p>
+
+<p>foo&#8230;</p>
+
+<p><a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></p>
+
+<p><a href="#cn:1" id="cnref:1" title="see citation" class="citation">[1]</a></p>
+
+<div class="footnotes">
+<hr />
+<ol>
+
+<li id="fn:1">
+<p>foo <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
+
+<div class="citations">
+<hr />
+<ol>
+
+<li id="cn:1">
+<p>bar <a href="#fnref:1" title="return to body" class="reversefootnote">&#160;&#8617;</a></p>
+</li>
+
+</ol>
+</div>
diff --git a/tests/MMD6Tests/Swedish.htmlc b/tests/MMD6Tests/Swedish.htmlc
new file mode 100644 (file)
index 0000000..014446c
--- /dev/null
@@ -0,0 +1,19 @@
+<p>language:   sv</p>
+
+<p>'foo'</p>
+
+<p>&quot;foo&quot;</p>
+
+<p>foo's</p>
+
+<p>foo --- bar</p>
+
+<p>foo -- bar</p>
+
+<p>5</p>
+
+<p>foo...</p>
+
+<p>[^foo]</p>
+
+<p>[#bar]</p>
diff --git a/tests/MMD6Tests/Swedish.text b/tests/MMD6Tests/Swedish.text
new file mode 100644 (file)
index 0000000..bd11d07
--- /dev/null
@@ -0,0 +1,19 @@
+language:      sv
+
+'foo'
+
+"foo"
+
+foo's
+
+foo --- bar
+
+foo -- bar
+
+5
+
+foo...
+
+[^foo]
+
+[#bar]