#include <config.h>
#include "Layout.h"
+#include "FontInfo.h"
#include "Language.h"
-#include "TextClass.h"
#include "Lexer.h"
-#include "FontInfo.h"
+#include "output_xhtml.h"
+#include "TextClass.h"
-#include "support/Messages.h"
#include "support/debug.h"
#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/Messages.h"
#include "support/regex.h"
LT_FONT,
LT_FREE_SPACING,
LT_PASS_THRU,
+ LT_PARBREAK_IS_NEWLINE,
//LT_HEADINGS,
LT_ITEMSEP,
LT_KEEPEMPTY,
newline_allowed = true;
free_spacing = false;
pass_thru = false;
+ parbreak_is_newline = false;
toclevel = NOT_IN_TOC;
commanddepth = 0;
htmllabelfirst_ = false;
{ "nextnoindent", LT_NEXTNOINDENT },
{ "obsoletedby", LT_OBSOLETEDBY },
{ "optionalargs", LT_OPTARGS },
+ { "parbreakisnewline", LT_PARBREAK_IS_NEWLINE },
{ "parindent", LT_PARINDENT },
{ "parsep", LT_PARSEP },
{ "parskip", LT_PARSKIP },
lex >> pass_thru;
break;
+ case LT_PARBREAK_IS_NEWLINE:
+ lex >> parbreak_is_newline;
+ break;
+
case LT_SPACING: // setspace.sty
readSpacing(lex);
break;
case LT_HTMLFORCECSS:
lex >> htmlforcecss_;
+ break;
case LT_HTMLPREAMBLE:
htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble"));
inpreamble = false;
}
- return !error;
+ return finished && !error;
}
}
-// NOTE There is a whole ton of stuff that could go into this.
-// Things like bottomsep, topsep, and parsep could become various
-// sorts of margins or padding, for example. But for now we are
-// going to keep it simple.
+namespace {
+ string makeMarginValue(double d) {
+ ostringstream os;
+ os << d << "ex";
+ return os.str();
+ }
+}
+
+
void Layout::makeDefaultCSS() const {
// this never needs to be redone, since reloading layouts will
// wipe out what we did before.
if (!htmldefaultstyle_.empty())
return;
- docstring const mainfontCSS = font.asCSS();
- if (!mainfontCSS.empty())
+
+ // main font
+ htmldefaultstyle_ = font.asCSS();
+
+ // top and bottom margins
+ string tmp;
+ if (topsep > 0)
+ tmp += "margin-top: " + makeMarginValue(topsep) + ";\n";
+ if (bottomsep > 0)
+ tmp += "margin-bottom: " + makeMarginValue(bottomsep) + ";\n";
+ if (!tmp.empty()) {
+ if (!htmldefaultstyle_.empty())
+ htmldefaultstyle_ += from_ascii("\n");
+ htmldefaultstyle_ += from_ascii(tmp);
+ }
+
+// tex2lyx does not see output_xhtml.cpp
+#ifndef TEX2LYX
+ // alignment
+ string where = alignmentToCSS(align);
+ if (!where.empty()) {
+ htmldefaultstyle_ += from_ascii("text-align: " + where + ";\n");
+ }
+#endif
+
+ // wrap up what we have, if anything
+ if (!htmldefaultstyle_.empty())
htmldefaultstyle_ =
from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
- mainfontCSS + from_ascii("\n}\n");
+ htmldefaultstyle_ + from_ascii("\n}\n");
+
if (labelfont == font || htmllabeltag() == "NONE")
return;
+
+ // label font
docstring const labelfontCSS = labelfont.asCSS();
if (!labelfontCSS.empty())
htmldefaultstyle_ +=