Пример #1
0
        private void AddImage(InlineCollection inlines, HtmlTagLexeme tagLexeme, string navigationUri)
        {
            var src = tagLexeme.Attributes["src"];

            if (src.StartsWith("https://www.inoreader.com/b/", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            AddImage(inlines, src, navigationUri);
        }
Пример #2
0
        private void TryAddYoutubeVideo(HtmlTagLexeme tagLexeme, InlineCollection inlines)
        {
            if (String.Equals(tagLexeme.Name, "iframe", StringComparison.OrdinalIgnoreCase))
            {
                string videoLink;
                if (!tagLexeme.Attributes.TryGetValue("src", out videoLink))
                {
                    return;
                }

                AddYoutubeLink(videoLink, inlines);
                return;
            }

            if (String.Equals(tagLexeme.Name, "object", StringComparison.OrdinalIgnoreCase))
            {
                string videoLink;
                if (!tagLexeme.Attributes.TryGetValue("data", out videoLink))
                {
                    return;
                }

                AddYoutubeLink(videoLink, inlines);
                return;
            }

            if (String.Equals(tagLexeme.Name, "embed", StringComparison.OrdinalIgnoreCase))
            {
                string videoLink;
                if (!tagLexeme.Attributes.TryGetValue("src", out videoLink))
                {
                    return;
                }

                AddYoutubeLink(videoLink, inlines);
            }
        }
Пример #3
0
        private HtmlTagLexeme GetHtmlTag(string token)
        {
            var tag = new HtmlTagLexeme();

            tag.IsOpen  = token[1] != '/';
            tag.IsClose = token[1] == '/' || token[token.Length - 2] == '/';

            var spacePos = token.IndexOf(' ');

            if (spacePos != -1)
            {
                tag.Name = token.Substring(1, spacePos - 1);

                var searchAttrStartPos = spacePos;

                //<a href="http://channel9.msdn.com/Shows/This+Week+On+Channel+9/TWC9-NET-Core-OSS-Update-CoreCLR-on-GitHub-Windows-10-for-Raspberry-Pi-2-Super-Bowl-Stories-and-more#time=1m06s">
                //<img src="https://www.inoreader.com/b/1438160281/1008166777" style="position: absolute; visibility: hidden">

                while (true)
                {
                    var eqPos = token.IndexOf('=', searchAttrStartPos + 1);
                    if (eqPos != -1)
                    {
                        var attrName  = token.Substring(searchAttrStartPos + 1, eqPos - searchAttrStartPos - 1).Trim();
                        var quoteSymb = token[eqPos + 1];

                        var endQuotePos = token.IndexOf(quoteSymb, eqPos + 2);
                        if (endQuotePos != -1)
                        {
                            var attrValue = token.Substring(eqPos + 2, endQuotePos - eqPos - 2);
                            tag.Attributes[attrName] = attrValue;

                            searchAttrStartPos = endQuotePos + 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                if (tag.IsOpen && !tag.IsClose)
                {
                    tag.Name = token.Substring(1, token.Length - 2);
                }
                else
                {
                    if (!tag.IsOpen && tag.IsClose)
                    {
                        tag.Name = token.Substring(2, token.Length - 3);
                    }
                }
            }

            return(tag);
        }
Пример #4
0
        private HtmlTagLexeme GetHtmlTag(string token)
        {
            var tag = new HtmlTagLexeme();

            tag.IsOpen = token[1] != '/';
            tag.IsClose = token[1] == '/' || token[token.Length - 2] == '/';

            var spacePos = token.IndexOf(' ');
            if (spacePos != -1)
            {
                tag.Name = token.Substring(1, spacePos - 1);

                var searchAttrStartPos = spacePos;

                //<a href="http://channel9.msdn.com/Shows/This+Week+On+Channel+9/TWC9-NET-Core-OSS-Update-CoreCLR-on-GitHub-Windows-10-for-Raspberry-Pi-2-Super-Bowl-Stories-and-more#time=1m06s">
                //<img src="https://www.inoreader.com/b/1438160281/1008166777" style="position: absolute; visibility: hidden">

                while (true)
                {
                    var eqPos = token.IndexOf('=', searchAttrStartPos + 1);
                    if (eqPos != -1)
                    {
                        var attrName = token.Substring(searchAttrStartPos + 1, eqPos - searchAttrStartPos - 1).Trim();
                        var quoteSymb = token[eqPos + 1];

                        var endQuotePos = token.IndexOf(quoteSymb, eqPos + 2);
                        if (endQuotePos != -1)
                        {
                            var attrValue = token.Substring(eqPos + 2, endQuotePos - eqPos - 2);
                            tag.Attributes[attrName] = attrValue;

                            searchAttrStartPos = endQuotePos + 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                if (tag.IsOpen && !tag.IsClose)
                {
                    tag.Name = token.Substring(1, token.Length - 2);
                }
                else
                {
                    if (!tag.IsOpen && tag.IsClose)
                    {
                        tag.Name = token.Substring(2, token.Length - 3);
                    }
                }
            }

            return tag;
        }