Ejemplo n.º 1
0
        public void Replay(IDocumentConsumer con)
        {
            int f = 0;

            for (int b = 0; b < blocks.Count; b++)
            {
            while (f < blocks[b].FragmentIndex)
            con.PushFragment(fragments[f++]);

            con.PushBlock(blocks[b].Content);
            }

            while (f < fragments.Count)
            con.PushFragment(fragments[f++]);

            con.Close();
        }
Ejemplo n.º 2
0
        public static void ParseStream(Stream s, IDocumentConsumer con)
        {
            var parser = new XHTMLParser(con);

            parser.Parse(s);
        }
Ejemplo n.º 3
0
 public XHTMLParser(IDocumentConsumer c)
 {
     consumer = c;
 }
Ejemplo n.º 4
0
        static void PrintEntry(TableOfContents toc,
			       IDocumentConsumer doc,
			       int ent, int depth, int depthLimit)
        {
            if ((depthLimit >= 0) && (depth > depthLimit))
            return;

            doc.PushBlock(new Block() {
            Indent = depth
            });

            doc.PushFragment(new Fragment() {
            Attr = Fragment.Attributes.Heading,
            Text = toc.GetName(ent),
            Linkref = toc.GetLinkref(ent)
            });

            for (int i = toc.FirstChild(ent); i >= 0; i = toc.NextSibling(i))
            PrintEntry(toc, doc, i, depth + 1, depthLimit);
        }
Ejemplo n.º 5
0
        public static void PrintToc(TableOfContents toc,
				    IDocumentConsumer doc,
				    int depthLimit = -1)
        {
            doc.PushBlock(new Block());
            doc.PushFragment(new Fragment() {
            Attr = Fragment.Attributes.Heading,
            Text = toc.Title
            });

            for (int i = toc.FirstRoot(); i >= 0; i = toc.NextSibling(i))
            PrintEntry(toc, doc, i, 0, depthLimit);

            doc.Close();
        }
Ejemplo n.º 6
0
        public void ProduceDocument(string path, IDocumentConsumer con)
        {
            path = EPath.GetPath(path);

            con = new NormalizeWhitespace(con);
            con = new ShiftLinks(path, con);

            using (Stream s = GetContent(path))
            XHTMLParser.ParseStream(s, con);
        }
Ejemplo n.º 7
0
        public void ProduceBook(IDocumentConsumer con)
        {
            for (int i = 0; i < Spine.Count; i++)
            {
            OPFManifest.Item item = Manifest.GetById(Spine[i]);
            IDocumentConsumer filter =
            new NamespaceAnchors(item.Linkref + "#", con);

            con.PushFragment(new Fragment() {
            Attr = Fragment.Attributes.AnchorName,
            Text = item.Linkref
            });

            ProduceDocument(item.Linkref, filter);
            }
        }
Ejemplo n.º 8
0
 public ShiftLinks(string p, IDocumentConsumer con)
 {
     basePath = p;
     next = con;
 }
Ejemplo n.º 9
0
        public ReflowParagraphs(IDocumentConsumer next,
				int tw = 79, int indent = 4)
        {
            consumer = next;
            targetWidth = tw;
            indentPerLevel = indent;
        }
Ejemplo n.º 10
0
 public NormalizeWhitespace(IDocumentConsumer next)
 {
     consumer = next;
 }
Ejemplo n.º 11
0
 public NamespaceAnchors(string p, IDocumentConsumer con)
 {
     basePath = p;
     next = con;
 }
Ejemplo n.º 12
0
 public IndentText(IDocumentConsumer next, int indent = 4)
 {
     consumer = next;
     indentPerLevel = indent;
 }