mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Restore basic paragraph output for XHTML. The insets are all disabled still.
Much of the point of this is to allow us properly to handle what LyX does as: <em>This is <strong>bold and italic</em> and now just bold.</strong> We output: <em>This is <strong>bold and italic</strong></em><strong> and now just bold.</strong> which is valid. Note how much easier this would have been if emphasis and boldness were insets rather than ranges. ;-) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32086 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7aebcc787f
commit
ad132e2e99
@ -2285,18 +2285,19 @@ pos_type Paragraph::firstWordDocBook(odocstream & os, OutputParams const & runpa
|
||||
}
|
||||
|
||||
|
||||
pos_type Paragraph::firstWordLyXHTML(odocstream & os, OutputParams const & runparams)
|
||||
pos_type Paragraph::firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams)
|
||||
const
|
||||
{
|
||||
pos_type i;
|
||||
for (i = 0; i < size(); ++i) {
|
||||
if (Inset const * inset = getInset(i)) {
|
||||
inset->xhtml(os, runparams);
|
||||
// FIXME XHTMLStream
|
||||
// inset->xhtml(xs, runparams);
|
||||
} else {
|
||||
char_type c = d->text_[i];
|
||||
if (c == ' ')
|
||||
break;
|
||||
os << html::escapeChar(c);
|
||||
xs << html::escapeChar(c);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
@ -2375,7 +2376,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
||||
|
||||
|
||||
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
||||
odocstream & os,
|
||||
XHTMLStream & xs,
|
||||
OutputParams const & runparams,
|
||||
Font const & outerfont,
|
||||
pos_type initial) const
|
||||
@ -2399,20 +2400,20 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
||||
// emphasis
|
||||
if (font_old.emph() != font.fontInfo().emph()) {
|
||||
if (font.fontInfo().emph() == FONT_ON) {
|
||||
os << "<em>";
|
||||
xs << StartTag("em");
|
||||
emph_flag = true;
|
||||
} else if (emph_flag && i != initial) {
|
||||
os << "</em>";
|
||||
xs << EndTag("em");
|
||||
emph_flag = false;
|
||||
}
|
||||
}
|
||||
// bold
|
||||
if (font_old.series() != font.fontInfo().series()) {
|
||||
if (font.fontInfo().series() == BOLD_SERIES) {
|
||||
os << "<strong>";
|
||||
xs << StartTag("strong");
|
||||
bold_flag = true;
|
||||
} else if (bold_flag && i != initial) {
|
||||
os << "</strong>";
|
||||
xs << EndTag("strong");
|
||||
bold_flag = false;
|
||||
}
|
||||
}
|
||||
@ -2424,12 +2425,13 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
||||
OutputParams np = runparams;
|
||||
if (!il.htmlisblock())
|
||||
np.html_in_par = true;
|
||||
retval += inset->xhtml(os, np);
|
||||
// FIXME XHTMLStream
|
||||
// retval += inset->xhtml(xs, np);
|
||||
} else {
|
||||
char_type c = d->text_[i];
|
||||
|
||||
if (style.pass_thru)
|
||||
os.put(c);
|
||||
xs << c;
|
||||
else if (c == '-') {
|
||||
docstring str;
|
||||
int j = i + 1;
|
||||
@ -2445,19 +2447,14 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
|
||||
}
|
||||
else
|
||||
str += c;
|
||||
os << str;
|
||||
xs << str;
|
||||
} else
|
||||
os << html::escapeChar(c);
|
||||
xs << c;
|
||||
}
|
||||
font_old = font.fontInfo();
|
||||
}
|
||||
|
||||
// FIXME This could be out of order. See above.
|
||||
if (emph_flag)
|
||||
os << "</em>";
|
||||
if (bold_flag)
|
||||
os << "</strong>";
|
||||
|
||||
xs.closeFontTags();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ class ParagraphParameters;
|
||||
class TexRow;
|
||||
class Toc;
|
||||
class WordLangTuple;
|
||||
class XHTMLStream;
|
||||
|
||||
class FontSpan {
|
||||
public:
|
||||
@ -151,7 +152,7 @@ public:
|
||||
pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const;
|
||||
|
||||
/// Output the first word of a paragraph, return the position where it left.
|
||||
pos_type firstWordLyXHTML(odocstream & os, OutputParams const & runparams) const;
|
||||
pos_type firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) const;
|
||||
|
||||
/// Writes to stream the docbook representation
|
||||
void simpleDocBookOnePar(Buffer const & buf,
|
||||
@ -162,7 +163,7 @@ public:
|
||||
/// \return any material that has had to be deferred until after the
|
||||
/// paragraph has closed.
|
||||
docstring simpleLyXHTMLOnePar(Buffer const & buf,
|
||||
odocstream &,
|
||||
XHTMLStream & xs,
|
||||
OutputParams const & runparams,
|
||||
Font const & outerfont,
|
||||
pos_type initial = 0) const;
|
||||
|
@ -497,7 +497,7 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// FIXME Just a temporary fix, so it will compile.
|
||||
// FIXME XHTMLStream
|
||||
XHTMLStream xs(os);
|
||||
if (undefined()) {
|
||||
xhtmlParagraphs(text_, buffer(), xs, runparams);
|
||||
|
@ -296,10 +296,12 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
|
||||
TagStack::const_reverse_iterator rit = tag_stack_.rbegin();
|
||||
TagStack::const_reverse_iterator ren = tag_stack_.rend();
|
||||
for (; rit != ren; ++rit) {
|
||||
if (rit->tag_ == etag.tag_)
|
||||
break;
|
||||
if (!html::isFontTag(rit->tag_)) {
|
||||
// we'll just leave it and, presumably, have to close it later.
|
||||
LYXERR0("Unable to close font tag `" << etag.tag_
|
||||
<< "' due to open non-font tags.");
|
||||
<< "' due to open non-font tag `" << rit->tag_ << "'.");
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
@ -457,8 +459,8 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
|
||||
(par == pbegin && runparams.html_in_par) ? false : true;
|
||||
if (opened)
|
||||
openTag(xs, lay);
|
||||
docstring const deferred = from_ascii("");
|
||||
// par->simpleLyXHTMLOnePar(buf, os, runparams, text.outerFont(distance(begin, par)));
|
||||
docstring const deferred =
|
||||
par->simpleLyXHTMLOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)));
|
||||
|
||||
// We want to issue the closing tag if either:
|
||||
// (i) We opened it, and either html_in_par is false,
|
||||
@ -588,8 +590,8 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
|
||||
else
|
||||
xs << StartTag("span", "class='" + to_utf8(style.name()) + " inneritem'>");
|
||||
}
|
||||
// par->simpleLyXHTMLOnePar(buf, os, runparams,
|
||||
// text.outerFont(distance(begin, par)), sep);
|
||||
par->simpleLyXHTMLOnePar(buf, xs, runparams,
|
||||
text.outerFont(distance(begin, par)), sep);
|
||||
if (!isNormalEnv(style) && !labelfirst)
|
||||
xs << EndTag("span");
|
||||
++par;
|
||||
@ -663,8 +665,8 @@ void makeCommand(Buffer const & buf,
|
||||
}
|
||||
|
||||
ParagraphList::const_iterator const begin = text.paragraphs().begin();
|
||||
// pbegin->simpleLyXHTMLOnePar(buf, os, runparams,
|
||||
// text.outerFont(distance(begin, pbegin)));
|
||||
pbegin->simpleLyXHTMLOnePar(buf, xs, runparams,
|
||||
text.outerFont(distance(begin, pbegin)));
|
||||
closeTag(xs, style);
|
||||
xs.cr();
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class OutputParams;
|
||||
class Text;
|
||||
|
||||
struct StartTag {
|
||||
///
|
||||
StartTag(std::string const & tag) : tag_(tag) {}
|
||||
///
|
||||
StartTag(std::string const & tag, std::string const & attr,
|
||||
bool keepempty = false)
|
||||
|
Loading…
Reference in New Issue
Block a user