mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Introduce HTMLClass tag, to make it easier to give these.
This commit is contained in:
parent
e658113ea6
commit
69a6c41b94
@ -619,7 +619,7 @@ InsetLayout Caption:FigCaption
|
||||
margin: 1ex;
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLAttr "class='float-caption float-caption-figcaption'"
|
||||
HTMLClass "float-caption float-caption-figcaption"
|
||||
End
|
||||
|
||||
|
||||
|
@ -222,7 +222,7 @@ InsetLayout Caption:Table
|
||||
margin: 1ex;
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLAttr "class='float-caption float-caption-table'"
|
||||
HTMLClass "float-caption float-caption-table"
|
||||
End
|
||||
|
||||
|
||||
|
@ -300,7 +300,7 @@ InsetLayout Caption:Centered
|
||||
margin: 1ex;
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLAttr "class='float-caption float-caption-centered'"
|
||||
HTMLClass "float-caption float-caption-centered"
|
||||
End
|
||||
|
||||
|
||||
|
@ -399,7 +399,7 @@ InsetLayout Caption:Centered
|
||||
margin: 1ex;
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLAttr "class='float-caption float-caption-centered'"
|
||||
HTMLClass "float-caption float-caption-centered"
|
||||
End
|
||||
|
||||
|
||||
|
@ -62,5 +62,5 @@ InsetLayout Caption:Bicaption
|
||||
margin: 1ex;
|
||||
}
|
||||
EndHTMLStyle
|
||||
HTMLAttr "class='float-caption float-caption-bicaption'"
|
||||
HTMLClass "float-caption float-caption-bicaption"
|
||||
End
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -116,7 +116,6 @@ Style Description
|
||||
Series Bold
|
||||
EndFont
|
||||
HTMLTag dl
|
||||
HTMLAttr class='description'
|
||||
HTMLItem dd
|
||||
HTMLLabel dt
|
||||
HTMLLabelFirst 1
|
||||
|
@ -29,7 +29,7 @@ Style Labeling
|
||||
EndFont
|
||||
EndArgument
|
||||
HTMLTag ol
|
||||
HTMLAttr class='lyxlist'
|
||||
HTMLClass lyxlist
|
||||
HTMLItem li
|
||||
HTMLLabel span
|
||||
HTMLLabelAttr class='lyxlist'
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
14
src/Layout.h
14
src/Layout.h
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user