Fix ReplaceWords so that it doesn't replace link tokens.

This commit is contained in:
Rich 2014-10-21 04:43:55 +00:00
parent f50fda89ff
commit 5e33d7ec2a

View File

@ -1973,7 +1973,7 @@ namespace Volian.Controls.Library
{ {
if (foundMatch.MyWord != null) if (foundMatch.MyWord != null)
{ {
if (VerifyNoHardSpace(text, foundMatch, offset)) if (VerifyNoHardSpace(text, foundMatch, offset) && VerifyNoLink(text, foundMatch, offset))
{ {
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}")) //if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
//{ //{
@ -2033,6 +2033,14 @@ namespace Volian.Controls.Library
} }
return text; return text;
} }
private bool VerifyNoLink(string text, FoundMatch fndMatch, int offset)
{
if (text.Substring(offset + fndMatch.MyMatch.Index, fndMatch.MyMatch.Length) == "START")
if (fndMatch.MyMatch.Index > 0 && offset + fndMatch.MyMatch.Index + fndMatch.MyMatch.Length < text.Length &&
text.Substring(offset + fndMatch.MyMatch.Index - 1, fndMatch.MyMatch.Length + 2) == "<START]")
return false;
return true;
}
internal static bool DiffUnit(string unit,ItemInfo myItemInfo,string prefix) internal static bool DiffUnit(string unit,ItemInfo myItemInfo,string prefix)
{ {
if (unit.StartsWith(prefix)) if (unit.StartsWith(prefix))