]> git.lyx.org Git - lyx.git/blobdiff - src/output_xhtml.cpp
tex2lyx/text.cpp: code simplification
[lyx.git] / src / output_xhtml.cpp
index bfabfd8bd7eddc69ff1b9f577d01bc47c2399db8..dee3060e59131c45f1f46a1f53208ae15874ddab 100644 (file)
@@ -227,7 +227,7 @@ bool XHTMLStream::closeFontTags()
                        return true;
                curtag = tag_stack_.back();
        }
-
+       
        if (curtag.tag_ == parsep_tag)
                return true;
 
@@ -246,9 +246,11 @@ bool XHTMLStream::closeFontTags()
 }
 
 
-void XHTMLStream::startParagraph()
+void XHTMLStream::startParagraph(bool keep_empty)
 {
        pending_tags_.push_back(html::StartTag(parsep_tag));
+       if (keep_empty)
+               clearTagDeque();
 }
 
 
@@ -922,10 +924,20 @@ void xhtmlParagraphs(Text const & text,
                       OutputParams const & runparams)
 {
        ParagraphList const & paragraphs = text.paragraphs();
-       ParagraphList::const_iterator par = paragraphs.begin();
-       ParagraphList::const_iterator pend = paragraphs.end();
-
-       while (par != pend) {
+       if (runparams.par_begin == runparams.par_end) {
+               runparams.par_begin = 0;
+               runparams.par_end = paragraphs.size();
+       }
+       pit_type bpit = runparams.par_begin;
+       pit_type const epit = runparams.par_end;
+       LASSERT(bpit < epit, /* */);
+
+       OutputParams ourparams = runparams;
+       ParagraphList::const_iterator const pend =
+               (epit == (int) paragraphs.size()) ?
+                       paragraphs.end() : paragraphs.constIterator(epit);
+       while (bpit < epit) {
+               ParagraphList::const_iterator par = paragraphs.constIterator(bpit);
                if (par->params().startOfAppendix()) {
                        // FIXME: only the counter corresponding to toplevel
                        // sectioning should be reset
@@ -934,7 +946,7 @@ void xhtmlParagraphs(Text const & text,
                        cnts.appendix(true);
                }
                Layout const & style = par->layout();
-               ParagraphList::const_iterator lastpar = par;
+               ParagraphList::const_iterator const lastpar = par;
                ParagraphList::const_iterator send;
 
                switch (style.latextype) {
@@ -942,13 +954,13 @@ void xhtmlParagraphs(Text const & text,
                        // The files with which we are working never have more than
                        // one paragraph in a command structure.
                        // FIXME 
-                       // if (runparams.html_in_par)
+                       // if (ourparams.html_in_par)
                        //   fix it so we don't get sections inside standard, e.g.
                        // note that we may then need to make runparams not const, so we
                        // can communicate that back.
                        // FIXME Maybe this fix should be in the routines themselves, in case
                        // they are called from elsewhere.
-                       makeCommand(buf, xs, runparams, text, par);
+                       makeCommand(buf, xs, ourparams, text, par);
                        ++par;
                        break;
                }
@@ -957,24 +969,21 @@ void xhtmlParagraphs(Text const & text,
                case LATEX_ITEM_ENVIRONMENT: {
                        // FIXME Same fix here.
                        send = searchEnvironmentHtml(par, pend);
-                       par = makeEnvironmentHtml(buf, xs, runparams, text, par, send);
+                       par = makeEnvironmentHtml(buf, xs, ourparams, text, par, send);
                        break;
                }
                case LATEX_BIB_ENVIRONMENT: {
                        // FIXME Same fix here.
                        send = searchEnvironmentHtml(par, pend);
-                       par = makeBibliography(buf, xs, runparams, text, par, send);
+                       par = makeBibliography(buf, xs, ourparams, text, par, send);
                        break;
                }
                case LATEX_PARAGRAPH:
                        send = searchParagraphHtml(par, pend);
-                       par = makeParagraphs(buf, xs, runparams, text, par, send);
+                       par = makeParagraphs(buf, xs, ourparams, text, par, send);
                        break;
                }
-               // FIXME??
-               // makeEnvironment may process more than one paragraphs and bypass pend
-               if (distance(lastpar, par) >= distance(lastpar, pend))
-                       break;
+               bpit += distance(lastpar, par);
        }
 }