The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 82b872365488d862a02d71f765e69c55f5260b5d Author: Richard Heck <rgh...@lyx.org> Date: Wed Mar 27 12:49:03 2013 -0400 Handle other text ranges in XHTML output. diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 10adb14..1d0f8b0 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -316,6 +316,25 @@ static docstring const rtloutputdblcol_def = from_ascii( ///////////////////////////////////////////////////////////////////// // +// 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 // ///////////////////////////////////////////////////////////////////// @@ -1300,6 +1319,13 @@ docstring const LaTeXFeatures::getTClassHTMLStyles() const DocumentClass const & tclass = params_.documentClass(); 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(); list<docstring>::const_iterator cit = usedLayouts_.begin(); diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 75dbff3..fffcfa5 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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, XHTMLStream & xs, OutputParams const & runparams, @@ -2841,6 +2854,11 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, bool emph_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_; @@ -2862,24 +2880,49 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, continue; Font font = getFont(buf.masterBuffer()->params(), i, outerfont); + bool const at_start = (i == initial); // emphasis - if (font_old.emph() != font.fontInfo().emph()) { - if (font.fontInfo().emph() == FONT_ON) { - xs << html::StartTag("em"); - emph_flag = true; - } else if (emph_flag && i != initial) { - xs << html::EndTag("em"); - emph_flag = false; - } - } + FontState curstate = font.fontInfo().emph(); + if (font_old.emph() != curstate) + doFontSwitch(xs, at_start, emph_flag, curstate, "em"); + + // noun + curstate = font.fontInfo().noun(); + 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 if (font_old.series() != font.fontInfo().series()) { if (font.fontInfo().series() == BOLD_SERIES) { - xs << html::StartTag("strong"); + xs << html::StartTag("b"); bold_flag = true; } else if (bold_flag && i != initial) { - xs << html::EndTag("strong"); + xs << html::EndTag("b"); bold_flag = false; } } diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 84fc0cd..30eda97 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -147,8 +147,9 @@ docstring cleanAttr(docstring const & str) 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"; } ----------------------------------------------------------------------- Summary of changes: src/LaTeXFeatures.cpp | 26 +++++++++++++++++++ src/Paragraph.cpp | 65 ++++++++++++++++++++++++++++++++++++++++-------- src/output_xhtml.cpp | 5 ++- 3 files changed, 83 insertions(+), 13 deletions(-) hooks/post-receive -- The LyX Source Repository