]> git.lyx.org Git - lyx.git/blobdiff - src/output_xhtml.cpp
Exporter.cpp: revert r34230 because this interferes with Enrico's new LyXVC feature...
[lyx.git] / src / output_xhtml.cpp
index 0b271dc8960e705c86a23d1b7afb3c6cfcc4d242..0a8222c8fb31cad5d0b96ffa946a73877ee44ecd 100644 (file)
@@ -18,6 +18,7 @@
 #include "buffer_funcs.h"
 #include "BufferParams.h"
 #include "Counters.h"
+#include "Font.h"
 #include "Layout.h"
 #include "OutputParams.h"
 #include "Paragraph.h"
@@ -140,7 +141,6 @@ bool isFontTag(string const & s)
 {
        return s == "em" || s == "strong"; // others?
 }
-} // namespace html
 
 
 docstring StartTag::asTag() const
@@ -176,6 +176,9 @@ docstring CompTag::asTag() const
        return from_utf8(output);
 }
 
+} // namespace html
+
+
 
 ////////////////////////////////////////////////////////////////
 ///
@@ -207,7 +210,7 @@ bool XHTMLStream::closeFontTags()
        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();
@@ -225,7 +228,8 @@ bool XHTMLStream::closeFontTags()
        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;
                }
        }
@@ -236,7 +240,7 @@ bool XHTMLStream::closeFontTags()
 void XHTMLStream::clearTagDeque()
 {
        while (!pending_tags_.empty()) {
-               StartTag const & tag = pending_tags_.front();
+               html::StartTag const & tag = pending_tags_.front();
                // tabs?
                os_ << tag.asTag();
                tag_stack_.push_back(tag);
@@ -298,7 +302,7 @@ XHTMLStream & XHTMLStream::operator<<(NextRaw const &)
 }
 
 
-XHTMLStream & XHTMLStream::operator<<(StartTag const & tag) 
+XHTMLStream & XHTMLStream::operator<<(html::StartTag const & tag) 
 {
        if (tag.tag_.empty())
                return *this;
@@ -309,7 +313,7 @@ XHTMLStream & XHTMLStream::operator<<(StartTag const & tag)
 }
 
 
-XHTMLStream & XHTMLStream::operator<<(CompTag const & tag) 
+XHTMLStream & XHTMLStream::operator<<(html::CompTag const & tag) 
 {
        if (tag.tag_.empty())
                return *this;
@@ -326,7 +330,6 @@ bool XHTMLStream::isTagOpen(string const & stag)
        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;
@@ -338,7 +341,7 @@ bool XHTMLStream::isTagOpen(string const & stag)
 // 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;
@@ -352,7 +355,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
 
        // 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_.
@@ -435,7 +438,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
                // 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_) {
@@ -462,7 +465,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
        // 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();
@@ -484,37 +487,37 @@ namespace {
 
 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
@@ -571,7 +574,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
        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)
@@ -618,14 +621,16 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
                                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;
 }
 
@@ -670,7 +675,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
                    && (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).
@@ -695,7 +700,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
                                        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;
@@ -717,7 +722,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
                                        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();
                                        }
@@ -725,7 +730,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
                                                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...
@@ -782,7 +787,7 @@ void makeCommand(Buffer const & buf,
 {
        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);
 
@@ -790,7 +795,7 @@ void makeCommand(Buffer const & buf,
        // 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(" ");
@@ -817,6 +822,13 @@ void xhtmlParagraphs(Text const & text,
 
        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;