mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Default CSS for InsetLayout.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31771 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4c004e0485
commit
e8631bf7ed
@ -35,6 +35,7 @@ InsetLayout::InsetLayout() :
|
||||
labelstring_(from_ascii("UNDEFINED")), decoration_(DEFAULT),
|
||||
latextype_(NOLATEXTYPE), font_(sane_font),
|
||||
labelfont_(sane_font), bgcolor_(Color_error),
|
||||
htmlforcecss_ (false), htmlisblock_(true),
|
||||
multipar_(false), custompars_(true), forceplain_(false),
|
||||
passthru_(false), needprotect_(false), freespacing_(false),
|
||||
keepempty_(false), forceltr_(false), intoc_(false)
|
||||
@ -84,6 +85,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
IL_FREESPACING,
|
||||
IL_HTMLTAG,
|
||||
IL_HTMLATTR,
|
||||
IL_HTMLFORCECSS,
|
||||
IL_HTMLINNERTAG,
|
||||
IL_HTMLINNERATTR,
|
||||
IL_HTMLISBLOCK,
|
||||
@ -119,6 +121,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
{ "forceplain", IL_FORCEPLAIN },
|
||||
{ "freespacing", IL_FREESPACING },
|
||||
{ "htmlattr", IL_HTMLATTR },
|
||||
{ "htmlforcecss", IL_HTMLFORCECSS },
|
||||
{ "htmlinnerattr", IL_HTMLINNERATTR},
|
||||
{ "htmlinnertag", IL_HTMLINNERTAG},
|
||||
{ "htmlisblock", IL_HTMLISBLOCK},
|
||||
@ -285,6 +288,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
||||
case IL_HTMLATTR:
|
||||
lex >> htmlattr_;
|
||||
break;
|
||||
case IL_HTMLFORCECSS:
|
||||
lex >> htmlforcecss_;
|
||||
break;
|
||||
case IL_HTMLINNERTAG:
|
||||
lex >> htmlinnertag_;
|
||||
break;
|
||||
@ -345,4 +351,67 @@ InsetLayout::InsetLyXType translateLyXType(std::string const & str)
|
||||
return InsetLayout::NOLYXTYPE;
|
||||
}
|
||||
|
||||
|
||||
string InsetLayout::defaultCSSClass() const
|
||||
{
|
||||
if (!defaultcssclass_.empty())
|
||||
return defaultcssclass_;
|
||||
docstring d;
|
||||
docstring::const_iterator it = name().begin();
|
||||
docstring::const_iterator en = name().end();
|
||||
for (; it != en; ++it) {
|
||||
if (!isalpha(*it))
|
||||
continue;
|
||||
if (islower(*it))
|
||||
d += *it;
|
||||
else
|
||||
d += support::lowercase(*it);
|
||||
}
|
||||
// are there other characters we need to remove?
|
||||
defaultcssclass_ = to_utf8(d);
|
||||
return defaultcssclass_;
|
||||
}
|
||||
|
||||
|
||||
void InsetLayout::makeDefaultCSS() const
|
||||
{
|
||||
#ifdef TEX2LYX
|
||||
// tex2lyx does not have FontInfo::asCSS()
|
||||
return;
|
||||
#else
|
||||
if (!htmldefaultstyle_.empty())
|
||||
return;
|
||||
if (!htmltag_.empty()) {
|
||||
docstring const mainfontCSS = font_.asCSS();
|
||||
if (!mainfontCSS.empty())
|
||||
htmldefaultstyle_ =
|
||||
from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") +
|
||||
mainfontCSS + from_ascii("\n}\n");
|
||||
}
|
||||
/*
|
||||
At present, we do not have default tags, etc, for the label.
|
||||
if (labelfont_ == font_)
|
||||
return;
|
||||
docstring const labelfontCSS = labelfont_.asCSS();
|
||||
if (!labelfontCSS.empty())
|
||||
htmldefaultstyle_ +=
|
||||
. from_ascii(htmllabeltag() + "." + defaultCSSLabelClass() + " {\n") +
|
||||
labelfontCSS + from_ascii("\n}\n");
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
docstring InsetLayout::htmlstyle() const
|
||||
{
|
||||
if (!htmlstyle_.empty() && !htmlforcecss_)
|
||||
return htmlstyle_;
|
||||
if (htmldefaultstyle_.empty())
|
||||
makeDefaultCSS();
|
||||
docstring retval = htmldefaultstyle_;
|
||||
if (!htmlstyle_.empty())
|
||||
retval += '\n' + htmlstyle_;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
} //namespace lyx
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
///
|
||||
std::string const & htmllabel() const { return htmllabel_; }
|
||||
///
|
||||
docstring htmlstyle() const { return htmlstyle_; }
|
||||
docstring htmlstyle() const;
|
||||
///
|
||||
docstring htmlpreamble() const { return htmlpreamble_; }
|
||||
///
|
||||
@ -118,7 +118,14 @@ public:
|
||||
bool forceLTR() const { return forceltr_; };
|
||||
///
|
||||
bool isInToc() const { return intoc_; };
|
||||
///
|
||||
private:
|
||||
///
|
||||
void makeDefaultCSS() const;
|
||||
///
|
||||
std::string defaultCSSClass() const;
|
||||
///
|
||||
std::string defaultCSSLabelClass() const { return defaultCSSClass() + "_label"; }
|
||||
///
|
||||
docstring name_;
|
||||
/**
|
||||
@ -147,20 +154,31 @@ private:
|
||||
docstring counter_;
|
||||
///
|
||||
docstring preamble_;
|
||||
/// The tag enclosing all the material in this inset.
|
||||
/// The tag enclosing all the material in this inset. Default is none.
|
||||
std::string htmltag_;
|
||||
/// Additional attributes for inclusion with the start tag.
|
||||
/// Additional attributes for inclusion with the start tag. Default (if
|
||||
/// a tag is provided) is: class="name".
|
||||
std::string htmlattr_;
|
||||
/// Tag for individual paragraphs in the inset.
|
||||
/// Tag for individual paragraphs in the inset. Default is none.
|
||||
std::string htmlinnertag_;
|
||||
/// Attributes for that tag.
|
||||
/// Attributes for that tag. Default (if a tag is provided) is:
|
||||
/// class="name_inner".
|
||||
std::string htmlinnerattr_;
|
||||
/// A label for this environment, possibly including a reference
|
||||
/// to a counter. E.g., for footnote, it might be:
|
||||
/// <span class='notenum'>\arabic{footnote}</span>
|
||||
/// No default.
|
||||
/// FIXME Could we get this from the layout?
|
||||
std::string htmllabel_;
|
||||
/// CSS associated with this inset.
|
||||
docstring htmlstyle_;
|
||||
/// Cache for default CSS info for this inset.
|
||||
mutable docstring htmldefaultstyle_;
|
||||
///
|
||||
mutable std::string defaultcssclass_;
|
||||
/// Whether to force generation of default CSS even if some is given.
|
||||
/// False by default.
|
||||
bool htmlforcecss_;
|
||||
/// Additional material for the header.
|
||||
docstring htmlpreamble_;
|
||||
/// Whether this inset represents a "block" of material, i.e., a set
|
||||
|
Loading…
Reference in New Issue
Block a user