From f88d92acab9787a034058441b870e02e0e46a5b7 Mon Sep 17 00:00:00 2001 From: twanvl Date: Wed, 21 Jul 2010 18:23:57 +0000 Subject: [PATCH] curly_quotes now considers EM_DASH to be a space, so it uses an open quote after it. Fixes #33 git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1449 0fc631ac-6414-0410-93d0-97cfa31319b6 --- data/magic.mse-game/script | 19 ++----------------- src/util/tagged_string.cpp | 6 +++++- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/data/magic.mse-game/script b/data/magic.mse-game/script index fb8cb7c5..00158333 100644 --- a/data/magic.mse-game/script +++ b/data/magic.mse-game/script @@ -453,22 +453,8 @@ text_filter := replace@( match: "\\[[SCTQXYZIWUBRG0-9/|]+\\]", replace: {"" + mana_filter_t() + ""} ) + - # step 6a : curly double quotes - replace@( - match: "[[.quotation-mark.]]|“", - in_context: "[“][A-Za-z,.!?+$<>:;-— 0-9\\\\]*", - replace: "”" )+ - replace@( - match: "[[.quotation-mark.]]", - replace: "“" )+ - # step 6b : curly single quotes - replace@( - match: "' |‘ ", - in_context: "[‘][A-Za-z,.!?+$<>:;-— 0-9\\\\]*", - replace: "’ " )+ - replace@( - match: " '", - replace: " ‘" )+ + # step 6 : curly quotes + curly_quotes + # step 7 : ??? replace@( match: "[(]([^)\n]|[(][^)\n]*[)])*[)]?", @@ -480,7 +466,6 @@ text_filter := + "([[:lower:]])" # match this + "(?![)])", # not followed by this replace: { _1 + to_upper(_2) }) + - #curly_quotes + # step 9 : spellcheck { if set.mark_errors then check_spelling( diff --git a/src/util/tagged_string.cpp b/src/util/tagged_string.cpp index 89697204..44f4779d 100644 --- a/src/util/tagged_string.cpp +++ b/src/util/tagged_string.cpp @@ -607,6 +607,10 @@ void check_tagged(const String& str, bool check_balance) { // ----------------------------------------------------------------------------- : Other utilities +bool is_space_like(Char c) { + return isSpace(c) || c == _('(') || c == _('[') || c == _('{') || c == EN_DASH || c == EM_DASH; +} + String curly_quotes(String str, bool curl) { bool open = true, in_tag = false; FOR_EACH(c, str) { @@ -620,7 +624,7 @@ String curly_quotes(String str, bool curl) { in_tag = false; } else if (!in_tag) { // Also allow double-nesting of quotes - open = isSpace(c) || c == _('(') || c == _('['); + open = is_space_like(c); } } return str;