From db2c7aced085d7026562d202fd45b947e8e2920d Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Sun, 3 Dec 2017 19:33:55 -0500 Subject: [PATCH] UPDATED: Add Spanish style quotes support --- Sources/libMultiMarkdown/aho-corasick.c | 8 +-- Sources/libMultiMarkdown/file.c | 46 ++++++++--------- Sources/libMultiMarkdown/file.h | 50 +++++++++---------- Sources/libMultiMarkdown/fodt.c | 2 + Sources/libMultiMarkdown/html.c | 2 + .../include/libMultiMarkdown.h | 1 + Sources/libMultiMarkdown/latex.c | 2 + Sources/libMultiMarkdown/mmd.c | 4 +- .../libMultiMarkdown/opendocument-content.c | 2 + Sources/libMultiMarkdown/writer.c | 9 ++-- tests/MMD6Tests/Spanish.fodt | 2 +- tests/MMD6Tests/Spanish.html | 2 +- tests/MMD6Tests/Spanish.tex | 2 +- 13 files changed, 72 insertions(+), 60 deletions(-) diff --git a/Sources/libMultiMarkdown/aho-corasick.c b/Sources/libMultiMarkdown/aho-corasick.c index 90cd8bc..a996380 100644 --- a/Sources/libMultiMarkdown/aho-corasick.c +++ b/Sources/libMultiMarkdown/aho-corasick.c @@ -478,9 +478,9 @@ void match_set_filter_leftmost_longest(match * header) { m->next->start > m->start && m->next->start < m->start + m->len) { // This match is "lefter" than next -#ifndef __clang_analyzer__ + #ifndef __clang_analyzer__ match_excise(m->next); -#endif + #endif } while (m->next && @@ -497,9 +497,9 @@ void match_set_filter_leftmost_longest(match * header) { m->prev->start >= m->start) { // We are "lefter" than previous n = m->prev; -#ifndef __clang_analyzer__ + #ifndef __clang_analyzer__ match_excise(n); -#endif + #endif } m = m->next; diff --git a/Sources/libMultiMarkdown/file.c b/Sources/libMultiMarkdown/file.c index cc4edab..e87bdcd 100644 --- a/Sources/libMultiMarkdown/file.c +++ b/Sources/libMultiMarkdown/file.c @@ -4,11 +4,11 @@ @file file.c - @brief + @brief @author Fletcher T. Penney - @bug + @bug **/ @@ -18,38 +18,38 @@ The `MultiMarkdown 6` project is released under the MIT License.. - + GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project: - + https://github.com/fletcher/MultiMarkdown-4/ - + MMD 4 is released under both the MIT License and GPL. - - + + CuTest is released under the zlib/libpng license. See CuTest.c for the text of the license. - + uthash library: Copyright (c) 2005-2016, Troy D. Hanson - + Licensed under Revised BSD license - + miniz library: Copyright 2013-2014 RAD Game Tools and Valve Software Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - + Licensed under the MIT license - + argtable3 library: Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann All rights reserved. - + Licensed under the Revised BSD License - - + + ## The MIT License ## - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -57,10 +57,10 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -68,10 +68,10 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - + + ## Revised BSD License ## - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -85,7 +85,7 @@ names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -97,7 +97,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + */ diff --git a/Sources/libMultiMarkdown/file.h b/Sources/libMultiMarkdown/file.h index 0c20108..03df736 100644 --- a/Sources/libMultiMarkdown/file.h +++ b/Sources/libMultiMarkdown/file.h @@ -4,11 +4,11 @@ @file file.h - @brief + @brief @author Fletcher T. Penney - @bug + @bug **/ @@ -18,38 +18,38 @@ The `MultiMarkdown 6` project is released under the MIT License.. - + GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project: - + https://github.com/fletcher/MultiMarkdown-4/ - + MMD 4 is released under both the MIT License and GPL. - - + + CuTest is released under the zlib/libpng license. See CuTest.c for the text of the license. - + uthash library: Copyright (c) 2005-2016, Troy D. Hanson - + Licensed under Revised BSD license - + miniz library: Copyright 2013-2014 RAD Game Tools and Valve Software Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - + Licensed under the MIT license - + argtable3 library: Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann All rights reserved. - + Licensed under the Revised BSD License - - + + ## The MIT License ## - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -57,10 +57,10 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -68,10 +68,10 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - + + ## Revised BSD License ## - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -85,7 +85,7 @@ names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -97,7 +97,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + */ @@ -146,8 +146,8 @@ char * absolute_path_for_argument(const char * arg); #if (defined(_WIN32) || defined(__WIN32__)) -// Windows does not know realpath(), so we need a "windows port" -char *realpath(const char *path, char *resolved_path); + // Windows does not know realpath(), so we need a "windows port" + char *realpath(const char *path, char *resolved_path); #endif #endif diff --git a/Sources/libMultiMarkdown/fodt.c b/Sources/libMultiMarkdown/fodt.c index d98b164..6c80f84 100644 --- a/Sources/libMultiMarkdown/fodt.c +++ b/Sources/libMultiMarkdown/fodt.c @@ -200,6 +200,7 @@ void mmd_print_localized_char_odf(DString * out, unsigned short type, scratch_pa break; case FRENCH: + case SPANISH: print_const("«"); break; @@ -224,6 +225,7 @@ void mmd_print_localized_char_odf(DString * out, unsigned short type, scratch_pa break; case FRENCH: + case SPANISH: print_const("»"); break; diff --git a/Sources/libMultiMarkdown/html.c b/Sources/libMultiMarkdown/html.c index 6987369..fdc89c2 100644 --- a/Sources/libMultiMarkdown/html.c +++ b/Sources/libMultiMarkdown/html.c @@ -209,6 +209,7 @@ void mmd_print_localized_char_html(DString * out, unsigned short type, scratch_p break; case FRENCH: + case SPANISH: print_const("«"); break; @@ -233,6 +234,7 @@ void mmd_print_localized_char_html(DString * out, unsigned short type, scratch_p break; case FRENCH: + case SPANISH: print_const("»"); break; diff --git a/Sources/libMultiMarkdown/include/libMultiMarkdown.h b/Sources/libMultiMarkdown/include/libMultiMarkdown.h index f9d1ee4..36ef020 100644 --- a/Sources/libMultiMarkdown/include/libMultiMarkdown.h +++ b/Sources/libMultiMarkdown/include/libMultiMarkdown.h @@ -520,6 +520,7 @@ enum smart_quotes_language { FRENCH, GERMAN, GERMANGUILL, + SPANISH, SWEDISH, }; diff --git a/Sources/libMultiMarkdown/latex.c b/Sources/libMultiMarkdown/latex.c index 81af5e0..03cde71 100644 --- a/Sources/libMultiMarkdown/latex.c +++ b/Sources/libMultiMarkdown/latex.c @@ -214,6 +214,7 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_ break; case FRENCH: + case SPANISH: print_const("«"); break; @@ -238,6 +239,7 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_ break; case FRENCH: + case SPANISH: print_const("»"); break; diff --git a/Sources/libMultiMarkdown/mmd.c b/Sources/libMultiMarkdown/mmd.c index 1315254..2ffde95 100644 --- a/Sources/libMultiMarkdown/mmd.c +++ b/Sources/libMultiMarkdown/mmd.c @@ -237,7 +237,7 @@ void mmd_engine_set_language(mmd_engine * e, short language) { break; case LC_ES: - e->quotes_lang = ENGLISH; + e->quotes_lang = SPANISH; break; case LC_FR: @@ -2398,7 +2398,7 @@ char * mmd_engine_metavalue_for_key(mmd_engine * e, const char * key) { if (e == NULL || key == NULL) { return NULL; } - + if (e->metadata_stack->size == 0) { // Ensure we have checked for metadata if (!mmd_engine_has_metadata(e, NULL)) { diff --git a/Sources/libMultiMarkdown/opendocument-content.c b/Sources/libMultiMarkdown/opendocument-content.c index 27ecbf0..9fc6a91 100644 --- a/Sources/libMultiMarkdown/opendocument-content.c +++ b/Sources/libMultiMarkdown/opendocument-content.c @@ -246,6 +246,7 @@ void mmd_print_localized_char_opendocument(DString * out, unsigned short type, s break; case FRENCH: + case SPANISH: print_const("«"); break; @@ -270,6 +271,7 @@ void mmd_print_localized_char_opendocument(DString * out, unsigned short type, s break; case FRENCH: + case SPANISH: print_const("»"); break; diff --git a/Sources/libMultiMarkdown/writer.c b/Sources/libMultiMarkdown/writer.c index f1e90aa..1d9bd77 100644 --- a/Sources/libMultiMarkdown/writer.c +++ b/Sources/libMultiMarkdown/writer.c @@ -598,10 +598,10 @@ attr * parse_attributes(char * source) { a->next = attr_new(key, value); a = a->next; } else { -#ifndef __clang_analyzer__ + #ifndef __clang_analyzer__ a = attr_new(key, value); attributes = a; -#endif + #endif } free(value); // We stored a modified copy @@ -1620,7 +1620,7 @@ void process_metadata_stack(mmd_engine * e, scratch_pad * scratch) { scratch->quotes_lang = GERMAN; } else if (strcmp(temp_char, "es") == 0) { scratch->language = LC_ES; - scratch->quotes_lang = ENGLISH; + scratch->quotes_lang = SPANISH; } else if (strcmp(temp_char, "fr") == 0) { scratch->language = LC_FR; scratch->quotes_lang = FRENCH; @@ -1662,6 +1662,9 @@ void process_metadata_stack(mmd_engine * e, scratch_pad * scratch) { scratch->quotes_lang = GERMAN; } else if (strcmp(temp_char, "germanguillemets") == 0) { scratch->quotes_lang = GERMANGUILL; + } else if ((strcmp(temp_char, "spanish") == 0) || + (strcmp(temp_char, "es") == 0)) { + scratch->quotes_lang = SPANISH; } else if ((strcmp(temp_char, "swedish") == 0) || (strcmp(temp_char, "sv") == 0)) { scratch->quotes_lang = SWEDISH; diff --git a/tests/MMD6Tests/Spanish.fodt b/tests/MMD6Tests/Spanish.fodt index 547ae32..943bd34 100644 --- a/tests/MMD6Tests/Spanish.fodt +++ b/tests/MMD6Tests/Spanish.fodt @@ -280,7 +280,7 @@ office:mimetype="application/vnd.oasis.opendocument.text"> ‘foo’ -“foo” +«foo» foo’s diff --git a/tests/MMD6Tests/Spanish.html b/tests/MMD6Tests/Spanish.html index d17d5f6..782a52c 100644 --- a/tests/MMD6Tests/Spanish.html +++ b/tests/MMD6Tests/Spanish.html @@ -8,7 +8,7 @@

‘foo’

-

“foo”

+

«foo»

foo’s

diff --git a/tests/MMD6Tests/Spanish.tex b/tests/MMD6Tests/Spanish.tex index 5da7605..a475ffe 100644 --- a/tests/MMD6Tests/Spanish.tex +++ b/tests/MMD6Tests/Spanish.tex @@ -4,7 +4,7 @@ `foo' -``foo'' +«foo» foo's -- 2.40.0