コード例 #1
0
        private CSS GetCss()
        {
            var sheet = new CSS();

            sheet.Analyze(DefaultEpubCss);

            var hrefs = _opfRoot
                        .Elements(_opfns + "manifest")
                        .Elements(_opfns + "item")
                        .Where(e =>
            {
                var mediaType = e.Attribute("media-type");
                return(mediaType != null && mediaType.Value == "text/css");
            })
                        .Attributes("href").Select(h => h.Value);

            foreach (var href in hrefs)
            {
                Stream stream = _zip.GetFileStream(_opfPath + href, false, true);
                if (stream != null)
                {
                    sheet.Analyze(new StreamReader(stream).ReadToEnd());
                }
            }
            return(sheet);
        }
コード例 #2
0
        private CSS GetCss()
        {
            CSS sheet = new CSS();

            sheet.Analyze(DefaultFb2Css);
            return(sheet);
        }
コード例 #3
0
        public override IEnumerable <TokenBase> GetTokens()
        {
            _css = new CSS();

            var html = new HtmlDocument
            {
                OptionOutputAsXml  = true,
                OptionReadEncoding = false
            };

            html.Load(_reader);
            var root = html.DocumentNode.SelectSingleNode("//body");

            var cssNode = html.DocumentNode.SelectSingleNode("//style");

            if (cssNode != null)
            {
                _css.Analyze(cssNode.InnerText);
            }

            var stack = new Stack <TextVisualProperties>();
            var item  = new TextVisualProperties();

            stack.Push(item);

            return(ParseTokens(root, stack, new TokenIndex()));
        }