]> git.lyx.org Git - lyx.git/commitdiff
Add HTMLClass for InsetLayout as well. Layout format change.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 6 Dec 2022 04:42:50 +0000 (23:42 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 6 Dec 2022 04:42:50 +0000 (23:42 -0500)
17 files changed:
lib/layouts/aastex.layout
lib/layouts/aguplus.inc
lib/layouts/apa.layout
lib/layouts/apax.inc
lib/layouts/bicaption.module
lib/layouts/logicalmkup.module
lib/layouts/scrclass.inc
lib/layouts/stdinsets.inc
lib/scripts/layout2layout.py
src/Layout.cpp
src/Layout.h
src/TextClass.cpp
src/insets/InsetCaption.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetText.cpp
src/insets/InsetWrap.cpp

index 58b8b14ba18193278572cbbd46e910110191f641..2e34010bf38410d6c7aa6c7fa35ca7c3d83db72e 100644 (file)
@@ -619,7 +619,7 @@ InsetLayout Caption:FigCaption
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-figcaption'"
+       HTMLClass   "float-caption float-caption-figcaption"
 End
 
 
index 7453b2a9af935ad2a4f64093759d66b475bc5ba6..4535d0cd70241b290795b587b26aa9d2a8fd4ea9 100644 (file)
@@ -222,7 +222,7 @@ InsetLayout Caption:Table
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-table'"
+       HTMLClass   "float-caption float-caption-table"
 End
 
 
index 57af913dce4162189b4a7c5bc38842b44b36a6ad..ad4f5f84fc8e423fdf55722b2d1b5450e512acaf 100644 (file)
@@ -300,7 +300,7 @@ InsetLayout Caption:Centered
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-centered'"
+       HTMLClass   "float-caption float-caption-centered"
 End
 
 
index 9a51d372f26c273e99ed7f19058d617d2cafe1d7..669da4059bb1390e94dd7b895fb316940d24dfcc 100644 (file)
@@ -399,7 +399,7 @@ InsetLayout Caption:Centered
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-centered'"
+       HTMLClass   "float-caption float-caption-centered"
 End
 
 
index d3b258a9e062145a4eaf1536cd46ac09bfbf6047..ad38b11cba688c627f006bbc1f128146649f29a5 100644 (file)
@@ -62,5 +62,5 @@ InsetLayout Caption:Bicaption
           margin: 1ex;
          }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-bicaption'"
+       HTMLClass  "float-caption float-caption-bicaption"
 End
index 88ba523ba8a79011528f35559d2ecc3363bc5b73..b872b5124fac4b31bcfcf0a8e3b0ceedfd7b3ed6 100644 (file)
@@ -19,7 +19,7 @@ InsetLayout Flex:Noun
        Requires              noun
        InToc                 true
        HTMLTag               span
-       HTMLAttr              "class='noun'"
+       HTMLClass             "noun"
        HTMLStyle
                span.noun {
                        font-family: sans-serif;
index b1c1c9f2dac368895d362f19a21be0baaa8e921a..fc7dea8fb07e37516e265cd506de02c501554a46 100644 (file)
@@ -335,7 +335,7 @@ InsetLayout Caption:Above
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-above'"
+       HTMLClass   "float-caption float-caption-above"
 End
 
 
@@ -360,7 +360,7 @@ InsetLayout Caption:Below
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-below'"
+       HTMLClass    "float-caption float-caption-below"
 End
 
 
index cac502d6bdc4b694b5d7dd99482ca345b0b86091..33a56a4331c2c6eb68e8c50c8461ecd400c673ca 100644 (file)
@@ -666,7 +666,7 @@ InsetLayout Info:menu
        Font
          Family              sans
        EndFont
-       HTMLAttr             "class='info menu'"
+       HTMLClass             "info menu"
        HTMLStyle
                span.menu { font-family: sans-serif; }
        EndHTMLStyle
@@ -685,7 +685,7 @@ InsetLayout Info:shortcut
        Font
          Family              sans
        EndFont
-       HTMLAttr             "class='info shortcut'"
+       HTMLClass             "info shortcut"
        HTMLStyle
                span.shortcut { font-family: sans-serif; }
        EndHTMLStyle
@@ -706,7 +706,7 @@ InsetLayout Info:shortcuts
        Font
          Family              sans
        EndFont
-       HTMLAttr             "class='info shortcut'"
+       HTMLClass             "info shortcut"
        HTMLStyle
                span.shortcuts { font-family: sans-serif; }
        EndHTMLStyle
@@ -737,7 +737,7 @@ InsetLayout Caption:Standard
                        margin: 1ex;
                }
        EndHTMLStyle
