}
-string Paragraph::getID() const
+string Paragraph::getID(Buffer const & buf, OutputParams const & runparams) const
{
for (pos_type i = 0; i < size(); ++i) {
if (isInset(i)) {
InsetBase::Code lyx_code = inset->lyxCode();
if (lyx_code == InsetBase::LABEL_CODE) {
string const id = static_cast<InsetCommand const *>(inset)->getContents();
- return "id=\"" + sgml::cleanID(id) + "\"";
+ return "id=\"" + sgml::cleanID(buf, runparams, id) + "\"";
}
}
pos_type Paragraph::getFirstWord(Buffer const & buf, ostream & os, OutputParams const & runparams) const
{
pos_type i;
- LyXLayout_ptr const & style = layout();
for (i = 0; i < size(); ++i) {
if (isInset(i)) {
InsetBase const * inset = getInset(i);
string str;
boost::tie(ws, str) = sgml::escapeChar(c);
- if (style->pass_thru)
- os << c;
- else
- os << str;
+ os << str;
}
}
return i;
}
+
+bool Paragraph::onlyText(Buffer const & buf, LyXFont const & outerfont, pos_type initial) const
+{
+ LyXLayout_ptr const & style = layout();
+ LyXFont font_old;
+
+ for (pos_type i = initial; i < size(); ++i) {
+ LyXFont font = getFont(buf.params(), i, outerfont);
+ if (isInset(i))
+ return false;
+ if ( i != initial and font != font_old)
+ return false;
+ font_old = font;
+ }
+
+ return true;
+}
+
+
void Paragraph::simpleDocBookOnePar(Buffer const & buf,
ostream & os,
OutputParams const & runparams,
LyXFont font_old =
style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
- bool cdata = (style->innertag() == "CDATA");
+ if (style->pass_thru and not onlyText(buf, outerfont, initial))
+ os << "]]>";
// parsing main loop
for (pos_type i = initial; i < size(); ++i) {
LyXFont font = getFont(buf.params(), i, outerfont);
// handle <emphasis> tag
if (font_old.emph() != font.emph()) {
if (font.emph() == LyXFont::ON) {
- if (cdata)
- os << "]]>";
os << "<emphasis>";
- if (cdata)
- os << "<![CDATA[";
emph_flag = true;
} else if (i != initial) {
- if (cdata)
- os << "]]>";
os << "</emphasis>";
- if (cdata)
- os << "<![CDATA[";
emph_flag = false;
}
}
if (isInset(i)) {
InsetBase const * inset = getInset(i);
- if (cdata)
- os << "]]>";
inset->docbook(buf, os, runparams);
- if (cdata)
- os << "<![CDATA[";
} else {
char c = getChar(i);
bool ws;
}
if (emph_flag) {
- if (cdata)
- os << "]]>";
os << "</emphasis>";
- if (cdata)
- os << "<![CDATA[";
}
if (style->free_spacing)
os << '\n';
+ if (style->pass_thru and not onlyText(buf, outerfont, initial))
+ os << "<![CDATA[";
}