public bool Equals(Substring theOther) { return (length == theOther.length ? string.Compare(source, start, theOther.source, theOther.start, length) == 0 : false); }
string FromPosition(Substring start) { var from = start.Truncate(current).ToString(); var result = new StringBuilder(); for (var index = 0; index < from.Length; index++) { if (index < from.Length - 1 && from[index] == '\\') index++; result.Append(from[index]); } return result.ToString(); }
static string GetTag(Substring theInput) { var tag = new StringBuilder(); int i = 0; if (theInput[0] == '/') tag.Append(theInput[i++]); while (i < theInput.Length && char.IsLetter(theInput[i])) { tag.Append(theInput[i++]); } return tag.ToString().ToLower(); }
static string GetTag(Substring theInput) { var current = theInput; var tag = new StringBuilder(); if (theInput[0] == '/') { tag.Append('/'); current = current.Skip(1); } while (!current.IsEmpty && char.IsLetter(current[0])) { tag.Append(current[0]); current = current.Skip(1); } return tag.ToString().ToLower(); }
public void MoveNext() { current = current.After; if (current.AtEnd) { return; } if (current.StartsWith("\\")) { Type = CharacterType.Letter; current = current.Skip(1).Truncate(1); } else if (current.StartsWith("[\n")) { Type = CharacterType.BeginCell; current = current.Truncate(2); } else if (current.StartsWith("\n]")) { Type = CharacterType.EndCell; current = current.Truncate(2); } else if (current.StartsWith("\n")) { Type = CharacterType.Newline; current = current.Truncate(1); } else if (current.StartsWith("\"") || current.StartsWith("'")) { Type = CharacterType.Quote; current = current.Truncate(1); } else if (current.StartsWith("|")) { Type = CharacterType.Separator; current = current.Truncate(1); } else if (current.StartsWith(TextStoryTestBegin, StringComparison.OrdinalIgnoreCase)) { Type = CharacterType.BeginTest; current = current.Truncate(5); } else if (current.StartsWith("@test", StringComparison.OrdinalIgnoreCase)) { Type = CharacterType.EndTest; current = current.Truncate(5); } else if (char.IsWhiteSpace(current[0])) { Type = CharacterType.WhiteSpace; current = current.Truncate(1); } else if (current.StartsWith("<br", StringComparison.OrdinalIgnoreCase) && current.Contains(">")) { Type = CharacterType.Newline; current = current.TruncateAfter(">"); } else { Type = CharacterType.Letter; current = current.Truncate(1); } }
public void Append(Substring theInput) { var current = theInput; while (!current.IsEmpty) { var input = current[0]; if (isStandard && input != '\u00a0' && char.IsWhiteSpace(input)) { if (!myWhitespace) { myText.Append(' '); myLastTag = myLastTag + " "; } myWhitespace = true; } else { switch (input) { case '\u201c': input = '"'; break; case '\u201d': input = '"'; break; case '\u2018': input = '\''; break; case '\u2019': input = '\''; break; case '\u00a0': input = ' '; break; case '&': if (current.ContainsAt(1, "nbsp;")) { input = ' '; current = current.Skip(5); } break; } myText.Append(input); myWhitespace = false; myLastTag = string.Empty; } current = current.Skip(1); } }
string FromPosition(Substring start) { var from = start.Truncate(current).ToString(); var result = new StringBuilder(); for (var index = 0; index < from.Length; index++) { if (index < from.Length - 1 && from[index] == '\\') { index++; } result.Append(from[index]); } return(result.ToString()); }
static string GetTag(Substring theInput) { var tag = new StringBuilder(); int i = 0; if (theInput[0] == '/') { tag.Append(theInput[i++]); } while (i < theInput.Length && char.IsLetter(theInput[i])) { tag.Append(theInput[i++]); } return(tag.ToString().ToLower()); }
public void Append(Substring theInput) { for (int i = 0; i < theInput.Length; i++) { char input = theInput[i]; if (isStandard && input != '\u00a0' && char.IsWhiteSpace(input)) { if (!myWhitespace) { myText.Append(' '); myLastTag = myLastTag + " "; } myWhitespace = true; } else { switch (input) { case '\u201c': input = '"'; break; case '\u201d': input = '"'; break; case '\u2018': input = '\''; break; case '\u2019': input = '\''; break; case '\u00a0': input = ' '; break; case '&': if (theInput.Contains(i + 1, "nbsp;")) { input = ' '; i += 5; } break; } myText.Append(input); myWhitespace = false; myLastTag = string.Empty; } } }
static string GetTag(Substring theInput) { var current = theInput; var tag = new StringBuilder(); if (theInput[0] == '/') { tag.Append('/'); current = current.Skip(1); } while (!current.IsEmpty && char.IsLetter(current[0])) { tag.Append(current[0]); current = current.Skip(1); } return(tag.ToString().ToLower()); }
public void FindTokenPair(string theFirstToken, string theSecondToken, TokenBodyFilter theFilter) { Leader = Substring.Empty; Body = Substring.Empty; Element = Substring.Empty; if (myPrevious >= myInput.Length) { return; } int first, second = 0; for (first = myPrevious; first < myInput.Length; first = second + theSecondToken.Length) { first = Find(myInput, theFirstToken, first); second = Find(myInput, theSecondToken, first + theFirstToken.Length + 1); if (second == myInput.Length) { first = second; break; } int body = first + theFirstToken.Length; if (second <= body) { continue; } Body = new Substring(myInput, body, second - body); Element = new Substring(myInput, first, second - first + theSecondToken.Length); if (theFilter(Body)) { break; } } if (first > myPrevious) { Leader = new Substring(myInput, myPrevious, first - myPrevious); } myPrevious = second + theSecondToken.Length; }
public Substring Truncate(Substring next) { return(new Substring(source, start, next.start - start)); }
public Substring Truncate(Substring next) { return new Substring(source, start, next.start - start); }
static bool FilterString(Substring theTokenBody) { return !ourFilterString.Equals(theTokenBody); }
public void FindTokenPairFilter(string theFirstToken, string theSecondToken, string theFilterString) { ourFilterString = new Substring(theFilterString); myScanner.FindTokenPair(theFirstToken, theSecondToken, ourFilter); }
static bool NullTokenBodyFilter(Substring theTokenBody) { return(true); }
static bool IsValidTag(Substring theBody) { return(theBody[0] == '/' || char.IsLetter(theBody[0])); }
public Characters(string input) { current = new Substring(input.Replace("\r", string.Empty), 0, 0); MoveNext(); }
static bool IsValidTag(Substring theBody) { return theBody[0] == '/' || char.IsLetter(theBody[0]); }