예제 #1
0
        public IAbstractMarkupData CreateTagPair(string tagId, string tagContent)
        {
            var tagName = GetStartTagName(tagContent, out var refId);

            var startTagProperties = _propertiesFactory.CreateStartTagProperties(tagContent);

            if (ExistingTagPairIds.Contains(startTagProperties.TagId.Id))
            {
                if (!ExistingTagPairIds.Contains(tagId))
                {
                    startTagProperties.TagId = new TagId(tagId);
                }
                else
                {
                    startTagProperties.TagId = new TagId(GetUniqueTagPairId());
                }
            }

            if (!ExistingTagPairIds.Contains(startTagProperties.TagId.Id))
            {
                ExistingTagPairIds.Add(startTagProperties.TagId.Id);
            }

            var endTagProperties = _propertiesFactory.CreateEndTagProperties("</" + tagName + ">");

            //TODO formatting example
            //var xItem = _formattingFactory.CreateFormattingItem("italic", "True");
            //x.Formatting = _formattingFactory.CreateFormatting();
            //x.Formatting.Add(xItem);

            var tagPair = _factory.CreateTagPair(startTagProperties, endTagProperties);

            return(tagPair);
        }
예제 #2
0
        private string GetUniqueTagPairId()
        {
            var id = 1;

            while (ExistingTagPairIds.Contains(id.ToString()))
            {
                id++;
            }

            return(id.ToString());
        }