-       HTMLAttr "class='float-caption float-caption-standard'"
+       HTMLClass             "float-caption float-caption-standard"
 End
 
 
index 4add2e5beb48d0bdad3161c792291967dacfe511..d923d65752d4bd019a57282b1abc911535261f82 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 97
+currentFormat = 98
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -328,6 +328,9 @@ currentFormat = 97
 # Incremented to format 97, 4 December 2022 by rikiheck
 # Add HTMLClass
 
+# Incremented to format 98, 5 December 2022 by rikiheck
+# Add HTMLClass for InsetLayout
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
index 88d5539d96bfefa2d93e30c3a4bb6c3e1ec93e78..515226da3e1f677003eea62bbd5c3eccb9377334 100644 (file)
@@ -1817,12 +1817,6 @@ string const & Layout::htmltag() const
 }
 
 
-string const & Layout::htmlattr() const
-{
-       return htmlattr_;
-}
-
-
 string const & Layout::htmlclass() const
 {
        // If it's an enumeration or itemize list, then we recalculate the class each
@@ -1844,6 +1838,7 @@ string const & Layout::htmlGetAttrString() const {
        return htmlfullattrs_;
 }
 
+
 string const & Layout::htmlitemtag() const
 {
        if (htmlitemtag_.empty())
index 98b702feee91d647a272a2b56018f0db2c6c0725..e837339c4976cf9f366742400ca71ca3bf845fa7 100644 (file)
@@ -183,7 +183,7 @@ public:
        ///
        std::string const & htmltag() const;
        ///
-       std::string const & htmlattr() const;
+       std::string const & htmlattr() const { return htmlattr_; }
        ///
        std::string const & htmlclass() const;
        /// Returns a complete attribute string, including class, etc.
index d00446e9227460465d1a4da9816936d18768d82d..8973eb0643cc469c194f6ac0afd06da37f4cb464 100644 (file)
@@ -59,7 +59,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 97; // rikiheck: HTMLClass
+int const LAYOUT_FORMAT = 98; // rikiheck: HTMLClass for InsetLayout
 
 
 // Layout format for the current lyx file format. Controls which format is
index ad25ee36e87c9804f3bf876c0ccc4179ce08ed7d..e1ace0dc925b1c759b0b3eb410eac5c1e735133b 100644 (file)
@@ -311,7 +311,7 @@ docstring InsetCaption::xhtml(XMLStream & xs, OutputParams const & rp) const
                return docstring();
        InsetLayout const & il = getLayout();
        string const & tag = il.htmltag();
-       string attr = il.htmlattr();
+       string attr = il.htmlGetAttrString();
        if (!type_.empty()) {
                string const our_class = "float-caption-" + type_;
                size_t const loc = attr.find("class='");
index 64258a8483cefd2c1dbce56e550b40713dc7d58a..0d1322aa7fbeee1e0393ea2707ff0a82b00766c5 100644 (file)
@@ -83,6 +83,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_FREESPACING,
                IL_HTMLTAG,
                IL_HTMLATTR,
+               IL_HTMLCLASS,
                IL_HTMLFORCECSS,
                IL_HTMLINNERTAG,
                IL_HTMLINNERATTR,
@@ -188,6 +189,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "forceplain", IL_FORCEPLAIN },
                { "freespacing", IL_FREESPACING },
                { "htmlattr", IL_HTMLATTR },
+               { "htmlclass", IL_HTMLCLASS },
                { "htmlforcecss", IL_HTMLFORCECSS },
                { "htmlinnerattr", IL_HTMLINNERATTR},
                { "htmlinnertag", IL_HTMLINNERTAG},
@@ -499,6 +501,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_HTMLATTR:
                        lex >> htmlattr_;
                        break;
+               case IL_HTMLCLASS:
+                       lex >> htmlclass_;
+                       break;
                case IL_HTMLFORCECSS:
                        lex >> htmlforcecss_;
                        break;
@@ -653,11 +658,23 @@ string const & InsetLayout::htmltag() const
 }
 
 
-string const & InsetLayout::htmlattr() const
+string const & InsetLayout::htmlclass() const
 {
-       if (htmlattr_.empty())
-               htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
-       return htmlattr_;
+       if (htmlclass_.empty())
+               htmlclass_ = defaultCSSClass();
+       return htmlclass_;
+}
+
+
+std::string const & InsetLayout::htmlGetAttrString() const {
+       if (!htmlfullattrs_.empty())
+               return htmlfullattrs_;
+       htmlfullattrs_ = htmlclass();
+       if (!htmlfullattrs_.empty())
+               htmlfullattrs_ = "class='" + htmlfullattrs_ + "'";
+       if (!htmlattr_.empty())
+               htmlfullattrs_ += " " + htmlattr_;
+       return htmlfullattrs_;
 }
 
 
index ed3c9a96ba830b1959fedc559a5fecb388795a4e..48d53038a87e50747a0a1778820d416edb8a97c1 100644 (file)
@@ -121,7 +121,11 @@ public:
        std::string const & htmltag() const;
        /// Additional attributes for inclusion with the start tag. Default (if
        /// a tag is provided) is: class="name".
-       std::string const & htmlattr() const;
+       std::string const & htmlattr() const { return htmlattr_; }
+       ///
+       std::string const & htmlclass() const;
+       ///
+       std::string const & htmlGetAttrString() const;
        /// Tag for individual paragraphs in the inset. Default is none.
        std::string const & htmlinnertag() const { return htmlinnertag_; }
        /// Attributes for that tag. Default (if a tag is provided) is:
@@ -302,6 +306,10 @@ private:
        ///
        mutable std::string htmlattr_;
        ///
+       mutable std::string htmlclass_;
+       /// cache
+       mutable std::string htmlfullattrs_;
+       ///
        std::string htmlinnertag_;
        ///
        mutable std::string htmlinnerattr_;
index 4cecec8cd7ec31019ca85795a67b609ffd5363dd..99324aaeaf3f99270896c7877d962654b6dc320d 100644 (file)
@@ -868,7 +868,7 @@ docstring InsetText::insetAsXHTML(XMLStream & xs, OutputParams const & rp,
 
        InsetLayout const & il = getLayout();
        if (opts & WriteOuterTag)
-               xs << xml::StartTag(il.htmltag(), il.htmlattr());
+               xs << xml::StartTag(il.htmltag(), il.htmlGetAttrString());
 
        if ((opts & WriteLabel) && !il.counter().empty()) {
                BufferParams const & bp = buffer().masterBuffer()->params();
index 8987405cb8157c39cd0c4294fc705ac3b90ce5fc..69e5b259e50a0f80269f4d1d0bc32b1501795efe 100644 (file)
@@ -219,7 +219,7 @@ docstring InsetWrap::xhtml(XMLStream & xs, OutputParams const & rp) const
        string const width = len.empty() ? "50%" : len;
        InsetLayout const & il = getLayout();
        string const & tag = il.htmltag();
-       string const attr = il.htmlattr() + " style='width:" + width + ";'";
+       string const attr = il.htmlGetAttrString() + " style='width:" + width + ";'";
        xs << xml::StartTag(tag, attr);
        docstring const deferred =
                InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag);