/// <summary>
 /// Override this message to change the parsing of spans.
 /// </summary>
 /// <param name="spanBegin">The span begin.</param>
 /// <param name="document">The document.</param>
 /// <param name="words">The words.</param>
 /// <param name="span">The span.</param>
 /// <param name="lineOffset">The line offset.</param>
 /// <returns>
 /// <c>true</c> if this method has parsed the span (customized parsing).
 /// <c>false</c> to parse the span as normal.
 /// </returns>
 protected virtual bool OverrideSpan(string spanBegin, IDocument document, List<TextWord> words, Span span, ref int lineOffset)
 {
     return false;
 }
 /// <summary>
 /// Gets the rule set for a span.
 /// </summary>
 /// <param name="span">The span.</param>
 /// <returns>The rule set.</returns>
 public HighlightRuleSet GetRuleSet(Span span)
 {
     if (span == null)
       {
     return _defaultRuleSet;
       }
       else
       {
     if (span.RuleSet != null)
     {
       if (span.RuleSet.Reference != null)
     return span.RuleSet.Highlighter.GetRuleSet(null);
       else
     return span.RuleSet;
     }
     else
     {
       return null;
     }
       }
 }
 void UpdateSpanStateVariables()
 {
   inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty);
   activeSpan = inSpan ? currentSpanStack.Peek() : null;
   activeRuleSet = GetRuleSet(activeSpan);
 }
 void UpdateSpanCountryVariables()
 {
     _inSpan = (_currentSpanStack != null && !_currentSpanStack.IsEmpty);
       _activeSpan = _inSpan ? _currentSpanStack.Peek() : null;
       _activeRuleSet = GetRuleSet(_activeSpan);
 }
    /// <summary>
    /// Initializes a new instance of the <see cref="TextWord"/> class.
    /// </summary>
    /// <param name="document">The document.</param>
    /// <param name="span">The <see cref="Span"/>.</param>
    /// <param name="line">The line.</param>
    /// <param name="offset">The offset.</param>
    /// <param name="length">The length.</param>
    /// <param name="color">The color.</param>
    /// <param name="hasDefaultColor">if set to <c>true</c> [has default color].</param>
    public TextWord(IDocument document, Span span, LineSegment line, int offset, int length, HighlightColor color, bool hasDefaultColor)
    {
      Debug.Assert(document != null);
      Debug.Assert(line != null);
      Debug.Assert(color != null);

      this.document = document;
      _span = span;
      this.line = line;
      this.offset = offset;
      this.length = length;
      this.color = color;
      this.hasDefaultColor = hasDefaultColor;
    }