Commit 1b133f4a authored by twanvl's avatar twanvl

Remove curly quotes for MWS and apprentice export

parent aa7322b1
...@@ -358,7 +358,7 @@ void ApprDistro::writeD(wxTextOutputStream& tout, const String& name, int c, int ...@@ -358,7 +358,7 @@ void ApprDistro::writeD(wxTextOutputStream& tout, const String& name, int c, int
/// Untag function for apprentice, replaces newlines with \r\n /// Untag function for apprentice, replaces newlines with \r\n
String untag_appr(const String& s) { String untag_appr(const String& s) {
return replace_all(untag(s), _("\n"), _("\r\n")); return replace_all(untag(curly_quotes(s,false)), _("\n"), _("\r\n"));
} }
DECLARE_POINTER_TYPE(ApprCardRecord); DECLARE_POINTER_TYPE(ApprCardRecord);
......
...@@ -23,7 +23,8 @@ DECLARE_TYPEOF_COLLECTION(CardP); ...@@ -23,7 +23,8 @@ DECLARE_TYPEOF_COLLECTION(CardP);
/// Convert a tagged string to MWS format: \t\t before each line beyond the first /// Convert a tagged string to MWS format: \t\t before each line beyond the first
String untag_mws(const String& str) { String untag_mws(const String& str) {
return replace_all(untag(str), _("\n"), _("\n\t\t") ); // TODO : em dashes?
return replace_all(untag(curly_quotes(str,false)), _("\n"), _("\n\t\t") );
} }
//String untag_mws(const Defaultable<String>& str) { //String untag_mws(const Defaultable<String>& str) {
// str. // str.
...@@ -36,6 +37,7 @@ String card_color_mws(const String& col) { ...@@ -36,6 +37,7 @@ String card_color_mws(const String& col) {
if (col == _("black")) return _("B"); if (col == _("black")) return _("B");
if (col == _("red")) return _("R"); if (col == _("red")) return _("R");
if (col == _("green")) return _("G"); if (col == _("green")) return _("G");
if (col == _("artifact")) return _("Art");
if (col == _("colorless")) return _("Art"); if (col == _("colorless")) return _("Art");
if (col.find(_("land")) != String::npos) { if (col.find(_("land")) != String::npos) {
return _("Lnd"); // land return _("Lnd"); // land
......
...@@ -267,22 +267,7 @@ SCRIPT_FUNCTION(format) { ...@@ -267,22 +267,7 @@ SCRIPT_FUNCTION(format) {
SCRIPT_FUNCTION(curly_quotes) { SCRIPT_FUNCTION(curly_quotes) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
bool open = true, in_tag = false; SCRIPT_RETURN(curly_quotes(input,true));
FOR_EACH(c, input) {
if (c == _('\'') || c == LEFT_SINGLE_QUOTE || c == RIGHT_SINGLE_QUOTE) {
c = open ? LEFT_SINGLE_QUOTE : RIGHT_SINGLE_QUOTE;
} else if (c == _('\"') || c == LEFT_DOUBLE_QUOTE || c == RIGHT_DOUBLE_QUOTE) {
c = open ? LEFT_DOUBLE_QUOTE : RIGHT_DOUBLE_QUOTE;
} else if (c == _('<')) {
in_tag = true;
} else if (c == _('>')) {
in_tag = false;
} else if (!in_tag) {
// Also allow double-nesting of quotes
open = isSpace(c) || c == _('(') || c == _('[');
}
}
SCRIPT_RETURN(input);
} }
// regex escape a string // regex escape a string
......
...@@ -567,3 +567,24 @@ String simplify_tagged_overlap(const String& str) { ...@@ -567,3 +567,24 @@ String simplify_tagged_overlap(const String& str) {
} }
return ret; return ret;
} }
// ----------------------------------------------------------------------------- : Other utilities
String curly_quotes(String str, bool curl) {
bool open = true, in_tag = false;
FOR_EACH(c, str) {
if (c == _('\'') || c == LEFT_SINGLE_QUOTE || c == RIGHT_SINGLE_QUOTE) {
c = curl ? (open ? LEFT_SINGLE_QUOTE : RIGHT_SINGLE_QUOTE) : _('\'');
} else if (c == _('\"') || c == LEFT_DOUBLE_QUOTE || c == RIGHT_DOUBLE_QUOTE) {
c = curl ? (open ? LEFT_DOUBLE_QUOTE : RIGHT_DOUBLE_QUOTE) : _('\"');
} else if (c == _('<')) {
in_tag = true;
} else if (c == _('>')) {
in_tag = false;
} else if (!in_tag) {
// Also allow double-nesting of quotes
open = isSpace(c) || c == _('(') || c == _('[');
}
}
return str;
}
...@@ -198,5 +198,10 @@ String simplify_tagged_merge(const String& str, bool all = false); ...@@ -198,5 +198,10 @@ String simplify_tagged_merge(const String& str, bool all = false);
*/ */
String simplify_tagged_overlap(const String& str); String simplify_tagged_overlap(const String& str);
// ----------------------------------------------------------------------------- : Other utilities
/// Turn straight quotes into curly ones or vice-versa
String curly_quotes(String str, bool curl);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment