Example #1
0
        private void GetFullText(ITagPair tagPair, StringBuilder stringBuilder)
        {
            var startTag = tagPair.StartTagProperties.TagContent;

            stringBuilder.Append(startTag);

            foreach (var item in tagPair.AllSubItems)
            {
                // Make sure we do not add content of container nodes
                if (object.ReferenceEquals(item.Parent, tagPair))
                {
                    if (item is IText)
                    {
                        var txt = ((IText)item).Properties.Text;
                        stringBuilder.Append(txt);
                    }
                    else if (item is IPlaceholderTag)
                    {
                        var tag = ((IPlaceholderTag)item).TagProperties.TagContent;
                        stringBuilder.Append(tag);
                    }
                    else if (item is ITagPair)
                    {
                        GetFullText((ITagPair)item, stringBuilder);
                    }
                }
            }

            var endTag = tagPair.EndTagProperties.TagContent;

            stringBuilder.Append(endTag);
        }
Example #2
0
 public override void VisitTagPair(ITagPair tagPair)
 {
     // don't count characters for tag pairs
     if (isCheckTags)
     {
         VisitChildren(tagPair);
     }
 }
Example #3
0
        public void VisitTagPair(ITagPair tagPair)
        {
            if ((ElementTypeToSearch == Token.TokenType.TagOpen || ElementTypeToSearch == Token.TokenType.TagClose) && tagPair.TagProperties.TagId.Id == ElementIdToSearch)
            {
                FoundElement = tagPair;
            }

            VisitChildren(tagPair);
        }
Example #4
0
        public void VisitTagPair(ITagPair tagPair)
        {
            if (IncludeTagText)
            {
                TagUnits.Add(new TagUnit(tagPair.TagProperties.TagId.Id, tagPair.TagProperties.DisplayText, tagPair.StartTagProperties.TagContent, TagUnit.TagUnitState.IsOpening, TagUnit.TagUnitType.IsTag));

                SegmentSections.Add(IsRevisionMarker
                    ? new SegmentSection(SegmentSection.ContentType.Tag, tagPair.TagProperties.TagId.Id,
                                         tagPair.StartTagProperties.TagContent, RevisionMarker)
                    : new SegmentSection(SegmentSection.ContentType.Tag, tagPair.TagProperties.TagId.Id,
                                         tagPair.StartTagProperties.TagContent));


                PlainText.Append(tagPair.StartTagProperties.TagContent);
            }

            var tgStart = new Sdl.LanguagePlatform.Core.Tag
            {
                Type           = Sdl.LanguagePlatform.Core.TagType.Start,
                Anchor         = TagCounter,
                TagID          = tagPair.StartTagProperties.TagId.Id,
                TextEquivalent = tagPair.StartTagProperties.DisplayText
            };


            Segment.Add(tgStart);



            VisitChildren(tagPair);



            var tgEnd = new Sdl.LanguagePlatform.Core.Tag
            {
                Type           = Sdl.LanguagePlatform.Core.TagType.End,
                TagID          = tagPair.StartTagProperties.TagId.Id,
                Anchor         = TagCounter,
                TextEquivalent = tagPair.EndTagProperties.DisplayText
            };

            Segment.Add(tgEnd);

            if (IncludeTagText)
            {
                TagUnits.Add(new TagUnit(tagPair.TagProperties.TagId.Id, string.Empty, tagPair.EndTagProperties.TagContent, TagUnit.TagUnitState.IsClosing, TagUnit.TagUnitType.IsTag));

                SegmentSections.Add(IsRevisionMarker
                    ? new SegmentSection(SegmentSection.ContentType.TagClosing,
                                         tagPair.TagProperties.TagId.Id, tagPair.EndTagProperties.TagContent, RevisionMarker)
                    : new SegmentSection(SegmentSection.ContentType.TagClosing,
                                         tagPair.TagProperties.TagId.Id, tagPair.EndTagProperties.TagContent));

                PlainText.Append(tagPair.EndTagProperties.TagContent);
            }
            TagCounter++;
        }
