Work on spellcheck/tags - thx OmrSi :)

Work on #3183
This commit is contained in:
Nikolaj Olsson 2018-11-18 07:55:06 +01:00
parent bfbff43703
commit 9c582b4d74
2 changed files with 25 additions and 0 deletions

View File

@ -179,6 +179,30 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
return s;
}
public string ReplaceAssTagsWithBlanks(string s)
{
int start = s.IndexOf("{\\", StringComparison.Ordinal);
int end = s.IndexOf('}');
if (start < 0 || end < 0 || end < start)
{
return s;
}
while (start >= 0)
{
end = s.IndexOf('}', start + 1);
if (end < start)
break;
int l = end - start + 1;
s = s.Remove(start, l).Insert(start, string.Empty.PadLeft(l));
end++;
if (end >= s.Length)
break;
start = s.IndexOf("{\\", end, StringComparison.Ordinal);
}
return s;
}
public bool IsWordInUserPhrases(int index, List<SpellCheckWord> words)
{
string current = words[index].Text;

View File

@ -785,6 +785,7 @@ namespace Nikse.SubtitleEdit.Forms
private void SetWords(string s)
{
s = _spellCheckWordLists.ReplaceHtmlTagsWithBlanks(s);
s = _spellCheckWordLists.ReplaceAssTagsWithBlanks(s);
s = _spellCheckWordLists.ReplaceKnownWordsOrNamesWithBlanks(s);
_words = SpellCheckWordLists.Split(s);
}