rgh...@lyx.org schreef:
Author: rgheck
Date: Fri Jun  5 19:26:30 2009
New Revision: 29947
URL: http://www.lyx.org/trac/changeset/29947

Log:
Layout infrastructure for HTML output.

Modified:
   lyx-devel/trunk/src/Layout.cpp
   lyx-devel/trunk/src/Layout.h
   lyx-devel/trunk/src/TextClass.cpp
   lyx-devel/trunk/src/TextClass.h

Modified: lyx-devel/trunk/src/Layout.cpp
==============================================================================
--- lyx-devel/trunk/src/Layout.cpp      Fri Jun  5 10:55:36 2009        (r29946)
+++ lyx-devel/trunk/src/Layout.cpp      Fri Jun  5 19:26:30 2009        (r29947)
@@ -92,6 +92,13 @@
        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 @@
                { "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 @@
                        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;
}
        }

Modified: lyx-devel/trunk/src/Layout.h
==============================================================================
--- lyx-devel/trunk/src/Layout.h        Fri Jun  5 10:55:36 2009        (r29946)
+++ lyx-devel/trunk/src/Layout.h        Fri Jun  5 19:26:30 2009        (r29947)
@@ -108,6 +108,20 @@
        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 @@
        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.

Modified: lyx-devel/trunk/src/TextClass.cpp
==============================================================================
--- lyx-devel/trunk/src/TextClass.cpp   Fri Jun  5 10:55:36 2009        (r29946)
+++ lyx-devel/trunk/src/TextClass.cpp   Fri Jun  5 19:26:30 2009        (r29947)
@@ -175,6 +175,7 @@
        TC_TOCDEPTH,
        TC_CLASSOPTIONS,
        TC_PREAMBLE,
+       TC_HTMLPREAMBLE,
        TC_PROVIDES,
        TC_REQUIRES,
        TC_LEFTMARGIN,
@@ -205,6 +206,7 @@
                { "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 @@
                        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;

Modified: lyx-devel/trunk/src/TextClass.h
==============================================================================
--- lyx-devel/trunk/src/TextClass.h     Fri Jun  5 10:55:36 2009        (r29946)
+++ lyx-devel/trunk/src/TextClass.h     Fri Jun  5 19:26:30 2009        (r29947)
@@ -254,6 +254,8 @@
        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 @@
        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?

We have to double this code for each output format that is added to LyX ? Isn't there a way to do it somewhat more generic ?

Vincent

Reply via email to