Example #5
0
        public void VisitTagPair(ITagPair tagPair)
        {
            var newTagPair = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);

            _currentContainer.Add(newTagPair);
            _currentContainer = newTagPair;

            VisitChildElements(tagPair);

            _currentContainer = newTagPair.Parent;
        }
        public void VisitTagPair(ITagPair tagPair)
        {
            var newTagPair = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);
            TagToOriginalText(tagPair.StartTagProperties);

            _currentContainer.Add(newTagPair);
            _currentContainer = newTagPair;
            VisitChildElements(tagPair);

            TagToOriginalText(tagPair.EndTagProperties);
            _currentContainer = newTagPair.Parent;
        }
 public void VisitTagPair(ITagPair tagPair)
 {
     if (_detailLevel == DetailLevel.JustText)
     {
         VisitChildren(tagPair);
     }
     if (_detailLevel == DetailLevel.JustTagContent)
     {
         _textBuilder.Append(tagPair.TagProperties.TagContent);
         VisitChildren(tagPair);
     }
 }
        public void VisitTagPair(ITagPair tagPair)
        {
            Tags.Add(new TagData(tagPair.StartTagProperties.TagId.Id,
                                 PlainText.Length,
                                 tagPair.StartTagProperties.TagContent));

            VisitChildren(tagPair);

            Tags.Add(new TagData(string.Empty,
                                 PlainText.Length,
                                 tagPair.EndTagProperties.TagContent));
        }
        public void VisitTagPair(ITagPair tagPair)
        {
            var tagPair2 = _itemFactory.CreateTagPair(tagPair.StartTagProperties, tagPair.EndTagProperties);

            _currentContainer.Add(tagPair2);
            _currentContainer = tagPair2;
            foreach (var current in tagPair)
            {
                current.AcceptVisitor(this);
            }
            _currentContainer = tagPair2.Parent;
        }
Example #10
0
        public void VisitTagPair(ITagPair tagPair)
        {
            if (_element is ElementTagPair elementTagPair)
            {
                if (elementTagPair.Type == Element.TagType.OpeningTag || elementTagPair.Type == Element.TagType.ClosingTag &&
                    tagPair.TagProperties.TagId.Id == _elementIdToSearch)
                {
                    FoundElement = tagPair;
                }

                VisitChildren(tagPair);
            }
        }
        public void VisitTagPair(ITagPair tagPair)
        {
            if (IncludeTagText)
            {
                PlainText.Append(tagPair.StartTagProperties.TagContent);
            }

            VisitChildren(tagPair);

            if (IncludeTagText)
            {
                PlainText.Append(tagPair.EndTagProperties.TagContent);
            }
        }
Example #12
0
        private void CreateNewFormatting(HtmlNode node, ITagPair tagPair)
        {
            if (node.Name == "cf" && node.HasAttributes)
            {
                var formattingGroup = CreateFormattingGroup();

                foreach (var attrib in node.Attributes)
                {
                    formattingGroup.Add(CreateFormattingItem(attrib.OriginalName, attrib.Value));
                }

                tagPair.StartTagProperties.Formatting = formattingGroup;
            }
        }
Example #13
0
 private void AddOpenTagContainer(ContentMatch match)
 {
     if (match.MatchRule.IsContentTranslatable)
     {
         ITagPair tagPair = CreateTagPair(match);
         _currentContainer.Add(tagPair);
         _currentContainer = tagPair;
     }
     else
     {
         //treat non-translatable content as locked
         ILockedContent lockedContent = CreateLockedContent();
         _currentContainer.Add(lockedContent);
         _currentContainer = lockedContent.Content;
     }
 }
 public void VisitTagPair(ITagPair tagPair)
 {
     PlainText.Append("<" + tagPair.StartTagProperties.TagContent + ">");
     VisitChildren(tagPair);
     PlainText.Append("</" + tagPair.EndTagProperties.TagContent + ">");
 }  
 public void VisitTagPair(ITagPair tagPair)
 {
     _tokens.Add(new Token(tagPair.StartTagProperties.TagId.Id, Token.TokenType.TagOpen));
     VisitChildren(tagPair);
     _tokens.Add(new Token(tagPair.StartTagProperties.TagId.Id, Token.TokenType.TagClose));
 }
 public void VisitTagPair(ITagPair tagPair)
 {
     //Tag content is ignored only visit children
     VisitChildren(tagPair);
 }