mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Make the float interface for XHTML consistent with the others.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32846 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
aec9fc1c5b
commit
ebfb4c09ad
@ -14,6 +14,8 @@
|
||||
|
||||
#include "Floating.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@ -28,11 +30,11 @@ Floating::Floating(string const & type, string const & placement,
|
||||
string const & ext, string const & within,
|
||||
string const & style, string const & name,
|
||||
string const & listName, string const & htmlTag,
|
||||
string const & htmlClass, string const & htmlStyle,
|
||||
string const & htmlAttrib, string const & htmlStyle,
|
||||
bool builtin)
|
||||
: type_(type), placement_(placement), ext_(ext), within_(within),
|
||||
style_(style), name_(name), listName_(listName), html_tag_(htmlTag),
|
||||
html_class_(htmlClass), html_style_(htmlStyle), builtin_(builtin)
|
||||
html_attrib_(htmlAttrib), html_style_(htmlStyle), builtin_(builtin)
|
||||
{}
|
||||
|
||||
|
||||
@ -84,11 +86,11 @@ string const & Floating::htmlStyle() const
|
||||
}
|
||||
|
||||
|
||||
string const & Floating::htmlClass() const
|
||||
string const & Floating::htmlAttrib() const
|
||||
{
|
||||
if (html_class_.empty())
|
||||
html_class_ = "float-" + type_;
|
||||
return html_class_;
|
||||
if (html_attrib_.empty())
|
||||
html_attrib_ = "class='float " + defaultCSSClass() + "'";
|
||||
return html_attrib_;
|
||||
}
|
||||
|
||||
|
||||
@ -100,6 +102,28 @@ string const & Floating::htmlTag() const
|
||||
}
|
||||
|
||||
|
||||
string Floating::defaultCSSClass() const
|
||||
{
|
||||
if (!defaultcssclass_.empty())
|
||||
return defaultcssclass_;
|
||||
string d;
|
||||
string n = type_;
|
||||
string::const_iterator it = n.begin();
|
||||
string::const_iterator en = n.end();
|
||||
for (; it != en; ++it) {
|
||||
if (!isalpha(*it))
|
||||
d += "_";
|
||||
else if (islower(*it))
|
||||
d += *it;
|
||||
else
|
||||
d += support::lowercase(*it);
|
||||
}
|
||||
// are there other characters we need to remove?
|
||||
defaultcssclass_ = "float-" + d;
|
||||
return defaultcssclass_;
|
||||
}
|
||||
|
||||
|
||||
bool Floating::builtin() const
|
||||
{
|
||||
return builtin_;
|
||||
|
@ -51,12 +51,14 @@ public:
|
||||
/// style information, for preamble
|
||||
std::string const & htmlStyle() const;
|
||||
/// class, for css, defaults to "float-" + type()
|
||||
std::string const & htmlClass() const;
|
||||
std::string const & htmlAttrib() const;
|
||||
/// tag type, defaults to "div"
|
||||
std::string const & htmlTag() const;
|
||||
///
|
||||
bool builtin() const;
|
||||
private:
|
||||
///
|
||||
std::string defaultCSSClass() const;
|
||||
///
|
||||
std::string type_;
|
||||
///
|
||||
@ -74,7 +76,9 @@ private:
|
||||
///
|
||||
mutable std::string html_tag_;
|
||||
///
|
||||
mutable std::string html_class_;
|
||||
mutable std::string html_attrib_;
|
||||
///
|
||||
mutable std::string defaultcssclass_;
|
||||
///
|
||||
std::string html_style_;
|
||||
///
|
||||
|
@ -852,7 +852,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
FT_LISTNAME,
|
||||
FT_BUILTIN,
|
||||
FT_HTMLSTYLE,
|
||||
FT_HTMLCLASS,
|
||||
FT_HTMLATTR,
|
||||
FT_HTMLTAG,
|
||||
FT_END
|
||||
};
|
||||
@ -861,7 +861,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
{ "end", FT_END },
|
||||
{ "extension", FT_EXT },
|
||||
{ "guiname", FT_NAME },
|
||||
{ "htmlclass", FT_HTMLCLASS },
|
||||
{ "htmlattr", FT_HTMLATTR },
|
||||
{ "htmlstyle", FT_HTMLSTYLE },
|
||||
{ "htmltag", FT_HTMLTAG },
|
||||
{ "latexbuiltin", FT_BUILTIN },
|
||||
@ -875,7 +875,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
lexrc.pushTable(floatTags);
|
||||
|
||||
string ext;
|
||||
string htmlclass;
|
||||
string htmlattr;
|
||||
string htmlstyle;
|
||||
string htmltag;
|
||||
string listName;
|
||||
@ -940,9 +940,9 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
lexrc.next();
|
||||
builtin = lexrc.getBool();
|
||||
break;
|
||||
case FT_HTMLCLASS:
|
||||
case FT_HTMLATTR:
|
||||
lexrc.next();
|
||||
htmlclass = lexrc.getString();
|
||||
htmlattr = lexrc.getString();
|
||||
break;
|
||||
case FT_HTMLSTYLE:
|
||||
lexrc.next();
|
||||
@ -961,7 +961,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
// Here if have a full float if getout == true
|
||||
if (getout) {
|
||||
Floating fl(type, placement, ext, within, style, name,
|
||||
listName, htmltag, htmlclass, htmlstyle, builtin);
|
||||
listName, htmltag, htmlattr, htmlstyle, builtin);
|
||||
floatlist_.newFloat(fl);
|
||||
// each float has its own counter
|
||||
counters_.newCounter(from_ascii(type), from_ascii(within),
|
||||
|
@ -287,7 +287,7 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
|
||||
FloatList const & floats = buffer().params().documentClass().floats();
|
||||
Floating const & ftype = floats.getType(params_.type);
|
||||
string const & htmltype = ftype.htmlTag();
|
||||
string const attr = "class='float " + ftype.htmlClass() + "'";
|
||||
string const & attr = ftype.htmlAttrib();
|
||||
|
||||
odocstringstream ods;
|
||||
XHTMLStream newxs(ods);
|
||||
|
Loading…
Reference in New Issue
Block a user