예제 #1
0
 private bool TryGetSimpleTextNode(TextNode node, out string textvalue)
 {
     textvalue = null;
     bool issimple = ((node.Chunks.Count == 0) || ((node.Chunks.Count == 1) && (node.Chunks[0] is TextChunk)));
     if (issimple)
     {
         textvalue = "";
         if (node.Chunks.Count == 1)
             textvalue = (node.Chunks[0] as TextChunk).Text;
     }
     return issimple;
 }
예제 #2
0
 public override void Visit(TextNode node)
 {
     foreach(var chunk in node.Chunks)
         Visit(chunk);
 }
예제 #3
0
        private IEnumerable<AttributeNode> SortAndJoinAttributes(IEnumerable<AttributeNode> inputAttributes)
        {
            var queue = new List<AttributeNode>(inputAttributes);

            var attributes = new List<AttributeNode>();
            while (queue.Count > 0)
            {
                var first = queue[0];
                queue.RemoveAt(0);
                attributes.Add(first);

                var isId = first.Name.Equals("id", StringComparison.InvariantCultureIgnoreCase);

                var value = first.Value;
                if (value == null)
                {
                    value = new TextNode(new TextChunk(""));
                }

                var buf = new List<object> { Capture(value) };

                foreach (var sameAtt in queue.FindAll(a => a.Name == first.Name))
                {
                    queue.Remove(sameAtt);
                    buf.Add(Capture(sameAtt.Value));
                }

                first.Value = DataJoiner(isId ? "_" : " ", buf.ToArray(), !isId);
            }

            attributes.Sort((a1, a2) => a1.Name.CompareTo(a2.Name));

            return attributes;
        }
예제 #4
0
 public virtual void Visit(TextNode node)
 {
 }