#include "buffer_funcs.h"
#include "BufferParams.h"
#include "Counters.h"
+#include "Font.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"
#include "Text.h"
#include "TextClass.h"
-#include "support/lassert.h"
+#include "support/convert.h"
#include "support/debug.h"
+#include "support/lassert.h"
#include "support/lstrings.h"
#include <vector>
{
return s == "em" || s == "strong"; // others?
}
-} // namespace html
docstring StartTag::asTag() const
return from_utf8(output);
}
+} // namespace html
+
+
////////////////////////////////////////////////////////////////
///
if (tag_stack_.empty())
return true;
// first, we close any open font tags we can close
- StartTag curtag = tag_stack_.back();
+ html::StartTag curtag = tag_stack_.back();
while (html::isFontTag(curtag.tag_)) {
os_ << curtag.asEndTag();
tag_stack_.pop_back();
bool noFontTags = true;
for (; it != en; ++it) {
if (html::isFontTag(it->tag_)) {
- writeError("Font tag `" + it->tag_ + "' still open in closeFontTags().");
+ writeError("Font tag `" + it->tag_ + "' still open in closeFontTags().\n"
+ "This is likely not a problem, but you might want to check.");
noFontTags = false;
}
}
void XHTMLStream::clearTagDeque()
{
while (!pending_tags_.empty()) {
- StartTag const & tag = pending_tags_.front();
+ html::StartTag const & tag = pending_tags_.front();
// tabs?
os_ << tag.asTag();
- cr();
tag_stack_.push_back(tag);
pending_tags_.pop_front();
}
}
+XHTMLStream & XHTMLStream::operator<<(int i)
+{
+ clearTagDeque();
+ os_ << i;
+ nextraw_ = false;
+ return *this;
+}
+
+
XHTMLStream & XHTMLStream::operator<<(NextRaw const &)
{
nextraw_ = true;
}
-XHTMLStream & XHTMLStream::operator<<(StartTag const & tag)
+XHTMLStream & XHTMLStream::operator<<(html::StartTag const & tag)
{
if (tag.tag_.empty())
return *this;
}
-XHTMLStream & XHTMLStream::operator<<(CompTag const & tag)
+XHTMLStream & XHTMLStream::operator<<(html::CompTag const & tag)
{
if (tag.tag_.empty())
return *this;
TagStack::const_iterator sit = tag_stack_.begin();
TagStack::const_iterator const sen = tag_stack_.end();
for (; sit != sen; ++sit)
- // we could check for the
if (sit->tag_ == stag)
return true;
return false;
// sure of that, but we won't assert (yet) if we run into
// a problem. we'll just output error messages and try our
// best to make things work.
-XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
+XHTMLStream & XHTMLStream::operator<<(html::EndTag const & etag)
{
if (etag.tag_.empty())
return *this;
+
+ // make sure there are tags to be closed
+ if (tag_stack_.empty()) {
+ writeError("Tried to close `" + etag.tag_
+ + "' when no tags were open!");
+ return *this;
+ }
+
// first make sure we're not closing an empty tag
if (!pending_tags_.empty()) {
- StartTag const & stag = pending_tags_.back();
+ html::StartTag const & stag = pending_tags_.back();
if (etag.tag_ == stag.tag_) {
// we have <tag></tag>, so we discard it and remove it
// from the pending_tags_.
if (etag.tag_ == tag_stack_.back().tag_) {
// output it...
os_ << etag.asEndTag();
- cr();
// ...and forget about it
tag_stack_.pop_back();
return *this;
// and are being asked to closed em. we want:
// <em>this is <strong>bold</strong></em><strong>
// first, we close the intervening tags...
- StartTag curtag = tag_stack_.back();
+ html::StartTag curtag = tag_stack_.back();
// ...remembering them in a stack.
TagStack fontstack;
while (curtag.tag_ != etag.tag_) {
os_ << curtag.asEndTag();
- cr();
fontstack.push_back(curtag);
tag_stack_.pop_back();
curtag = tag_stack_.back();
}
// now close our tag...
os_ << etag.asEndTag();
- cr();
tag_stack_.pop_back();
// ...and restore the other tags.
// at least guarantees proper nesting.
writeError("Closing tag `" + etag.tag_
+ "' when other tags are open, namely:");
- StartTag curtag = tag_stack_.back();
+ html::StartTag curtag = tag_stack_.back();
while (curtag.tag_ != etag.tag_) {
writeError(curtag.tag_);
os_ << curtag.asEndTag();
inline void openTag(XHTMLStream & xs, Layout const & lay)
{
- xs << StartTag(lay.htmltag(), lay.htmlattr());
+ xs << html::StartTag(lay.htmltag(), lay.htmlattr());
}
inline void closeTag(XHTMLStream & xs, Layout const & lay)
{
- xs << EndTag(lay.htmltag());
+ xs << html::EndTag(lay.htmltag());
}
inline void openLabelTag(XHTMLStream & xs, Layout const & lay)
{
- xs << StartTag(lay.htmllabeltag(), lay.htmllabelattr());
+ xs << html::StartTag(lay.htmllabeltag(), lay.htmllabelattr());
}
inline void closeLabelTag(XHTMLStream & xs, Layout const & lay)
{
- xs << EndTag(lay.htmllabeltag());
+ xs << html::EndTag(lay.htmllabeltag());
}
inline void openItemTag(XHTMLStream & xs, Layout const & lay)
{
- xs << StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true);
+ xs << html::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true);
}
inline void closeItemTag(XHTMLStream & xs, Layout const & lay)
{
- xs << EndTag(lay.htmlitemtag());
+ xs << html::EndTag(lay.htmlitemtag());
}
// end of convenience functions
for (; par != pend; ++par) {
Layout const & lay = par->layout();
if (!lay.counter.empty())
- buf.params().documentClass().counters().step(lay.counter);
+ buf.params().documentClass().counters().step(lay.counter, OutputUpdate);
// FIXME We should see if there's a label to be output and
// do something with it.
if (par != pbegin)
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
- xs << StartTag("h2", "class='bibliography'");
+ // FIXME XHTML
+ // Use TextClass::htmlTOCLayout() to figure out how we should look.
+ xs << html::StartTag("h2", "class='bibliography'");
xs << pbegin->layout().labelstring(false);
- xs << EndTag("h2");
+ xs << html::EndTag("h2");
xs.cr();
- xs << StartTag("div", "class='bibliography'");
+ xs << html::StartTag("div", "class='bibliography'");
xs.cr();
makeParagraphs(buf, xs, runparams, text, pbegin, pend);
- xs << EndTag("div");
+ xs << html::EndTag("div");
return pend;
}
&& (par == pbegin || !isNormalEnv(style))
&& cnts.hasCounter(cntr)
)
- cnts.step(cntr);
+ cnts.step(cntr, OutputUpdate);
ParagraphList::const_iterator send;
// this will be positive, if we want to skip the initial word
// (if it's been taken for the label).
closeItemTag(xs, *lastlay);
lastlay = 0;
}
- bool const labelfirst = style.htmllabelfirst();
if (isNormalEnv(style)) {
// in this case, we print the label only for the first
// paragraph (as in a theorem).
openItemTag(xs, style);
if (par == pbegin && style.htmllabeltag() != "NONE") {
docstring const lbl =
- pbegin->expandLabel(style, buf.params(), false);
+ pbegin->params().labelString();
if (!lbl.empty()) {
openLabelTag(xs, style);
xs << lbl;
xs.cr();
}
} else { // some kind of list
+ bool const labelfirst = style.htmllabelfirst();
if (!labelfirst)
openItemTag(xs, style);
if (style.labeltype == LABEL_MANUAL
&& style.htmllabeltag() != "NONE") {
openLabelTag(xs, style);
-// sep = par->firstWordLyXHTML(xs, runparams);
+ sep = par->firstWordLyXHTML(xs, runparams);
closeLabelTag(xs, style);
xs.cr();
}
else if (style.labeltype != LABEL_NO_LABEL
&& style.htmllabeltag() != "NONE") {
openLabelTag(xs, style);
- xs << par->expandLabel(style, buf.params(), false);
+ xs << par->params().labelString();
closeLabelTag(xs, style);
xs.cr();
}
openItemTag(xs, style);
}
par->simpleLyXHTMLOnePar(buf, xs, runparams,
- text.outerFont(distance(begin, par)), false, sep);
+ text.outerFont(distance(begin, par)), sep);
++par;
// We may not want to close the tag yet, in particular,
// if we're not at the end...
{
Layout const & style = pbegin->layout();
if (!style.counter.empty())
- buf.params().documentClass().counters().step(style.counter);
+ buf.params().documentClass().counters().step(style.counter, OutputUpdate);
openTag(xs, style);
// FIXME Probably need to account for LABEL_MANUAL
if (style.labeltype != LABEL_NO_LABEL) {
openLabelTag(xs, style);
- xs << pbegin->expandLabel(style, buf.params(), false);
+ xs << pbegin->params().labelString();
closeLabelTag(xs, style);
// Otherwise the label might run together with the text
xs << from_ascii(" ");
OutputParams ourparams = runparams;
while (par != pend) {
+ if (par->params().startOfAppendix()) {
+ // FIXME: only the counter corresponding to toplevel
+ // sectioning should be reset
+ Counters & cnts = buf.masterBuffer()->params().documentClass().counters();
+ cnts.reset();
+ cnts.appendix(true);
+ }
Layout const & style = par->layout();
ParagraphList::const_iterator lastpar = par;
ParagraphList::const_iterator send;