Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
1b133f4a
Commit
1b133f4a
authored
Aug 02, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove curly quotes for MWS and apprentice export
parent
aa7322b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
18 deletions
+31
-18
src/data/format/apprentice.cpp
src/data/format/apprentice.cpp
+1
-1
src/data/format/mws.cpp
src/data/format/mws.cpp
+3
-1
src/script/functions/basic.cpp
src/script/functions/basic.cpp
+1
-16
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+21
-0
src/util/tagged_string.hpp
src/util/tagged_string.hpp
+5
-0
No files found.
src/data/format/apprentice.cpp
View file @
1b133f4a
...
@@ -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
);
...
...
src/data/format/mws.cpp
View file @
1b133f4a
...
@@ -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
...
...
src/script/functions/basic.cpp
View file @
1b133f4a
...
@@ -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
...
...
src/util/tagged_string.cpp
View file @
1b133f4a
...
@@ -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
;
}
src/util/tagged_string.hpp
View file @
1b133f4a
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment