Add HTMLClass for InsetLayout as well. Layout format change.

This commit is contained in:
Richard Kimberly Heck 2022-12-05 23:42:50 -05:00
parent 8567e09dbf
commit c50f0b125d
17 changed files with 52 additions and 29 deletions

View 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

View 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

View 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

View 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

View 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

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

View 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

View 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

View 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").

View 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())

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

View 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

View 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='");

View 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_;
}

View 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_;

View 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();

View 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);