From 0dbf7d0d3ddb6ab2365f5eddaa7602eec362e234 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 5 Jun 2009 17:26:30 +0000 Subject: [PATCH] Layout infrastructure for HTML output. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29947 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Layout.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/Layout.h | 35 +++++++++++++++++++++++++++++++++++ src/TextClass.cpp | 6 ++++++ src/TextClass.h | 4 ++++ 4 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/Layout.cpp b/src/Layout.cpp index 95d9cb944f..f38f828fa1 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -92,6 +92,13 @@ enum LayoutTags { LT_INNERTAG, LT_LABELTAG, LT_ITEMTAG, + LT_HTMLTAG, + LT_HTMLATTR, + LT_HTMLITEM, + LT_HTMLITEMATTR, + LT_HTMLLABEL, + LT_HTMLLABELATTR, + LT_HTMLSTYLE, LT_INTITLE // keep this last! }; @@ -152,6 +159,13 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) { "fill_top", LT_FILL_TOP }, { "font", LT_FONT }, { "freespacing", LT_FREE_SPACING }, + { "htmlattr", LT_HTMLATTR }, + { "htmlitem", LT_HTMLITEM }, + { "htmlitemattr", LT_HTMLITEMATTR }, + { "htmllabel", LT_HTMLLABEL }, + { "htmllabelattr", LT_HTMLLABELATTR }, + { "htmlstyle", LT_HTMLSTYLE }, + { "htmltag", LT_HTMLTAG }, { "innertag", LT_INNERTAG }, { "intitle", LT_INTITLE }, { "itemsep", LT_ITEMSEP }, @@ -455,12 +469,41 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) readSpacing(lex); break; - case LT_REQUIRES: + case LT_REQUIRES: { lex.eatLine(); vector const req = getVectorFromString(lex.getString()); requires_.insert(req.begin(), req.end()); break; + } + + case LT_HTMLTAG: + lex >> htmltag_; + break; + + case LT_HTMLATTR: + lex >> htmlattr_; + break; + + case LT_HTMLITEM: + lex >> htmlitem_; + break; + + case LT_HTMLITEMATTR: + lex >> htmlitemattr_; + break; + + case LT_HTMLLABEL: + lex >> htmllabel_; + break; + + case LT_HTMLLABELATTR: + lex >> htmllabelattr_; + break; + + case LT_HTMLSTYLE: + htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle")); + break; } } diff --git a/src/Layout.h b/src/Layout.h index 3c1d0847d6..b9f099349b 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -108,6 +108,20 @@ public: std::string const & labeltag() const { return labeltag_; } /// std::string const & itemtag() const { return itemtag_; } + /// + std::string const & htmltag() const { return htmltag_; } + /// + std::string const & htmlattr() const { return htmlattr_; } + /// + std::string const & htmlitem() const { return htmlitem_; } + /// + std::string const & htmlitemattr() const { return htmlitemattr_; } + /// + std::string const & htmllabel() const { return htmllabel_; } + /// + std::string const & htmllabelattr() const { return htmllabelattr_; } + /// + docstring const & htmlstyle() const { return htmlstyle_; } /// docstring const & labelstring_appendix() const { return labelstring_appendix_; @@ -271,6 +285,27 @@ private: std::string labeltag_; /// Internal tag to surround the item text in a list) std::string itemtag_; + /// Tag for HTML output, e.g., h2. + std::string htmltag_; + /// Additional attributes for inclusion with the start tag, + /// e.g.: class='section'. + std::string htmlattr_; + /// Tag for individual paragraphs in an environment. In lists, this + /// would be something like "li". But it also needs to be set for + /// quotation, e.g., since the paragraphs in a quote need to be + /// in "p" tags. + std::string htmlitem_; + /// Attributes for htmlitem_ + std::string htmlitemattr_; + /// Tag for labels, of whatever sort. One use for this is in setting + /// descriptions, in which case it would be: dt. Another use is to + /// customize the display of, say, the auto-generated label for + /// sections (in that case, it might be: span). + std::string htmllabel_; + /// Attributes for the label. + std::string htmllabelattr_; + /// CSS information needed by this layout. + docstring htmlstyle_; /// This is the `category' for this layout. The following are /// recommended basic categories: FrontMatter, BackMatter, MainText, /// Section, Starred, List, Theorem. diff --git a/src/TextClass.cpp b/src/TextClass.cpp index de60bb1e96..53634ca9af 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -175,6 +175,7 @@ enum TextClassTags { TC_TOCDEPTH, TC_CLASSOPTIONS, TC_PREAMBLE, + TC_HTMLPREAMBLE, TC_PROVIDES, TC_REQUIRES, TC_LEFTMARGIN, @@ -205,6 +206,7 @@ namespace { { "excludesmodule", TC_EXCLUDESMODULE }, { "float", TC_FLOAT }, { "format", TC_FORMAT }, + { "htmlpreamble", TC_HTMLPREAMBLE }, { "input", TC_INPUT }, { "insetlayout", TC_INSETLAYOUT }, { "leftmargin", TC_LEFTMARGIN }, @@ -498,6 +500,10 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) preamble_ = from_utf8(lexrc.getLongString("EndPreamble")); break; + case TC_HTMLPREAMBLE: + htmlpreamble_ = from_utf8(lexrc.getLongString("EndPreamble")); + break; + case TC_ADDTOPREAMBLE: preamble_ += from_utf8(lexrc.getLongString("EndPreamble")); break; diff --git a/src/TextClass.h b/src/TextClass.h index 2ea9bba86c..5f0510ca28 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -254,6 +254,8 @@ protected: static const docstring plain_layout_; /// preamble text to support layout styles docstring preamble_; + /// same, but for HTML output + docstring htmlpreamble_; /// latex packages loaded by document class. std::set provides_; /// latex packages requested by document class. @@ -380,6 +382,8 @@ public: std::string const & pagestyle() const { return pagestyle_; } /// docstring const & preamble() const { return preamble_; } + /// + docstring const & htmlpreamble() const { return htmlpreamble_; } /// is this feature already provided by the class? bool provides(std::string const & p) const; /// features required by the class? -- 2.39.5