public virtual void HandleAnchors() { if (!this.AnchorsHandled) { if (this.Anchors.Count > 0) { int counter = 0; this.Value = this.Transformer.AnchorsRegex.Replace(this.Value, delegate(Match m) { AnchorTag anchor = this.Anchors[counter++]; List <ItemTag> items = anchor.ReferenceItems; if (items.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); foreach (ItemTag item in items) { if (item.Anchors.Count > 0 && !item.AnchorsHandled) { item.HandleAnchors(); } sb.Append(item.Output); item.Handled = true; } string tpl = anchor.Template; return((tpl == null || tpl.Length == 0) ? sb.ToString() : anchor.GetTemplate(tpl).Apply(sb.ToString())); }); } this.AnchorsHandled = true; } }
public virtual void ParseAnchors() { if (this is INoneValuableToken) { return; } if (this.anchors == null) { this.anchors = new List <AnchorTag>(); string value = this.Value; if (!string.IsNullOrEmpty(value)) { MatchCollection matches = this.Transformer.AnchorsRegex.Matches(value); foreach (Match match in matches) { AnchorTag token = new AnchorTag(match, this); this.anchors.Add(token); token.Transformer = this.Transformer; if (this.Transformer != null) { //this.Parser.Tokens.Add(token); try { this.Transformer.TokensById.Add(token.ID, token); } catch (ArgumentException e) { throw new TokenNotUniqueException(token); } this.Transformer.Groups["anchor"].Add(token); } } } } }
public virtual void ParseAnchors() { if (this is INoneValuableToken) { return; } if (this.anchors == null) { this.anchors = new List<AnchorTag>(); string value = this.Value; if (!string.IsNullOrEmpty(value)) { MatchCollection matches = this.Transformer.AnchorsRegex.Matches(value); foreach (Match match in matches) { AnchorTag token = new AnchorTag(match, this); this.anchors.Add(token); token.Transformer = this.Transformer; if (this.Transformer != null) { //this.Parser.Tokens.Add(token); try { this.Transformer.TokensById.Add(token.ID, token); } catch (ArgumentException e) { throw new TokenNotUniqueException(token); } this.Transformer.Groups["anchor"].Add(token); } } } } }