*
* \author Asger Alstrup
* \author Lars Gullik Bjønnes
+ * \author Richard Heck (XHTML output)
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
* \author John Levon
OutputParams const & runparams);
///
- void validate(LaTeXFeatures & features,
- Layout const & layout) const;
+ void validate(LaTeXFeatures & features) const;
/// Checks if the paragraph contains only text and no inset or font change.
bool onlyText(Buffer const & buf, Font const & outerfont,
}
-void Paragraph::Private::validate(LaTeXFeatures & features,
- Layout const & layout) const
+void Paragraph::Private::validate(LaTeXFeatures & features) const
{
+ if (layout_->inpreamble && inset_owner_) {
+ Buffer const & buf = inset_owner_->buffer();
+ BufferParams const & bp = buf.params();
+ Font f;
+ TexRow tr;
+ odocstringstream ods;
+ owner_->latex(bp, f, ods, tr, features.runparams());
+ docstring d = ods.str();
+ if (!d.empty())
+ features.addPreambleSnippet(to_utf8(d));
+ }
+
// check the params.
if (!params_.spacing().isDefault())
features.require("setspace");
// then the layouts
- features.useLayout(layout.name());
+ features.useLayout(layout_->name());
// then the fonts
fontlist_.validate(features);
for (; icit != iend; ++icit) {
if (icit->inset) {
icit->inset->validate(features);
- if (layout.needprotect &&
+ if (layout_->needprotect &&
icit->inset->lyxCode() == FOOT_CODE)
features.require("NeedLyXFootnoteCode");
}
void Paragraph::validate(LaTeXFeatures & features) const
{
- d->validate(features, *d->layout_);
+ d->validate(features);
}
{
LYXERR(Debug::LATEX, "Paragraph::latex... " << this);
+ if (layout().inpreamble)
+ return true;
+
bool return_value = false;
bool const allowcust = allowParagraphCustomization();
}
-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);
+ inset->xhtml(xs, runparams);
} else {
char_type c = d->text_[i];
if (c == ' ')
break;
- os << html::escapeChar(c);
+ xs << c;
}
}
return i;
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
- odocstream & os,
+ XHTMLStream & xs,
OutputParams const & runparams,
Font const & outerfont,
+ bool fortoc,
pos_type initial) const
{
docstring retval;
- // FIXME We really need to manage the tag nesting here.
- // Probably in the same sort of way as in output_xhtml.
bool emph_flag = false;
bool bold_flag = false;
std::string closing_tag;
Layout const & style = *d->layout_;
+
+ if (!fortoc) {
+ // generate a magic label for this paragraph
+ string const attr = "id='" + magicLabel() + "'";
+ xs << CompTag("a", attr);
+ }
+
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
// 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;
}
}
- // FIXME Other such tags?
+ // FIXME XHTML
+ // Other such tags? What about the other text ranges?
Inset const * inset = getInset(i);
if (inset) {
+ InsetCommand const * ic = inset->asInsetCommand();
InsetLayout const & il = inset->getLayout();
- OutputParams np = runparams;
- if (!il.htmlisblock())
- np.html_in_par = true;
- retval += inset->xhtml(os, np);
+ if (!fortoc || il.isInToc() || (ic && ic->isInToc())) {
+ OutputParams np = runparams;
+ if (!il.htmlisblock())
+ np.html_in_par = true;
+ 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;
}
else
str += c;
- os << str;
+ // We don't want to escape the entities. Note that
+ // it is safe to do this, since str can otherwise
+ // only be "-". E.g., it can't be "<".
+ xs << XHTMLStream::NextRaw() << 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;
}
// There was no inset at the beginning, so we need to create one with
// the key and label of the one we erased.
InsetBibitem * inset =
- new InsetBibitem(buffer, InsetCommandParams(BIBITEM_CODE));
+ new InsetBibitem(const_cast<Buffer *>(&buffer), InsetCommandParams(BIBITEM_CODE));
// restore values of previously deleted item in this par.
if (!oldkey.empty())
inset->setParam("key", oldkey);
}
+string Paragraph::magicLabel() const
+{
+ stringstream ss;
+ ss << "magicparlabel-" << id();
+ return ss.str();
+}
+
+
} // namespace lyx