Fixed logic to properly handle curly braces next to links (Transitions or Referenced Objects)
This commit is contained in:
parent
8c9b73902c
commit
00b6045076
@ -1003,14 +1003,10 @@ namespace Volian.Controls.Library
|
||||
case '}':
|
||||
return token;
|
||||
case 'v': // save link hidden info
|
||||
if (Regex.IsMatch(token, @"^\\v0? ?$")) return token; // comment part of link
|
||||
// end comment may end in space or may end in '\' if another rtf command,
|
||||
// or may end at end of string. First check for space, keep it in string
|
||||
// if it is there.
|
||||
//if (Regex.IsMatch(token, @"\\v0 "))
|
||||
// return token;
|
||||
//if (Regex.IsMatch(token, @"\\v0"))
|
||||
// return token;
|
||||
if (token == "\\viewkind4 ") break;
|
||||
if (Regex.IsMatch(token, @"^\\v0? ?$"))
|
||||
return token; // comment part of link
|
||||
_MyLog.WarnFormat("<<<ERROR>>>\r\n==> Token including Comment not processed '{0}'", token);
|
||||
break;
|
||||
case 'l':
|
||||
if (Regex.IsMatch(token, @"^\\line ?$")) return token;
|
||||
@ -1038,12 +1034,13 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
|
||||
// are rtf so were getting removed and/or not handled correctly.
|
||||
string retval = rtf.Replace(@"\{", @"(![");
|
||||
retval = retval.Replace(@"\}", @"(!]");
|
||||
string retval = rtf.Replace(@"\{", @" (![");
|
||||
retval = retval.Replace(@"\}", @" (!]");
|
||||
|
||||
// remove carriage return/newlines after \par commands (these are introduced by rtb
|
||||
// for hard returns, goes into rtb as \par and comes out as \par\r\n):
|
||||
retval = Regex.Replace(retval, @"\\par\r\n(?!\\)", "\\par ");
|
||||
retval = retval.Replace("\\v0\r\n", "\\v0 "); // Replace Carriage Return and Newline after comment
|
||||
retval = Regex.Replace(retval, @"[\r\n]", "", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
|
||||
retval = Regex.Replace(retval, @"^\{(.*)\}$", "$1", RegexOptions.Singleline); // Strip Opening and Closing Braces
|
||||
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
|
||||
@ -1057,8 +1054,8 @@ namespace Volian.Controls.Library
|
||||
if (retval.Length == 0) return "";
|
||||
if (retval.EndsWith(@"\v")) retval = retval.Remove(retval.Length - 2, 2);
|
||||
retval = _MyItemInfo.RemoveRtfStyles(retval); // RemoveRtfStyles(retval);
|
||||
retval = retval.Replace(@"(![", @"\{");
|
||||
retval = retval.Replace(@"(!]", @"\}");
|
||||
retval = retval.Replace(@" (![", @"\{");
|
||||
retval = retval.Replace(@" (!]", @"\}");
|
||||
retval = retval.TrimEnd(' ');
|
||||
return retval;
|
||||
}
|
||||
@ -1067,8 +1064,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
|
||||
// are rtf so were getting removed and/or not handled correctly.
|
||||
string retval = rtf.Replace(@"\{", @"(![");
|
||||
retval = retval.Replace(@"\}", @"(!]");
|
||||
string retval = rtf.Replace(@"\{", @" (![");
|
||||
retval = retval.Replace(@"\}", @" (!]");
|
||||
|
||||
// For hardspaces, the windows richtextbox does some 'quirky' things:
|
||||
// A unicode representation of \u160? is sent INTO the rtb. Coming out,
|
||||
@ -1083,6 +1080,7 @@ namespace Volian.Controls.Library
|
||||
retval = Regex.Replace(retval, @"\\par\r\n(?!\\)", "\\par ");
|
||||
//retval = Regex.Replace(retval, @"\\par\r\n(?=\\)", "\\par");
|
||||
|
||||
retval = retval.Replace("\\v0\r\n", "\\v0 "); // Replace Carriage Return and Newline after comment
|
||||
retval = Regex.Replace(retval, @"[\r\n]", "", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
|
||||
retval = Regex.Replace(retval, @"^\{(.*)\}$", "$1", RegexOptions.Singleline); // Strip Opening and Closing Braces
|
||||
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
|
||||
@ -1117,8 +1115,8 @@ namespace Volian.Controls.Library
|
||||
//if (itmInfo != null)
|
||||
// retval = StaticRemoveRtfStyles(retval, itmInfo);
|
||||
|
||||
retval = retval.Replace(@"(![", @"\{");
|
||||
retval = retval.Replace(@"(!]", @"\}");
|
||||
retval = retval.Replace(@" (![", @"\{");
|
||||
retval = retval.Replace(@" (!]", @"\}");
|
||||
retval = retval.TrimEnd(' ');
|
||||
|
||||
// the indent character was translated in the richtextbox, change it back:
|
||||
|
Loading…
x
Reference in New Issue
Block a user