]> git.lyx.org Git - lyx.git/commitdiff
Introduce HTMLClass tag, to make it easier to give these.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 4 Dec 2022 18:27:19 +0000 (13:27 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 4 Dec 2022 18:36:34 +0000 (13:36 -0500)
16 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/layouts/stdlists.inc
lib/layouts/stdlyxlist.inc
lib/scripts/layout2layout.py
src/Layout.cpp
src/Layout.h
src/TextClass.cpp
src/insets/InsetIndex.cpp
src/output_xhtml.cpp

index 52933dc19d02f78a4c5367dc128df141a91cbacc..6551e2f1d710739a4d205db9ab22b5bfdf009255 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 1d7ceb5302159b6466d6af3f654745ca41dcd759..f21aa55baa865274976e9249f48720be13a51f60 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 5ddd1f85c57c5cbf2d98dd1d505e4272ef3724af..bed15f6e4f6c736a189da031ef66398417843bc3 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 8981e36cc0129dd8a3c366cc6f5538fe48ba88e1..321dd08ff6c9645fe91a3112984c0d20926ea04f 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 12c4f2591567d3e6539e8b6a1225a4b1ea195fc4..fc2c10507a9fd85f2f2899a44fa338b967867b29 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 78d1009f418a5918fa1960e85f2d70f1aeb464ff..7c56aed5cb9a738537f2fff9ebd69158789bf99d 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 c437c0eaafff4b585565d09e9d3c4d07c4b83ed2..5127ab51d106e82c954158cb57a046138459ef0f 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 b102ceb4b9789d5b09211422a2281d976df578fd..57f05af855c6e3ff8ee884fc09f9ce6b971ca4a0 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 1a50878991e4ada60150d2e166c39ac0550d4492..d4a7d922a55c1f776f403c27b794dc25fb8ad3f9 100644 (file)
@@ -116,7 +116,6 @@ Style Description
          Series              Bold
        EndFont
        HTMLTag               dl
-       HTMLAttr              class='description'
        HTMLItem              dd
        HTMLLabel             dt
        HTMLLabelFirst        1
index 064c357d6c8adf91749b75f41af3ef6008f2cdf1..c3ea8edda5ca19b724a6fa4d43cc4dbeb17ee382 100644 (file)
@@ -29,7 +29,7 @@ Style Labeling
                EndFont
        EndArgument
        HTMLTag               ol
-       HTMLAttr              class='lyxlist'
+       HTMLClass             lyxlist
        HTMLItem              li
        HTMLLabel             span
        HTMLLabelAttr         class='lyxlist'
index 144cb350fd0373cd9a6421713f345bf921d77076..4add2e5beb48d0bdad3161c792291967dacfe511 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 = 96
+currentFormat = 97
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -325,6 +325,9 @@ currentFormat = 96
 # Incremented to format 96, 4 December 2022 by rikiheck
 # Add HTMLInToc
 
+# Incremented to format 97, 4 December 2022 by rikiheck
+# Add HTMLClass
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -575,7 +578,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if 87 <= format <= 96:
+        if 87 <= format <= 97:
             # nothing to do.
             i += 1
             continue
index f782c12d9b01a8ef6a5b943fb19ed75d4e991fd2..7578d155afb48451ce789302cee69f1fff7bfa77 100644 (file)
@@ -94,6 +94,7 @@ enum LayoutTags {
        LT_ITEMTAG,
        LT_HTMLTAG,
        LT_HTMLATTR,
+       LT_HTMLCLASS,
        LT_HTMLITEM,
        LT_HTMLITEMATTR,
        LT_HTMLLABEL,
@@ -271,6 +272,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
                { "forcelocal",     LT_FORCELOCAL },
                { "freespacing",    LT_FREE_SPACING },
                { "htmlattr",       LT_HTMLATTR },
+               { "htmlclass",      LT_HTMLCLASS },
                { "htmlforcecss",   LT_HTMLFORCECSS },
                { "htmlintoc",      LT_HTMLINTOC },
                { "htmlitem",       LT_HTMLITEM },
@@ -718,6 +720,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
                        lex >> htmlattr_;
                        break;
 
+               case LT_HTMLCLASS:
+                       lex >> htmlclass_;
+                       break;
+
                case LT_HTMLITEM:
                        lex >> htmlitemtag_;
                        break;
@@ -1668,6 +1674,10 @@ void Layout::write(ostream & os) const
                os << "\tHTMLTag " << htmltag_ << '\n';
        if (!htmlattr_.empty())
                os << "\tHTMLAttr " << htmlattr_ << '\n';
+       if (!htmlclass_.empty())
+               os << "\tHTMLClass " << htmlclass_ << '\n';
+       if (!htmlintoc_)
+               os << "\tHTMLInToc " << htmlintoc_ << '\n';
        if (!htmlitemtag_.empty())
                os << "\tHTMLItem " << htmlitemtag_ << '\n';
        if (!htmlitemattr_.empty())
@@ -1809,14 +1819,31 @@ string const & Layout::htmltag() const
 
 string const & Layout::htmlattr() const
 {
-       // If it's an enumeration, then we recalculate the class each time through
-       // unless it has been given explicitly
-       if (htmlattr_.empty() && labeltype != LABEL_ENUMERATE)
-               htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
        return htmlattr_;
 }
 
 
+string const & Layout::htmlclass() const
+{
+       // If it's an enumeration, then we recalculate the class each time through
+       // unless it has been given explicitly. So we do nothing here.
+       if (htmlclass_.empty() && labeltype != LABEL_ENUMERATE)
+               htmlclass_ = defaultCSSClass();
+       return htmlclass_;
+}
+
+
+string const & Layout::htmlGetAttrString() const {
+       if (!htmlfullattrs_.empty())
+               return htmlfullattrs_;
+       htmlfullattrs_ = htmlclass();
+       if (!htmlfullattrs_.empty())
+               htmlfullattrs_ = "class='" + htmlfullattrs_ + "'";
+       if (!htmlattr_.empty())
+               htmlfullattrs_ += " " + htmlattr_;
+       return htmlfullattrs_;
+}
+
 string const & Layout::htmlitemtag() const
 {
        if (htmlitemtag_.empty())
index dd64bce75987879b9688d9efeabc9bad7f91f961..98b702feee91d647a272a2b56018f0db2c6c0725 100644 (file)
@@ -185,6 +185,10 @@ public:
        ///
        std::string const & htmlattr() const;
        ///
+       std::string const & htmlclass() const;
+       /// Returns a complete attribute string, including class, etc.
+       std::string const & htmlGetAttrString() const;
+       ///
        std::string const & htmlitemtag() const;
        ///
        std::string const & htmlitemattr() const;
@@ -491,9 +495,13 @@ private:
        ///
        /// Defaults to "div".
        mutable std::string htmltag_;
-       /// Additional attributes for inclusion with the start tag. Defaults
-       /// to: class="layoutname".
-       mutable std::string htmlattr_;
+       /// Additional attributes for inclusion with the start tag.
+       /// Note that the CSS class is handled separately.
+       std::string htmlattr_;
+       /// The CSS class to use. Calculated from the layout name if not given.
+       mutable std::string htmlclass_;
+       /// cached
+       mutable std::string htmlfullattrs_;
        /// 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
index b387ce1a191f1180cfe07f327bf260947b5db231..d00446e9227460465d1a4da9816936d18768d82d 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 = 96; // rikiheck: HTMLInToc
+int const LAYOUT_FORMAT = 97; // rikiheck: HTMLClass
 
 
 // Layout format for the current lyx file format. Controls which format is
index f40ba031fcca8bf7b88f223e34eecc7f129a3c90..a6fcae77be00f41bfdd0ad403eb1074f79cfbc2b 100644 (file)
@@ -1890,7 +1890,7 @@ docstring InsetPrintIndex::xhtml(XMLStream &, OutputParams const & op) const
 
        xs << xml::StartTag("div", tocattr);
        xs << xml::CR();
-       xs << xml::StartTag(lay.htmltag(), lay.htmlattr());
+       xs << xml::StartTag(lay.htmltag(), lay.htmlGetAttrString());
        xs << translateIfPossible(indexName, op.local_font->language()->lang());
        xs << xml::EndTag(lay.htmltag());
        xs << xml::CR();
index 3fb292e4dacbacae6bf95876665720003c672128..0c4bdb97176a35848a7cdb108e2efd2d6d278601 100644 (file)
@@ -159,7 +159,7 @@ namespace {
 inline void openParTag(XMLStream & xs, Layout const & lay,
                        std::string const & parlabel)
 {
-       string attrs = lay.htmlattr();
+       string attrs = lay.htmlGetAttrString();
        if (!parlabel.empty())
                attrs += " id='" + parlabel + "'";
        xs << xml::ParTag(lay.htmltag(), attrs);
@@ -185,7 +185,7 @@ void openParTag(XMLStream & xs, Layout const & lay,
                openParTag(xs, lay, parlabel);
                return;
        }
-       string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
+       string attrs = lay.htmlGetAttrString() + " style='text-align: " + align + ";'";
        if (!parlabel.empty())
                attrs += " id='" + parlabel + "'";
        xs << xml::ParTag(lay.htmltag(), attrs);
@@ -225,7 +225,7 @@ void openItemTag(XMLStream & xs, Layout const & lay,
                openItemTag(xs, lay);
                return;
        }
-       string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
+       string attrs = lay.htmlGetAttrString() + " style='text-align: " + align + ";'";
        xs << xml::StartTag(lay.htmlitemtag(), attrs);
 }
 
@@ -408,7 +408,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        depth_type const origdepth = pbegin->params().depth();
 
        // open tag for this environment
-       if (bstyle.labeltype == LABEL_ENUMERATE && bstyle.htmlattr().empty()) {
+       if (bstyle.labeltype == LABEL_ENUMERATE && bstyle.htmlclass().empty()) {
                // In this case, we have to calculate the CSS class ourselves, each time
                // through
                // FIXME We assume in these cases that the standard enumeration counter