]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTOC.cpp
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetTOC.cpp
index 9f20ee5675a30d9b4bc9a726eedb87fe72fd6917..84b5d6a38efda919f95e9b833706e53b054195d7 100644 (file)
@@ -91,9 +91,10 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
 
        xs << StartTag("div", "class='toc'");
 
-       // we want to figure out look like a chapter, section, or whatever.
+       // we want to look like a chapter, section, or whatever.
        // so we're going to look for the layout with the minimum toclevel
-       // number. we'll take the first one, just because.
+       // number > 0, because we don't want Part. 
+       // we'll take the first one, just because.
        DocumentClass const & dc = buffer().params().documentClass();
        TextClass::LayoutList::const_iterator lit = dc.begin();
        TextClass::LayoutList::const_iterator len = dc.end();
@@ -101,14 +102,14 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
        Layout const * lay = NULL;
        for (; lit != len; ++lit) {
                int const level = lit->toclevel;
-               if (level == Layout::NOT_IN_TOC || level >= minlevel)
+               if (level > 0 && (level == Layout::NOT_IN_TOC || level >= minlevel))
                        continue;
                lay = &*lit;
                minlevel = level;
        }
        
-       string const tocclass = lay ? lay->defaultCSSClass() + " ": "";
-       string const tocattr = "class='" + tocclass + "tochead'";
+       string const tocclass = lay ? " " + lay->defaultCSSClass(): "";
+       string const tocattr = "class='tochead" + tocclass + "'";
        
        xs << StartTag("div", tocattr) 
           << _("Table of Contents") 
@@ -118,8 +119,10 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
        int lastdepth = 0;
        for (; it != en; ++it) {
                Paragraph const & par = it->dit().innerParagraph();
-               Font const dummy;
                int const depth = it->depth();
+               if (depth > buffer().params().tocdepth)
+                       continue;
+               Font const dummy;
                if (depth > lastdepth) {
                        xs.cr();
                        // open as many tags as we need to open to get to this level
@@ -148,7 +151,14 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
                        attr << "class='lyxtoc-" << depth << "'";
                        xs << StartTag("div", attr.str());
                }
+               string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
                par.simpleLyXHTMLOnePar(buffer(), xs, op, dummy, true);
+               xs << " ";
+               xs << StartTag("a", parattr);
+               // FIXME XHTML 
+               // There ought to be a simple way to customize this.
+               xs << XHTMLStream::NextRaw() << "&seArr;";
+               xs << EndTag("a");              
        }
        for (int i = lastdepth; i > 0; --i) 
                xs << EndTag("div");
@@ -157,15 +167,4 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
 }
 
 
-void InsetTOC::validate(LaTeXFeatures & features) const
-{
-       if (features.runparams().flavor != OutputParams::HTML)
-               return;
-       features.addPreambleSnippet("<style type=\"text/css\">\n"
-                       "div.lyxtoc-1 { margin-left: 2em; text-indent: -2em; }\n"
-                       "span.bibtexlabel:before{ content: \"[\"; }\n"
-                       "span.bibtexlabel:after{ content: \"] \"; }\n"
-                       "</style>");
-}
-
 } // namespace lyx