#include "buffer_funcs.h"
#include "BufferParams.h"
#include "Counters.h"
+#include "Font.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"
}
+XHTMLStream & XHTMLStream::operator<<(char c)
+{
+ clearTagDeque();
+ if (nextraw_) {
+ os_ << c;
+ nextraw_ = false;
+ } else {
+ string const d = html::escapeChar(c);
+ os_ << from_ascii(d);
+ }
+ return *this;
+}
+
+
XHTMLStream & XHTMLStream::operator<<(int i)
{
clearTagDeque();
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;
}
+void openTag(XHTMLStream & xs, Layout const & lay,
+ ParagraphParameters const & params)
+{
+ // FIXME Are there other things we should handle here?
+ string const align = alignmentToCSS(params.align());
+ if (align.empty()) {
+ openTag(xs, lay);
+ return;
+ }
+ string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
+ xs << html::StartTag(lay.htmltag(), attrs);
+}
+
+
inline void closeTag(XHTMLStream & xs, Layout const & lay)
{
xs << html::EndTag(lay.htmltag());
}
+void openItemTag(XHTMLStream & xs, Layout const & lay,
+ ParagraphParameters const & params)
+{
+ // FIXME Are there other things we should handle here?
+ string const align = alignmentToCSS(params.align());
+ if (align.empty()) {
+ openItemTag(xs, lay);
+ return;
+ }
+ string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
+ xs << html::StartTag(lay.htmlitemtag(), attrs);
+}
+
+
inline void closeItemTag(XHTMLStream & xs, Layout const & lay)
{
xs << html::EndTag(lay.htmlitemtag());
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)
bool const opened = runparams.html_make_pars &&
(par != pbegin || !runparams.html_in_par);
if (opened)
- openTag(xs, lay);
+ openTag(xs, lay, par->params());
docstring const deferred =
par->simpleLyXHTMLOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)));
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
+ // FIXME XHTML
+ // Use TextClass::htmlTOCLayout() to figure out how we should look.
xs << html::StartTag("h2", "class='bibliography'");
xs << pbegin->layout().labelstring(false);
xs << html::EndTag("h2");
&& (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;
}
- 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);
- if (!lbl.empty()) {
+
+ bool const labelfirst = style.htmllabelfirst();
+ if (!labelfirst)
+ openItemTag(xs, style, par->params());
+
+ // label output
+ if (style.labeltype != LABEL_NO_LABEL &&
+ style.htmllabeltag() != "NONE") {
+ if (isNormalEnv(style)) {
+ // in this case, we print the label only for the first
+ // paragraph (as in a theorem).
+ if (par == pbegin) {
+ docstring const lbl =
+ pbegin->params().labelString();
+ if (!lbl.empty()) {
+ openLabelTag(xs, style);
+ xs << lbl;
+ closeLabelTag(xs, style);
+ }
+ xs.cr();
+ }
+ } else { // some kind of list
+ if (style.labeltype == LABEL_MANUAL) {
openLabelTag(xs, style);
- xs << lbl;
+ sep = par->firstWordLyXHTML(xs, runparams);
closeLabelTag(xs, style);
+ xs.cr();
+ }
+ else {
+ openLabelTag(xs, style);
+ xs << par->params().labelString();
+ closeLabelTag(xs, style);
+ xs.cr();
}
- 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);
- 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);
- closeLabelTag(xs, style);
- xs.cr();
}
- if (labelfirst)
- openItemTag(xs, style);
- }
+ } // end label output
+
+ if (labelfirst)
+ openItemTag(xs, style, par->params());
+
par->simpleLyXHTMLOnePar(buf, xs, runparams,
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...
+
+ // We may not want to close the tag yet, in particular:
+ // If we're not at the end...
if (par != pend
// and are doing items...
&& !isNormalEnv(style)
{
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);
+ openTag(xs, style, pbegin->params());
// Label around sectioning number:
// 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;
}
+string alignmentToCSS(LyXAlignment align) {
+ switch (align) {
+ case LYX_ALIGN_BLOCK:
+ // we are NOT going to use text-align: justify!!
+ case LYX_ALIGN_LEFT:
+ return "left";
+ case LYX_ALIGN_RIGHT:
+ return "right";
+ case LYX_ALIGN_CENTER:
+ return "center";
+ default:
+ break;
+ }
+ return "";
+}
+
} // namespace lyx