mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Handle other text ranges in XHTML output.
This commit is contained in:
parent
dd7d76cc6c
commit
82b8723654
@ -314,6 +314,25 @@ static docstring const rtloutputdblcol_def = from_ascii(
|
|||||||
"\\@mparswitchtrue\n");
|
"\\@mparswitchtrue\n");
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// LyXHTML strings
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static docstring const lyxnoun_style = from_ascii(
|
||||||
|
"dfn.lyxnoun {\n"
|
||||||
|
" font-variant: small-caps;\n"
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
|
||||||
|
// this is how it normally renders, but it might not always do so.
|
||||||
|
static docstring const lyxstrikeout_style = from_ascii(
|
||||||
|
"del.strikeout {\n"
|
||||||
|
" text-decoration: line-through;\n"
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// LaTeXFeatures
|
// LaTeXFeatures
|
||||||
@ -1300,6 +1319,13 @@ docstring const LaTeXFeatures::getTClassHTMLStyles() const
|
|||||||
DocumentClass const & tclass = params_.documentClass();
|
DocumentClass const & tclass = params_.documentClass();
|
||||||
odocstringstream tcpreamble;
|
odocstringstream tcpreamble;
|
||||||
|
|
||||||
|
if (mustProvide("noun"))
|
||||||
|
tcpreamble << lyxnoun_style;
|
||||||
|
// this isn't exact, but it won't hurt that much if it
|
||||||
|
// wasn't for this.
|
||||||
|
if (mustProvide("ulem"))
|
||||||
|
tcpreamble << lyxstrikeout_style;
|
||||||
|
|
||||||
tcpreamble << tclass.htmlstyles();
|
tcpreamble << tclass.htmlstyles();
|
||||||
|
|
||||||
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
||||||
|
@ -2831,6 +2831,19 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void doFontSwitch(XHTMLStream & xs, bool startrange,
|
||||||
|
bool & flag, FontState curstate, std::string tag, std::string attr = "")
|
||||||
|
{
|
||||||
|
if (curstate == FONT_ON) {
|
||||||
|
xs << html::StartTag(tag, attr);
|
||||||
|
flag = true;
|
||||||
|
} else if (flag && !startrange) {
|
||||||
|
xs << html::EndTag(tag);
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
||||||
XHTMLStream & xs,
|
XHTMLStream & xs,
|
||||||
OutputParams const & runparams,
|
OutputParams const & runparams,
|
||||||
@ -2841,6 +2854,11 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
|||||||
|
|
||||||
bool emph_flag = false;
|
bool emph_flag = false;
|
||||||
bool bold_flag = false;
|
bool bold_flag = false;
|
||||||
|
bool noun_flag = false;
|
||||||
|
bool ubar_flag = false;
|
||||||
|
bool dbar_flag = false;
|
||||||
|
bool sout_flag = false;
|
||||||
|
bool wave_flag = false;
|
||||||
|
|
||||||
Layout const & style = *d->layout_;
|
Layout const & style = *d->layout_;
|
||||||
|
|
||||||
@ -2862,24 +2880,49 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Font font = getFont(buf.masterBuffer()->params(), i, outerfont);
|
Font font = getFont(buf.masterBuffer()->params(), i, outerfont);
|
||||||
|
bool const at_start = (i == initial);
|
||||||
|
|
||||||
// emphasis
|
// emphasis
|
||||||
if (font_old.emph() != font.fontInfo().emph()) {
|
FontState curstate = font.fontInfo().emph();
|
||||||
if (font.fontInfo().emph() == FONT_ON) {
|
if (font_old.emph() != curstate)
|
||||||
xs << html::StartTag("em");
|
doFontSwitch(xs, at_start, emph_flag, curstate, "em");
|
||||||
emph_flag = true;
|
|
||||||
} else if (emph_flag && i != initial) {
|
// noun
|
||||||
xs << html::EndTag("em");
|
curstate = font.fontInfo().noun();
|
||||||
emph_flag = false;
|
if (font_old.noun() != curstate)
|
||||||
}
|
doFontSwitch(xs, at_start, noun_flag, curstate, "dfn", "class='lyxnoun'");
|
||||||
}
|
|
||||||
|
// underbar
|
||||||
|
curstate = font.fontInfo().underbar();
|
||||||
|
if (font_old.underbar() != curstate)
|
||||||
|
doFontSwitch(xs, at_start, ubar_flag, curstate, "u");
|
||||||
|
|
||||||
|
// strikeout
|
||||||
|
curstate = font.fontInfo().strikeout();
|
||||||
|
if (font_old.strikeout() != curstate)
|
||||||
|
doFontSwitch(xs, at_start, sout_flag, curstate, "del", "class='strikeout'");
|
||||||
|
|
||||||
|
// HTML does not really have an equivalent of the next two, so we will just
|
||||||
|
// output a single underscore with a class, and people can style it if they
|
||||||
|
// wish to do so
|
||||||
|
|
||||||
|
// double underbar
|
||||||
|
curstate = font.fontInfo().uuline();
|
||||||
|
if (font_old.uuline() != curstate)
|
||||||
|
doFontSwitch(xs, at_start, dbar_flag, curstate, "u", "class='dline'");
|
||||||
|
|
||||||
|
// wavy line
|
||||||
|
curstate = font.fontInfo().uwave();
|
||||||
|
if (font_old.uwave() != curstate)
|
||||||
|
doFontSwitch(xs, at_start, wave_flag, curstate, "u", "class='wavyline'");
|
||||||
|
|
||||||
// bold
|
// bold
|
||||||
if (font_old.series() != font.fontInfo().series()) {
|
if (font_old.series() != font.fontInfo().series()) {
|
||||||
if (font.fontInfo().series() == BOLD_SERIES) {
|
if (font.fontInfo().series() == BOLD_SERIES) {
|
||||||
xs << html::StartTag("strong");
|
xs << html::StartTag("b");
|
||||||
bold_flag = true;
|
bold_flag = true;
|
||||||
} else if (bold_flag && i != initial) {
|
} else if (bold_flag && i != initial) {
|
||||||
xs << html::EndTag("strong");
|
xs << html::EndTag("b");
|
||||||
bold_flag = false;
|
bold_flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,9 @@ docstring cleanAttr(docstring const & str)
|
|||||||
|
|
||||||
bool isFontTag(string const & s)
|
bool isFontTag(string const & s)
|
||||||
{
|
{
|
||||||
// others?
|
return s == "em" || s == "strong" || s == "i" || s == "b"
|
||||||
return s == "em" || s == "strong" || s == "i" || s == "b";
|
|| s == "dfn" || s == "kbd" || s == "var" || s == "samp"
|
||||||
|
|| s == "del";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user