From: Fletcher T. Penney Date: Thu, 9 Feb 2017 03:44:53 +0000 (-0500) Subject: ADDED: Add smart quote support for other languages (resolves #15) X-Git-Tag: 0.1.4a^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f12012abf3ac2df60d9d74259fdb5c5722a907d3;p=multimarkdown ADDED: Add smart quote support for other languages (resolves #15) --- diff --git a/src/writer.c b/src/writer.c index 810b136..b53f8b4 100644 --- a/src/writer.c +++ b/src/writer.c @@ -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 index 0000000..bf86374 --- /dev/null +++ b/tests/MMD6Tests/Dutch.html @@ -0,0 +1,39 @@ +

‘foo’

+ +

„foo”

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/Dutch.htmlc b/tests/MMD6Tests/Dutch.htmlc new file mode 100644 index 0000000..20decdc --- /dev/null +++ b/tests/MMD6Tests/Dutch.htmlc @@ -0,0 +1,19 @@ +

language: nl

+ +

'foo'

+ +

"foo"

+ +

foo's

+ +

foo --- bar

+ +

foo -- bar

+ +

5

+ +

foo...

+ +

[^foo]

+ +

[#bar]

diff --git a/tests/MMD6Tests/Dutch.text b/tests/MMD6Tests/Dutch.text new file mode 100644 index 0000000..8f13699 --- /dev/null +++ b/tests/MMD6Tests/Dutch.text @@ -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 index 0000000..40c4da4 --- /dev/null +++ b/tests/MMD6Tests/English.html @@ -0,0 +1,39 @@ +

‘foo’

+ +

“foo”

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/English.htmlc b/tests/MMD6Tests/English.htmlc new file mode 100644 index 0000000..f5c2b7d --- /dev/null +++ b/tests/MMD6Tests/English.htmlc @@ -0,0 +1,19 @@ +

language: en

+ +

'foo'

+ +

"foo"

+ +

foo's

+ +

foo --- bar

+ +

foo -- bar

+ +

5

+ +

foo...

+ +

[^foo]

+ +

[#bar]

diff --git a/tests/MMD6Tests/English.text b/tests/MMD6Tests/English.text new file mode 100644 index 0000000..9172ef1 --- /dev/null +++ b/tests/MMD6Tests/English.text @@ -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 index 0000000..3046b5e --- /dev/null +++ b/tests/MMD6Tests/French.html @@ -0,0 +1,39 @@ +

'foo’

+ +

«foo»

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/French.htmlc b/tests/MMD6Tests/French.htmlc new file mode 100644 index 0000000..4314734 --- /dev/null +++ b/tests/MMD6Tests/French.htmlc @@ -0,0 +1,19 @@ +

language: fr

+ +

'foo'

+ +

"foo"

+ +

foo's

+ +

foo --- bar

+ +

foo -- bar

+ +

5

+ +

foo...

+ +

[^foo]

+ +

[#bar]

diff --git a/tests/MMD6Tests/French.text b/tests/MMD6Tests/French.text new file mode 100644 index 0000000..c496fbc --- /dev/null +++ b/tests/MMD6Tests/French.text @@ -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 index 0000000..05627f6 --- /dev/null +++ b/tests/MMD6Tests/German Guillemets.html @@ -0,0 +1,39 @@ +

›foo‹

+ +

»foo«

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/German Guillemets.htmlc b/tests/MMD6Tests/German Guillemets.htmlc new file mode 100644 index 0000000..c62c0af --- /dev/null +++ b/tests/MMD6Tests/German Guillemets.htmlc @@ -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 Guillemets.text b/tests/MMD6Tests/German Guillemets.text new file mode 100644 index 0000000..fada37f --- /dev/null +++ b/tests/MMD6Tests/German Guillemets.text @@ -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 index 0000000..4b468a1 --- /dev/null +++ b/tests/MMD6Tests/German.html @@ -0,0 +1,39 @@ +

‚foo‘

+ +

„foo“

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/German.htmlc b/tests/MMD6Tests/German.htmlc new file mode 100644 index 0000000..b13d0ee --- /dev/null +++ b/tests/MMD6Tests/German.htmlc @@ -0,0 +1,19 @@ +

language: de

+ +

'foo'

+ +

"foo"

+ +

foo's

+ +

foo --- bar

+ +

foo -- bar

+ +

5

+ +

foo...

+ +

[^foo]

+ +

[#bar]

diff --git a/tests/MMD6Tests/German.text b/tests/MMD6Tests/German.text new file mode 100644 index 0000000..c26c033 --- /dev/null +++ b/tests/MMD6Tests/German.text @@ -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 index 0000000..07a918c --- /dev/null +++ b/tests/MMD6Tests/Swedish.html @@ -0,0 +1,39 @@ +

’foo’

+ +

”foo”

+ +

foo’s

+ +

foo — bar

+ +

foo – bar

+ +

5

+ +

foo…

+ +

[1]

+ +

[1]

+ +
+
+
    + +
  1. +

    foo  ↩

    +
  2. + +
+
+ +
+
+
    + +
  1. +

    bar  ↩

    +
  2. + +
+
diff --git a/tests/MMD6Tests/Swedish.htmlc b/tests/MMD6Tests/Swedish.htmlc new file mode 100644 index 0000000..014446c --- /dev/null +++ b/tests/MMD6Tests/Swedish.htmlc @@ -0,0 +1,19 @@ +

language: sv

+ +

'foo'

+ +

"foo"

+ +

foo's

+ +

foo --- bar

+ +

foo -- bar

+ +

5

+ +

foo...

+ +

[^foo]

+ +

[#bar]

diff --git a/tests/MMD6Tests/Swedish.text b/tests/MMD6Tests/Swedish.text new file mode 100644 index 0000000..bd11d07 --- /dev/null +++ b/tests/MMD6Tests/Swedish.text @@ -0,0 +1,19 @@ +language: sv + +'foo' + +"foo" + +foo's + +foo --- bar + +foo -- bar + +5 + +foo... + +[^foo] + +[#bar]