Layout infrastructure for HTML output.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29947 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-06-05 17:26:30 +00:00
parent 14a2d495a5
commit 0dbf7d0d3d
4 changed files with 89 additions and 1 deletions

View File

@ -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<string> 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;
}
}

View File

@ -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.

View File

@ -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;

View File

@ -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<std::string> 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?