Ejemplo n.º 1
0
        /* Function: HasAnyTag
         * Whether the passed block of text contains any Javadoc tags at all.
         */
        protected bool HasAnyTag(TokenIterator start, TokenIterator end)
        {
            string text     = start.Tokenizer.RawText;
            int    endIndex = end.RawTextIndex;

            int textIndex = text.IndexOf('@', start.RawTextIndex, endIndex - start.RawTextIndex);

            while (textIndex != -1)
            {
                start.NextByCharacters(textIndex - start.RawTextIndex);
                start.Next();

                if (textIndex > 0 && text[textIndex - 1] == '{')
                {
                    if (InlineTags.Contains(start.String))
                    {
                        return(true);
                    }
                }
                else
                {
                    if (BlockTags.Contains(start.String))
                    {
                        return(true);
                    }
                }

                textIndex = text.IndexOf('@', textIndex + 1, endIndex - (textIndex + 1));
            }

            return(false);
        }
Ejemplo n.º 2
0
        private static void Plain(StringBuilder builder, ref ToPlainTextState state, IEnumerable <XNode> nodes)
        {
            foreach (var node in nodes)
            {
                if (node is XElement)
                {
                    var element = (XElement)node;
                    var tag     = element.Name.LocalName.ToLower();

                    if (tag == "br")
                    {
                        builder.AppendLine();
                        state = ToPlainTextState.StartLine;
                    }
                    else if (NonVisibleTags.Contains(tag))
                    {
                    }
                    else if (InlineTags.Contains(tag))
                    {
                        Plain(builder, ref state, element.Nodes());
                    }
                    else
                    {
                        if (state != ToPlainTextState.StartLine)
                        {
                            builder.AppendLine();
                            state = ToPlainTextState.StartLine;
                        }

                        Plain(builder, ref state, element.Nodes());
                        if (state != ToPlainTextState.StartLine)
                        {
                            builder.AppendLine();
                            state = ToPlainTextState.StartLine;
                        }
                    }
                }
                else if (node is XText)
                {
                    var text = (XText)node;
                    Process(builder, ref state, text.Value.ToCharArray());
                }
            }
        }
Ejemplo n.º 3
0
        private static void Plain(StringBuilder builder, ref ToPlainTextState state, IEnumerable <HtmlAgilityPack.HtmlNode> nodes)
        {
            foreach (var node in nodes)
            {
                if (node is HtmlAgilityPack.HtmlTextNode)
                {
                    var text = (HtmlAgilityPack.HtmlTextNode)node;
                    Process(builder, ref state, HtmlAgilityPack.HtmlEntity.DeEntitize(text.Text).ToCharArray());
                }
                else
                {
                    var tag = node.Name.ToLower();

                    if (tag == "br")
                    {
                        builder.AppendLine();
                        state = ToPlainTextState.StartLine;
                    }
                    else if (NonVisibleTags.Contains(tag))
                    {
                    }
                    else if (InlineTags.Contains(tag))
                    {
                        Plain(builder, ref state, node.ChildNodes);
                    }
                    else
                    {
                        if (state != ToPlainTextState.StartLine)
                        {
                            builder.AppendLine();
                            state = ToPlainTextState.StartLine;
                        }

                        Plain(builder, ref state, node.ChildNodes);
                        if (state != ToPlainTextState.StartLine)
                        {
                            builder.AppendLine();
                            state = ToPlainTextState.StartLine;
                        }
                    }
                }
            }
        }