예제 #1
0
        // ========================================
        // method
        // ========================================
        public IEnumerable <object> ParseCFHtml(string cfHtml)
        {
            _result = new List <object>();

            _contexts = new Stack <ParserContext>();
            _source   = ClipboardUtil.GetHtmlSourceUrl(cfHtml);

            var html = Sanitize(cfHtml);

            var doc = new HtmlDocument();

            doc.LoadHtml(html);
            var node = doc.DocumentNode;

            var bodies = doc.DocumentNode.SelectNodes(@"//html/body");

            if (bodies == null || bodies.Count == 0)
            {
                return(_result);
            }
            var body = bodies[0];

            ParseFlows(body);

            if (_currentParagraph != null)
            {
                /// Blockに囲まれていないInlineで終わった場合
                if (!_currentParagraph.IsEmpty)
                {
                    if (_currentStyledText == null)
                    {
                        _currentStyledText = CreateStyledText(_currentParagraph);
                    }
                    else
                    {
                        _currentStyledText.Add(_currentParagraph);
                    }
                }
                _currentParagraph = null;
            }

            if (_currentStyledText != null)
            {
                _result.Add(_currentStyledText);
            }

            return(_result);
        }