This really gets the TOC working now. We auto-generate labels for the

paragraphs the TOC targets, and link to them.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32461 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-12-10 20:03:35 +00:00
parent 46e70895a9
commit e5afe8db66
4 changed files with 36 additions and 1 deletions

View File

@ -34,6 +34,12 @@ AddToHTMLPreamble
div.lyxtoc-4 { margin: 0em 0em 0em 1em; }
div.lyxtoc-5 { margin: 0em 0em 0em 1em; }
div.lyxtoc-6 { margin: 0em 0em 0em 1em; }
a.tocarrow {
font-weight: bold;
text-decoration: none;
color: #909090;
}
a.tocarrow:visited { color: #C0C0C0; }
</style>
EndPreamble

View File

@ -2404,6 +2404,15 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
std::string closing_tag;
Layout const & style = *d->layout_;
if (!fortoc
&& style.toclevel != Layout::NOT_IN_TOC
&& style.toclevel <= buf.params().tocdepth) {
// we need to generate a magic label for this paragraph
string const attr = "id='" + magicLabel() + "'";
xs << CompTag("a", attr);
}
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
@ -3141,4 +3150,12 @@ bool Paragraph::isMisspelled(pos_type pos) const
}
string Paragraph::magicLabel() const
{
stringstream ss;
ss << "magicparlabel-" << id();
return ss.str();
}
} // namespace lyx

View File

@ -424,6 +424,9 @@ public:
/// Spellcheck word at position \p pos.
/// \return true if pointed word is misspelled.
bool isMisspelled(pos_type pos) const;
/// an automatically generated identifying label for this paragraph.
/// presently used only in the XHTML output routines.
std::string magicLabel() const;
private:
///

View File

@ -119,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
@ -149,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");