]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
That didn't really work. So revert to old CSS for gray notes.
[lyx.git] / src / Paragraph.cpp
index 1a86aec67266d78d155d219531b4d971ac345ac9..0266c2e6ff9cf19a5b7875a12ebee99a7fceed7e 100644 (file)
@@ -1072,6 +1072,18 @@ bool Paragraph::Private::latexSpecialPhrase(odocstream & os, pos_type & i,
 
 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");
@@ -1946,6 +1958,9 @@ bool Paragraph::latex(BufferParams const & bparams,
 {
        LYXERR(Debug::LATEX, "Paragraph::latex...     " << this);
 
+       if (layout().inpreamble)
+               return true;
+
        bool return_value = false;
 
        bool const allowcust = allowParagraphCustomization();
@@ -2297,7 +2312,7 @@ pos_type Paragraph::firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runp
                        char_type c = d->text_[i];
                        if (c == ' ')
                                break;
-                       xs << html::escapeChar(c);
+                       xs << c;
                }
        }
        return i;
@@ -2379,6 +2394,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
                                    XHTMLStream & xs,
                                    OutputParams const & runparams,
                                    Font const & outerfont,
+                                               bool fortoc,
                                    pos_type initial) const
 {
        docstring retval;
@@ -2388,6 +2404,13 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
        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;
 
@@ -2415,15 +2438,19 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
                                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(xs, 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];
 
@@ -2444,6 +2471,9 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
                                }
                                else
                                        str += c;
+                               // 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
                                xs << c;
@@ -3118,4 +3148,12 @@ bool Paragraph::isMisspelled(pos_type pos) const
 }
 
 
+string Paragraph::magicLabel() const
+{
+       stringstream ss;
+       ss << "magicparlabel-" << id();
+       return ss.str();
+}
+
+
 } // namespace lyx