diff --git a/src/Layout.cpp b/src/Layout.cpp index 32f565297e..7df75754ff 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -101,6 +101,7 @@ enum LayoutTags { LT_HTMLLABELFIRST, LT_HTMLPREAMBLE, LT_HTMLSTYLE, + LT_HTMLFORCEDEFAULT, LT_INTITLE // keep this last! }; @@ -140,6 +141,7 @@ Layout::Layout() toclevel = NOT_IN_TOC; commanddepth = 0; htmllabelfirst_ = false; + htmlforcedefault_ = false; } @@ -162,7 +164,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) { "fill_top", LT_FILL_TOP }, { "font", LT_FONT }, { "freespacing", LT_FREE_SPACING }, - { "htmlattr", LT_HTMLATTR }, + { "htmlattr", LT_HTMLATTR }, + { "htmlforcedefault", LT_HTMLFORCEDEFAULT }, { "htmlitem", LT_HTMLITEM }, { "htmlitemattr", LT_HTMLITEMATTR }, { "htmllabel", LT_HTMLLABEL }, @@ -514,6 +517,9 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle")); break; + case LT_HTMLFORCEDEFAULT: + lex >> htmlforcedefault_; + case LT_HTMLPREAMBLE: htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble")); break; @@ -863,6 +869,24 @@ docstring const Layout::babelpreamble(Language const * lang) const } +docstring Layout::htmlstyle() const { + if (!htmlstyle_.empty() && !htmlforcedefault_) + return htmlstyle_; + if (htmldefaultstyle_.empty()) + makeDefaultCSS(); + docstring retval = htmldefaultstyle_; + if (!htmlstyle_.empty()) + retval += '\n' + htmlstyle_; + return retval; +} + + +void Layout::makeDefaultCSS() const { +// FIXME just an empty hook for now. +// i'll get to this shortly. +} + + bool Layout::operator==(Layout const & rhs) const { // This is enough for the applications we actually make, diff --git a/src/Layout.h b/src/Layout.h index 28085dbd6b..b1027fdb39 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -124,7 +124,7 @@ public: /// bool htmllabelfirst() const { return htmllabelfirst_; } /// - docstring const & htmlstyle() const { return htmlstyle_; } + docstring htmlstyle() const; /// docstring const & htmlpreamble() const { return htmlpreamble_; } /// @@ -249,6 +249,9 @@ public: private: + /// generates the default CSS for this layout + void makeDefaultCSS() const; + /// Name of the layout/paragraph environment docstring name_; @@ -315,6 +318,13 @@ private: bool htmllabelfirst_; /// CSS information needed by this layout. docstring htmlstyle_; + /// Should we generate the default CSS for this layout, even if HTMLStyle + /// has been given? Default is false. + /// Note that the default CSS is output first, then the user CSS, so it is + /// possible to override what one does not want. + bool htmlforcedefault_; + /// A cache for the default style info so generated. + mutable docstring htmldefaultstyle_; /// Any other info for the HTML header. docstring htmlpreamble_; /// This is the `category' for this layout. The following are