Commit 368d5150 authored by twanvl's avatar twanvl

Support for automatic curly quotes

parent 6f8d74df
...@@ -265,7 +265,8 @@ init script: ...@@ -265,7 +265,8 @@ init script:
replace_rule( replace_rule(
match: "[a-z]", match: "[a-z]",
in_context: "[(](<param-[a-z]*>)?<match>|[ ]*: <param-cost><match>|—<match>| — <match>", in_context: "[(](<param-[a-z]*>)?<match>|[ ]*: <param-cost><match>|—<match>| — <match>",
replace: { to_upper() }) replace: { to_upper() }) +
curly_quotes
#character filter for title line #character filter for title line
name_filter := name_filter :=
...@@ -309,7 +310,9 @@ init script: ...@@ -309,7 +310,9 @@ init script:
# step 1 : remove italic tags # step 1 : remove italic tags
tag_remove_rule(tag: "<i-flavor>") + tag_remove_rule(tag: "<i-flavor>") +
# step 2 : surround by <i> tags # step 2 : surround by <i> tags
{ "<i-flavor>" + input + "</i-flavor>" } { "<i-flavor>" + input + "</i-flavor>" } +
# curly quotes
curly_quotes
# Used in FPM and Future Sight # Used in FPM and Future Sight
brush_context := brush_context :=
"(?ix) # case insensitive, ignore whitespace "(?ix) # case insensitive, ignore whitespace
...@@ -1210,6 +1213,9 @@ keyword mode: ...@@ -1210,6 +1213,9 @@ keyword mode:
keyword mode: keyword mode:
name: pseudo name: pseudo
description: Pseudo keyword / named ability (Hellbent, Threshold, etc.) description: Pseudo keyword / named ability (Hellbent, Threshold, etc.)
keyword mode:
name: inline
description: Inline keyword, reminder text at end of line (Scry, Regenerate, etc.)
keyword mode: keyword mode:
is default: true is default: true
name: custom name: custom
...@@ -1643,8 +1649,12 @@ keyword: ...@@ -1643,8 +1649,12 @@ keyword:
keyword: keyword:
keyword: Fateseal keyword: Fateseal
match: Fateseal <atom-param>number</atom-param> match: Fateseal <atom-param>number</atom-param>
mode: expert mode: inline
reminder: Look at the top {english_number_multiple(param1)} card(s) of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order. reminder:
Look at the top {
if param1.value==1 then "card of an opponent's library, then you may put it on the bottom of that player's library."
else "{english_number(param1)} cards of an opponent's library, then put any number of them on the bottom of that player's library and the rest on top in any order."
}
keyword: keyword:
keyword: Transfigure keyword: Transfigure
match: Transfigure <atom-param>cost</atom-param> match: Transfigure <atom-param>cost</atom-param>
......
...@@ -75,6 +75,26 @@ SCRIPT_RULE_1(format, String, format) { ...@@ -75,6 +75,26 @@ SCRIPT_RULE_1(format, String, format) {
} }
} }
SCRIPT_FUNCTION(curly_quotes) {
SCRIPT_PARAM(String, input);
bool open = true, in_tag = false;
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;
}
if (c == _('<')) {
in_tag = true;
} else if (c == _('>')) {
in_tag = false;
} else if (!in_tag) {
open = isSpace(c);
}
}
SCRIPT_RETURN(input);
}
// ----------------------------------------------------------------------------- : Tagged string // ----------------------------------------------------------------------------- : Tagged string
...@@ -576,6 +596,7 @@ void init_script_basic_functions(Context& ctx) { ...@@ -576,6 +596,7 @@ void init_script_basic_functions(Context& ctx) {
ctx.setVariable(_("contains"), script_contains); ctx.setVariable(_("contains"), script_contains);
ctx.setVariable(_("format"), script_format); ctx.setVariable(_("format"), script_format);
ctx.setVariable(_("format rule"), script_format_rule); ctx.setVariable(_("format rule"), script_format_rule);
ctx.setVariable(_("curly quotes"), script_curly_quotes);
// tagged string // tagged string
ctx.setVariable(_("tag contents"), script_tag_contents); ctx.setVariable(_("tag contents"), script_tag_contents);
ctx.setVariable(_("remove tag"), script_tag_remove); ctx.setVariable(_("remove tag"), script_tag_remove);
......
...@@ -64,9 +64,17 @@ void writeUTF8(wxTextOutputStream& stream, const String& str); ...@@ -64,9 +64,17 @@ void writeUTF8(wxTextOutputStream& stream, const String& str);
#ifdef UNICODE #ifdef UNICODE
#define LEFT_ANGLE_BRACKET _("\x2039") #define LEFT_ANGLE_BRACKET _("\x2039")
#define RIGHT_ANGLE_BRACKET _("\x203A") #define RIGHT_ANGLE_BRACKET _("\x203A")
#define LEFT_SINGLE_QUOTE _('\x2018')
#define RIGHT_SINGLE_QUOTE _('\x2019')
#define LEFT_DOUBLE_QUOTE _('\x201C')
#define RIGHT_DOUBLE_QUOTE _('\x201D')
#else #else
#define LEFT_ANGLE_BRACKET _("<") #define LEFT_ANGLE_BRACKET _("<")
#define RIGHT_ANGLE_BRACKET _(">") #define RIGHT_ANGLE_BRACKET _(">")
#define LEFT_SINGLE_QUOTE _('\'')
#define RIGHT_SINGLE_QUOTE _('\'')
#define LEFT_DOUBLE_QUOTE _('\"')
#define RIGHT_DOUBLE_QUOTE _('\"')
#endif #endif
// ----------------------------------------------------------------------------- : Char functions // ----------------------------------------------------------------------------- : Char functions
......
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