X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetLayout.cpp;h=f2b701dfb8057f81bb21b03d0242a519b9cc0ec4;hb=996505c2ae981187d34580633fca410972c2493d;hp=0659761810bd521d7f90f02ebf9edb66e05ddcd2;hpb=0c1ff6d89e72ae82e4a68f99934b735ade5fea5c;p=lyx.git diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 0659761810..f2b701dfb8 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -35,7 +35,7 @@ InsetLayout::InsetLayout() : latextype_(NOLATEXTYPE), font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error), htmlforcecss_ (false), htmlisblock_(true), - multipar_(false), custompars_(true), forceplain_(false), + multipar_(true), custompars_(true), forceplain_(false), passthru_(false), needprotect_(false), freespacing_(false), keepempty_(false), forceltr_(false), intoc_(false) { @@ -351,64 +351,73 @@ InsetLayout::InsetLyXType translateLyXType(std::string const & str) } +string const & InsetLayout::htmltag() const +{ + if (htmltag_.empty()) + htmltag_ = multipar_ ? "div" : "span"; + return htmltag_; +} + + +string const & InsetLayout::htmlattr() const +{ + if (htmlattr_.empty()) + htmlattr_ = "class=\"" + defaultCSSClass() + "\""; + return htmlattr_; +} + + +string const & InsetLayout::htmlinnerattr() const +{ + if (htmlinnerattr_.empty()) + htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\""; + return htmlinnerattr_; +} + + string InsetLayout::defaultCSSClass() const { if (!defaultcssclass_.empty()) return defaultcssclass_; - docstring d; - docstring::const_iterator it = name().begin(); - docstring::const_iterator en = name().end(); + string d; + string n = to_utf8(name()); + string::const_iterator it = n.begin(); + string::const_iterator en = n.end(); for (; it != en; ++it) { if (!isalpha(*it)) - continue; - if (islower(*it)) + d += "_"; + else if (islower(*it)) d += *it; - else + else d += support::lowercase(*it); } // are there other characters we need to remove? - defaultcssclass_ = to_utf8(d); + defaultcssclass_ = 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 const mainfontCSS = font_.asCSS(); + if (!mainfontCSS.empty()) + htmldefaultstyle_ = + from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") + + mainfontCSS + from_ascii("\n}\n"); } + docstring InsetLayout::htmlstyle() const { if (!htmlstyle_.empty() && !htmlforcecss_) return htmlstyle_; - if (htmldefaultstyle_.empty()) + if (htmldefaultstyle_.empty()) makeDefaultCSS(); docstring retval = htmldefaultstyle_; if (!htmlstyle_.empty()) - retval += '\n' + htmlstyle_; + retval += '\n' + htmlstyle_ + '\n'; return retval; }