From 5e8d08cb9e56dfee0681ffbb532179a5f0bbaf41 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 11 Jun 2009 20:08:39 +0000 Subject: [PATCH] Get InsetBibitem working, and the output for LATEX_BIB_ENVIRONMENT. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30045 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/HTML/HTML.notes | 4 ++++ lib/layouts/stdstruct.inc | 2 ++ src/insets/InsetBibitem.cpp | 10 ++++++++- src/insets/InsetBibitem.h | 2 ++ src/insets/InsetText.cpp | 2 +- src/output_xhtml.cpp | 41 ++++++++++++++++++++++++++++++------- src/output_xhtml.h | 2 ++ 7 files changed, 54 insertions(+), 9 deletions(-) diff --git a/development/HTML/HTML.notes b/development/HTML/HTML.notes index a183023804..6e81421213 100644 --- a/development/HTML/HTML.notes +++ b/development/HTML/HTML.notes @@ -23,6 +23,10 @@ These insets work but still need work: These insets do not work but should be completely straightforward: Caption, Flex (uses collapsable) + +May need to make use here of TocWidget::itemInset, which should then be moved +to TocBackend. + These do not yet work and need some attention: InsetBibitem: Should be fairly straightforward, in itself, actually. InsetBibtex: We should be able to collect the keys of references in diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc index 28197760c1..5c61391998 100644 --- a/lib/layouts/stdstruct.inc +++ b/lib/layouts/stdstruct.inc @@ -57,4 +57,6 @@ Style Bibliography Series Bold Size Larger EndFont + HTMLTag p + HTMLAttr class='bibliography' End diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 554eb57411..3a0851f8f1 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -24,6 +24,7 @@ #include "InsetIterator.h" #include "InsetList.h" #include "Lexer.h" +#include "output_xhtml.h" #include "Paragraph.h" #include "ParagraphList.h" #include "TextClass.h" @@ -251,7 +252,7 @@ void InsetBibitem::fillWithBibKeys(BiblioInfo & keys, InsetIterator const & it) } -/// Update the counters of this inset and of its contents +// Update the counters of this inset and of its contents void InsetBibitem::updateLabels(ParIterator const &) { Counters & counters = buffer().masterBuffer()->params().documentClass().counters(); @@ -265,4 +266,11 @@ void InsetBibitem::updateLabels(ParIterator const &) } +int InsetBibitem::xhtml(odocstream & os, OutputParams const &) const +{ + os << ""; + os << "" << bibLabel() << " "; +} + + } // namespace lyx diff --git a/src/insets/InsetBibitem.h b/src/insets/InsetBibitem.h index ca5559ce42..4850f73a1f 100644 --- a/src/insets/InsetBibitem.h +++ b/src/insets/InsetBibitem.h @@ -61,6 +61,8 @@ private: /// int plaintext(odocstream &, OutputParams const &) const; /// + int xhtml(odocstream &, OutputParams const &) const; + /// virtual void fillWithBibKeys(BiblioInfo &, InsetIterator const &) const; /// Update the counter of this inset virtual void updateLabels(ParIterator const &); diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 0fc3a9a0da..c991f31501 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -547,7 +547,7 @@ void InsetText::addToToc(DocIterator const & cdit) break; } } - /// now the toc entry for the paragraph + // now the toc entry for the paragraph int const toclevel = par.layout().toclevel; if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) { dit.pos() = 0; diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 62a5ee8046..d008bc0eab 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -65,6 +65,11 @@ docstring escapeChar(char_type c) } +// FIXME do something here. +docstring htmlize(docstring const & str) { + return str; +} + // FIXME This needs to be protected somehow. static vector taglist; @@ -212,6 +217,22 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf, } +ParagraphList::const_iterator makeBibliography(Buffer const & buf, + odocstream & os, + OutputParams const & runparams, + ParagraphList const & paragraphs, + ParagraphList::const_iterator const & pbegin, + ParagraphList::const_iterator const & pend) +{ + os << "
\n" + << "

" + << pbegin->layout().labelstring() + << "

\n"; + makeParagraphs(buf, os, runparams, paragraphs, pbegin, pend); + return pend; +} + + ParagraphList::const_iterator makeEnvironment(Buffer const & buf, odocstream & os, OutputParams const & runparams, @@ -310,8 +331,13 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, send = searchParagraph(par, pend); par = makeParagraphs(buf, os, runparams, paragraphs, par, send); break; - // FIXME + // Shouldn't happen case LATEX_BIB_ENVIRONMENT: + send = par; + ++send; + par = makeParagraphs(buf, os, runparams, paragraphs, par, send); + break; + // Shouldn't happen case LATEX_COMMAND: ++par; break; @@ -385,16 +411,17 @@ void xhtmlParagraphs(ParagraphList const & paragraphs, case LATEX_LIST_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: { send = searchEnvironment(par, pend); - par = makeEnvironment(buf, os, runparams, paragraphs, par,send); + par = makeEnvironment(buf, os, runparams, paragraphs, par, send); + break; + } + case LATEX_BIB_ENVIRONMENT: { + send = searchEnvironment(par, pend); + par = makeBibliography(buf, os, runparams, paragraphs, par, send); break; } case LATEX_PARAGRAPH: send = searchParagraph(par, pend); - par = makeParagraphs(buf, os, runparams, paragraphs, par,send); - break; - case LATEX_BIB_ENVIRONMENT: - // FIXME - ++par; + par = makeParagraphs(buf, os, runparams, paragraphs, par, send); break; } // FIXME?? diff --git a/src/output_xhtml.h b/src/output_xhtml.h index 529eca9274..6ebb018f59 100644 --- a/src/output_xhtml.h +++ b/src/output_xhtml.h @@ -29,6 +29,8 @@ void xhtmlParagraphs(ParagraphList const & subset, namespace html { /// docstring escapeChar(char_type c); + /// converts a string to a form safe for links, etc + docstring htmlize(docstring const & str); /// \return true if tag was opened, false if not bool openTag(odocstream & os, std::string const & tag, std::string const & attr);